本文介绍了OpenGL ES 2.0 GLSL texture2D 未绑定时返回值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下代码中:

gl_FragColor = vColor * texture2D(u_Texture, v_TexCoordinate);

我注意到如果 u_Texture 未绑定,则 texture2D 返回的默认值是白色 (1,1,1,1).

I noticed the default value returned by texture2D is a white (1,1,1,1) if u_Texture is unbound.

我的着色器基于这个事实是否安全?

Is it safe to base my shader on this fact?

推荐答案

我没想到.

我见过默认值为黑色的其他实例.如果采样器使用的内存是一段未初始化的视频内存,理论上它可以是任何颜色,这取决于 opengl 实现

I have seen other instances where the default value has been black. It could theoretically be any colour in the case where the memory used by the sampler is a section of uninitialised video memory, it depends on the opengl implementation

这篇关于OpenGL ES 2.0 GLSL texture2D 未绑定时返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 11:18
查看更多