Skip to content

Commit

Permalink
Merge branch 'feat/built-in-lut' of github.com:zhuxudong/engine into …
Browse files Browse the repository at this point in the history
…feat/built-in-lut
  • Loading branch information
GuoLei1990 committed Jan 7, 2025
2 parents 95fa1ab + ec06db2 commit c2cd4ab
Show file tree
Hide file tree
Showing 190 changed files with 7,521 additions and 2,148 deletions.
121 changes: 117 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Checkout Engine repo
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -32,11 +33,123 @@ jobs:
registry-url: https://registry.npmjs.org/
cache: pnpm

- name: Build
- name: Build Engine
run: pnpm b:all

- name: Release current monorepo
uses: galacean/[email protected]
- name: Cache Engine Package
uses: actions/cache@v3
with:
path: ./packages/galacean
key: ${{ runner.os }}-engine-${{ github.sha }}

- name: Checkout Sub-repositories
run: |
git clone https://github.com/galacean/engine-toolkit.git
git clone https://github.com/galacean/engine-lottie.git
git clone https://github.com/galacean/engine-spine.git -b dev/4.2
- name: Install and Link Engine and Build for Toolkit
working-directory: ./engine-toolkit
run: |
pnpm install
pnpm link ../packages/galacean
pnpm b:all
- name: Install and Link Engine and Build for Lottie
working-directory: ./engine-lottie
run: |
pnpm install --ignore-workspace
pnpm link ../packages/galacean
pnpm build
- name: Install and Link Engine and Build for Spine
working-directory: ./engine-spine
run: |
pnpm install --ignore-workspace --frozen-lockfile=false
pnpm link ../packages/galacean
pnpm build
- name: Structure Temp Directory
run: |
mkdir -p ${{ github.workspace }}/temp
mkdir -p ${{ github.workspace }}/temp/@galacean/engine
cp -r ${{ github.workspace }}/packages/galacean/dist ${{ github.workspace }}/temp/@galacean/engine
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-xr
cp -r ${{ github.workspace }}/packages/xr/dist ${{ github.workspace }}/temp/@galacean/engine-xr
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-shaderlab
cp -r ${{ github.workspace }}/packages/shader-lab/dist ${{ github.workspace }}/temp/@galacean/engine-shaderlab
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-shader-shaderlab
cp -r ${{ github.workspace }}/packages/shader-shaderlab/dist ${{ github.workspace }}/temp/@galacean/engine-shader-shaderlab
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-physics-lite
cp -r ${{ github.workspace }}/packages/physics-lite/dist ${{ github.workspace }}/temp/@galacean/engine-physics-lite
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-physics-physx
cp -r ${{ github.workspace }}/packages/physics-physx/dist ${{ github.workspace }}/temp/@galacean/engine-physics-physx
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-toolkit
cp -r ${{ github.workspace }}/engine-toolkit/packages/galacean-engine-toolkit/dist/umd ${{ github.workspace }}/temp/@galacean/engine-toolkit
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-lottie
cp -r ${{ github.workspace }}/engine-lottie/dist ${{ github.workspace }}/temp/@galacean/engine-lottie
mkdir -p ${{ github.workspace }}/temp/@galacean/engine-spine
cp -r ${{ github.workspace }}/engine-spine/dist ${{ github.workspace }}/temp/@galacean/engine-spine
find ${{ github.workspace }}/temp
- name: Ensure Adapter Directory Exists
run: mkdir -p ${{ github.workspace }}/platform-adapter/dist

# Create a mock package.json to specify the path and version of the adapter build result when syncing with the CDN later.
# name is set to @galacean/engine-platform-adapter-release to avoid conflicts with the real package.json
# version is set to the version of the engine package
- name: Create package.json for platform-adapter
run: |
VERSION=$(jq -r '.version' ${{ github.workspace }}/packages/galacean/package.json)
echo "{\"name\": \"@galacean/engine-platform-adapter-release\", \"version\": \"$VERSION\"}" > ${{ github.workspace }}/platform-adapter/package.json
cat ${{ github.workspace }}/platform-adapter/package.json
- name: Bundle polyfill and engine
uses: galacean/platform-adapter@main
env:
ADAPTER_BUNDLE_SETTINGS: |
{
"polyfill": true,
"engine": [
"${{ github.workspace }}/temp/@galacean/engine/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-xr/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-shaderlab/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-shader-shaderlab/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-physics-lite/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-physics-physx/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-toolkit/umd/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-lottie/dist/browser.js",
"${{ github.workspace }}/temp/@galacean/engine-spine/dist/browser.js"
],
"wasm": [
"${{ github.workspace }}/packages/physics-physx/libs/physx.release.wasm"
],
"jsWASMLoader": [
"${{ github.workspace }}/packages/physics-physx/libs/physx.release.js"
],
"outputDir": "${{ github.workspace }}/platform-adapter/dist"
}
- name: Print Adapter Bundle
run: find ${{ github.workspace }}/platform-adapter -type f

- name: Release engine packages and Sync to CDN
uses: galacean/publish@main
if: success() || failure()
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_CONFIG_PROVENANCE: true
OASISBE_UPLOAD_URL: https://oasisbe.alipay.com/api/file/no-auth/crypto/upload
OASISBE_REQUEST_HEADER: ${{secrets.OASISBE_REQUEST_HEADER}}
OASISBE_PUBLIC_KEY: ${{secrets.OASISBE_PUBLIC_KEY}}

- name: Sync Platform Adapter to CDN
uses: galacean/publish@main
if: success() || failure()
with:
publish: false
packages: |
platform-adapter
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_CONFIG_PROVENANCE: true
Expand Down
52 changes: 27 additions & 25 deletions e2e/case/material-LUT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,27 @@ import { Camera, Material, MeshRenderer, PrimitiveMesh, Shader, Vector3, WebGLEn
import { initScreenshot, updateForE2E } from "./.mockForE2E";

// Create engine
WebGLEngine.create({ canvas: "canvas" }).then((engine) => {
engine.canvas.resizeByClientSize(2);
WebGLEngine.create({ canvas: "canvas" })
.then((engine) => {
engine.canvas.resizeByClientSize(2);

const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();
// engine.run();
const scene = engine.sceneManager.activeScene;
const rootEntity = scene.createRootEntity();
// engine.run();

// Create camera
const cameraEntity = rootEntity.createChild("Camera");
cameraEntity.transform.position = new Vector3(0, 0, 3);
const camera = cameraEntity.addComponent(Camera);
// Create camera
const cameraEntity = rootEntity.createChild("Camera");
cameraEntity.transform.position = new Vector3(0, 0, 3);
const camera = cameraEntity.addComponent(Camera);

const entity = rootEntity.createChild("Entity");
entity.transform.setRotation(90, 0, 0);
const renderer = entity.addComponent(MeshRenderer);
renderer.mesh = PrimitiveMesh.createPlane(engine, 1, 1);
const entity = rootEntity.createChild("Entity");
entity.transform.setRotation(90, 0, 0);
const renderer = entity.addComponent(MeshRenderer);
renderer.mesh = PrimitiveMesh.createPlane(engine, 1, 1);

const shader = Shader.create(
"LUT-test",
`
const shader = Shader.create(
"LUT-test",
`
attribute vec3 POSITION;
attribute vec2 TEXCOORD_0;
uniform mat4 renderer_MVPMat;
Expand All @@ -35,19 +36,20 @@ WebGLEngine.create({ canvas: "canvas" }).then((engine) => {
gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);
v_uv = TEXCOORD_0;
}`,
`
`
varying vec2 v_uv;
uniform sampler2D scene_prefilteredLUT;
uniform sampler2D scene_PrefilteredDFG;
void main(){
gl_FragColor = texture2D(scene_prefilteredLUT, v_uv);
gl_FragColor = texture2D(scene_PrefilteredDFG, v_uv);
}
`
);
const material = new Material(engine, shader);
renderer.setMaterial(material);
setTimeout(() => {
);
const material = new Material(engine, shader);
renderer.setMaterial(material);
updateForE2E(engine);
initScreenshot(engine, camera);
}, 0);
});
})
.catch((e) => {
console.log(e);
});
17 changes: 9 additions & 8 deletions e2e/case/multi-camera-no-clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
*/
import {
BlinnPhongMaterial,
BloomEffect,
Camera,
CameraClearFlags,
Color,
Engine,
Layer,
Logger,
MeshRenderer,
PostProcess,
PrimitiveMesh,
Scene,
TonemappingEffect,
WebGLEngine,
WebGLMode
} from "@galacean/engine";
Expand Down Expand Up @@ -67,15 +70,13 @@ function initFirstScene(engine: Engine): Scene {
camera2.clearFlags = CameraClearFlags.None;
camera2.msaaSamples = 1;

// @ts-ignore
const bloomEffect = scene._postProcessManager._bloomEffect;
// @ts-ignore
const tonemappingEffect = scene._postProcessManager._tonemappingEffect;
const globalPostProcessEntity = scene.createRootEntity();
const postProcess = globalPostProcessEntity.addComponent(PostProcess);
const bloomEffect = postProcess.addEffect(BloomEffect);
postProcess.addEffect(TonemappingEffect);

bloomEffect.enabled = true;
tonemappingEffect.enabled = true;
bloomEffect.threshold = 0.1;
bloomEffect.intensity = 2;
bloomEffect.threshold.value = 0.1;
bloomEffect.intensity.value = 2;
cameraEntity.transform.setPosition(0, 0, 20);

// Create cube
Expand Down
18 changes: 9 additions & 9 deletions e2e/case/multi-scene-clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
*/
import {
BlinnPhongMaterial,
BloomEffect,
Camera,
CameraClearFlags,
Color,
Engine,
Logger,
MeshRenderer,
PostProcess,
PrimitiveMesh,
Scene,
TonemappingEffect,
WebGLEngine
} from "@galacean/engine";
import { initScreenshot, updateForE2E } from "./.mockForE2E";
Expand Down Expand Up @@ -60,15 +62,13 @@ function initSecondScene(engine: Engine): Camera {
camera.enablePostProcess = true;
// camera.clearFlags = CameraClearFlags.None;

// @ts-ignore
const bloomEffect = scene._postProcessManager._bloomEffect;
// @ts-ignore
const tonemappingEffect = scene._postProcessManager._tonemappingEffect;
const globalPostProcessEntity = scene.createRootEntity();
const postProcess = globalPostProcessEntity.addComponent(PostProcess);
const bloomEffect = postProcess.addEffect(BloomEffect);
postProcess.addEffect(TonemappingEffect);

bloomEffect.enabled = true;
tonemappingEffect.enabled = true;
bloomEffect.threshold = 0.1;
bloomEffect.intensity = 2;
bloomEffect.threshold.value = 0.1;
bloomEffect.intensity.value = 2;
cameraEntity.transform.setPosition(0, 0, 20);

// Create cube
Expand Down
17 changes: 9 additions & 8 deletions e2e/case/multi-scene-no-clear.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
*/
import {
BlinnPhongMaterial,
BloomEffect,
Camera,
CameraClearFlags,
Color,
Engine,
Logger,
MeshRenderer,
PostProcess,
PrimitiveMesh,
Scene,
TonemappingEffect,
WebGLEngine,
WebGLMode
} from "@galacean/engine";
Expand Down Expand Up @@ -66,15 +69,13 @@ function initSecondScene(engine: Engine): Camera {
camera.enablePostProcess = true;
camera.clearFlags = CameraClearFlags.None;

// @ts-ignore
const bloomEffect = scene._postProcessManager._bloomEffect;
// @ts-ignore
const tonemappingEffect = scene._postProcessManager._tonemappingEffect;
const globalPostProcessEntity = scene.createRootEntity();
const postProcess = globalPostProcessEntity.addComponent(PostProcess);
const bloomEffect = postProcess.addEffect(BloomEffect);
postProcess.addEffect(TonemappingEffect);

bloomEffect.enabled = true;
tonemappingEffect.enabled = true;
bloomEffect.threshold = 0.1;
bloomEffect.intensity = 2;
bloomEffect.threshold.value = 0.1;
bloomEffect.intensity.value = 2;
cameraEntity.transform.setPosition(0, 0, 20);

// Create cube
Expand Down
20 changes: 10 additions & 10 deletions e2e/case/postProcess-HDR-bloom-ACES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @title Bloom + HDR + ACES Tonemapping
* @category PostProcess
*/
import { Camera, TonemappingMode } from "@galacean/engine";
import { BloomEffect, Camera, PostProcess, TonemappingEffect, TonemappingMode } from "@galacean/engine";
import { initPostProcessEnv } from "./.initPostProcessEnv";

initPostProcessEnv((camera: Camera, resArray) => {
Expand All @@ -11,15 +11,15 @@ initPostProcessEnv((camera: Camera, resArray) => {

camera.enablePostProcess = true;
camera.enableHDR = true;
// @ts-ignore
const bloomEffect = scene._postProcessManager._bloomEffect;
// @ts-ignore
const tonemappingEffect = scene._postProcessManager._tonemappingEffect;

bloomEffect.enabled = true;
tonemappingEffect.enabled = true;
const globalPostProcessEntity = scene.createRootEntity();
const postProcess = globalPostProcessEntity.addComponent(PostProcess);
const bloomEffect = postProcess.addEffect(BloomEffect);
const tonemappingEffect = postProcess.addEffect(TonemappingEffect);
tonemappingEffect.mode.value = TonemappingMode.ACES;

bloomEffect.threshold = 0.5;
bloomEffect.dirtTexture = dirtTexture;
tonemappingEffect.mode = TonemappingMode.ACES;
bloomEffect.threshold.value = 0.5;
bloomEffect.intensity.value = 1;
bloomEffect.dirtTexture.value = dirtTexture;
tonemappingEffect.mode.value = TonemappingMode.ACES;
});
20 changes: 10 additions & 10 deletions e2e/case/postProcess-HDR-bloom-neutral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @title Bloom + HDR + Neutral Tonemapping
* @category PostProcess
*/
import { Camera, TonemappingMode } from "@galacean/engine";
import { BloomEffect, Camera, PostProcess, TonemappingEffect, TonemappingMode } from "@galacean/engine";
import { initPostProcessEnv } from "./.initPostProcessEnv";

initPostProcessEnv((camera: Camera, resArray) => {
Expand All @@ -11,15 +11,15 @@ initPostProcessEnv((camera: Camera, resArray) => {

camera.enablePostProcess = true;
camera.enableHDR = true;
// @ts-ignore
const bloomEffect = scene._postProcessManager._bloomEffect;
// @ts-ignore
const tonemappingEffect = scene._postProcessManager._tonemappingEffect;

bloomEffect.enabled = true;
tonemappingEffect.enabled = true;
const globalPostProcessEntity = scene.createRootEntity();
const postProcess = globalPostProcessEntity.addComponent(PostProcess);
const bloomEffect = postProcess.addEffect(BloomEffect);
const tonemappingEffect = postProcess.addEffect(TonemappingEffect);
tonemappingEffect.mode.value = TonemappingMode.ACES;

bloomEffect.threshold = 0.5;
bloomEffect.dirtTexture = dirtTexture;
tonemappingEffect.mode = TonemappingMode.Neutral;
bloomEffect.threshold.value = 0.5;
bloomEffect.intensity.value = 1;
bloomEffect.dirtTexture.value = dirtTexture;
tonemappingEffect.mode.value = TonemappingMode.Neutral;
});
Loading

0 comments on commit c2cd4ab

Please sign in to comment.