| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsRenderBeastPrerequisites.h"
- #include "BsRenderer.h"
- #include "BsBounds.h"
- #include "BsSamplerOverrides.h"
- #include "BsRendererMaterial.h"
- #include "BsLightRendering.h"
- #include "BsObjectRendering.h"
- #include "BsPostProcessing.h"
- #include "BsRendererCamera.h"
- #include "BsRendererObject.h"
- namespace bs
- {
- struct RendererAnimationData;
- namespace ct
- {
- class LightGrid;
- /** @addtogroup RenderBeast
- * @{
- */
- /** Semantics that may be used for signaling the renderer for what is a certain shader parameter used for. */
- static StringID RPS_GBufferA = "GBufferA";
- static StringID RPS_GBufferB = "GBufferB";
- static StringID RPS_GBufferDepth = "GBufferDepth";
- static StringID RPS_BoneMatrices = "BoneMatrices";
- /**
- * Default renderer for Banshee. Performs frustum culling, sorting and renders all scene objects while applying
- * lighting, shadowing, special effects and post-processing.
- *
- * @note Sim thread unless otherwise noted.
- */
- class RenderBeast : public Renderer
- {
- /** Renderer information specific to a single render target. */
- struct RendererRenderTarget
- {
- SPtr<RenderTarget> target;
- Vector<const Camera*> cameras;
- };
- /** Renderer information for a single material. */
- struct RendererMaterial
- {
- Vector<SPtr<GpuParamsSet>> params;
- UINT32 matVersion;
- };
- /** Contains information global to an entire frame. */
- struct FrameInfo
- {
- FrameInfo(float timeDelta, const RendererAnimationData& animData)
- :timeDelta(timeDelta), animData(animData)
- { }
- float timeDelta;
- const RendererAnimationData& animData;
- };
- public:
- RenderBeast();
- ~RenderBeast() { }
- /** @copydoc Renderer::getName */
- const StringID& getName() const override;
- /** @copydoc Renderer::renderAll */
- void renderAll() override;
- /** Sets options used for controlling the rendering. */
- void setOptions(const SPtr<CoreRendererOptions>& options) override;
- /** Returns current set of options used for controlling the rendering. */
- SPtr<CoreRendererOptions> getOptions() const override;
- /** @copydoc Renderer::initialize */
- void initialize() override;
- /** @copydoc Renderer::destroy */
- void destroy() override;
- /** @copydoc Renderer::createPostProcessSettings */
- SPtr<PostProcessSettings> createPostProcessSettings() const override;
- private:
- /** @copydoc Renderer::notifyCameraAdded */
- void notifyCameraAdded(const Camera* camera) override;
- /** @copydoc Renderer::notifyCameraUpdated */
- void notifyCameraUpdated(const Camera* camera, UINT32 updateFlag) override;
- /** @copydocRenderer::notifyCameraRemoved */
- void notifyCameraRemoved(const Camera* camera) override;
- /** @copydoc Renderer::notifyLightAdded */
- void notifyLightAdded(Light* light) override;
- /** @copydoc Renderer::notifyLightUpdated */
- void notifyLightUpdated(Light* light) override;
- /** @copydoc Renderer::notifyLightRemoved */
- void notifyLightRemoved(Light* light) override;
- /** @copydoc Renderer::notifyRenderableAdded */
- void notifyRenderableAdded(Renderable* renderable) override;
- /** @copydoc Renderer::notifyRenderableUpdated */
- void notifyRenderableUpdated(Renderable* renderable) override;
- /** @copydoc Renderer::notifyRenderableRemoved */
- void notifyRenderableRemoved(Renderable* renderable) override;
- /**
- * Updates (or adds) renderer specific data for the specified camera. Should be called whenever camera properties
- * change.
- *
- * @param[in] camera Camera whose data to update.
- * @param[in] forceRemove If true, the camera data will be removed instead of updated.
- * @return Renderer camera object that represents the camera. Null if camera was removed.
- */
- RendererCamera* updateCameraData(const Camera* camera, bool forceRemove = false);
- /**
- * Updates the render options on the core thread.
- *
- * @note Core thread only.
- */
- void syncOptions(const RenderBeastOptions& options);
- /**
- * Performs rendering over all camera proxies.
- *
- * @param[in] time Current frame time in milliseconds.
- * @param[in] delta Time elapsed since the last frame.
- *
- * @note Core thread only.
- */
- void renderAllCore(float time, float delta);
- /**
- * Renders all provided views.
- *
- * @note Core thread only.
- */
- void renderViews(RendererCamera** views, UINT32 numViews, const FrameInfo& frameInfo);
- /**
- * Renders all objects visible by the provided view.
- *
- * @note Core thread only.
- */
- void renderView(RendererCamera* viewInfo, float frameDelta);
- /**
- * Renders all overlay callbacks of the provided view.
- *
- * @note Core thread only.
- */
- void renderOverlay(RendererCamera* viewInfo);
- /**
- * Renders a single element of a renderable object.
- *
- * @param[in] element Element to render.
- * @param[in] passIdx Index of the material pass to render the element with.
- * @param[in] bindPass If true the material pass will be bound for rendering, if false it is assumed it is
- * already bound.
- * @param[in] viewProj View projection matrix of the camera the element is being rendered with.
- */
- void renderElement(const BeastRenderableElement& element, UINT32 passIdx, bool bindPass, const Matrix4& viewProj);
- /**
- * Captures the scene at the specified location into a cubemap.
- *
- * @param[in] position Position to capture the scene at.
- * @param[in] hdr If true scene will be captured in a format that supports high dynamic range.
- * @param[in] size Cubemap face width/height in pixels.
- * @param[in] frameInfo Global information about the the frame currently being rendered.
- */
- SPtr<Texture> captureSceneCubeMap(const Vector3& position, bool hdr, UINT32 size, const FrameInfo& frameInfo);
- /** Creates data used by the renderer on the core thread. */
- void initializeCore();
- /** Destroys data used by the renderer on the core thread. */
- void destroyCore();
- /**
- * Checks all sampler overrides in case material sampler states changed, and updates them.
- *
- * @param[in] force If true, all sampler overrides will be updated, regardless of a change in the material
- * was detected or not.
- */
- void refreshSamplerOverrides(bool force = false);
- // Core thread only fields
- Vector<RendererRenderTarget> mRenderTargets;
- UnorderedMap<const Camera*, RendererCamera*> mCameras;
- UnorderedMap<SamplerOverrideKey, MaterialSamplerOverrides*> mSamplerOverrides;
- Vector<RendererObject*> mRenderables;
- Vector<CullInfo> mRenderableCullInfos;
- Vector<bool> mRenderableVisibility; // Transient
- Vector<RendererLight> mDirectionalLights;
- Vector<RendererLight> mRadialLights;
- Vector<RendererLight> mSpotLights;
- Vector<Sphere> mPointLightWorldBounds;
- Vector<Sphere> mSpotLightWorldBounds;
- SPtr<RenderBeastOptions> mCoreOptions;
- DefaultMaterial* mDefaultMaterial;
- TiledDeferredLightingMat* mTiledDeferredLightingMat;
- SkyboxMat* mSkyboxMat;
- GPULightData* mGPULightData;
- LightGrid* mLightGrid;
- ObjectRenderer* mObjectRenderer;
- // Sim thread only fields
- SPtr<RenderBeastOptions> mOptions;
- bool mOptionsDirty;
- // Helpers to avoid memory allocations
- Vector<LightData> mLightDataTemp;
- Vector<bool> mLightVisibilityTemp;
- };
- /** @} */
- }}
|