I’ve been trying to create a shader for a pixelated water reflection, but I’m new to Unity and especially new to shaders.
What I’m after is something like this: GIF
I’ve managed to use Grabpass and flip it to get the surface to distort, but i cant figure out how to do the distortion.
Been trying something like this where i changed _Offset in a script over time, but the best result i got with that was a single wave, which is not what i’m really after. I was considering checking the y-coordinate compared to _Offset and using modulus to change direction of every third/fourth pixel or something but there doesnt seem to be any modulus available for shaders. Completely lost at this point.
fixed4 frag(v2f IN) : SV_Target
{
fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
fixed4 up = tex2D(_MainTex, IN.texcoord + fixed2(0, _MainTex_TexelSize.y));
fixed4 down = tex2D(_MainTex, IN.texcoord - fixed2(0, _MainTex_TexelSize.y));
fixed4 left = tex2D(_MainTex, IN.texcoord - fixed2(_MainTex_TexelSize.x, 0));
fixed4 right = tex2D(_MainTex, IN.texcoord + fixed2(_MainTex_TexelSize.x, 0));
if(IN.texcoord.y > _Offset && IN.texcoord.y < _Offset + 0.01){
c.rgb = right;
}else{
c.rgb = left;
}
return c;
}
I realize this code is nowhere close to what i want to do, but that’s about as far as my experiments has taken me.
Would appreciate some help or some pointers