浏览代码

Fixed some cascade issues

/main
Felipe Lira 6 年前
当前提交
0d778bae
共有 5 个文件被更改,包括 12 次插入12 次删除
  1. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
  2. 1
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs
  3. 7
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Shadows.hlsl
  4. 10
      com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightScreenSpaceShadows.shader
  5. 2
      com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightStandard.shader

4
com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs


if (success)
{
shadowQuality = (shadowData.supportsSoftShadows) ? light.shadows : LightShadows.Hard;
SetupDirectionalShadowReceiverConstants(ref context, cmd, ref shadowData, shadowLight);
SetupDirectionalShadowReceiverConstants(cmd, ref shadowData, shadowLight);
}
}
context.ExecuteCommandBuffer(cmd);

shadowData.renderedDirectionalShadowQuality = shadowQuality;
}
void SetupDirectionalShadowReceiverConstants(ref ScriptableRenderContext context, CommandBuffer cmd, ref ShadowData shadowData, VisibleLight shadowLight)
void SetupDirectionalShadowReceiverConstants(CommandBuffer cmd, ref ShadowData shadowData, VisibleLight shadowLight)
{
Light light = shadowLight.light;

1
com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs


void SetShadowCollectPassKeywords(CommandBuffer cmd, ref ShadowData shadowData)
{
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.SoftShadows, shadowData.renderedDirectionalShadowQuality == LightShadows.Soft);
CoreUtils.SetKeyword(cmd, LightweightKeywordStrings.CascadeShadows, shadowData.directionalLightCascadeCount > 1);
}
}
}

7
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Shadows.hlsl


#define MAX_SHADOW_CASCADES 4
#ifndef SHADOWS_SCREEN
#if defined(SHADER_API_GLES) || !defined(_SHADOWS_CASCADE)
#define SHADOWS_SCREEN 0
#else
#if defined(_SHADOWS_ENABLED) && defined(_SHADOWS_CASCADE) && !defined(SHADER_API_GLES)
#else
#define SHADOWS_SCREEN 0
#endif
#endif

half shadowStrength = GetMainLightShadowStrength();
return SampleShadowmap(shadowCoord, TEXTURE2D_PARAM(_DirectionalShadowmapTexture, sampler_DirectionalShadowmapTexture), shadowSamplingData, shadowStrength);
#endif
}
half LocalLightRealtimeShadowAttenuation(int lightIndex, float3 positionWS)

10
com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightScreenSpaceShadows.shader


HLSLINCLUDE
// Note: Screenspace shadow resolve is only performed when shadow cascades are enabled
// Shadow cascades require cascade index and shadowCoord to be computed on pixel.
#define _SHADOWS_CASCADE
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
//Keep compiler quiet about Shadows.hlsl.

#include "LWRP/ShaderLibrary/Core.hlsl"
#include "LWRP/ShaderLibrary/Shadows.hlsl"
// Note: Screenspace shadow resolve is only performed when shadow cascades are enabled
// Shadow cascades require cascade index and shadowCoord to be computed on pixel.
#define _SHADOWS_CASCADE
#if defined(UNITY_STEREO_INSTANCING_ENABLED) || defined(UNITY_STEREO_MULTIVIEW_ENABLED)
TEXTURE2D_ARRAY_FLOAT(_CameraDepthTexture);

float3 wpos = mul(unity_CameraToWorld, float4(vpos, 1)).xyz;
//Fetch shadow coordinates for cascade.
float4 coords = TransformWorldToShadowCoord(wpos);
float4 coords = TransformWorldToShadowCoord(wpos);
// Screenspace shadowmap is only used for directional lights which use orthogonal projection.
ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();

2
com.unity.render-pipelines.lightweight/LWRP/Shaders/LightweightStandard.shader


#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _LOCAL_SHADOWS_ENABLED
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _SHADOWS_CASCADES
#pragma multi_compile _ _SHADOWS_CASCADE
// -------------------------------------
// Unity defined keywords

正在加载...
取消
保存