小编mys*_*elf的帖子

Three.js - 在单个 PointCloud 中使用多个纹理

我正在尝试使用 ShaderMaterial 在单个 PointCloud 中使用多个纹理。我将纹理数组与纹理索引属性一起传递给着色器,并选择适当的纹理以在片段着色器中使用。

相关设置代码:

var particleCount = 100;

var uniforms = {
    textures: {
        type: 'tv',
        value: this.getTextures()
    }
};

var attributes = {
    texIndex: {
        type: 'f',
        value: []
    },
    color: {
        type: 'c',
        value: []
    },
};

var material = new THREE.ShaderMaterial({
    uniforms: uniforms,
    attributes: attributes,
    vertexShader: document.getElementById('vertexShader').textContent,
    fragmentShader: document.getElementById('fragmentShader').textContent,
    transparent: true
});

var geometry = new THREE.Geometry();

for (var i = 0; i < particleCount; i++) {
    geometry.vertices.push(new THREE.Vector3(
    (Math.random() - 0.5) * 50, (Math.random() …
Run Code Online (Sandbox Code Playgroud)

javascript webgl three.js glsles

5
推荐指数
1
解决办法
2399
查看次数

标签 统计

glsles ×1

javascript ×1

three.js ×1

webgl ×1