【发布时间】:2021-07-26 18:55:41
【问题描述】:
我们使用的是 3 0.115 版本,一切正常。由于我们遇到
我们有一个应用程序使用通过缓冲区几何(位置、大小和颜色缓冲区属性)和着色器材质渲染的点云。
function vertexShader() {
return `attribute float size;
attribute vec3 customColor;
varying vec3 vColor;
attribute float visibility;
varying float vVisible;
void main() {
vColor = customColor;
vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
gl_PointSize = size * ( 300.0 / -mvPosition.z );
gl_Position = projectionMatrix * mvPosition;
vVisible = visibility;
}`
}
function fragmentShader() {
return `uniform vec3 color;
uniform sampler2D pointTexture;
varying vec3 vColor;
varying float vVisible;
void main() {
gl_FragColor = vec4( color * vColor, 1.0 );
gl_FragColor = gl_FragColor * texture2D( pointTexture, gl_PointCoord );
if ( gl_FragColor.a < ALPHATEST ) discard;
if (vVisible < 0.5) discard;
}`
}
在我们的 javascript 初始化代码中。
const material = new THREE.ShaderMaterial({
uniforms: {
color: { value: new THREE.Color(0xffffff) },
texture: { value: new THREE.TextureLoader().load(circle) },
resolution: { value: new THREE.Vector2() },
},
vertexShader: vertexShader(),
fragmentShader: fragmentShader(),
alphaTest: 0.9,
blending: THREE.AdditiveBlending
});
控制台没有错误。但是没有渲染点。我们使用 raycast 来检测点,并且没有任何问题。
知道为什么在升级到最新版本的 3 后,点的渲染失败了吗?这和shadermaterial有关吗?
感谢您的帮助:)
【问题讨论】:
标签: three.js