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: Setting receiveShadow to true produces shader error with flat shaded objects. #29325

Closed
Mugen87 opened this issue Sep 4, 2024 · 2 comments
Labels
Milestone

Comments

@Mugen87
Copy link
Collaborator

Mugen87 commented Sep 4, 2024

Description

While working on ShadowMapViewer I have noticed that flat shaded objects that receive shadow produce a WGSL error which is logged in the browser console as a warning.

Error while parsing WGSL: :87:33 error: built-in cannot be used by vertex pipeline stage
normalFlat = normalize( cross( dpdx( varyings.v_positionView ), - dpdy( varyings.v_positionView ) ) );
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The screen also gets white so nothing is rendered.

Commenting out mesh.receiveShadow = true; or disable flat shading fixes the issue.

Reproduction steps

  1. Open https://jsfiddle.net/fcxk984g/
  2. Check browser console.

Live example

Version

r168

Device

Desktop, Mobile, Headset

Browser

Chrome

OS

MacOS

@Mugen87 Mugen87 changed the title WebGPURenderer: Setting receiveShadow to true produces shader error. WebGPURenderer: Setting receiveShadow to true produces shader error with flat shaded objects. Sep 4, 2024
@Mugen87 Mugen87 added Bug and removed Regression labels Sep 4, 2024
@Mugen87
Copy link
Collaborator Author

Mugen87 commented Sep 6, 2024

According to the WGSL spec, derivative functions can only be used in a fragment shader stage.

https://www.w3.org/TR/WGSL/#derivative-builtin-functions

So it seems the TSL must avoid to use dFdx() and dFdy() in code assigned to vertex node.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented Oct 22, 2024

This seems to be fixed in dev 🎉.

@Mugen87 Mugen87 closed this as completed Oct 22, 2024
@Mugen87 Mugen87 added this to the r170 milestone Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant