| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsRenderBeastPrerequisites.h"
- #include "BsRendererMaterial.h"
- #include "BsParamBlocks.h"
- namespace bs { namespace ct
- {
- /** @addtogroup RenderBeast
- * @{
- */
- /** Information about a single light, as seen by the lighting shader. */
- struct LightData
- {
- Vector3 position;
- float radius;
- Vector3 direction;
- float intensity;
- Vector3 spotAngles;
- float radiusSqrdInv;
- Vector3 color;
- };
- /** Renderer information specific to a single light. */
- class RendererLight
- {
- public:
- RendererLight(Light* light);
- /** Populates the structure with light parameters. */
- void getParameters(LightData& output) const;
- /** Gets the internal light representation. */
- Light* getInternal() const { return mInternal; }
- private:
- Light* mInternal;
- };
- /** Contains GPU buffers used by the renderer to manipulate lights. */
- class GPULightData
- {
- public:
- GPULightData();
- /** Updates the internal buffers with a new set of lights. */
- void setLights(const Vector<LightData>& lightData, UINT32 numDirLights, UINT32 numRadialLights,
- UINT32 numSpotLights);
- /** Returns a GPU bindable buffer containing information about every light. */
- SPtr<GpuBuffer> getLightBuffer() const { return mLightBuffer; }
- /** Returns a GPU bindable param buffer containing meta-data about light in the ligth buffer. */
- SPtr<GpuParamBlockBuffer> getParamBuffer() const { return mParamBuffer; }
- /** Returns the number of directional lights in the lights buffer. */
- UINT32 getNumDirLights() const { return mNumLights[0]; }
- /** Returns the number of radial point lights in the lights buffer. */
- UINT32 getNumRadialLights() const { return mNumLights[1]; }
- /** Returns the number of spot point lights in the lights buffer. */
- UINT32 getNumSpotLights() const { return mNumLights[2]; }
- private:
- SPtr<GpuParamBlockBuffer> mParamBuffer;
- SPtr<GpuBuffer> mLightBuffer;
- UINT32 mNumLights[3];
- };
- BS_PARAM_BLOCK_BEGIN(TiledLightingParamDef)
- BS_PARAM_BLOCK_ENTRY(Vector3I, gLightOffsets)
- BS_PARAM_BLOCK_END
- extern TiledLightingParamDef gTiledLightingParamDef;
- /** Shader that performs a lighting pass over data stored in the Gbuffer. */
- class TiledDeferredLightingMat : public RendererMaterial<TiledDeferredLightingMat>
- {
- RMAT_DEF("TiledDeferredLighting.bsl");
- public:
- TiledDeferredLightingMat();
- /** Binds the material for rendering, sets up parameters and executes it. */
- void execute(const SPtr<RenderTargets>& gbuffer, const SPtr<GpuParamBlockBuffer>& perCamera);
- /** Binds all the active lights. */
- void setLights(const GPULightData& lightData);
- private:
- GpuParamTexture mGBufferA;
- GpuParamTexture mGBufferB;
- GpuParamTexture mGBufferDepth;
- GpuParamBuffer mLightBufferParam;
- GpuParamLoadStoreTexture mOutputParam;
- static const UINT32 TILE_SIZE;
- };
- /** @} */
- }}
|