Phew, got the reason for one warning I'm constantly getting, but not sure about way around it. Warning is:
"RENDER WARNING: there is no texture bound to the unit 0". The problem is we are trying to access texture2D in shaders only when there is a texture set.
Like the following code (for 2d shaders)
- cpp Code: Select all
precision mediump float;
/* Uniforms */
uniform int uTextureUsage;
uniform sampler2D uTextureUnit;
/* Varyings */
varying vec2 vTextureCoord;
varying vec4 vVertexColor;
vec4 Color = vVertexColor;
Color *= texture2D(uTextureUnit, vTextureCoord);
gl_FragColor = Color;
This should only call texture2D when uTextureUsage is != 0. But... the browser gives me still warnings about an invalid texture unit used in texture2D even if uTextureUsage is 0! I tried ininitializing uTextureUsage to 0 earlier, I checked it it's never set to another value etc - doesn't help. If I call anything else instead of texture2D like setting color to red or so... doesn't happen - so that code is really not used. But I guess for WebGL it's already a problem if that is code which _might_ be used maybe?
Anyone got an idea? I mean I could do 2 different workaround. One would be setting a white texture as placeholder which is send whenever we have no other texture set (relatively easy, thought slightly ugly). Other workaround would be to switch to another shader whenever we have no texture (which would be nice as it's very effective, but needs rather a lot of changes to Irrlicht, so I don't really want to do that right now).
edit: Solved it by splitting the shader for 2d pixel rendering into texture/no_texture versions. For 3d materials the users can do that split in their application.