- Home /
Question by
Katerpilet · Apr 19, 2016 at 06:41 AM ·
androidunity 5shaderglsl
How to use #extension with GLSL shader
I receive this error when my shader is compiled on Android: Adreno : ERROR: 0:20: '' : GLSL compile error: Extension directives must occur before any non-preprocessor tokens.
My shader looks like:
Shader "testShader" { // defines the name of the shader
Properties{
_MainTex("Texture", 2D) = "" {}
}
SubShader { // Unity chooses the subshader that fits the GPU best
Pass { // some shaders require multiple passes
GLSLPROGRAM // here begins the part in Unity's GLSL
#extension GL_OES_EGL_image_external : require
#ifdef VERTEX // here begins the vertex shader
varying vec2 glFragment_uv;
void main() // all vertex shaders define a main() function
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
glFragment_uv = gl_MultiTexCoord0.xy;
}
#endif // here ends the definition of the vertex shader
#ifdef FRAGMENT // here begins the fragment shader
varying vec2 glFragment_uv;
uniform samplerExternalOES _MainTex;
void main() // all fragment shaders define a main() function
{
gl_FragColor = texture2D(glFragment_uv, _MainTex);
}
#endif // here ends the definition of the fragment shader
ENDGLSL // here ends the part in GLSL
}
}
}
The extension is compiled to be after preprocessor tokens
Comment
Your answer
Follow this Question
Related Questions
Graphics/Shader on Android Device brokes down 1 Answer
Pink custom shader on Android build 0 Answers
how to solve shader problems while switching to another plateform? -1 Answers
Realistic metalic on mobile 0 Answers
GLSL shader not working on android 0 Answers