-
-
Notifications
You must be signed in to change notification settings - Fork 36.1k
WebGPURenderer: Improve AO approach #28863
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
base: dev
Are you sure you want to change the base?
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
src/nodes/display/AfterImageNode.js
Outdated
| import { nodeObject, addNodeElement, tslFn, float, vec4 } from '../shadernode/ShaderNode.js'; | ||
| import { NodeUpdateType } from '../core/constants.js'; | ||
| import { uv } from '../accessors/UVNode.js'; | ||
| import { after } from '../utils/AfterNode.js' |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
|
I'm all in for improving quality but we have to make sure to make the examples not too complex. Or at least we should provide a good mix of simple and advanced demos. Hence, I suggest to keep Then we can add advanced examples ( A component like That said, it should still be easy to configure a basic pass chain on app level so I would like to not move away from this possibility. But it's a good idea to provide a component like |
|
I was coming to this conclusion too, yesterday I made some related modifications and I'm updating the PR. I was thinking about just keeping What do you think about This should be the code necessary to obtain AO: postProcessing = new THREE.PostProcessing( renderer );
const scenePass = standardPass( scene, camera, { enableAO: true } );
// scenePass.aoIntensityNode = uniform( 1 ); // optional
postProcessing.outputNode = scenePass;I thought about the possibility of having an opaquePass that we could share but we would have problems with the AO not respecting the lighting model. |
Yes, it should be possible to enable/disable the effects. But tbh, I'm still unsure about the API at this point and would like to hear the opinion of @mrdoob. The thing is....if we have something like It reminds me a bit at the old material system from FX is in general a custom step and pass chains usually look different from app to app. I'm not familiar enough with something like That said, I would only use I would consider |
|
MRT also results in other overheads, I don't think this approach would have that much overhead considering the benefits. I can't see an ideal scenario for using AO when it's not compatible with transparent materials outside of our example bubble. About Maybe the ideal would be to have an |
|
I'll look for a way to remove |
Could we at least make the the opaque pass configurable so if not wanted it can be disabled? In this case the normal and depth buffer from the beauty pass should be used. Edit: I'm okay if opaque pass is used by default. But it would be great to have the option for an optimization.
Sounds good! |
|
|
||
| let camera, scene, renderer, postProcessing, controls, clock, stats, mixer; | ||
|
|
||
| let aoPass, denoisePass, blendPassAO, blendPassDenoise, scenePassColor, aoIntensity; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
|
|
||
| let camera, scene, renderer, postProcessing, controls, clock, stats, mixer; | ||
|
|
||
| let aoPass, denoisePass, blendPassAO, blendPassDenoise, scenePassColor, aoIntensity; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
|
|
||
| let camera, scene, renderer, postProcessing, controls, clock, stats, mixer; | ||
|
|
||
| let aoPass, denoisePass, blendPassAO, blendPassDenoise, scenePassColor, aoIntensity; |
Check notice
Code scanning / CodeQL
Unused variable, import, function or class
|
After spending a lot of time with our new post processing stack I must say I love the way we define post processing effects via nodes! Hence, I came up with an updated version of what has been discussed/developed in this PR one year ago. How about we introduce a new TSL function const prePassNode = prePass( scene, camera );
// below properties control the standard output, both would be true by default.
// in most cases, developers should be interested in a depth and normal prepass
prePassNode.depth = true;
prePassNode.normals = true;
// below properties control which render lists should be honored
prePassNode.opaque = true;
prePassNode.transparent = false;
// optionally, prePass() also accepts a MRT configuration
/*
scenePass.setMRT( mrt( {
output: normalView,
emissive: emissive
} ) );
*/
const prePassDepth = prePassNode.getTextureNode( 'depth' );
const prePassNormals = prePassNode.getTextureNode( 'normal' );
// compute AO
const aoNode = ao( prePassDepth, prePassNormals, camera );
// scene pass
const scenePass = pass( scene, camera );
scenePass.aoNode = aoNode; // this wires the AO with the beauty pass
// scenePass.sssNode = sssNode; // potential SSS integration
// output
postProcessing.outputNode = scenePass;The idea is to connect the output of I have not added @sunag What do you think of this approach? |
I loved the approach. I can work on improvements to make this possible. It should be more about having a global context node that could be changed between render calls. |
|
Feel free to start working on this 🙌 . It's mostly based on your code of the PR anyway just with a slight different interface. I'll focus on #31768 first before I do something else^^. |
|
I like the |
Related issue: #28844
Description
Introduce NodeHandler
You could manipulate materials individually, allowing direct customization of materials globally. This would be a step towards solving Add support for skinning >4 bones per vertex with a bone weight texture #26222 (comment)
Introduce renderer.transparent and renderer.opaque
I added new handlers to have different approaches in transparent and opaque materials, important for the pass() approach.
TSL: Introduce after and before
Allows you to control the sequence of node updates, important for
pass()andnode.updateBefore()add standardPass() and improve ao approach
The idea here is to have a simplified
pass()making available the main and common resources of the renderer, such asao,bloom,3dlut, which can be enabled or disabled, leaving the approach part to us, which would simplify mainly for the beginner to have a PP of good quality.I'll create separate PRs for
render.transparent/opaque,NodeHandlerandafter/beforebefore merge this one.AO Approch
Live example
I will improve this example too 😅. It is possible to see a transparent object and an emissive one respecting the lighting model.