Hey Guys i want to build up a simple water shader for a 2D game, that well reflects everything in realtime.
i got it to a point there im just using the grabpass flipped on the y Axis but since the UNITY_MATRIX_MVP matrix also includes the rotation the final output image gets not only flipped but also a bit offsetted and rotated if im moving the camera (second part doesnt matters, since it’s a 2D game anyways)
But actually it looks really weird in game
Vertex Shader:
void vert (inout appdata_full v, out Input o)
{
float4 position = mul(UNITY_MATRIX_MVP, v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.proj2.xy = (float2(position.x, (min(position.y+_ReflHeight,_ReflHeightMax)) * -scale) + position.w) * 0.5;
o.proj2.zw = position.zw;
}
(Im currently limitting the movement by those two values [_ReflHeight,_ReflHeightMax])
Surface:
half4 refl = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(IN.proj2));
Is there a way to stop the movement? since you wont see anything anyways if you are not near the water. it shouldnt matter if the screen renders it for the grab pass funktion
Thanks in Advance