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

MeshPhysicalMaterial: Fix shader error for clear coat/anisotropy when normal map is missing. #26334

Merged
merged 2 commits into from
Jun 27, 2023

Conversation

repalash
Copy link
Contributor

@repalash repalash commented Jun 27, 2023

Related PR discussion: #25580 (comment)

Description

Add support for using vUv or vClearcoatMapUv for anisotropy when normal map is not present.
This is the smallest fix. It's also possible to set USE_UV in javascript instead of checking for USE_ANISTROPY while defining the variable.

Fixes loading of model from: https://discourse.threejs.org/t/shader-error-0-validate-status-false/53195/2
Model: https://sketchfab.com/3d-models/free-1975-porsche-911-930-turbo-8568d9d14a994b9cae59499f0dbed21e#download

@github-actions
Copy link

github-actions bot commented Jun 27, 2023

📦 Bundle size

Full ESM build, minified and gzipped.

Filesize dev Filesize PR Diff
642.9 kB (159.4 kB) 643.1 kB (159.5 kB) +266 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Filesize dev Filesize PR Diff
436.1 kB (105.6 kB) 436.4 kB (105.6 kB) +266 B

@elalish
Copy link
Contributor

elalish commented Jun 27, 2023

Thanks, that looks reasonable to me.

@Mugen87
Copy link
Collaborator

Mugen87 commented Jun 27, 2023

I can confirm this fixes the issues for me as well! Merging for now so we have a hotfix for r154.

@Mugen87 Mugen87 added this to the r154 milestone Jun 27, 2023
@Mugen87 Mugen87 merged commit e2ea766 into mrdoob:dev Jun 27, 2023
@Mugen87 Mugen87 changed the title Fix shader error in anisotropy when normal map is missing MeshPhysicalMaterial: Fix shader error for clear coat/anisotropy when normal map is missing. Jun 27, 2023
@@ -1,5 +1,5 @@
export default /* glsl */`
#ifdef USE_UV
#if defined( USE_UV ) || defined( USE_ANISOTROPY )
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this line is required, then USE_UV is not properly defined.

It's also possible to set USE_UV in javascript instead of checking for USE_ANISOTROPY while defining the variable.

Right. Why didn't you do that?

Copy link
Contributor Author

@repalash repalash Jun 27, 2023

Choose a reason for hiding this comment

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

I was not sure what the plan was for USE_UV after #25740 and a hotfix was required.
Do you recommend setting parameters.vertexUvs when anisotropy is present or creating the define either in WebGLProgram or WebGLRenderer.
Also, there is vAnisotropyMapUv that could be considered or defined cleanly when no normal map is present.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@repalash This is not your fault. Thank you for your contribution.

I think USE_UV should be properly defined. Where it is best to define it at this point I would leave to @Mugen87 and yourself.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, there is vAnisotropyMapUv that could be considered or defined cleanly when no normal map is present.

I would favor this approach (if feasible) since anisotropy would work similar to clear coat then.

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