使用余弦函数的OpenGL颜色插值?(OpenGL color interpolation using a cosine function?)
我想渲染四边形,我希望四边形的一边是白色而另一边是黑色。 我需要它来模仿余弦函数,而不是对像素之间进行简单的线性颜色插值。
有什么好方法可以解决这个问题?
I want to render a quad, I want one side of the quad to be white and the other to be black. Instead of a simple linear color interpolation for the pixels between, I need for it to mimic a cosine function.
What is a good way to approach this?
最满意答案
您可以在片段着色器中执行此操作。 即:
gl_FragColor = vec4( vec3( cos( in_TexCoord.x ) ), 1.0 );您可以根据需要为每个颜色通道调整幅度和相位的精确值。
You can do it in a fragment shader. I.e.:
gl_FragColor = vec4( vec3( cos( in_TexCoord.x ) ), 1.0 );You can tune the exact values of amplitude and phase as you like for every color channel.
更多推荐
发布评论