init
init
这家伙很懒,什么也没写!

注册于 2月前

回答
1
文章
0
关注者
0

我对着色器不太懂,我把代码贴出来,可以帮忙看一下咋加吗

const creatShaderMaterial = (texture) => {
  return new THREE.ShaderMaterial ({
    vertexShader: `
      varying vec2 vUv;
      void main() {
        gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
        vUv = uv;
      }
    `,
    fragmentShader: `
    uniform sampler2D heightMap;
        uniform float uOpacity;
        varying vec2 vUv;
        void main() {
            gl_FragColor = vec4(texture2D(heightMap, vUv.xy).rgb, uOpacity);
    }
    `,
    uniforms: {
      uOpacity: { value: 0.9 },
      heightMap: { value: texture },
    },

    polygonOffsetUnits: 1,
    polygonOffsetFactor: 1,
    polygonOffset: true,
    
    depthWrite: true,
    depthTest: true,
    transparent: true,
    side: THREE.DoubleSide,

  });
};

发布
问题