浏览代码

Merge pull request #1260 from Azaezel/alpha41/dynamicReflectionRevisions

fix dynamicCubemaps on objects
Brian Roberts 1 年之前
父节点
当前提交
29ba0439b7

+ 5 - 3
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 );
    }

+ 1 - 1
Engine/source/scene/reflector.cpp

@@ -532,7 +532,7 @@ F32 PlaneReflector::calcScore( const ReflectParams &params )
    return score;
 }
 
-void PlaneReflector::updateReflection( const ReflectParams &params )
+void PlaneReflector::updateReflection( const ReflectParams &params, Point3F explicitPostion)
 {
    PROFILE_SCOPE(PlaneReflector_updateReflection);   
    GFXDEBUGEVENT_SCOPE( PlaneReflector_updateReflection, ColorI::WHITE );

+ 5 - 5
Engine/source/scene/reflector.h

@@ -97,7 +97,7 @@ public:
 
    virtual void unregisterReflector();
    virtual F32 calcScore( const ReflectParams &params );
-   virtual void updateReflection( const ReflectParams &params ) {}
+   virtual void updateReflection( const ReflectParams &params, Point3F explicitPostion = Point3F::Max) {}
 
    GFXOcclusionQuery* getOcclusionQuery() const { return mOcclusionQuery; }
 
@@ -151,7 +151,7 @@ public:
                            ReflectorDesc *inDesc );
 
    void unregisterReflector() override;
-   virtual void updateReflection( const ReflectParams &params, Point3F explicitPostion = Point3F::Max);
+   void updateReflection( const ReflectParams &params, Point3F explicitPostion = Point3F::Max) override;
 
    GFXCubemap* getCubemap() const { return mCubemap; }
 
@@ -174,7 +174,7 @@ protected:
       U32 faceIdx;
       CubeReflector *cube;
 
-      void updateReflection( const ReflectParams &params ) override { cube->updateFace( params, faceIdx ); } 
+      void updateReflection( const ReflectParams &params, Point3F explicitPostion = Point3F::Max) override { cube->updateFace( params, faceIdx ); }
       F32 calcScore( const ReflectParams &params ) override;
    };
 
@@ -201,7 +201,7 @@ public:
                            ReflectorDesc *inDesc );
 
    F32 calcScore( const ReflectParams &params ) override;
-   void updateReflection( const ReflectParams &params ) override; 
+   void updateReflection( const ReflectParams &params, 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_
+#endif // _REFLECTOR_H_

+ 2 - 2
Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp

@@ -1922,9 +1922,9 @@ void ReflectCubeFeatGLSL::processPix(  Vector<ShaderComponent*> &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);
       

+ 2 - 2
Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

@@ -1987,11 +1987,11 @@ void ReflectCubeFeatHLSL::processPix(  Vector<ShaderComponent*> &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
    {