- Home /
Shaders: OpenGL ES 2.0 surface program?
Hey all,
We recently released a game and as such we found that an android device wasn't rendering correctly. After some research we uncommented a line that was pragma exclude_renderers gles
and above that was
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it
// does not contain a surface program or both vertex and fragment programs.
after more research i could not figure out why it wont work on a specific device, and what does the surface program has to do with it not working on it.
it works on that device if i uncomment the exclude but it just uses the fallback.
so does anyone know what does it mean that OpenGl ES has no surface/vertex/fragment programs, being that it works on most Android devices?
It would be beneficial to post the shader's source code.
Answer by Chiri · Jun 20, 2013 at 08:24 PM
The following is the shader Code.
// MatCap Shader, (c) 2013 Jean Moreno
Shader "MatCap/Vertex/Textured Lit"
{
Properties
{
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}
_MatCap ("MatCap (RGB)", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 300
CGPROGRAM
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
#pragma exclude_renderers gles
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
sampler2D _MatCap;
float4 _Color;
struct Input
{
half2 uv_MainTex : TEXCOORD0;
float2 matcapUV;
};
void vert (inout appdata_full v, out Input o)
{
o.matcapUV = float2(dot(UNITY_MATRIX_IT_MV[0].xyz,v.normal),dot(UNITY_MATRIX_IT_MV[1].xyz,v.normal)) * 0.5 + 0.5;
}
void surf (Input IN, inout SurfaceOutput o)
{
half4 c = tex2D(_MainTex, IN.uv_MainTex);
half4 mc = tex2D(_MatCap, IN.matcapUV);
o.Albedo = c.rgb * mc * _Color * 2.0;
}
ENDCG
}
Fallback "Diffuse Detail"
}
Ok figured it out, The first part refers to it ignoring OpenGl ES and forcing it to go back to the fallback shader on a platform that uses that $$anonymous$$odel.
The second part was requesting that the $$anonymous$$imum functions required to work if i used a Surface shader or a vertex shader.
I still have the problem so i will do a follow up question for the actual issue why this is not working.
If the problem is you are running into an instruction limit, try forcing Shader$$anonymous$$odel 3 #pragma target 3.0
or forcing GLSL conversion #pragma glsl
which may help. Source documentation here.
Your answer
Follow this Question
Related Questions
how to enable Compute shaders for OpenGL ES 3.X in Unity 5.1.x? 1 Answer
GUI and Shader problem on specific Android devices (HTC ONE X) 0 Answers
Standart(roughness setup) to Autodesk Interactive Issue 0 Answers
Android Export, Screen Flashes From Shaders 0 Answers
Strumpy Shader Editor for Mobile? 1 Answer