BsLightRendering.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsRenderBeastPrerequisites.h"
  5. #include "BsRendererMaterial.h"
  6. #include "BsParamBlocks.h"
  7. namespace BansheeEngine
  8. {
  9. BS_PARAM_BLOCK_BEGIN(PerLightParamBuffer)
  10. BS_PARAM_BLOCK_ENTRY(Vector4, gLightPositionAndType)
  11. BS_PARAM_BLOCK_ENTRY(Vector4, gLightColorAndIntensity)
  12. BS_PARAM_BLOCK_ENTRY(Vector4, gLightSpotAnglesAndSqrdInvRadius)
  13. BS_PARAM_BLOCK_ENTRY(Vector3, gLightDirection)
  14. BS_PARAM_BLOCK_ENTRY(Vector4, gLightGeometry)
  15. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatConeTransform)
  16. BS_PARAM_BLOCK_END
  17. /** Manipulates PerLight parameter buffer used in various shaders. */
  18. class PerLightParams
  19. {
  20. public:
  21. /** Updates data in the parameter buffer from the data in the provided light. */
  22. void setParameters(const LightCore* light);
  23. /** Returns the internal parameter buffer that can be bound to the pipeline. */
  24. const SPtr<GpuParamBlockBufferCore>& getBuffer() const;
  25. private:
  26. PerLightParamBuffer mBuffer;
  27. };
  28. /** Shader that renders directional light sources during deferred rendering light pass. */
  29. class DirectionalLightMat : public RendererMaterial<DirectionalLightMat>
  30. {
  31. RMAT_DEF("DeferredDirectionalLightPass.bsl");
  32. public:
  33. DirectionalLightMat();
  34. /** Updates parameters that are common for all lights. */
  35. void setStaticParameters(const SPtr<RenderTargets>& gbuffer, const SPtr<GpuParamBlockBufferCore>& perCamera);
  36. /** Updates the parameter buffers used by the material. */
  37. void setParameters(const LightCore* light);
  38. private:
  39. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  40. MaterialParamTextureCore mGBufferA;
  41. MaterialParamTextureCore mGBufferB;
  42. MaterialParamTextureCore mGBufferDepth;
  43. };
  44. /** Shader that renders point (radial & spot) light sources during deferred rendering light pass. */
  45. class PointLightMat : public RendererMaterial<PointLightMat>
  46. {
  47. RMAT_DEF("DeferredPointLightPass.bsl");
  48. public:
  49. PointLightMat();
  50. /** Updates parameters that are common for all lights. */
  51. void setStaticParameters(const SPtr<RenderTargets>& gbuffer, const SPtr<GpuParamBlockBufferCore>& perCamera);
  52. /** Updates the parameter buffers used by the material. */
  53. void setParameters(const LightCore* light);
  54. private:
  55. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  56. MaterialParamTextureCore mGBufferA;
  57. MaterialParamTextureCore mGBufferB;
  58. MaterialParamTextureCore mGBufferDepth;
  59. };
  60. }