【发布时间】:2021-08-05 03:51:35
【问题描述】:
我为 three.js 编写了一个自定义着色器,所以点是四舍五入的。着色器如下:
new ShaderMaterial({
transparent: true,
depthWrite: false,
uniforms: {
size: { value: pointSize * canvasSize * 0.5 },
color: { value: [...color, opacity ?? 1] },
},
vertexShader: `
uniform float size;
void main() {
gl_PointSize = size;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,
fragmentShader: `
uniform vec4 color;
void main() {
if (length(gl_PointCoord - vec2(0.5)) > 0.5) discard;
gl_FragColor = color;
}
`
})
但我还需要在相机放大时增加点大小。我该怎么做?
【问题讨论】:
-
this post 中的答案不考虑缩放,只考虑旋转。
-
你的意思是你想在相机放大时增加点的大小?你的意思是你只需要标准的基于距离的缩放,因为它可以追溯到更远的地方?喜欢in this example?
-
@Marquizzo 也不尊重缩放,使用与
PointsMaterial相同的顶点着色器(顶部带有#define USE_SIZEATTENUATION)不尊重缩放。
标签: javascript three.js glsl shader