MCPcopy Create free account
hub / github.com/carbonengine/trinity / ProcessOutdatedRTAnimations

Method ProcessOutdatedRTAnimations

trinity/Eve/EveSpaceScene.cpp:4143–4244  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4141}
4142
4143void EveSpaceScene::ProcessOutdatedRTAnimations( Tr2RenderContext& renderContext )
4144{
4145 TriFrustumOrtho sunShadowFrustum;
4146 auto sunDir = m_sunData.DirWorld;
4147
4148 { // Process Sun light
4149 // Let's compute left, right, top, bottom of the frustum divided by the near clipping plane. We need this for SetupShadowSplit.
4150 Matrix cameraProjection = Tr2Renderer::GetProjectionTransform();
4151 float rightMinusLeft = 2.f / cameraProjection._11; // = ( r - l ) / zn
4152 float bottomMinusTop = 2.f / -cameraProjection._22; // = ( b - t ) / zn
4153 float left = ( cameraProjection._31 - 1.f ) / 2.f * rightMinusLeft; // = l / zn
4154 float top = ( -cameraProjection._32 - 1.f ) / 2.f * bottomMinusTop; // = t / zn
4155 float right = rightMinusLeft + left; // = r / zn
4156 float bottom = bottomMinusTop + top; // = b / zn
4157
4158 // Make a projection matrix that fills
4159 auto sunProjection = PerspectiveOffCenterMatrix( left, right, bottom, top, MIN_SHADOW_SPLIT, MAX_SHADOW_SPLIT );
4160
4161 // we can apply the inverse of the view and projection matrices on the corner points of the unit cube to get the frustum corners in world space
4162 Matrix invViewProj = Inverse( sunProjection ) * Tr2Renderer::GetInverseViewTransform();
4163
4164 // Find light view
4165 Matrix lightView = Inverse( OrthoNormalBasisZ( -m_sunData.DirWorld ) );
4166
4167 Vector3 corners[8];
4168
4169 AxisAlignedBoundingBox aabb = Tr2ShadowMap::CalculateAABB( sunProjection, Tr2Renderer::GetInverseViewTransform(), lightView, corners );
4170
4171 // create shadow frustum out from lightView, aabb.min, aabb.max
4172 sunShadowFrustum.DeriveFrustum( lightView, aabb.m_min, aabb.m_max );
4173 }
4174
4175 std::vector<const Tr2LightManager::PerLightData*> pointsLightDatas;
4176 std::vector<TriFrustum> spotLightFrustums;
4177
4178 // Process other lights
4179 if( auto lightManager = Tr2LightManager::GetInstance() )
4180 {
4181 if( lightManager->GetShadowCastingLights().size() > 0 )
4182 {
4183 for( uint32_t lightIndex : lightManager->GetShadowCastingLights() )
4184 {
4185 const Tr2LightManager::PerLightData* lightData = &lightManager->GetLightData( lightIndex );
4186
4187 // Point light
4188 if( lightData->innerAngle <= 0.0f )
4189 {
4190 pointsLightDatas.push_back( lightData );
4191 }
4192 else // Spot light
4193 {
4194 Matrix projection;
4195 Matrix view;
4196 GetLightMatrices( *lightData, projection, view );
4197
4198 TriFrustum shadowFrustum;
4199 shadowFrustum.DeriveFrustum( &view, &lightData->position, &projection, renderContext.m_esm.GetViewport() );
4200 spotLightFrustums.push_back( shadowFrustum );

Callers

nothing calls this directly

Calls 10

GetProjectionTransformFunction · 0.85
TriShadowFrustumClass · 0.85
sizeMethod · 0.80
IsShadowCastingDirtyMethod · 0.80
GetFrustumMethod · 0.80
MarkRtDirtyMethod · 0.80
DeriveFrustumMethod · 0.45
GetViewportMethod · 0.45
IsCastingShadowMethod · 0.45

Tested by

no test coverage detected