ShaderMaterial from MeshStandarMaterial how can i use the standard color

Hello i try to generate a MeshStandardMaterial with a ShaderMaterial

let standard = THREE.ShaderLib[‘standard’];
const material = new THREE.ShaderMaterial({
lights:true,
fog:true,
fragmentShader: standard.fragmentShader,
vertexShader: standard.vertexShader,
defaultAttributeValues: {‘color’: new THREE.Color(0x0054df ),‘uv’: [ 0, 0 ],
‘uv2’: [ 0, 0 ]},
uniforms:{ …UniformsUtils.clone(standard.uniforms)
},
color: new THREE.Color(0x0054df )
});

but i add this to a PlaneBuffer Geometry and set the material needsUpdate true

anyway the color is still black

Does your scene have any lighting? You’ll need at least an ambient to see anything.

hmm thx will try! i use the scene.environment with THREE.PMREMGenerator

found this example https://jsfiddle.net/684vtyoz/ from @Mugen87

ok found the problem on my side on generating the ShaderMateril scene.enviroment is null

is there a way to listen to a enviroment map change or set?

Just set the scene.environment or material.envMap to the loader.

eg.
scene.environment = new THREE.CubeTextureLoader().setPath( etc…

actually I usually create a reference I can use in multiple places…

environmentMap = new THREE.CubeTextureLoader();
scene.environment = environmentMap;
material.envMap = environmentMap;

etc.

1 Like

thx @becky_rose this bring me in the right direction!