Skip to content
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

WebGPURenderer: Revert and fix updateBefore() - (2) #26422

Merged
merged 3 commits into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions examples/jsm/renderers/common/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,10 @@ class Renderer {

//

sceneRef.onBeforeRender( this, scene, camera, renderTarget );

//

_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
_frustum.setFromProjectionMatrix( _projScreenMatrix, coordinateSystem );

Expand Down Expand Up @@ -318,6 +322,10 @@ class Renderer {

this._lastRenderContext = renderContext;

//

sceneRef.onAfterRender( this, scene, camera, renderTarget );

}

setAnimationLoop( callback ) {
Expand Down Expand Up @@ -822,12 +830,6 @@ class Renderer {

}

_getRenderObject( object, material, scene, camera, lightsNode, passId ) {

return this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, passId );

}

_renderObject( object, scene, camera, geometry, material, group, lightsNode ) {

material = scene.overrideMaterial !== null ? scene.overrideMaterial : material;
Expand All @@ -836,36 +838,23 @@ class Renderer {

object.onBeforeRender( this, scene, camera, geometry, material, group );

//

const renderObject = this._getRenderObject( object, material, scene, camera, lightsNode );

this._nodes.updateBefore( renderObject );

//

object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
object.normalMatrix.getNormalMatrix( object.modelViewMatrix );

//

material.onBeforeRender( this, scene, camera, geometry, material, group );

//

if ( material.transparent === true && material.side === DoubleSide && material.forceSinglePass === false ) {

material.side = BackSide;
this._renderObjectDirect( this._getRenderObject( object, material, scene, camera, lightsNode, 'backSide' ) ); // create backSide pass id
this._renderObjectDirect( object, material, scene, camera, lightsNode, 'backSide' ); // create backSide pass id

material.side = FrontSide;
this._renderObjectDirect( renderObject ); // use default pass id
this._renderObjectDirect( object, material, scene, camera, lightsNode ); // use default pass id

material.side = DoubleSide;

} else {

this._renderObjectDirect( renderObject );
this._renderObjectDirect( object, material, scene, camera, lightsNode );

}

Expand All @@ -875,7 +864,20 @@ class Renderer {

}

_renderObjectDirect( renderObject ) {
_renderObjectDirect( object, material, scene, camera, lightsNode, passId ) {

const renderObject = this._objects.get( object, material, scene, camera, lightsNode, this._currentRenderContext, passId );

//

this._nodes.updateBefore( renderObject );

//

object.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );
Copy link
Contributor

Choose a reason for hiding this comment

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

Wouldn't these lines be called twice in case of double-pass transparent rendering?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Wouldn't these lines be called twice in case of double-pass transparent rendering?

The updateBefore() can made RTT because of some nodes, and this can affect the current modelViewMatrix, I'll improve this once I have a better idea, I'm currently prioritizing stability.

object.normalMatrix.getNormalMatrix( object.modelViewMatrix );

//

this._nodes.updateForRender( renderObject );
this._geometries.updateForRender( renderObject );
Expand Down