- Home /
The question is answered, right answer was accepted
WaterProDaytime with color gradient
Hello,
I created a mesh with a WaterProDaytime material. Now I want the refraction color of this material to behave like a gradient. For example the left side of the water mesh is brown and the right side of the water mesh is blue and between those ends there should be a continous color transition. Is this possible or did I choose the wrong approch to do this task? In principle I want a continous color transition in the water color. The WaterProDayTime material is not necessary, but it would be beautiful because this material looks so good.
Thanks in advance!
Answer by PhilippL · Sep 22, 2015 at 07:53 AM
I solved this problem myself. I have performed the following edits to the FXWaterProShader:
the struct v2f has now the fixed3 color : COLOR0 value
in the vert-function:
fixed3 color_left_side = fixed3(0.5, 0.2, 0.1); o.color = color_left_side+v.vertex.zzz*2;
this code is for the z-value dependent color transition of the mesh
In the frag-function under the HAS_REFRACTION line I added these lines:
half4 v = half4(i.color.x, i.color.y, i.color.z, 0); half4 refr = tex2Dproj( _RefractionTex, UNITY_PROJ_COORD(uv2) ) * v;
Now hopefully you can see a continous color transition of the water mesh from brown to black :-)