From 824b9a9cd564c6ec9adbffd4ede674cfe02913a1 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Thu, 18 Apr 2024 13:57:29 -0500 Subject: [PATCH] fix dynamicCubemaps on objects --- Engine/source/materials/processedShaderMaterial.cpp | 8 +++++--- Engine/source/scene/reflector.cpp | 2 +- Engine/source/scene/reflector.h | 10 +++++----- Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp | 4 ++-- Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp | 4 ++-- 5 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Engine/source/materials/processedShaderMaterial.cpp b/Engine/source/materials/processedShaderMaterial.cpp index 450d0bf25..77566ef29 100644 --- a/Engine/source/materials/processedShaderMaterial.cpp +++ b/Engine/source/materials/processedShaderMaterial.cpp @@ -329,7 +329,8 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, if (String::compare(LIGHTMGR->getId(), "BLM") == 0) { fd.features.addFeature(MFT_ForwardShading); - fd.features.addFeature(MFT_ReflectionProbes); + if (!mMaterial->mDynamicCubemap) + fd.features.addFeature(MFT_ReflectionProbes); } // Disabling the InterlacedDeferred feature for now. It is not ready for prime-time @@ -357,7 +358,8 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, if (mMaterial->isTranslucent()) { fd.features.addFeature(MFT_RTLighting); - fd.features.addFeature(MFT_ReflectionProbes); + if (!mMaterial->mDynamicCubemap) + fd.features.addFeature(MFT_ReflectionProbes); } if ( mMaterial->mAnimFlags[stageNum] ) @@ -369,7 +371,7 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum, // cubemaps only available on stage 0 for now - bramage if ( stageNum < 1 && mMaterial->isTranslucent() && ( ( mMaterial->mCubemapData && mMaterial->mCubemapData->mCubemap ) || - mMaterial->mDynamicCubemap ) && !features.hasFeature(MFT_ReflectionProbes)) + mMaterial->mDynamicCubemap ) /*&& !features.hasFeature(MFT_ReflectionProbes) */ ) { fd.features.addFeature( MFT_CubeMap ); } diff --git a/Engine/source/scene/reflector.cpp b/Engine/source/scene/reflector.cpp index 7117bc8ff..a58e0e164 100644 --- a/Engine/source/scene/reflector.cpp +++ b/Engine/source/scene/reflector.cpp @@ -531,7 +531,7 @@ F32 PlaneReflector::calcScore( const ReflectParams ¶ms ) return score; } -void PlaneReflector::updateReflection( const ReflectParams ¶ms ) +void PlaneReflector::updateReflection( const ReflectParams ¶ms, Point3F explicitPostion) { PROFILE_SCOPE(PlaneReflector_updateReflection); GFXDEBUGEVENT_SCOPE( PlaneReflector_updateReflection, ColorI::WHITE ); diff --git a/Engine/source/scene/reflector.h b/Engine/source/scene/reflector.h index d39451089..77c90cb4f 100644 --- a/Engine/source/scene/reflector.h +++ b/Engine/source/scene/reflector.h @@ -97,7 +97,7 @@ public: virtual void unregisterReflector(); virtual F32 calcScore( const ReflectParams ¶ms ); - virtual void updateReflection( const ReflectParams ¶ms ) {} + virtual void updateReflection( const ReflectParams ¶ms, Point3F explicitPostion = Point3F::Max) {} GFXOcclusionQuery* getOcclusionQuery() const { return mOcclusionQuery; } @@ -151,7 +151,7 @@ public: ReflectorDesc *inDesc ); void unregisterReflector() override; - virtual void updateReflection( const ReflectParams ¶ms, Point3F explicitPostion = Point3F::Max); + void updateReflection( const ReflectParams ¶ms, Point3F explicitPostion = Point3F::Max) override; GFXCubemap* getCubemap() const { return mCubemap; } @@ -174,7 +174,7 @@ protected: U32 faceIdx; CubeReflector *cube; - void updateReflection( const ReflectParams ¶ms ) override { cube->updateFace( params, faceIdx ); } + void updateReflection( const ReflectParams ¶ms, Point3F explicitPostion = Point3F::Max) override { cube->updateFace( params, faceIdx ); } F32 calcScore( const ReflectParams ¶ms ) override; }; @@ -201,7 +201,7 @@ public: ReflectorDesc *inDesc ); F32 calcScore( const ReflectParams ¶ms ) override; - void updateReflection( const ReflectParams ¶ms ) override; + void updateReflection( const ReflectParams ¶ms, Point3F explicitPostion = Point3F::Max) override; /// Set up the GFX matrices void setGFXMatrices( const MatrixF &camTrans ); @@ -233,4 +233,4 @@ public: bool objectSpace; }; -#endif // _REFLECTOR_H_ \ No newline at end of file +#endif // _REFLECTOR_H_ diff --git a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp index 650b3c799..33c3f520d 100644 --- a/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp +++ b/Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp @@ -1922,9 +1922,9 @@ void ReflectCubeFeatGLSL::processPix( Vector &componentList, Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) ); Var *roughness = (Var*)LangElement::find("roughness"); if (roughness) //try to grab roughness directly - texCube = new GenOp("textureLod( @, @, min((1.0 - @)*@ + 1.0, @))", cubeMap, reflectVec, roughness, cubeMips, cubeMips); + texCube = new GenOp("textureLod( @, @, min(@*@ + 1.0, @))", cubeMap, reflectVec, roughness, cubeMips, cubeMips); else if (glossColor) //failing that, try and find color data - texCube = new GenOp("textureLod( @, @, min((1.0 - @.b)*@ + 1.0, @))", cubeMap, reflectVec, glossColor, cubeMips, cubeMips); + texCube = new GenOp("textureLod( @, @, min(@.b*@ + 1.0, @))", cubeMap, reflectVec, glossColor, cubeMips, cubeMips); else //failing *that*, just draw the cubemap texCube = new GenOp("texture( @, @)", cubeMap, reflectVec); diff --git a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp index 0af9f770c..0f1bf06fd 100644 --- a/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp +++ b/Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp @@ -1987,11 +1987,11 @@ void ReflectCubeFeatHLSL::processPix( Vector &componentList, if (roughness) //try to grab roughness directly { - texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min((1.0 - @)*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, roughness, cubeMips, cubeMips); + texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min(@*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, roughness, cubeMips, cubeMips); } else if (glossColor)//failing that, try and find color data { - texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min((1.0 - @.b)*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, glossColor, cubeMips, cubeMips); + texCube = new GenOp("@.SampleLevel( @, float3(@).rgb, min(@.b*@ + 1.0, @))", cubeMapTex, cubeMap, reflectVec, glossColor, cubeMips, cubeMips); } else //failing *that*, just draw the cubemap {