WebGPURenderer: Apply fog before tonemapping and encoding#27850
Merged
Conversation
Collaborator
Author
|
I created an example of how we can solve this in TSL without needing a transparent background. // render scene pass ( the same of css )
const scenePass = pass( scene, camera );
const scenePassViewZ = scenePass.getViewZNode();
// background color
const backgroundColor = color( 0x0066ff );
// get fog factor from scene pass context
// equivalent to: scene.fog = new THREE.Fog( 0x0066ff, 2.5, 4 );
const fogFactor = rangeFog( backgroundColor, 2.5, 4 ).context( { viewZ: scenePassViewZ } );
// tone mapping scene pass
const scenePassTM = scenePass.toneMapping( THREE.ACESFilmicToneMapping );
// mix fog from fog factor and background color
const compose = fogFactor.mix( scenePassTM, backgroundColor );
postProcessing = new PostProcessing( renderer );
postProcessing.outputNode = compose; |
LeviPesin
reviewed
Mar 8, 2024
|
|
||
| } | ||
|
|
||
| getViewZNode() { |
Contributor
There was a problem hiding this comment.
Maybe we can do these just as getters? I.e. something like get viewZ(), get depth() instead of getViewZNode(), getDepthNode()?
Collaborator
Author
There was a problem hiding this comment.
I think it's a good idea move to getters, I just will add *Node suffix.
LeviPesin
reviewed
Mar 8, 2024
| export const toneMapping = ( mapping, exposure, color ) => nodeObject( new ToneMappingNode( mapping, nodeObject( exposure ), nodeObject( color ) ) ); | ||
| export const toneMappingExposure = rendererReference( 'toneMappingExposure', 'float' ); | ||
|
|
||
| addNodeElement( 'toneMapping', ( color, mapping, exposure ) => toneMapping( mapping, exposure, color ) ); |
Contributor
There was a problem hiding this comment.
I think this may be quite confusing...
Owner
Sounds good yep! |
This was referenced Mar 23, 2024
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

Related: #26857
@mrdoob Do you think we can advance this implementation in
WebGPURenderer? it seems important to add transmission in this architecture.