Skip to content

Commit

Permalink
fix: Show caustics on water surface too.
Browse files Browse the repository at this point in the history
  • Loading branch information
shanecelis committed Jun 6, 2019
1 parent 6047425 commit 4268259
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Materials/Unlit_Water Above.mat
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- causticTex:
m_Texture: {fileID: 8400000, guid: 3062e5323be2b4230bcb1e33ed472d1f, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- sky:
m_Texture: {fileID: 8900000, guid: e5e2dace18ebc4185a6e9a445cd287b9, type: 2}
m_Scale: {x: 1, y: 1}
Expand Down
4 changes: 4 additions & 0 deletions Materials/Unlit_Water Below.mat
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Material:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- causticTex:
m_Texture: {fileID: 8400000, guid: 3062e5323be2b4230bcb1e33ed472d1f, type: 2}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- sky:
m_Texture: {fileID: 8900000, guid: e5e2dace18ebc4185a6e9a445cd287b9, type: 2}
m_Scale: {x: 1, y: 1}
Expand Down
2 changes: 2 additions & 0 deletions Shaders/Water.shader
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Shader "Unlit/Water"
water ("Water", 2D) = "black" {}
eye ("Eye", Vector) = (0, -1, 0, 0)
sky ("Sky Cubemap", Cube) = "white" {}
causticTex ("Caustics", 2D) = "white" {}
[Toggle(UNDER_WATER)]
_UnderWater ("Under Water?", Float) = 0
// [Enum(Off,0,Front,1,Back,2)] _MyCullVariable ("Cull", Int) = 2
Expand Down Expand Up @@ -134,6 +135,7 @@ Shader "Unlit/Water"
// XXX This lerp is not working. If you provide 0 as its last argument or multiply by 0, it
// shows the reflectedColor. If however, you multiply its last argument by 0.00000001, you
// get a black surface.
// fixed4 col = float4(lerp(reflectedColor, saturate(refractedColor), (1.0 - fresnel) * length(refractedRay)), 1.0);
fixed4 col = float4(lerp(reflectedColor, saturate(refractedColor), (1.0 - fresnel) * length(refractedRay)), 1.0);
// fixed4 col = float4(reflectedColor, 1);
// fixed4 col = float4(refractedColor, 1);
Expand Down

0 comments on commit 4268259

Please sign in to comment.