| 822 | } |
| 823 | |
| 824 | void ReflectionProbe::prepRenderImage(SceneRenderState *state) |
| 825 | { |
| 826 | if (!mEnabled || (!RenderProbeMgr::smRenderReflectionProbes && !dStrcmp(Con::getVariable("$Probes::Capturing", "0"),"1"))) |
| 827 | return; |
| 828 | |
| 829 | Point3F distVec = getRenderPosition() - state->getCameraPosition(); |
| 830 | F32 dist = distVec.len(); |
| 831 | |
| 832 | //Culling distance. Can be adjusted for performance options considerations via the scalar |
| 833 | if (dist > RenderProbeMgr::smMaxProbeDrawDistance * Con::getFloatVariable("$pref::GI::ProbeDrawDistScale", 1.0)) |
| 834 | { |
| 835 | mProbeInfo.mScore = RenderProbeMgr::smMaxProbeDrawDistance; |
| 836 | return; |
| 837 | } |
| 838 | |
| 839 | if (mReflectionModeType == DynamicCubemap && mRefreshRateMS < (Platform::getRealMilliseconds() - mDynamicLastBakeMS)) |
| 840 | { |
| 841 | bake(); |
| 842 | mDynamicLastBakeMS = Platform::getRealMilliseconds(); |
| 843 | } |
| 844 | |
| 845 | //Submit our probe to actually do the probe action |
| 846 | // Get a handy pointer to our RenderPassmanager |
| 847 | //RenderPassManager *renderPass = state->getRenderPass(); |
| 848 | |
| 849 | //Update our score based on our radius, distance |
| 850 | mProbeInfo.mScore = mMax(dist, 1.0f); |
| 851 | |
| 852 | Point3F vect = distVec; |
| 853 | vect.normalizeSafe(); |
| 854 | |
| 855 | //mProbeInfo.mScore *= mMax(mAbs(mDot(vect, state->getCameraTransform().getForwardVector())),0.001f); |
| 856 | |
| 857 | PROBEMGR->submitProbe(&mProbeInfo); |
| 858 | |
| 859 | #ifdef TORQUE_TOOLS |
| 860 | if (ReflectionProbe::smRenderPreviewProbes && gEditingMission && mPrefilterMap != nullptr) |
| 861 | { |
| 862 | if(!mEditorShapeInst) |
| 863 | createEditorResources(); |
| 864 | |
| 865 | GFXTransformSaver saver; |
| 866 | |
| 867 | // Calculate the distance of this object from the camera |
| 868 | Point3F cameraOffset; |
| 869 | getRenderTransform().getColumn(3, &cameraOffset); |
| 870 | cameraOffset -= state->getDiffuseCameraPosition(); |
| 871 | dist = cameraOffset.len(); |
| 872 | if (dist < 0.01f) |
| 873 | dist = 0.01f; |
| 874 | |
| 875 | // Set up the LOD for the shape |
| 876 | F32 invScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z)); |
| 877 | |
| 878 | mEditorShapeInst->setDetailFromDistance(state, dist * invScale); |
| 879 | |
| 880 | // Make sure we have a valid level of detail |
| 881 | if (mEditorShapeInst->getCurrentDetail() < 0) |
nothing calls this directly
no test coverage detected