mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-12 19:31:41 +00:00
Finished current cleanup/reorg.
Temporarily disabled logic for forward render of probes to avoid data mangle. TODO: fix up forward once deferred math is locked in Split probe modes out into distinct environmental probe objects Removed the probes from tracking their own baked cubemap file paths and instead have a pref store it Removed old probe shaders and materials that aren't used now. Fixed mLastConst memory leak by removing nono line.
This commit is contained in:
parent
58e3349286
commit
788e265477
18 changed files with 1024 additions and 1282 deletions
|
|
@ -55,28 +55,26 @@
|
|||
static U32 MAXPROBECOUNT = 50;
|
||||
|
||||
class PostEffect;
|
||||
class ReflectionProbe;
|
||||
|
||||
struct ProbeRenderInst : public SystemInterface<ProbeRenderInst>
|
||||
{
|
||||
LinearColorF mAmbient;
|
||||
|
||||
MatrixF mTransform;
|
||||
|
||||
F32 mRadius;
|
||||
F32 mIntensity;
|
||||
|
||||
bool mDirty;
|
||||
|
||||
Box3F mBounds;
|
||||
Point3F mPosition;
|
||||
Point3F mProbePosOffset;
|
||||
|
||||
GFXCubemapHandle mCubemap;
|
||||
GFXCubemapHandle mIrradianceCubemap;
|
||||
|
||||
//Utilized in dynamic reflections
|
||||
CubeReflector mCubeReflector;
|
||||
|
||||
GFXTexHandle *mBRDFTexture;
|
||||
|
||||
/// The priority of this light used for
|
||||
/// light and shadow scoring.
|
||||
F32 mPriority;
|
||||
|
|
@ -87,16 +85,6 @@ struct ProbeRenderInst : public SystemInterface<ProbeRenderInst>
|
|||
|
||||
bool mIsSkylight;
|
||||
|
||||
/// Whether to render debugging visualizations
|
||||
/// for this light.
|
||||
bool mDebugRender;
|
||||
|
||||
GFXPrimitiveBufferHandle primBuffer;
|
||||
GFXVertexBufferHandle<GFXVertexPC> vertBuffer;
|
||||
U32 numPrims;
|
||||
U32 numVerts;
|
||||
Vector< U32 > numIndicesForPoly;
|
||||
|
||||
enum ProbeShapeType
|
||||
{
|
||||
Sphere = 0, ///< Sphere shaped
|
||||
|
|
@ -105,10 +93,6 @@ struct ProbeRenderInst : public SystemInterface<ProbeRenderInst>
|
|||
|
||||
ProbeShapeType mProbeShapeType;
|
||||
|
||||
//Spherical Harmonics data
|
||||
LinearColorF mSHTerms[9];
|
||||
F32 mSHConstants[5];
|
||||
|
||||
public:
|
||||
|
||||
ProbeRenderInst();
|
||||
|
|
@ -121,28 +105,18 @@ public:
|
|||
const MatrixF& getTransform() const { return mTransform; }
|
||||
void setTransform(const MatrixF &xfm) { mTransform = xfm; }
|
||||
|
||||
Point3F getPosition() const { return mTransform.getPosition(); }
|
||||
void setPosition(const Point3F &pos) { mTransform.setPosition(pos); }
|
||||
Point3F getPosition() const { return mPosition; }
|
||||
void setPosition(const Point3F &pos) { mPosition = pos; }
|
||||
|
||||
VectorF getDirection() const { return mTransform.getForwardVector(); }
|
||||
void setDirection(const VectorF &val);
|
||||
|
||||
const LinearColorF& getAmbient() const { return mAmbient; }
|
||||
void setAmbient(const LinearColorF &val) { mAmbient = val; }
|
||||
|
||||
void setPriority(F32 priority) { mPriority = priority; }
|
||||
F32 getPriority() const { return mPriority; }
|
||||
|
||||
void setScore(F32 score) { mScore = score; }
|
||||
F32 getScore() const { return mScore; }
|
||||
|
||||
bool isDebugRenderingEnabled() const { return mDebugRender; }
|
||||
void enableDebugRendering(bool value) { mDebugRender = value; }
|
||||
|
||||
// Builds the world to light view projection used for
|
||||
// shadow texture and cookie lookups.
|
||||
void getWorldToLightProj(MatrixF *outMatrix) const;
|
||||
|
||||
void clear();
|
||||
};
|
||||
|
||||
|
|
@ -174,26 +148,6 @@ struct ProbeShaderConstants
|
|||
|
||||
typedef Map<GFXShader*, ProbeShaderConstants*> ProbeConstantMap;
|
||||
|
||||
class ReflectProbeMatInstance : public MatInstance
|
||||
{
|
||||
typedef MatInstance Parent;
|
||||
protected:
|
||||
MaterialParameterHandle * mProbeParamsSC;
|
||||
bool mInternalPass;
|
||||
|
||||
GFXStateBlockRef mProjectionState;
|
||||
|
||||
ProcessedShaderMaterial* mShaderMat;
|
||||
|
||||
public:
|
||||
ReflectProbeMatInstance(Material &mat) : Parent(mat), mProbeParamsSC(NULL), mInternalPass(false), mProjectionState(NULL) {}
|
||||
|
||||
virtual bool init(const FeatureSet &features, const GFXVertexFormat *vertexFormat);
|
||||
virtual bool setupPass(SceneRenderState *state, const SceneData &sgData);
|
||||
|
||||
ProcessedShaderMaterial* getProcessedShaderMaterial() { return mShaderMat; }
|
||||
};
|
||||
|
||||
//**************************************************************************
|
||||
// RenderObjectMgr
|
||||
//**************************************************************************
|
||||
|
|
@ -201,99 +155,53 @@ class RenderProbeMgr : public RenderBinManager
|
|||
{
|
||||
typedef RenderBinManager Parent;
|
||||
|
||||
struct ReflectProbeMaterialInfo
|
||||
{
|
||||
ReflectProbeMatInstance *matInstance;
|
||||
|
||||
// { zNear, zFar, 1/zNear, 1/zFar }
|
||||
MaterialParameterHandle *zNearFarInvNearFar;
|
||||
|
||||
// Far frustum plane (World Space)
|
||||
MaterialParameterHandle *farPlane;
|
||||
|
||||
// Far frustum plane (View Space)
|
||||
MaterialParameterHandle *vsFarPlane;
|
||||
|
||||
// -dot( farPlane, eyePos )
|
||||
MaterialParameterHandle *negFarPlaneDotEye;
|
||||
|
||||
// Light Parameters
|
||||
MaterialParameterHandle *probeLSPos;
|
||||
MaterialParameterHandle *probeWSPos;
|
||||
MaterialParameterHandle *attenuation;
|
||||
MaterialParameterHandle *radius;
|
||||
|
||||
MaterialParameterHandle *useCubemap;
|
||||
MaterialParameterHandle *cubemap;
|
||||
MaterialParameterHandle *cubeMips;
|
||||
|
||||
MaterialParameterHandle *eyePosWorld;
|
||||
MaterialParameterHandle *bbMin;
|
||||
MaterialParameterHandle *bbMax;
|
||||
|
||||
MaterialParameterHandle *useSphereMode;
|
||||
|
||||
MaterialParameterHandle *shTerms[9];
|
||||
MaterialParameterHandle *shConsts[5];
|
||||
|
||||
MaterialParameterHandle *probeCount;
|
||||
|
||||
ReflectProbeMaterialInfo(const String &matName, const GFXVertexFormat *vertexFormat);
|
||||
|
||||
virtual ~ReflectProbeMaterialInfo();
|
||||
|
||||
|
||||
void setViewParameters(const F32 zNear,
|
||||
const F32 zFar,
|
||||
const Point3F &eyePos,
|
||||
const PlaneF &farPlane,
|
||||
const PlaneF &_vsFarPlane);
|
||||
|
||||
void setProbeParameters(const ProbeRenderInst *probe, const SceneRenderState* renderState, const MatrixF &worldViewOnly);
|
||||
};
|
||||
|
||||
enum SpecialProbeTypesEnum
|
||||
{
|
||||
SkylightProbeType,
|
||||
SpecialProbeTypesCount
|
||||
};
|
||||
|
||||
Vector<U32> mRegisteredProbes;
|
||||
|
||||
ReflectProbeMaterialInfo* mReflectProbeMaterial;
|
||||
//Array rendering
|
||||
U32 mEffectiveProbeCount;
|
||||
S32 mMipCount;
|
||||
Vector<Point4F> probePositionsData;
|
||||
Vector<MatrixF> probeWorldToObjData;
|
||||
Vector<Point4F> probeBBMinData;
|
||||
Vector<Point4F> probeBBMaxData;
|
||||
Vector<Point4F> probeUseSphereModeData;
|
||||
Vector<Point4F> probeRadiusData;
|
||||
Vector<Point4F> probeAttenuationData;
|
||||
Vector<GFXCubemapHandle> cubeMaps;
|
||||
Vector<GFXCubemapHandle> irradMaps;
|
||||
|
||||
GFXShaderConstHandle *numProbesSC;
|
||||
GFXShaderConstHandle *probePositionSC;
|
||||
GFXShaderConstHandle *probeWorldToObjSC;
|
||||
GFXShaderConstHandle *probeBBMinSC;
|
||||
GFXShaderConstHandle *probeBBMaxSC;
|
||||
GFXShaderConstHandle *probeUseSphereModeSC;
|
||||
GFXShaderConstHandle *probeRadiusSC;
|
||||
GFXShaderConstHandle *probeAttenuationSC;
|
||||
AlignedArray<Point4F> mProbePositions;
|
||||
AlignedArray<Point4F> mProbeBBMin;
|
||||
AlignedArray<Point4F> mProbeBBMax;
|
||||
AlignedArray<float> mProbeUseSphereMode;
|
||||
AlignedArray<float> mProbeRadius;
|
||||
AlignedArray<float> mProbeAttenuation;
|
||||
|
||||
/// The scene graph the light manager is associated with.
|
||||
//SceneManager *mSceneManager;
|
||||
GFXCubemapArrayHandle mCubemapArray;
|
||||
GFXCubemapArrayHandle mIrradArray;
|
||||
|
||||
//Utilized in forward rendering
|
||||
ProbeConstantMap mConstantLookup;
|
||||
GFXShaderRef mLastShader;
|
||||
GFXShaderConstBufferRef mLastConstants;
|
||||
ProbeShaderConstants* mLastForwardConstants;
|
||||
|
||||
//
|
||||
//
|
||||
PostEffect* getProbeArrayEffect();
|
||||
ProbeShaderConstants* mLastConstants;
|
||||
|
||||
//
|
||||
SimObjectPtr<PostEffect> mProbeArrayEffect;
|
||||
|
||||
protected:
|
||||
public:
|
||||
RenderProbeMgr();
|
||||
RenderProbeMgr(RenderInstType riType, F32 renderOrder, F32 processAddOrder);
|
||||
|
||||
virtual void onRemove();
|
||||
|
||||
// ConsoleObject
|
||||
static void initPersistFields();
|
||||
DECLARE_CONOBJECT(RenderProbeMgr);
|
||||
|
||||
protected:
|
||||
/// The current active light manager.
|
||||
static RenderProbeMgr *smProbeManager;
|
||||
|
||||
typedef GFXVertexPNTT FarFrustumQuadVert;
|
||||
GFXVertexBufferHandle<FarFrustumQuadVert> mFarFrustumQuadVerts;
|
||||
|
||||
/// This helper function sets the shader constansts
|
||||
/// for the stock 4 light forward lighting code.
|
||||
void _update4ProbeConsts(const SceneData &sgData,
|
||||
|
|
@ -307,38 +215,6 @@ protected:
|
|||
GFXShaderConstHandle *probeLocalPosSC,
|
||||
GFXShaderConstBuffer *shaderConsts);
|
||||
|
||||
GFXTextureObject * mBrdfTexture;
|
||||
|
||||
//Array rendering
|
||||
U32 mEffectiveProbeCount;
|
||||
S32 mMipCount;
|
||||
Vector<Point4F> probePositions;
|
||||
Vector<MatrixF> probeWorldToObj;
|
||||
Vector<Point4F> probeBBMin;
|
||||
Vector<Point4F> probeBBMax;
|
||||
Vector<Point4F> probeUseSphereMode;
|
||||
Vector<Point4F> probeRadius;
|
||||
Vector<Point4F> probeAttenuation;
|
||||
Vector<GFXCubemapHandle> cubeMaps;
|
||||
Vector<GFXCubemapHandle> irradMaps;
|
||||
|
||||
AlignedArray<Point4F> mProbePositions;
|
||||
AlignedArray<Point4F> mProbeBBMin;
|
||||
AlignedArray<Point4F> mProbeBBMax;
|
||||
AlignedArray<float> mProbeUseSphereMode;
|
||||
AlignedArray<float> mProbeRadius;
|
||||
AlignedArray<float> mProbeAttenuation;
|
||||
|
||||
GFXCubemapArrayHandle mCubemapArray;
|
||||
GFXCubemapArrayHandle mIrradArray;
|
||||
public:
|
||||
RenderProbeMgr();
|
||||
RenderProbeMgr(RenderInstType riType, F32 renderOrder, F32 processAddOrder);
|
||||
|
||||
// RenderBinMgr
|
||||
void updateProbes();
|
||||
|
||||
protected:
|
||||
void _setupStaticParameters();
|
||||
void _setupPerFrameParameters(const SceneRenderState *state);
|
||||
virtual void addElement(RenderInst *inst);
|
||||
|
|
@ -346,18 +222,16 @@ protected:
|
|||
|
||||
ProbeShaderConstants* getProbeShaderConstants(GFXShaderConstBuffer* buffer);
|
||||
|
||||
PostEffect* getProbeArrayEffect();
|
||||
|
||||
public:
|
||||
// ConsoleObject
|
||||
static void initPersistFields();
|
||||
DECLARE_CONOBJECT(RenderProbeMgr);
|
||||
// RenderBinMgr
|
||||
void updateProbes();
|
||||
|
||||
/// Returns the active LM.
|
||||
static inline RenderProbeMgr* getProbeManager();
|
||||
|
||||
ReflectProbeMaterialInfo* getReflectProbeMaterial();
|
||||
|
||||
void registerProbe(U32 probeIdx);
|
||||
|
||||
void unregisterProbe(U32 probeIdx);
|
||||
|
||||
virtual void setProbeInfo(ProcessedMaterial *pmat,
|
||||
|
|
@ -369,6 +243,9 @@ public:
|
|||
|
||||
/// Debug rendering
|
||||
static bool smRenderReflectionProbes;
|
||||
|
||||
void bakeProbe(ReflectionProbe *probeInfo);
|
||||
void bakeProbes();
|
||||
};
|
||||
|
||||
RenderProbeMgr* RenderProbeMgr::getProbeManager()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue