-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support post process #2129
Merged
Merged
Support post process #2129
Changes from 48 commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
7dd4ad9
feat: init API from RFC
zhuxudong 84ab347
refactor: use pass
zhuxudong 7fce166
feat: init passes
zhuxudong fe68f92
feat: init effect api
zhuxudong 297edda
feat: add hdr
zhuxudong d976fc2
refactor: change independentCanvasEnabled
zhuxudong fa36515
feat: add RT switch
zhuxudong 03240bf
feat: init filter effect
zhuxudong 2a2221f
feat: add HQ bloom
zhuxudong 3e00e8e
fix: gamma to linear
zhuxudong 2dc255a
feat: init bloom shader
zhuxudong 09b76e4
feat: support bloom shader
zhuxudong 27a56d7
Merge branch 'dev/1.3' into feat/post-process
zhuxudong f13e3ea
feat: init tonemapping
zhuxudong 53531d5
fix: shader error
zhuxudong 0205090
refactor: limit max iteration
zhuxudong 9fb5169
fix: clamp specular AA
zhuxudong 7884c6d
ci: test error
zhuxudong 52a1c91
Merge branch 'dev/1.3' into feat/post-process
zhuxudong 54dcbaa
refactor: use RenderBufferStoreAction
zhuxudong 1cc4f0a
refactor: move postProcess code to manager
zhuxudong d38375c
refactor: use triangle to blit render target
zhuxudong cd9facc
refactor: remove post renderTarget from context to manager
zhuxudong 409ad66
refactor: neutral shader refactor
zhuxudong d459ec9
refactor: add full workflow ACES tonemapping
zhuxudong e248d60
refactor: rename
zhuxudong db81a33
fix: color space error
zhuxudong bb5f096
refactor: saturate final color
zhuxudong 7979b9b
ci: add e2e test
zhuxudong d377549
ci: commit AI check
zhuxudong c9a218c
refactor: use better hdr format (#12)
GuoLei1990 55bbd85
perf: use R11G11B10_Ufloat format for HDR
zhuxudong 02d2199
refactor: move shader strings to shaderlib
zhuxudong 95a8945
refactor: rename
zhuxudong 1ad73ca
chore: rename
zhuxudong 1d748e4
test: change api
zhuxudong 528329e
perf: use mediump precision
zhuxudong 26288f1
perf: blit to screen
zhuxudong 4356e66
ci: add comment
zhuxudong 3e978f8
perf: use const pre compute
zhuxudong edc047b
perf: use aces simple workflow
zhuxudong 75c7013
perf: check active post pocess effect when enablePostProcess
zhuxudong c3c499b
perf: release internal RT when disable bloom
zhuxudong c86a9d4
perf: no need generateMipmaps before blit
zhuxudong 5458d9c
perf: less blit
zhuxudong 3120f58
refactor: delete engine in constructor
zhuxudong 24d5a31
refactor: format code and e2e
zhuxudong 17cf57e
fix: clamp specular AA
zhuxudong 5bf3965
refactor: comment
zhuxudong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
AmbientLight, | ||
AssetType, | ||
BackgroundMode, | ||
Camera, | ||
GLTFResource, | ||
PrimitiveMesh, | ||
SkyBoxMaterial, | ||
Texture2D, | ||
Vector3, | ||
WebGLEngine | ||
} from "@galacean/engine"; | ||
import { initScreenshot, updateForE2E } from "./.mockForE2E"; | ||
|
||
export async function initPostProcessEnv( | ||
callback: (camera: Camera, resArray: [GLTFResource, AmbientLight, Texture2D]) => void | ||
) { | ||
WebGLEngine.create({ canvas: "canvas" }).then((engine) => { | ||
engine.canvas.resizeByClientSize(); | ||
|
||
const scene = engine.sceneManager.activeScene; | ||
const rootEntity = scene.createRootEntity(); | ||
|
||
//Create camera | ||
const cameraNode = rootEntity.createChild("camera_node"); | ||
cameraNode.transform.position.set(4, 0, 6); | ||
cameraNode.transform.lookAt(new Vector3(1, 0, 0)); | ||
const camera = cameraNode.addComponent(Camera); | ||
|
||
Promise.all([ | ||
engine.resourceManager | ||
.load<GLTFResource>("https://gw.alipayobjects.com/os/bmw-prod/a1da72a4-023e-4bb1-9629-0f4b0f6b6fc4.glb") | ||
.then((glTF) => { | ||
const defaultSceneRoot = glTF.instantiateSceneRoot(); | ||
rootEntity.addChild(defaultSceneRoot); | ||
return glTF; | ||
}), | ||
engine.resourceManager | ||
.load<AmbientLight>({ | ||
type: AssetType.Env, | ||
url: "https://gw.alipayobjects.com/os/bmw-prod/89c54544-1184-45a1-b0f5-c0b17e5c3e68.bin" | ||
}) | ||
.then((ambientLight) => { | ||
scene.ambientLight = ambientLight; | ||
const sky = scene.background.sky; | ||
const skyMaterial = new SkyBoxMaterial(engine); | ||
scene.background.mode = BackgroundMode.Sky; | ||
|
||
sky.material = skyMaterial; | ||
sky.mesh = PrimitiveMesh.createCuboid(engine, 1, 1, 1); | ||
skyMaterial.texture = ambientLight.specularTexture; | ||
skyMaterial.textureDecodeRGBM = true; | ||
return ambientLight; | ||
}), | ||
engine.resourceManager.load<Texture2D>({ | ||
type: AssetType.Texture2D, | ||
url: "https://mdn.alipayobjects.com/huamei_dmxymu/afts/img/A*tMeTQ4Mx60oAAAAAAAAAAAAADuuHAQ/original" | ||
}) | ||
]).then((resArray) => { | ||
callback(camera, resArray); | ||
|
||
updateForE2E(engine); | ||
|
||
initScreenshot(engine, camera); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @title Bloom + HDR + ACES Tonemapping | ||
* @category PostProcess | ||
*/ | ||
import { Camera, TonemappingMode } from "@galacean/engine"; | ||
import { initPostProcessEnv } from "./.initPostProcessEnv"; | ||
|
||
initPostProcessEnv((camera: Camera, resArray) => { | ||
const [_, __, dirtTexture] = resArray; | ||
const scene = camera.scene; | ||
|
||
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; | ||
|
||
bloomEffect.threshold = 0.5; | ||
bloomEffect.dirtTexture = dirtTexture; | ||
tonemappingEffect.mode = TonemappingMode.ACES; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @title Bloom + HDR + Neutral Tonemapping | ||
* @category PostProcess | ||
*/ | ||
import { Camera, TonemappingMode } from "@galacean/engine"; | ||
import { initPostProcessEnv } from "./.initPostProcessEnv"; | ||
|
||
initPostProcessEnv((camera: Camera, resArray) => { | ||
const [_, __, dirtTexture] = resArray; | ||
const scene = camera.scene; | ||
|
||
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; | ||
|
||
bloomEffect.threshold = 0.5; | ||
bloomEffect.dirtTexture = dirtTexture; | ||
tonemappingEffect.mode = TonemappingMode.Neutral; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* @title Bloom + LDR + Neutral Tonemapping | ||
* @category PostProcess | ||
*/ | ||
import { Camera, TonemappingMode } from "@galacean/engine"; | ||
import { initPostProcessEnv } from "./.initPostProcessEnv"; | ||
|
||
initPostProcessEnv((camera: Camera, resArray) => { | ||
const [_, __, dirtTexture] = resArray; | ||
const scene = camera.scene; | ||
|
||
camera.enablePostProcess = true; | ||
camera.enableHDR = false; | ||
// @ts-ignore | ||
const bloomEffect = scene._postProcessManager._bloomEffect; | ||
// @ts-ignore | ||
const tonemappingEffect = scene._postProcessManager._tonemappingEffect; | ||
Comment on lines
+14
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid using private properties directly. Using private properties like // @ts-ignore
const bloomEffect = scene._postProcessManager._bloomEffect;
// @ts-ignore
const tonemappingEffect = scene._postProcessManager._tonemappingEffect;
// Consider refactoring to use public methods if available
|
||
|
||
bloomEffect.enabled = true; | ||
tonemappingEffect.enabled = true; | ||
|
||
bloomEffect.threshold = 0.5; | ||
bloomEffect.dirtTexture = dirtTexture; | ||
tonemappingEffect.mode = TonemappingMode.Neutral; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
e2e/fixtures/originImage/PostProcess_postProcess-HDR-bloom-ACES.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
e2e/fixtures/originImage/PostProcess_postProcess-HDR-bloom-neutral.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
e2e/fixtures/originImage/PostProcess_postProcess-LDR-bloom-neutral.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using private properties directly.
Using private properties like
_postProcessManager
directly is discouraged. Consider adding public methods to access these properties.