I have been trying to create some waves like effect with unity shader. I did it and it works fine in editor, but on Android device(Samsung J1) it gives error:
GLES20: vprog textures are used, but not supported
GLSL link error: L0100 GLSL allows exactly two attached shaders (one of each type) per program
then it shows nothing.
I searched internet about it, but didn't find anything useful.
In order to implement this effect I created perlin noise image 512x512 and used it's pixel values to displace y position of vertices.
From my understanding, problem is coming from the tex2Dlod
.
Shader "Custom/Wave"
{
Properties
{
_Color("Color",COLOR) = (0.5,0.5,0.5,1.0)
_MainTex("Base (RGB)", 2D) = "white" {}
_Noise("Noise", 2D) = "white"{}
_Curvature("Curvature", Float) = 0.01
_ScrollXSpeed("X", Range(0,10)) = 2
_ScrollYSpeed("Y", Range(0,10)) = 3
_WaveIntensity("Intensity", Range(0,20)) = 5
}
SubShader
{
Tags { "RenderType" = "Opaque" }
LOD 150
CGPROGRAM
#pragma surface surf Lambert vertex:vert addshadow
#pragma glsl
#pragma target 3.0
sampler2D _MainTex;
sampler2D _Noise;
fixed4 _Color;
float _Curvature;
fixed _ScrollXSpeed;
fixed _ScrollYSpeed;
fixed _WaveIntensity;
struct Input
{
float2 uv_MainTex;
};
void vert(inout appdata_full v) {
// Apply scroll
half2 texcoord = v.texcoord.xy;
texcoord.x += _Time.x * _ScrollXSpeed;
texcoord.y += _Time.x * _ScrollYSpeed;
// Get value of perlin noise
float waveHeight = tex2Dlod(_Noise, float4(texcoord,0,0)).r * _WaveIntensity;
// Get world position of vertex
float4 worldSpace = mul(unity_ObjectToWorld, v.vertex);
// Get distance relative to camera
worldSpace.xyz -= _WorldSpaceCameraPos.xyz;
// Square distance and apply curvature with perlin noise
worldSpace = float4(0.0f, (worldSpace.z * worldSpace.z) * -_Curvature + waveHeight, 0.0f, 0.0f);
// Assign position to vertex
v.vertex += mul(unity_WorldToObject, worldSpace);
}
void surf(Input IN, inout SurfaceOutput o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = _Color.xyz;
o.Alpha = c.a;
}
ENDCG
}
Fallback "Mobile/VertexLit"
}
How can I fix it so it will work on any device?