Bläddra i källkod

hook up attenuation value. todo: sort networkjing properly

Azaezel 6 år sedan
förälder
incheckning
ba8948a5b1

+ 14 - 71
Engine/source/T3D/lighting/boxEnvironmentProbe.cpp

@@ -78,6 +78,7 @@ BoxEnvironmentProbe::BoxEnvironmentProbe() : ReflectionProbe()
 {
    mCaptureMask = REFLECTION_PROBE_CAPTURE_TYPEMASK;
    mProbeShapeType = ProbeRenderInst::Box;
+   mAtten = 0.0;
 }
 
 BoxEnvironmentProbe::~BoxEnvironmentProbe()
@@ -92,6 +93,8 @@ void BoxEnvironmentProbe::initPersistFields()
    // SceneObject already handles exposing the transform
    Parent::initPersistFields();
 
+   addField("attenuation", TypeF32, Offset(mAtten, BoxEnvironmentProbe), "falloff percent");
+
    removeField("radius");
 }
 
@@ -136,6 +139,11 @@ U32 BoxEnvironmentProbe::packUpdate(NetConnection *conn, U32 mask, BitStream *st
    // Allow the Parent to get a crack at writing its info
    U32 retMask = Parent::packUpdate(conn, mask, stream);
 
+   if (stream->writeFlag(mask & UpdateMask))
+   {
+      stream->write(mAtten);
+   }
+
    return retMask;
 }
 
@@ -143,6 +151,11 @@ void BoxEnvironmentProbe::unpackUpdate(NetConnection *conn, BitStream *stream)
 {
    // Let the Parent read any info it sent
    Parent::unpackUpdate(conn, stream);
+
+   if (stream->readFlag())  // UpdateMask
+   {
+      stream->read(&mAtten);
+   }
 }
 
 //-----------------------------------------------------------------------------
@@ -154,79 +167,9 @@ void BoxEnvironmentProbe::updateProbeParams()
    Parent::updateProbeParams();
 
    mProbeInfo->mProbeShapeType = ProbeRenderInst::Box;
+   mProbeInfo->mAtten = mAtten;
 }
 
-/*void BoxEnvironmentProbe::prepRenderImage(SceneRenderState *state)
-{
-   if (!mEnabled || !ReflectionProbe::smRenderPreviewProbes)
-      return;
-
-   if (ReflectionProbe::smRenderPreviewProbes && gEditingMission && mEditorShapeInst && mPrefilterMap != nullptr)
-   {
-      GFXTransformSaver saver;
-
-      // Calculate the distance of this object from the camera
-      Point3F cameraOffset;
-      getRenderTransform().getColumn(3, &cameraOffset);
-      cameraOffset -= state->getDiffuseCameraPosition();
-      F32 dist = cameraOffset.len();
-      if (dist < 0.01f)
-         dist = 0.01f;
-
-      // Set up the LOD for the shape
-      F32 invScale = (1.0f / getMax(getMax(mObjScale.x, mObjScale.y), mObjScale.z));
-
-      mEditorShapeInst->setDetailFromDistance(state, dist * invScale);
-
-      // Make sure we have a valid level of detail
-      if (mEditorShapeInst->getCurrentDetail() < 0)
-         return;
-
-      BaseMatInstance* probePrevMat = mEditorShapeInst->getMaterialList()->getMaterialInst(0);
-
-      setPreviewMatParameters(state, probePrevMat);
-
-      // GFXTransformSaver is a handy helper class that restores
-      // the current GFX matrices to their original values when
-      // it goes out of scope at the end of the function
-
-      // Set up our TS render state      
-      TSRenderState rdata;
-      rdata.setSceneState(state);
-      rdata.setFadeOverride(1.0f);
-
-      // We might have some forward lit materials
-      // so pass down a query to gather lights.
-      LightQuery query;
-      query.init(getWorldSphere());
-      rdata.setLightQuery(&query);
-
-      // Set the world matrix to the objects render transform
-      MatrixF mat = getRenderTransform();
-      mat.scale(Point3F(1, 1, 1));
-      GFX->setWorldMatrix(mat);
-
-      // Animate the the shape
-      mEditorShapeInst->animate();
-
-      // Allow the shape to submit the RenderInst(s) for itself
-      mEditorShapeInst->render(rdata);
-
-      saver.restore();
-   }
-
-   // If the light is selected or light visualization
-   // is enabled then register the callback.
-   const bool isSelectedInEditor = (gEditingMission && isSelected());
-   if (isSelectedInEditor)
-   {
-      ObjectRenderInst *ri = state->getRenderPass()->allocInst<ObjectRenderInst>();
-      ri->renderDelegate.bind(this, &ReflectionProbe::_onRenderViz);
-      ri->type = RenderPassManager::RIT_Editor;
-      state->getRenderPass()->addInst(ri);
-   }
-}*/
-
 void BoxEnvironmentProbe::setPreviewMatParameters(SceneRenderState* renderState, BaseMatInstance* mat)
 {
    Parent::setPreviewMatParameters(renderState, mat);

+ 1 - 1
Engine/source/T3D/lighting/boxEnvironmentProbe.h

@@ -56,7 +56,7 @@ class BaseMatInstance;
 class BoxEnvironmentProbe : public ReflectionProbe
 {
    typedef ReflectionProbe Parent;
-
+   F32 mAtten;
 private:
 
     //Debug rendering

+ 4 - 5
Engine/source/renderInstance/renderProbeMgr.cpp

@@ -82,7 +82,8 @@ ProbeRenderInst::ProbeRenderInst() : SystemInterface(),
    mIrradianceCubemap(NULL),
    mRadius(1.0f),
    mProbeRefOffset(0, 0, 0),
-   mProbeRefScale(1,1,1)
+   mProbeRefScale(1,1,1),
+   mAtten(0.0)
 {
 }
 
@@ -108,6 +109,7 @@ void ProbeRenderInst::set(const ProbeRenderInst *probeInfo)
    mBounds = probeInfo->mBounds;
    mIsSkylight = probeInfo->mIsSkylight;
    mScore = probeInfo->mScore;
+   mAtten = probeInfo->mAtten;
 }
 
 //
@@ -312,9 +314,6 @@ void RenderProbeMgr::_setupStaticParameters()
    cubeMaps.clear();
    irradMaps.clear();
 
-   //This should probably ultimately be a per-probe value, but for now, global for testing/adjustability
-   F32 attenuation = Con::getFloatVariable("$pref::ReflectionProbes::AttenuationStrength", 3.5);
-
    for (U32 i = 0; i < probeCount; i++)
    {
       if (mEffectiveProbeCount >= MAXPROBECOUNT)
@@ -352,7 +351,7 @@ void RenderProbeMgr::_setupStaticParameters()
 
       probeConfigData[mEffectiveProbeCount] = Point4F(curEntry.mProbeShapeType, 
          curEntry.mRadius,
-         attenuation,
+         curEntry.mAtten,
          1);
 
       cubeMaps.push_back(curEntry.mCubemap);

+ 1 - 0
Engine/source/renderInstance/renderProbeMgr.h

@@ -70,6 +70,7 @@ struct ProbeRenderInst : public SystemInterface<ProbeRenderInst>
    Point3F mPosition;
    Point3F mProbeRefOffset;
    Point3F mProbeRefScale;
+   F32 mAtten;
 
    GFXCubemapHandle mCubemap;
    GFXCubemapHandle mIrradianceCubemap;

+ 1 - 2
Templates/Full/game/shaders/common/lighting/advanced/reflectionProbeArrayP.hlsl

@@ -71,8 +71,7 @@ float getDistBoxToPoint(float3 pt, float3 extents)
 float defineBoxSpaceInfluence(Surface surface, ProbeData probe, float3 wsEyeRay)
 {
    float3 surfPosLS = mul(probe.worldToLocal, float4(surface.P, 1.0)).xyz;
-   float probeattenuationvalue = 0.5; // feed meh
-   float atten = 1.0-probeattenuationvalue;
+   float atten = probe.attenuation;
    float baseVal = 0.25;
    float dist = getDistBoxToPoint(surfPosLS,float3(baseVal,baseVal,baseVal));
    return saturate(smoothstep(baseVal+0.0001,atten*baseVal,dist));