Skip to content

Commit

Permalink
discard fragments at infinity
Browse files Browse the repository at this point in the history
  • Loading branch information
LGhassen committed Jan 31, 2021
1 parent e68a1c4 commit dda19fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions Assets/Shaders/ScreenSpaceCloudShadow.shader
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ Shader "EVE/ScreenSpaceCloudShadow" {
{
float zdepth = tex2Dlod(_CameraDepthTexture, float4(IN.uv,0,0));

#if SHADER_API_D3D11
if (zdepth == 0.0) {discard;}
#else
if (zdepth == 1.0) {discard;}
#endif

float3 worldPos = getPreciseWorldPosFromDepth(IN.uv, zdepth, CameraToWorld);

float4 vertexPos = float4(worldPos,1.0);
Expand Down Expand Up @@ -132,10 +138,6 @@ Shader "EVE/ScreenSpaceCloudShadow" {

float fadeout = clamp(0.01 * (sphereRadius - originDist), 0.0, 1.0);

#if !defined(SHADER_API_D3D11)
//don't render anything at or near clipping planes on ogl since we have 2 cameras
fadeout*= (zdepth == 1.0) ? 0.0 : 1.0;
#endif
return lerp(1, color, shadowCheck*fadeout);
}

Expand Down
10 changes: 6 additions & 4 deletions Assets/Shaders/ScreenSpaceSpherePlanetLighting.shader
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ Shader "EVE/ScreenSpacePlanetLight" {

float zdepth = tex2Dlod(_CameraDepthTexture, float4(IN.uv,0,0));

#if SHADER_API_D3D11
if (zdepth == 0.0) {discard;}
#else
if (zdepth == 1.0) {discard;}
#endif

float3 worldPos = getPreciseWorldPosFromDepth(IN.uv, zdepth, CameraToWorld);

color.rgb = MultiBodyShadow(worldPos.xyz, _SunRadius, _SunPos, _ShadowBodies);

float fadeout = (zdepth == 1.0) ? 0.0 : 1.0; //don't render anything at or near clipping planes

color.rgb = lerp(1.0,color.rgb,fadeout);

return color;
}
ENDCG
Expand Down

0 comments on commit dda19fa

Please sign in to comment.