vault backup: 2025-02-13 13:48:03
This commit is contained in:
parent
152f067a54
commit
ac2194ab1d
@ -455,6 +455,61 @@ void DeferredLightPixelMain(
|
|||||||
#endif
|
#endif
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### GetLightAttenuationFromShadow() => GetPerPixelLightAttenuation()
|
||||||
|
原文:https://zhuanlan.zhihu.com/p/23216110797
|
||||||
|
有提到阴影模糊问题。
|
||||||
|
FDeferredLightPS::FParameters GetDeferredLightPSParameters()可以看到该Sampler的模式是Point模式。
|
||||||
|
```c++
|
||||||
|
float4 GetPerPixelLightAttenuation(float2 UV)
|
||||||
|
{
|
||||||
|
return DecodeLightAttenuation(Texture2DSampleLevel(LightAttenuationTexture, LightAttenuationTextureSampler, UV, 0));
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
之后可以仿照GetPerPixelLightAttenuation写一个针对ToonShadow的函数:
|
||||||
|
```c++
|
||||||
|
//对卡通阴影进行降采样抗锯齿
|
||||||
|
float4 GetPerPixelLightAttenuationToonAA(float2 UV)
|
||||||
|
{
|
||||||
|
int texture_x, texture_y;
|
||||||
|
LightAttenuationTexture.GetDimensions(texture_x, texture_y);
|
||||||
|
|
||||||
|
float2 texelSize = float2(1.0 / texture_x, 1.0 / texture_y);
|
||||||
|
|
||||||
|
float2 sampleOffsets[4] = {
|
||||||
|
float2(-1.5, 0.5),
|
||||||
|
float2( 0.5, 0.5),
|
||||||
|
float2(-1.5, -1.5),
|
||||||
|
float2( 0.5, -1.5)
|
||||||
|
};
|
||||||
|
|
||||||
|
float4 shadowSum = float4(0,0,0,0);
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
float2 sampleUV = UV + sampleOffsets[i] * texelSize;
|
||||||
|
shadowSum += DecodeLightAttenuation(Texture2DSampleLevel(LightAttenuationTexture, LightAttenuationTextureSampler_Toon, sampleUV, 0));
|
||||||
|
}
|
||||||
|
return shadowSum * 0.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取卡通灯光衰减
|
||||||
|
float4 GetLightAttenuationFromShadowToonAA(in FInputParams InputParams, float SceneDepth, float3 TranslatedWorldPosition)
|
||||||
|
{
|
||||||
|
float4 LightAttenuation = float4(1, 1, 1, 1);
|
||||||
|
|
||||||
|
#if USE_VIRTUAL_SHADOW_MAP_MASK
|
||||||
|
if (VirtualShadowMapId != INDEX_NONE)
|
||||||
|
{
|
||||||
|
float ShadowMask = GetVirtualShadowMapMaskForLight(ShadowMaskBits[InputParams.PixelPos], uint2(InputParams.PixelPos), SceneDepth, VirtualShadowMapId, TranslatedWorldPosition);
|
||||||
|
return ShadowMask.xxxx;
|
||||||
|
}else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return GetPerPixelLightAttenuationToonAA(InputParams.ScreenUV);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### GetDynamicLighting() => GetDynamicLightingSplit()
|
### GetDynamicLighting() => GetDynamicLightingSplit()
|
||||||
```c++
|
```c++
|
||||||
FDeferredLightingSplit GetDynamicLightingSplit(
|
FDeferredLightingSplit GetDynamicLightingSplit(
|
||||||
@ -700,7 +755,7 @@ void GetShadowTerms(float SceneDepth, half4 PrecomputedShadowFactors, uint Shadi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SUPPORT_CONTACT_SHADOWS
|
#if SUPPORT_CONTACT_SHADOWS //接触阴影相关逻辑
|
||||||
|
|
||||||
#if STRATA_ENABLED == 0
|
#if STRATA_ENABLED == 0
|
||||||
if (LightData.ShadowedBits < 2 && (ShadingModelID == SHADINGMODELID_HAIR))
|
if (LightData.ShadowedBits < 2 && (ShadingModelID == SHADINGMODELID_HAIR))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user