【发布时间】:2019-03-01 05:09:16
【问题描述】:
我正在尝试使用片段着色器绘制参考网格,我发现纹理在缩小时会丢失其定义,正如您在此处看到的那样。有人知道为什么吗?放大后看起来不错。
这里是代码:
#version 330 core
uniform int multiplicationFactor;
uniform lowp float threshold;
uniform vec4 gridColor;
in vec2 vUV;
void main() {
// multiplicationFactor scales the number of stripes
vec2 t = vUV * multiplicationFactor;
// the threshold constant defines the with of the lines
if (abs(t.x - round(t.x)) <= threshold || abs(t.y - round(t.y)) < threshold )
gl_FragColor = gridColor;
else
discard;
}
【问题讨论】:
-
看起来是精度问题。 't = uUV;'并与“(阈值/乘法因子)”进行比较有什么不同吗?
-
我不太明白你的意思,但如果你担心阈值精度低,我相信这不是问题。我已经从高到低的精度进行了测试,发现纹理有难以察觉的变化!
-
不完全是,但我认为 Rabbid76 有答案。
标签: c++ opengl graphics glsl fragment-shader