片段着色器顺利不透明
问题描述:
我想实现是相当简单的,因为片段着色器顺利不透明
a center point
a radius
a color
画一个圆圈的中心点与填充给定的颜色。
用100%的色圆的中心,颜色沿着半径方向淡出。
这是我已经实现
(BGCOLOR:10,20,30,255,lightColor:100,100,30,255):
的着色器代码片段:
#ifdef GL_ES
precision highp float;
#endif
uniform vec2 center;
uniform vec4 lightColor;
uniform float lightRadius;
void main()
{
float distance = abs(distance(center, gl_FragCoord.xy));
gl_FragColor = vec4(lightColor * (1.0 - 1.0/lightRadius * distance));
}
的问题是,颜色从中心到边缘的衰落是不光滑时(可能太似乎是显而易见的截图,上面虽然)。
不知有什么办法可以使其顺利淡出圈子?
任何建议将赞赏,感谢:)
答
答案很简单:如果我想要做的水木清华一样,我就用扭捏Phong光照。矢量数学更适合我认为的渐变。 目前,你可以试着改变1.o
到1.0LF
。这是#version 400 core
东西
[只是要清楚,你是指这些“涟漪”,因为它不光滑?](https://i.stack.imgur.com/x63La.png) – Vallentin
... [混合()'](https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/mix.xhtml)? – genpfault
是的,我的意思是那些涟漪... – supersuraccoon