vault backup: 2025-01-08 22:09:25
This commit is contained in:
parent
ba8b25b537
commit
a9d6e139a6
@ -41,17 +41,36 @@ if(PrimitiveSceneinfo->Proxy->IsToonDisableSelfShadow())
|
|||||||
{
|
{
|
||||||
const FViewInfo& View = Views[ViewIndex];
|
const FViewInfo& View = Views[ViewIndex];
|
||||||
const FMatrix& ViewMatrix = View.ShadowViewMatrices.GetViewMatrix()
|
const FMatrix& ViewMatrix = View.ShadowViewMatrices.GetViewMatrix()
|
||||||
FVector LightDirection = Lightsceneinfo->Proxy- GetDirection();
|
FVector LightDirection = Lightsceneinfo->Proxy->GetDirection();
|
||||||
const FVector CameraDirection = ViewMatrix.GetColumn(2).GetSafeNonmal()
|
const FVector CameraDirection = ViewMatrix.GetColumn(2).GetSafeNormal()
|
||||||
float LightViewBlendFactor = PrimitiveSceneinfo->Proxy->GetToonHalfVienShadowFactor();
|
float LightViewBlendFactor = PrimitiveSceneinfo->Proxy->GetToonHalfVienShadowFactor();
|
||||||
Fvector HalfViewLightDir = (LightDirection + ( 1 - LightViewBlendFactor) + CameraDirection * LightViewBlendFactor).GetSafeNormal();
|
Fvector HalfViewLightDir = (LightDirection + ( 1 - LightViewBlendFactor) + CameraDirection * LightViewBlendFactor).GetSafeNormal();
|
||||||
FMatrix FinalCombineMatrix = FNnverseRotationMatrix(HalfViewLightDir.Rotation())
|
FMatrix FinalCombineMatrix = FInverseRotationMatrix(HalfViewLightDir.Rotation())
|
||||||
ShadowInitializer.WorldTolight = FinalCombineMatrix;
|
ShadowInitializer.WorldToLight = FinalCombineMatrix;
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
相关代码位于`FDirectionalLightSceneProxy::GetPerObjectProjectedShadowInitializer()`,在在FSceneRenderer::CreatePerObjectProjectedShadow()被调用。
|
||||||
|
```c++
|
||||||
|
virtual bool GetPerObjectProjectedShadowInitializer(const FBoxSphereBounds& SubjectBounds,FPerObjectProjectedShadowInitializer& OutInitializer) const override
|
||||||
|
{
|
||||||
|
OutInitializer.PreShadowTranslation = -SubjectBounds.Origin;
|
||||||
|
OutInitializer.WorldToLight = FInverseRotationMatrix(FVector(WorldToLight.M[0][0],WorldToLight.M[1][0],WorldToLight.M[2][0]).GetSafeNormal().Rotation());
|
||||||
|
OutInitializer.Scales = FVector2D(1.0f / SubjectBounds.SphereRadius,1.0f / SubjectBounds.SphereRadius);
|
||||||
|
OutInitializer.SubjectBounds = FBoxSphereBounds(FVector::ZeroVector,SubjectBounds.BoxExtent,SubjectBounds.SphereRadius);
|
||||||
|
OutInitializer.WAxis = FVector4(0,0,0,1);
|
||||||
|
OutInitializer.MinLightW = -UE_OLD_HALF_WORLD_MAX;
|
||||||
|
// Reduce casting distance on a directional light
|
||||||
|
// This is necessary to improve floating point precision in several places, especially when deriving frustum verts from InvReceiverMatrix
|
||||||
|
// This takes the object size into account to ensure that large objects get an extended distance
|
||||||
|
OutInitializer.MaxDistanceToCastInLightW = FMath::Clamp(SubjectBounds.SphereRadius * CVarPerObjectCastDistanceRadiusScale.GetValueOnRenderThread(), CVarPerObjectCastDistanceMin.GetValueOnRenderThread(), (float)WORLD_MAX);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
PS.很有可能需要创建2个Atlas。Atlas的创建位于***FSceneRenderer::AllocateCachedShadowDepthTargets()***。数据存储在***SortedShadowsForShadowDepthPass.ShadowMapAtlases***中。大致由FSceneRenderer::FinishInitDynamicShadows()调用。
|
PS.很有可能需要创建2个Atlas。Atlas的创建位于***FSceneRenderer::AllocateCachedShadowDepthTargets()***。数据存储在***SortedShadowsForShadowDepthPass.ShadowMapAtlases***中。大致由FSceneRenderer::FinishInitDynamicShadows()调用。
|
||||||
|
|
||||||
**阴影Projection阶段**:
|
**阴影Projection阶段**:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user