MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / _render

Method _render

Engine/source/lighting/shadowMap/pssmLightShadowMap.cpp:198–397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198void PSSMLightShadowMap::_render( RenderPassManager* renderPass,
199 const SceneRenderState *diffuseState )
200{
201 PROFILE_SCOPE(PSSMLightShadowMap_render);
202
203 const ShadowMapParams *params = mLight->getExtended<ShadowMapParams>();
204 const LightMapParams *lmParams = mLight->getExtended<LightMapParams>();
205 const bool bUseLightmappedGeometry = lmParams ? !lmParams->representedInLightmap || lmParams->includeLightmappedGeometryInShadow : true;
206
207 const U32 texSize = getBestTexSize( params->numSplits < 4 ? params->numSplits : 2 );
208
209 if ( mShadowMapTex.isNull() ||
210 mNumSplits != params->numSplits ||
211 mTexSize != texSize )
212 {
213 _setNumSplits( params->numSplits, texSize );
214 mShadowMapDepth = _getDepthTarget( mShadowMapTex->getWidth(), mShadowMapTex->getHeight() );
215 }
216 mLogWeight = params->logWeight;
217
218 Frustum fullFrustum( diffuseState->getCameraFrustum() );
219 fullFrustum.cropNearFar(fullFrustum.getNearDist(), params->shadowDistance);
220
221 GFXFrustumSaver frustSaver;
222 GFXTransformSaver saver;
223
224 // Set our render target
225 GFX->pushActiveRenderTarget();
226 mTarget->attachTexture( GFXTextureTarget::Color0, mShadowMapTex );
227 mTarget->attachTexture( GFXTextureTarget::DepthStencil, mShadowMapDepth );
228 GFX->setActiveRenderTarget( mTarget );
229 GFX->clear( GFXClearStencil | GFXClearZBuffer | GFXClearTarget, ColorI(255,255,255), 1.0f, 0 );
230
231 // Calculate our standard light matrices
232 MatrixF lightMatrix;
233 calcLightMatrices( lightMatrix, diffuseState->getCameraFrustum() );
234 lightMatrix.inverse();
235 MatrixF lightViewProj = GFX->getProjectionMatrix() * lightMatrix;
236
237 // TODO: This is just retrieving the near and far calculated
238 // in calcLightMatrices... we should make that clear.
239 F32 pnear, pfar;
240 GFX->getFrustum( NULL, NULL, NULL, NULL, &pnear, &pfar, NULL );
241
242 // Set our view up
243 GFX->setWorldMatrix(lightMatrix);
244 MatrixF toLightSpace = lightMatrix; // * invCurrentView;
245
246 _calcSplitPos(fullFrustum);
247
248 mWorldToLightProj = GFX->getProjectionMatrix() * toLightSpace;
249
250 // Apply the PSSM
251 const F32 savedSmallestVisible = TSShapeInstance::smSmallestVisiblePixelSize;
252 const F32 savedDetailAdjust = TSShapeInstance::smDetailAdjust;
253 TSShapeInstance::smDetailAdjust *= smDetailAdjustScale;
254 TSShapeInstance::smSmallestVisiblePixelSize = smSmallestVisiblePixelSize;
255

Callers

nothing calls this directly

Calls 15

cropNearFarMethod · 0.80
getNearDistMethod · 0.80
setActiveRenderTargetMethod · 0.80
getProjectionMatrixMethod · 0.80
getFrustumMethod · 0.80
getFarDistMethod · 0.80
setFrustumMethod · 0.80
setOrthoMethod · 0.80
setProjectionMatrixMethod · 0.80
getNearLeftMethod · 0.80
getNearRightMethod · 0.80

Tested by

no test coverage detected