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

WebGLShadowmap: Handle TwoPassDoubleSide case #25221

Merged
merged 1 commit into from
Jan 4, 2023

Conversation

WestLangley
Copy link
Collaborator

No description provided.

@WestLangley WestLangley added this to the r149 milestone Jan 2, 2023
@WestLangley
Copy link
Collaborator Author

@gkjohnson @Mugen87

In light of this PR, does this code block need to be changed?

if ( type === VSMShadowMap ) {
result.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;
} else {
result.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ];
}

@gkjohnson
Copy link
Collaborator

With a quick look - it seems like it should be okay? The renderer falls back to using DoubleSided renderering with non transparent materials. But maybe it's worth being explicit?

if ( material.transparent === true && material.side === TwoPassDoubleSide ) {
material.side = BackSide;
material.needsUpdate = true;
getProgram( material, scene, object );
material.side = FrontSide;
material.needsUpdate = true;
getProgram( material, scene, object );
material.side = TwoPassDoubleSide;
} else {
getProgram( material, scene, object );
}

@@ -28,7 +28,7 @@ function WebGLShadowMap( _renderer, _objects, _capabilities ) {

_maxTextureSize = _capabilities.maxTextureSize;

const shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };
const shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide, 3: DoubleSide };
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we do { [ FrontSide ]: BackSide, [ BackSide ]: FrontSide, ... } here?

@WestLangley
Copy link
Collaborator Author

Rephrasing my question... Is VSM handled correctly given material.side can now be TwoPassDoubleSide? (Should it map to DoubleSide?)

if ( type === VSMShadowMap ) {
result.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;
} else {
result.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ];
}

FYI, see related comment.

@gkjohnson
Copy link
Collaborator

Rephrasing my question... Is VSM handled correctly given material.side can now be TwoPassDoubleSide? (Should it map to DoubleSide?)

What I'm saying is that the render behavior for shadows with DoubleSide and TwoPassDoubleSide should be the same since the materials are not transparent.

@WestLangley
Copy link
Collaborator Author

Thanks, @gkjohnson for your reply.

I still am not a fan this design, but the code needs to be fixed, so merging.

@WestLangley WestLangley merged commit 81cf2ab into mrdoob:dev Jan 4, 2023
@WestLangley WestLangley deleted the dev_two_pass branch January 4, 2023 00:27
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.

4 participants