I am trying to create a “water block” which is transparent but when I tile them up as seen in screenshot they overlap and I want to get rid of that overlap. Does anyone know of a way?
You may try write into depth inside transparent shader, it’s solve problem, but objects with this shader must be drawn after all transparent geometry.
Right now I am just using the standard shader. Do you have an idea on how I do a test for depth in a custom shader?
I’ve been reading tutorials but the shader stuff is way over my head. Does anyone know where I can hire a shader guru?
Hmm, I think I am getting closer. When I add “BlendOp Max” it creates the effect I need but the color looks weird.
Shader “Custom/Water”
{
Properties {
_Color ( “Color”, Color ) = ( 1.0, 1.0, 1.0, 0.5 )
}
SubShader {
Tags { “Queue” = “Transparent” }
Pass {
ZWrite Off
BlendOp Max
Blend One One
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
float4 _Color;
float4 vert(float4 v:POSITION) : SV_POSITION {
return mul (UNITY_MATRIX_MVP, v);
}
fixed4 frag() : SV_Target {
return _Color;
}
ENDCG
}
}
}
Perhaps there is a way in the fragment shader to discard the pixel if the alpha is bigger or something like that.
Hmm, this seems to get the desired effect also.
Tags { “Queue” = “Geometry+1” }
Pass {
ZWrite On
Blend SrcAlpha OneMinusSrcAlpha
But then it hides the other sprites when they are behind the water.
ie Transparent+1000 or something.