Hey folks,
I combined a few bits of shader code to make this foam water shader. It works in the editor and as OSX standalone, but in Windows standalone it breaks and the output log says: “Pass ’ ’ has no fragment shader.”
Can anyone diagnose?
Shader "FX/Water_al" {
Properties {
[NoScaleOffset] _ReflectiveColor ("Reflective color (RGB) fresnel (A) ", 2D) = "" {}
_HorizonColor ("Simple water horizon color", COLOR) = ( .172, .463, .435, 1)
//foam stuff
[NoScaleOffset] _Foam ("Foam texture", 2D) = "white" {}
[NoScaleOffset] _FoamGradient ("Foam gradient ", 2D) = "white" {}
_FoamStrength ("Foam strength", Range (0, 10.0)) = 1.0
}
// -----------------------------------------------------------
// Fragment program cards
Subshader {
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"
uniform float _FoamStrength;
struct appdata {
float4 vertex : POSITION;
// float3 normal : NORMAL;
};
struct v2f {
float4 pos : SV_POSITION;
float4 ref : TEXCOORD0;
float3 viewDir : TEXCOORD3;
float2 foamuv : TEXCOORD4;
UNITY_FOG_COORDS(4)
};
v2f vert(appdata v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
// scroll bump waves
float4 temp;
float4 wpos = mul (unity_ObjectToWorld, v.vertex);
//foam stuff
o.foamuv = 7.0f * wpos.xz + 0.05 * float2(_SinTime.w, _SinTime.w);
o.ref = ComputeScreenPos(o.pos);
// object space view direction (will normalize per pixel)
o.viewDir.xzy = WorldSpaceViewDir(v.vertex);
UNITY_TRANSFER_FOG(o,o.pos);
return o;
}
sampler2D _ReflectiveColor;
uniform float4 _HorizonColor;
//foam stuff
sampler2D _Foam;
sampler2D _FoamGradient;
uniform sampler2D _CameraDepthTexture; //Depth Texture
half4 frag( v2f i ) : SV_Target
{
i.viewDir = normalize(i.viewDir);
// fresnel factor
half fresnelFac = dot( i.viewDir, 0 );
// perturb reflection/refraction UVs by bumpmap, and lookup colors
half4 color;
half4 water = tex2D( _ReflectiveColor, float2(fresnelFac,fresnelFac) );
color.rgb = lerp( water.rgb, _HorizonColor.rgb, water.a );
color.a = _HorizonColor.a;
//foam stuff
float sceneZ = LinearEyeDepth (tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.ref)).r);
float objectZ = i.ref.z;
float intensityFactor = 1 - saturate((sceneZ - objectZ) / _FoamStrength);
half3 foamGradient = 1 - tex2D(_FoamGradient, float2(intensityFactor - _Time.y*0.2, 0) + 0 * 0.15);
float2 foamDistortUV = 0 * 0.2;
half3 foamColor = tex2D(_Foam, i.foamuv + foamDistortUV).rgb;
color.rgb += foamGradient * intensityFactor * foamColor;
UNITY_APPLY_FOG(i.fogCoord, color);
return color;
}
ENDCG
}
}
}