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

getShadowMask equivalent in TSL #30220

Closed
Samsy opened this issue Dec 27, 2024 · 6 comments · Fixed by #30247
Closed

getShadowMask equivalent in TSL #30220

Samsy opened this issue Dec 27, 2024 · 6 comments · Fixed by #30247

Comments

@Samsy
Copy link
Contributor

Samsy commented Dec 27, 2024

Description

Hey there !

Ocean Water from legacy to TSL,

The Ocean TSL examples does not support shadow-mapping as in the legacy one :

https://github.com/mrdoob/three.js/blob/master/examples/jsm/objects/Water.js#L181C71-L181C84

I was looking for an equivalent of getShadowMask, to be used inside a fragmentNode, checked on the examples and the wiki but had no chance :

float shadowMask = getShadowMask();

@sunag
Copy link
Collaborator

sunag commented Dec 30, 2024

@Mugen87 I think these examples like Water should be moved to .colorNode instead of .fragmentNode and perhaps we could use a MeshLambertNodeMaterial for shadow materials, must be compatible with fog, and MRT and would be more in line with a "real" lighting proposal.

@Mugen87
Copy link
Collaborator

Mugen87 commented Dec 30, 2024

That sounds good to me. Using fragmentNode was a start but it's indeed better to keep as much as built-in material features as possible.

@Samsy
Copy link
Contributor Author

Samsy commented Dec 31, 2024

About general customisation of materials, Is there a way to get access an equivalent of getShadowMask ?

@WestLangley
Copy link
Collaborator

WestLangley commented Dec 31, 2024

Water.js was introduced back when the three.js Lambert shader was implemented via per-vertex lighting. Hence, the need for getShadowMask(), which is a hack.

The same hack is required by MeshGouraudMaterial, where shadows not only have the incorrect tint, they are highly-sensitive to the tessellation of the geometry.

I am inclined to think that a better approach would be to improve the water shader -- and, perhaps, deprecate both MeshGouraudMaterial and getShadowMask().

@Mugen87
Copy link
Collaborator

Mugen87 commented Jan 1, 2025

In the meanwhile, I also think that just having Phong shading in materials is more beneficial than the small performance benefit of Gouraud shading. We end up with more consistent materials and less edge cases.

Hence, I support the suggested deprecation.

@sunag
Copy link
Collaborator

sunag commented Jan 1, 2025

About general customisation of materials, Is there a way to get access an equivalent of getShadowMask ?

Since shadow is the absence of light, in this case when we update Water to a material that is compatible with lighting, you can use material.receivedShadowNode to manipulate the shadow #29840

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants