PDA

View Full Version : Any hint on why this GLSL shader wont compile on GLES 2 devices?



Narann
03-11-2015, 08:24 PM
Hi all!

I'm fighting with OpenGL log (https://www.opengl.org/discussion_boards/showthread.php/185796-Info-log-of-a-failed-shader-compile-0��t-What-is-wrong?) and wonder if I could not simply ask you OpenGL ES 2 guru.

Is anyone could told me why this GLSL (http://pastebin.com/sVWVv3pE) shader won't compile on OpenGL ES 2 devices (GCW Zero in this case but I have the same problem on any other)?

I copy paste the shader here:


#version 100
precision lowp float;
uniform vec4 uBlendColor;
uniform vec4 uPrimColor;
uniform vec4 uEnvColor;
uniform vec3 uChromaKeyCenter;
uniform vec3 uChromaKeyScale;
uniform vec3 uChromaKeyWidth;
uniform float uLodFrac;
uniform float uPrimLodFrac;
uniform float uK5;
uniform float uK4;
uniform sampler2D uTex0;
uniform sampler2D uTex1;
uniform vec4 uFogColor;

varying vec2 vertexTexCoord0;
varying vec2 vertexTexCoord1;
varying float vertexFog;
varying vec4 vertexShadeColor;


void main()
{
vec4 outColor;
vec3 AColor = texture2D(uTex0,vertexTexCoord0).rgb;
vec3 BColor = vec3(0.0);
vec3 CColor = vertexShadeColor.rgb;
vec3 DColor = vec3(0.0);
float AAlpha = 0.0;
float BAlpha = 0.0;
float CAlpha = 0.0;
float DAlpha = vertexShadeColor.a;
vec3 cycle1Color = (AColor - BColor) * CColor + DColor;
float cycle1Alpha = (AAlpha - BAlpha) * CAlpha + DAlpha;
outColor.rgb = cycle1Color;
outColor.a = cycle1Alpha;
float coverage = 1.0;
coverage = step( 0.5, coverage );
outColor.a = coverage;
if( coverage < 0.1 ) discard;
gl_FragColor = outColor;
}

As you guess, I have no GLES 2 device for me and just make peoples having such compile and test my code... Not the best way I know.

For the tiny story, this is a shader dynamically generated to emulate the "N64 GPU" (kindof...). This explain why there is such a big number of uniform not used in the main(). Those inputs are always present in every dynamically generated GLSL shaders. I don't think those are the problem but as I'm not very confortable with embedded devices I ask. :)

Any hint or feedback is welcome.

GClements
03-12-2015, 02:02 AM
Is anyone could told me why this GLSL (http://pastebin.com/sVWVv3pE) shader won't compile on OpenGL ES 2 devices.

FWIW, it compiles fine under WebGL, which is based upon OpenGL ES 2.0.

Can you get any shader to compile? If not, that suggests a problem with your client code rather than the shader.

Narann
03-12-2015, 06:28 AM
FWIW, it compiles fine under WebGL, which is based upon OpenGL ES 2.0.
I also noticed that, if compiled with OpenGL ES 2 headers on a OpenGL Desktop it work fine. This would explain that.


Can you get any shader to compile? If not, that suggests a problem with your client code rather than the shader.
Good point, I will try to force the code to compile a simple shader using my function. Notice it work fine on OpenGL Desktop, this is why I don't understand...

The client code creating the shader is here (https://github.com/Narann/mupen64plus-video-rice/blob/master/src/OGLCombiner.cpp#L134). (We import gl symbols manually, this explain why they have pgl prefix)

GClements
03-13-2015, 02:15 AM
The client code creating the shader is here (https://github.com/Narann/mupen64plus-video-rice/blob/master/src/OGLCombiner.cpp#L134).

Your pastebin starts with:


Compile failure in (null) shader:


I can't match this against anything in your source code, but the (null) is indicative of passing a null pointer for a string.

Similarly, the garbage characters in the log message suggest that the calls to retrieve the log are failing and you're just printing uninitialised memory.

In short, you need more error checking. So far, there's no evidence that you even have a valid context (in which case, everything will fail).