|
|
@@ -5,6 +5,7 @@
|
|
|
#include "BsCorePrerequisites.h"
|
|
|
#include "Reflection/BsIReflectable.h"
|
|
|
#include "CoreThread/BsCoreObject.h"
|
|
|
+#include "Scene/BsSceneActor.h"
|
|
|
|
|
|
namespace bs
|
|
|
{
|
|
|
@@ -17,26 +18,21 @@ namespace bs
|
|
|
* @{
|
|
|
*/
|
|
|
|
|
|
- /** Signals which portion of a skybox is dirty. */
|
|
|
+ /** Signals which portion of a Skybox is dirty. */
|
|
|
enum class SkyboxDirtyFlag
|
|
|
{
|
|
|
- Texture = 0x01,
|
|
|
- Everything = 0x02
|
|
|
+ // First few bits reserved by ActorDiryFlag
|
|
|
+ Texture = 1 << 4
|
|
|
};
|
|
|
|
|
|
+
|
|
|
/** Base class for both core and sim thread implementations of a skybox. */
|
|
|
- class BS_CORE_EXPORT SkyboxBase
|
|
|
+ class BS_CORE_EXPORT SkyboxBase : public SceneActor
|
|
|
{
|
|
|
public:
|
|
|
SkyboxBase();
|
|
|
virtual ~SkyboxBase() { }
|
|
|
|
|
|
- /** Checks whether the skybox should be used or not. */
|
|
|
- bool getIsActive() const { return mIsActive; }
|
|
|
-
|
|
|
- /** Sets whether the skybox should be used or not. */
|
|
|
- void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
|
|
|
-
|
|
|
/**
|
|
|
* Brightness multiplier that will be applied to skybox values before they're being used. Allows you to make the
|
|
|
* skybox more or less bright. Equal to one by default.
|
|
|
@@ -46,40 +42,10 @@ namespace bs
|
|
|
/** @see setBrightness */
|
|
|
float getBrightness() const { return mBrightness; }
|
|
|
|
|
|
- /**
|
|
|
- * Marks the simulation thread object as dirty and notifies the system its data should be synced with its core
|
|
|
- * thread counterpart.
|
|
|
- */
|
|
|
- virtual void _markCoreDirty(SkyboxDirtyFlag flags = SkyboxDirtyFlag::Everything) { }
|
|
|
-
|
|
|
protected:
|
|
|
- bool mIsActive; /**< Determines whether the skybox should be rendered or not. */
|
|
|
float mBrightness; /**< Multiplier to apply to evaluated skybox values before using them. */
|
|
|
};
|
|
|
|
|
|
- /** Templated base class for both core and sim thread implementations of a skybox. */
|
|
|
- template<bool Core>
|
|
|
- class BS_CORE_EXPORT TSkybox : public SkyboxBase
|
|
|
- {
|
|
|
- typedef typename TTextureType<Core>::Type TextureType;
|
|
|
-
|
|
|
- public:
|
|
|
- TSkybox();
|
|
|
- virtual ~TSkybox() { }
|
|
|
-
|
|
|
- /**
|
|
|
- * Assigns an environment map to use for sampling skybox radiance. Must be a cube-map texture, and should ideally
|
|
|
- * contain HDR data.
|
|
|
- */
|
|
|
- void setTexture(const TextureType& texture) { mTexture = texture; _markCoreDirty(SkyboxDirtyFlag::Texture); }
|
|
|
-
|
|
|
- /** Gets the texture assigned through setTexture(). */
|
|
|
- TextureType getTexture() const { return mTexture; }
|
|
|
-
|
|
|
- protected:
|
|
|
- TextureType mTexture;
|
|
|
- };
|
|
|
-
|
|
|
/** @} */
|
|
|
/** @addtogroup Renderer-Internal
|
|
|
* @{
|
|
|
@@ -88,10 +54,19 @@ namespace bs
|
|
|
namespace ct { class Skybox; }
|
|
|
|
|
|
/** Allows you to specify an environment map to use for sampling radiance of the sky. */
|
|
|
- class BS_CORE_EXPORT Skybox : public IReflectable, public CoreObject, public TSkybox<false>
|
|
|
+ class BS_CORE_EXPORT Skybox : public IReflectable, public CoreObject, public SkyboxBase
|
|
|
{
|
|
|
public:
|
|
|
~Skybox();
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Determines an environment map to use for sampling skybox radiance. Must be a cube-map texture, and should ideally
|
|
|
+ * contain HDR data.
|
|
|
+ */
|
|
|
+ void setTexture(const HTexture& texture);
|
|
|
+
|
|
|
+ /** @copydoc setTexture */
|
|
|
+ HTexture getTexture() const { return mTexture; }
|
|
|
|
|
|
/** Retrieves an implementation of the skybox usable only from the core thread. */
|
|
|
SPtr<ct::Skybox> getCore() const;
|
|
|
@@ -112,11 +87,12 @@ namespace bs
|
|
|
SPtr<ct::CoreObject> createCore() const override;
|
|
|
|
|
|
/** @copydoc SkyboxBase::_markCoreDirty */
|
|
|
- void _markCoreDirty(SkyboxDirtyFlag flags = SkyboxDirtyFlag::Everything) override;
|
|
|
+ void _markCoreDirty(ActorDirtyFlag flags = ActorDirtyFlag::Everything) override;
|
|
|
|
|
|
/** @copydoc CoreObject::syncToCore */
|
|
|
CoreSyncData syncToCore(FrameAlloc* allocator) override;
|
|
|
|
|
|
+ HTexture mTexture;
|
|
|
SPtr<Texture> mFilteredRadiance;
|
|
|
SPtr<Texture> mIrradiance;
|
|
|
SPtr<ct::RendererTask> mRendererTask;
|
|
|
@@ -128,16 +104,22 @@ namespace bs
|
|
|
friend class SkyboxRTTI;
|
|
|
static RTTITypeBase* getRTTIStatic();
|
|
|
RTTITypeBase* getRTTI() const override;
|
|
|
+
|
|
|
+ /** Creates a new skybox instance without initializing it. */
|
|
|
+ static SPtr<Skybox> createEmpty();
|
|
|
};
|
|
|
|
|
|
namespace ct
|
|
|
{
|
|
|
/** Core thread usable version of a bs::Skybox */
|
|
|
- class BS_CORE_EXPORT Skybox : public CoreObject, public TSkybox<true>
|
|
|
+ class BS_CORE_EXPORT Skybox : public CoreObject, public SkyboxBase
|
|
|
{
|
|
|
public:
|
|
|
~Skybox();
|
|
|
|
|
|
+ /** @copydoc bs::Skybox::setTexture */
|
|
|
+ SPtr<Texture> getTexture() const { return mTexture; }
|
|
|
+
|
|
|
/**
|
|
|
* Returns a texture containing filtered version of the radiance texture used for reflections. This might not
|
|
|
* be available if it hasn't been generated yet.
|
|
|
@@ -152,7 +134,7 @@ namespace bs
|
|
|
protected:
|
|
|
friend class bs::Skybox;
|
|
|
|
|
|
- Skybox(const SPtr<Texture>& filteredRadiance, const SPtr<Texture>& irradiance);
|
|
|
+ Skybox(const SPtr<Texture>& radiance, const SPtr<Texture>& filteredRadiance, const SPtr<Texture>& irradiance);
|
|
|
|
|
|
/** @copydoc CoreObject::initialize */
|
|
|
void initialize() override;
|
|
|
@@ -160,6 +142,7 @@ namespace bs
|
|
|
/** @copydoc CoreObject::syncToCore */
|
|
|
void syncToCore(const CoreSyncData& data) override;
|
|
|
|
|
|
+ SPtr<Texture> mTexture;
|
|
|
SPtr<Texture> mFilteredRadiance;
|
|
|
SPtr<Texture> mIrradiance;
|
|
|
};
|