Error reported using shadermaterial

image
I created a shadermaterial material, and this error will appear when I use it.

This is the material I created

      var phongShader = THREE.ShaderLib['phong'];

      var uniforms = THREE.UniformsUtils.merge([phongShader.uniforms, {
        uTime: { type: 'f', value: 0 }
      }]);

      uniforms.diffuse = 0x444444;
      uniforms.specular = 0xcccccc;

      var vertexShader = [
        '#define PHONG',
        'varying vec3 vViewPosition;',
        '#ifndef FLAT_SHADED',
        'varying vec3 vNormal;',
        '#endif',
        '#include <common>',
        '#include <uv_pars_vertex>',
        '#include <uv2_pars_vertex>',
        '#include <displacementmap_pars_vertex>',
        '#include <envmap_pars_vertex>',
        '#include <color_pars_vertex>',
        '#include <fog_pars_vertex>',
        '#include <morphtarget_pars_vertex>',
        '#include <skinning_pars_vertex>',
        '#include <shadowmap_pars_vertex>',
        '#include <logdepthbuf_pars_vertex>',
        '#include <clipping_planes_pars_vertex>',
        'vec3 cubicBezier(vec3 p0, vec3 c0, vec3 c1, vec3 p1, float t)\n{\n    vec3 tp;\n    float tn = 1.0 - t;\n\n    tp.xyz = tn * tn * tn * p0.xyz + 3.0 * tn * tn * t * c0.xyz + 3.0 * tn * t * t * c1.xyz + t * t * t * p1.xyz;\n\n    return tp;\n}',
        'float ease(float t, float b, float c, float d) {\n  return c*((t=t/d - 1.0)*t*t + 1.0) + b;\n}',
        'vec3 rotateVector(vec4 q, vec3 v)\n{\n    return v + 2.0 * cross(q.xyz, cross(q.xyz, v) + q.w * v);\n}\n\nvec4 quatFromAxisAngle(vec3 axis, float angle)\n{\n    float halfAngle = angle * 0.5;\n    return vec4(axis.xyz * sin(halfAngle), cos(halfAngle));\n}',
        'uniform float uTime;',
        'attribute vec2 aAnimation;',
        'attribute vec3 aEndPosition;',
        'attribute vec4 aAxisAngle;',
        'void main() {',
        'float tDelay = aAnimation.x;',
        'float tDuration = aAnimation.y;',
        'float tTime = clamp(uTime - tDelay, 0.0, tDuration);',
        'float tProgress = ease(tTime, 0.0, 1.0, tDuration);',
        '#include <uv_vertex>',
        '#include <uv2_vertex>',
        '#include <color_vertex>',
        '#include <beginnormal_vertex>',
        '#include <morphnormal_vertex>',
        '#include <skinbase_vertex>',
        '#include <skinnormal_vertex>',
        '#include <defaultnormal_vertex>',
        '#ifndef FLAT_SHADED',
        'vNormal = normalize( transformedNormal );',
        '#endif',
        '#include <begin_vertex>',
        'transformed = mix(transformed, aEndPosition, tProgress);',
        'float angle = aAxisAngle.w * tProgress;',
        'vec4 tQuat = quatFromAxisAngle(aAxisAngle.xyz, angle);',
        'transformed = rotateVector(tQuat, transformed);',
        '#include <morphtarget_vertex>',
        '#include <skinning_vertex>',
        '#include <displacementmap_vertex>',
        '#include <project_vertex>',
        '#include <logdepthbuf_vertex>',
        '#include <clipping_planes_vertex>',
        'vViewPosition = - mvPosition.xyz;',
        '#include <worldpos_vertex>',
        '#include <envmap_vertex>',
        '#include <shadowmap_vertex>',
        '#include <fog_vertex>',
        "}"
      ].join("\n")

      let material = new THREE.ShaderMaterial({
        uniforms: uniforms,
        vertexShader: vertexShader,
        fragmentShader: phongShader.fragmentShader
      })

Hi!

Uniforms have .value property. So, it should be uniforms.specular.value.set(0xcccccc); :thinking:

1 Like

Ha ha, just now I found out :blush:

1 Like