MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / prepRenderImage

Method prepRenderImage

Engine/source/environment/VolumetricFog.cpp:961–1048  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

959}
960
961void VolumetricFog::prepRenderImage(SceneRenderState *state)
962{
963 if (!mShapeLoaded || mFogDensity <= 0.0f || mResizing)
964 return;
965
966 if (!state->isDiffusePass())
967 {
968 if (!state->isReflectPass())
969 return;
970 }
971
972 PROFILE_SCOPE(VolumetricFog_prepRenderImage);
973
974 // Time critical therefore static_cast
975 ShapeBase* control = static_cast<ShapeBase*>(conn->getControlObject());
976 if (control->getWaterCoverage() >= 0.9f && !mIgnoreWater)
977 return;
978
979 camPos = state->getCameraPosition();
980 F32 dist = (camPos - getBoxCenter()).len();
981 F32 scaleFactor = dist * mInvScale;
982 if (scaleFactor <= 0.0f)
983 {
984 if (mCurDetailLevel != 0)
985 UpdateBuffers(0);
986 }
987 const F32 pixelScale = state->getViewport().extent.y / 300.0f;
988
989 mPixelSize = (mRadius / scaleFactor) * state->getWorldToScreenScale().y * pixelScale;
990 if (mPixelSize < mMinDisplaySize)
991 return;
992 if (mNumDetailLevels > 1)
993 {
994 if ((det_size[mCurDetailLevel].det_size > mPixelSize) && (mCurDetailLevel < mNumDetailLevels - 1))
995 UpdateBuffers(mCurDetailLevel + 1);
996 else if (mCurDetailLevel > 0)
997 {
998 if (mPixelSize >= det_size[mCurDetailLevel - 1].det_size)
999 UpdateBuffers(mCurDetailLevel - 1);
1000 }
1001 }
1002
1003 if (state->isReflectPass() && mReflect)
1004 {
1005 ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
1006 ri->renderDelegate.bind(this, &VolumetricFog::reflect_render);
1007 ri->type = RenderPassManager::RIT_VolumetricFog;
1008 ri->translucentSort = true;
1009 ri->sortDistSq = getRenderWorldBox().getSqDistanceToPoint(camPos);
1010 if (dist < 1.0f)
1011 ri->defaultKey = 1;
1012 else
1013 ri->defaultKey = U32(dist);
1014 state->getRenderPass()->addInst(ri);
1015 return;
1016 }
1017 else if (state->isDiffusePass())
1018 {

Callers

nothing calls this directly

Calls 15

mAtan2Function · 0.85
mAsinFunction · 0.85
isDiffusePassMethod · 0.80
isReflectPassMethod · 0.80
getWorldToScreenScaleMethod · 0.80
getFarPlaneMethod · 0.80
getFovMethod · 0.80
U32Enum · 0.50
getControlObjectMethod · 0.45
getWaterCoverageMethod · 0.45
lenMethod · 0.45
getRenderPassMethod · 0.45

Tested by

no test coverage detected