Shader compile error in Unity 5.2.x and 5.3.x
Hi,
the following shader used to work on Unity 5.0.2f1, but it's not working on Unity 5.2.X or 5.3.X.
Shader "VideoShaderImageExternal" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
_Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0)
_Scale ("Scale", Range (0, 1) ) = 1.0
}
SubShader {
Pass {
GLSLPROGRAM
#extension GL_OES_EGL_image_external : require
precision highp float;
uniform samplerExternalOES _MainTex;
varying highp vec4 texCoords;
uniform lowp vec4 _Color;
uniform float _Scale;
#ifdef VERTEX
void main()
{
texCoords = gl_MultiTexCoord0; // Unity has predefined constants for vertex attributes
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
#endif
#ifdef FRAGMENT
void main()
{
vec2 a_texCoords = vec2(texCoords);
float newT = 1.0 - a_texCoords.t;
newT = _Scale * newT;
vec4 texture = texture2D(_MainTex, vec2(a_texCoords.s, newT));
gl_FragColor = vec4(texture.rgb * (_Color.rgb * texture.a + (1. - texture.a)), 1);
}
#endif
ENDGLSL
}
}
}
the error for Unity 5.2.x is
0:11: P0001: Extension directive must occur before any non-preprocessor tokens
the following shader used to work on Unity 5.0.2f1, but it's not working on Unity 5.2.X or 5.3.X.
Shader "VideoShaderImageExternal" {
Properties {
_MainTex ("Texture Image", 2D) = "white" {}
_Color ("Color", Color) = (1.0, 1.0, 1.0, 1.0)
_Scale ("Scale", Range (0, 1) ) = 1.0
}
SubShader {
Pass {
GLSLPROGRAM
#extension GL_OES_EGL_image_external : require
precision highp float;
uniform samplerExternalOES _MainTex;
varying highp vec4 texCoords;
uniform lowp vec4 _Color;
uniform float _Scale;
#ifdef VERTEX
void main()
{
texCoords = gl_MultiTexCoord0; // Unity has predefined constants for vertex attributes
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
}
#endif
#ifdef FRAGMENT
void main()
{
vec2 a_texCoords = vec2(texCoords);
float newT = 1.0 - a_texCoords.t;
newT = _Scale * newT;
vec4 texture = texture2D(_MainTex, vec2(a_texCoords.s, newT));
gl_FragColor = vec4(texture.rgb * (_Color.rgb * texture.a + (1. - texture.a)), 1);
}
#endif
ENDGLSL
}
}
}
the error for Unity 5.2.x is
0:11: P0001: Extension directive must occur before any non-preprocessor tokens
