FarazzShaikh / THREE-CustomShaderMaterial

🧩 Extend Three.js standard materials with your own shaders!
https://farazzshaikh.github.io/THREE-CustomShaderMaterial/
MIT License
890 stars 56 forks source link

CSM doesn't source texture maps #17

Closed hmans closed 2 years ago

hmans commented 2 years ago

When creating a CSM based off MeshStandardMaterial and assigning a map prop referencing a texture, the texture will only be used when not passing a fragment shader chunk to the CSM, or passing a fragment shader chunk that doesn't have a main entrypoint. As soon as you pass a chunk with a main, the diffuse/fragment colors will always reset to red (or whatever color you end up setting yourself in the shader.)

Currently, you need to work around this by sourcing the texture yourself:

void main() {
  csm_FragColor = texture2D(map, vUv);
}
hmans commented 2 years ago

Quickly updating this to mention that I was no longer able to reproduce this, so I'm self-closing it for now until I can.

FarazzShaikh commented 2 years ago

3.4.0 should button this up even if its not fixed

hmans commented 2 years ago

Correction to my previous comment: I could reproduce it, the bug occurred when I had a code comment that included the string csm_DiffuseColor. But since a fix is coming up, I will leave it closed. Thanks!