FarazzShaikh / THREE-CustomShaderMaterial

Extend Three.js standard materials with your own shaders!
Other
846 stars 54 forks source link

If the base material has a map, a CSM from it throws an error on three >= 0.151.0 #35

Closed hamzakubba closed 1 year ago

hamzakubba commented 1 year ago

Managed to repro here: https://codesandbox.io/s/customshadermaterial-hero-forked-0976xh?file=/src/App.jsx you do need to open your browser console to see this as it doesn't show up in CSB's console.

I believe this is related to this change https://github.com/mrdoob/three.js/pull/25740/files#diff-202a730a51aad3c22e059efd980a6cd5c5d0637a6abd240b3bdee3e5ff30aaa2L530 from this PR https://github.com/mrdoob/three.js/pull/25740

Relevant error (line numbers may be different):

FRAGMENT ERROR: 0:1553: 'vUv' : undeclared identifier

  1548:     #if defined IS_UNKNOWN || defined IS_SHADERMATERIAL || defined IS_MESHDEPTHMATERIAL || defined IS_MESHNORMALMATERIAL || defined IS_SHADOWMATERIAL
  1549:         vec4 csm_DiffuseColor = vec4(1., 0., 1., 1.);
  1550:         vec4 csm_FragColor = vec4(1., 0., 1., 1.);
  1551:     #else
  1552:         #ifdef USE_MAP
> 1553:             vec4 _csm_sampledDiffuseColor = texture2D(map, vUv);
  1554: 
  1555:             #ifdef DECODE_VIDEO_TEXTURE

I'm not entirely sure this can be fixed on this end... thanks! :)

PS: opened corresponding issue on three's repo: https://github.com/mrdoob/three.js/issues/25742

FarazzShaikh commented 1 year ago

Fixed in 5.3.4 https://codesandbox.io/s/customshadermaterial-hero-forked-um6eqv