最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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);
        }
    `,
});
发布评论

评论列表(0)

  1. 暂无评论