Hello @Fyrestar,
This extension is just what I was looking for. I’ve been wrangling with onBeforeCompile
but it’s been tricky to get exactly what I need.
I’m having a bit of trouble passing in maps and uniforms and I’m wondering if you can help with the syntax.
My MeshStandardMaterial
looks like this:
const surfMat = new THREE.MeshStandardMaterial({
map: earthAlbedoTex,
bumpMap: earthBumpTex,
bumpScale: 0.02,
roughness: 0.4,
});
and I’m not sure how to pass this info into the extended shader.
I tried:
const surfMat = THREE.extendMaterial(THREE.MeshStandardMaterial,
{
class: THREE.CustomMaterial,
material: {
map: earthAlbedoTex,
bumpMap: earthBumpTex,
bumpScale: 0.02,
roughness: 0.4,
}
});
which errors out with:
three.module.js:22738 Uncaught TypeError: Cannot set property 'value' of undefined
at refreshUniformsStandard (three.module.js:22738)
at Object.refreshMaterialUniforms (three.module.js:22286)
at setProgram (three.module.js:24565)
at WebGLRenderer.renderBufferDirect (three.module.js:23631)
at renderObject (three.module.js:24192)
at renderObjects (three.module.js:24165)
at WebGLRenderer.render (three.module.js:23959)
I also tried:
const surfMat = THREE.extendMaterial(THREE.MeshStandardMaterial,
{
class: THREE.CustomMaterial,
uniforms: {
map: earthAlbedoTex,
bumpMap: earthBumpTex,
bumpScale: 0.02,
roughness: 0.4,
}
});
which errors out with:
three.module.js:1051 Uncaught TypeError: Cannot read property 'elements' of undefined
at Matrix3.copy (three.module.js:1051)
at refreshUniformsCommon (three.module.js:22491)
at Object.refreshMaterialUniforms (three.module.js:22278)
at setProgram (three.module.js:24565)
at WebGLRenderer.renderBufferDirect (three.module.js:23631)
at renderObject (three.module.js:24192)
at renderObjects (three.module.js:24165)
at WebGLRenderer.render (three.module.js:23959)
I’m also a bit new to three.js so might be missing something obvious.
Thanks for the help!