Skip to content

Conversation

@sunag
Copy link
Collaborator

@sunag sunag commented Feb 29, 2024

Related: #26857

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

@sunag
Copy link
Collaborator Author

sunag commented Mar 3, 2024

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;

image

/cc @donmccurdy @Mugen87 @LeviPesin

@sunag sunag added this to the r163 milestone Mar 3, 2024

}

getViewZNode() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can do these just as getters? I.e. something like get viewZ(), get depth() instead of getViewZNode(), getDepthNode()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea move to getters, I just will add *Node suffix.

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 ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be quite confusing...

@mrdoob
Copy link
Owner

mrdoob commented Mar 12, 2024

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

Sounds good yep!

@sunag sunag marked this pull request as ready for review March 13, 2024 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants