three.js - How to support InstanceMeshBatchedMesh in custom ShaderMaterial? - Stack Overflow

I have no idea how to extend my shader. It is quite simple. I have geometries with custom focus attribu

I have no idea how to extend my shader. It is quite simple. I have geometries with custom focus attribute with value between 0-1 and based on that I render plane colour. But for BatchedMesh this shader does not work. (I see geometry on (0,0,0) point ) In web I found something about instanceMatrix attribute but I don`t know how to use it correctly.

const focusMaterial = new THREE.ShaderMaterial({
    vertexShader: /* glsl */`

    attribute float focus;

    varying float vFocus;

    void main() {
        vFocus = focus;
        gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
    }`,
    fragmentShader: /* glsl */`
        varying float vFocus;

        void main() {
            gl_FragColor = vec4(vFocus,vFocus,0.5,1.0);
        }
    `,
});

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743754404a4501492.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信