浏览代码

shadowcoord is now using high precision

/main
Felipe Lira 7 年前
当前提交
db534016
共有 4 个文件被更改,包括 21 次插入21 次删除
  1. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
  2. 6
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl
  3. 26
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Shadows.hlsl
  4. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardTerrain.shader

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


// Fragment Functions //
// Used by ShaderGraph and others builtin renderers //
///////////////////////////////////////////////////////////////////////////////
half4 LightweightFragmentPBR(float3 positionWS, half3 normalWS, half3 viewDirectionWS, half4 shadowCoord,
half4 LightweightFragmentPBR(float3 positionWS, half3 normalWS, half3 viewDirectionWS, float4 shadowCoord,
half3 bakedGI, half3 vertexLighting, half3 albedo, half metallic, half3 specular,
half smoothness, half occlusion, half3 emission, half alpha)
{

return half4(color, alpha);
}
half4 LightweightFragmentLambert(float3 positionWS, half3 normalWS, half3 viewDirectionWS, half4 shadowCoord,
half4 LightweightFragmentLambert(float3 positionWS, half3 normalWS, half3 viewDirectionWS, float4 shadowCoord,
half fogFactor, half3 bakedGI, half3 diffuse, half3 emission, half alpha)
{
Light mainLight = GetMainLight(positionWS);

return half4(finalColor, alpha);
}
half4 LightweightFragmentBlinnPhong(float3 positionWS, half3 normalWS, half3 viewDirectionWS, half4 shadowCoord,
half4 LightweightFragmentBlinnPhong(float3 positionWS, half3 normalWS, half3 viewDirectionWS, float4 shadowCoord,
half fogFactor, half3 bakedGI, half3 diffuse, half4 specularGloss, half shininess, half3 emission, half alpha)
{
Light mainLight = GetMainLight(positionWS);

6
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl


half4 fogFactorAndVertexLight : TEXCOORD7; // x: fogFactor, yzw: vertex light
#ifdef _SHADOWS_ENABLED
half4 shadowCoord : TEXCOORD8;
float4 shadowCoord : TEXCOORD8;
#endif
float4 clipPos : SV_POSITION;

// viewDirection should be normalized here, but we avoid doing it as it's close enough and we save some ALU.
half3 viewDirectionWS = IN.viewDir;
half4 shadowCoord = half4(0, 0, 0, 0);
float4 shadowCoord = float4(0, 0, 0, 0);
#ifdef _SHADOWS_ENABLED
shadowCoord = IN.shadowCoord;
#endif

half3 normalWS = normalize(IN.normal);
#endif
half4 shadowCoord = half4(0, 0, 0, 0);
float4 shadowCoord = float4(0, 0, 0, 0);
#ifdef _SHADOWS_ENABLED
shadowCoord = IN.shadowCoord;
#endif

26
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Shadows.hlsl


// Last cascade is initialized with a no-op matrix. It always transforms
// shadow coord to half(0, 0, NEAR_PLANE). We use this trick to avoid
// branching since ComputeCascadeIndex can return cascade index = MAX_SHADOW_CASCADES
float4x4 _WorldToShadow[MAX_SHADOW_CASCADES + 1];
float4 _DirShadowSplitSpheres[MAX_SHADOW_CASCADES];
float4 _DirShadowSplitSphereRadii;
half4 _ShadowOffset0;
half4 _ShadowOffset1;
half4 _ShadowOffset2;
half4 _ShadowOffset3;
half4 _ShadowData; // (x: shadowStrength)
half4 _ShadowmapSize; // (xy: 1/width and 1/height, zw: width and height)
float4x4 _WorldToShadow[MAX_SHADOW_CASCADES + 1];
float4 _DirShadowSplitSpheres[MAX_SHADOW_CASCADES];
float4 _DirShadowSplitSphereRadii;
half4 _ShadowOffset0;
half4 _ShadowOffset1;
half4 _ShadowOffset2;
half4 _ShadowOffset3;
half4 _ShadowData; // (x: shadowStrength)
float4 _ShadowmapSize; // (xy: 1/width and 1/height, zw: width and height)
inline half SampleShadowmap(half4 shadowCoord)
inline half SampleShadowmap(float4 shadowCoord)
{
#if defined(_SHADOWS_PERSPECTIVE)
shadowCoord.xyz = shadowCoord.xyz /= shadowCoord.w;

return 4 - dot(weights, half4(4, 3, 2, 1));
}
half4 ComputeShadowCoord(float3 positionWS)
float4 ComputeShadowCoord(float3 positionWS)
{
#ifdef _SHADOWS_CASCADE
half cascadeIndex = ComputeCascadeIndex(positionWS);

return 1.0;
#endif
half4 shadowCoord = ComputeShadowCoord(positionWS);
float4 shadowCoord = ComputeShadowCoord(positionWS);
half RealtimeShadowAttenuation(float3 positionWS, half4 shadowCoord)
half RealtimeShadowAttenuation(float3 positionWS, float4 shadowCoord)
{
#if !defined(_SHADOWS_ENABLED)
return 1.0;

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardTerrain.shader


float3 positionWS : TEXCOORD7;
#ifdef _SHADOWS_ENABLED
half4 shadowCoord : TEXCOORD8;
float4 shadowCoord : TEXCOORD8;
#endif
float4 clipPos : SV_POSITION;

indirectDiffuse = SampleLightmap(IN.uvControlAndLM.zw, normalWS);
#endif
half4 shadowCoord = half4(0, 0, 0, 0);
float4 shadowCoord = float4(0, 0, 0, 0);
#ifdef _SHADOWS_ENABLED
shadowCoord = IN.shadowCoord;
#endif

正在加载...
取消
保存