- Home /
Uniform variable fails on the android
Hello,
I set a shader's global variable in my c# code and use this variable in the shader. It works correctly on my laptop, but when I load it to my android phone, the shader doesn't work( it just draws default color for the object). I use Unity 4.3.0, and build apk by OpenGL ES 3.0 and Android 4.3. My phone runs Android 5.0.
This is the c# code:
void OnPreRender()
{
Shader.SetGlobalInt("OFFSETX", mOffsetX);
}
This is the glsl:
Shader "GLSL Test"{ SubShader { Pass { GLSLPROGRAM
varying vec4 position;
uniform int OFFSETX = 0;
uniform int OFFSETY = 0;
#ifdef VERTEX
void main()
{
}
#endif
#ifdef FRAGMENT
void main()
{
if( fract((gl_FragCoord.x+OFFSETX)/16.0f)< 0.0625)
{
gl_FragColor = vec4(1.0, 1.0, 0.0, 1.0);
}
else
{
discard;
}
}
#endif
ENDGLSL
}
} }
Thank you so much in advance!!
The shader fails on the Android phone after I add this line: if( fract((gl_FragCoord.x+OFFSETX)/16.0f)< 0.0625)
Your answer
Follow this Question
Related Questions
ES2.0 Diffuse Shader? 0 Answers
clipping shader for OpenGL quad 0 Answers
conditional vertex texture fetch / texture lookups in vertex shader 0 Answers
GLSL shader adding UV offset 1 Answer