在进行纹理映射操作之前设置 GL 颜色有什么作用?
我正在看一本书中的一些示例代码,它通过将场景(以不同的偏移量)重复渲染到屏幕外纹理上,然后使用该纹理在主视图中重复绘制一个四边形并设置一些混合内容,从而创建抖动的抗锯齿效果。
为了“正确”地累积颜色,代码如下设置颜色:
glColor4f(f, f, f, 1);
其中 f 是 1.0/number_of_samples ,然后绑定离屏纹理并渲染它。
由于纹理带有自己的颜色和 alpha 数据,那么提前设置整体“颜色”会达到什么效果(数学上和直观上)?
谢谢。
I am looking at some sample code in a book that creates a jittered antialiasing effect by repeatedly rendering a scene (at different offsets) onto a offscreen texture, then using that texture to repeatedly draw a quad in the main view with some blend stuff set up.
To accumulate the color "correctly", the code is setting the color like so:
glColor4f(f, f, f, 1);
where f is 1.0/number_of_samples
, and then binding the offscreen texture and rendering it.
Since textures come with their own color and alpha data, what is the effect (mathematically and intuitively) that setting the overall "color" in advance achieves?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认的纹理环境是GL_MODULATE,这意味着顶点颜色(用glColor设置)与纹理颜色相乘。
所以,从数学上来说,确实如此:
希望能解释它。
The default texture environment is GL_MODULATE, this means that the vertex color (set with glColor) is multiplied with the texture color.
So, mathematically, it does:
Hope that explains it.