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

NormalMapNode: Fix dpdx and dpdy called from non-uniform control flow #24062

Merged
merged 1 commit into from
May 21, 2022

Conversation

sunag
Copy link
Collaborator

@sunag sunag commented May 15, 2022

Related issue: #24059 (comment)

Description

I believe that this conditional was inserted to optimize the shader, although conditionals are always expensive for GPU.

Code without conditionals is understood as uniform control flow and with conditional non-uniform control flow.
Ref: https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.4.50.pdf - page 23

This fix WebGPU warning: 'dpdy' must only be called from uniform control flow and follow the approach closer of http://www.thetenthplanet.de/archives/1180

I wounder if this is not responsible for bugs in WebGL using perturbNormal2Arb too!?...

This contribution is funded by Google via Igalia

@sunag sunag added this to the r141 milestone May 15, 2022
@sunag sunag changed the title NormalMapNode: Fix dpdx and dpdy called from uniform control flow NormalMapNode: Fix dpdx and dpdy called from non-uniform control flow May 15, 2022
@Mugen87
Copy link
Collaborator

Mugen87 commented May 16, 2022

I wounder if this is not responsible for bugs in WebGL using perturbNormal2Arb too!?...

On what line of code in normalmap_pars_fragment are you referring to?

@LeviPesin
Copy link
Contributor

I think

float scale = ( det == 0.0 ) ? 0.0 : faceDirection * inversesqrt( det );
.

@sunag
Copy link
Collaborator Author

sunag commented May 16, 2022

On what line of code in normalmap_pars_fragment are you referring to?

The line was the mentioned by @LeviPesin, I say this mainly because of the workaround for Adreno

@sunag sunag merged commit 2231124 into mrdoob:dev May 21, 2022
@sunag sunag deleted the dev-fix-dpdxy branch May 21, 2022 23:54
abernier pushed a commit to abernier/three.js that referenced this pull request Sep 16, 2022
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