I’d like to pass a map
options that holds a texture to my custom ShaderMaterial but I get an error, like this:
const material = new ShaderMaterial({
// ... literally copied MeshLambertMaterial shader here, verbatim ...
map: texture, // and I want to use a texture
})
// ...
renderer.render(scene, camera)
But when I try to do this, i get an error in console like
gl.getShaderInfoLog() fragment ERROR: 0:884: 'map' : undeclared identifier
When I check the shader output in the console, I see that USE_MAP
is not defined.
I also tried this:
const material = new ShaderMaterial({
// ... literally copied MeshLambertMaterial shader here, verbatim ...
map: texture, // and I want to use a texture
})
// RIGHT HERE
material.uniforms.map.value = texture
// ...
renderer.render(scene, camera)
so set the uniform, which I thought would cause WebGLProgram to see the map and therefore to #define USE_MAP
, but that doesn’t seem to happen.
I basically made an exact replica of MeshLambertMaterial
by concatenating ShaderChunk
s, etc, so the result shader code is identical to MeshLambertMaterial’s shader code).
How do we apply a texture to a this shader that is built using all the default pars
as MeshLambertMaterial, so that USE_MAP will be defined and the map
variable will exist?