BsLightRendering.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #pragma once
  2. #include "BsRenderBeastPrerequisites.h"
  3. #include "BsRendererMaterial.h"
  4. #include "BsParamBlocks.h"
  5. namespace BansheeEngine
  6. {
  7. BS_PARAM_BLOCK_BEGIN(PerLightParamBuffer)
  8. BS_PARAM_BLOCK_ENTRY(Vector4, gLightPositionAndType)
  9. BS_PARAM_BLOCK_ENTRY(Vector4, gLightColorAndIntensity)
  10. BS_PARAM_BLOCK_ENTRY(Vector2, gLightSpotAngles)
  11. BS_PARAM_BLOCK_ENTRY(Vector3, gLightDirection)
  12. BS_PARAM_BLOCK_ENTRY(Vector4, gLightGeometry)
  13. BS_PARAM_BLOCK_END
  14. /**
  15. * Manipulates PerLight parameter buffer used in various shaders.
  16. */
  17. class PerLightParams
  18. {
  19. public:
  20. /**
  21. * Updates data in the parameter buffer from the data in the provided light.
  22. */
  23. void setParameters(const LightCore* light);
  24. /**
  25. * Returns the internal parameter buffer that can be bound to the pipeline.
  26. */
  27. const SPtr<GpuParamBlockBufferCore>& getBuffer() const;
  28. private:
  29. PerLightParamBuffer mBuffer;
  30. };
  31. /**
  32. * Shader that renders directional light sources during deferred rendering light pass.
  33. */
  34. class DirectionalLightMat : public RendererMaterial<DirectionalLightMat>
  35. {
  36. RMAT_DEF("DeferredDirectionalLightPass.bsl");
  37. public:
  38. DirectionalLightMat();
  39. /**
  40. * Binds the gbuffer used for rendering the light.
  41. */
  42. void setGBuffer(const SPtr<RenderTargets>& gbuffer);
  43. /**
  44. * Updates the parameter buffers used by the material.
  45. */
  46. void setParameters(const LightCore* light);
  47. private:
  48. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  49. MaterialParamTextureCore mGBufferA;
  50. MaterialParamTextureCore mGBufferB;
  51. MaterialParamTextureCore mGBufferDepth;
  52. };
  53. /**
  54. * Shader that renders point (radial & spot) light sources during deferred rendering light pass.
  55. */
  56. class PointLightMat : public RendererMaterial<PointLightMat>
  57. {
  58. RMAT_DEF("DeferredPointLightPass.bsl");
  59. public:
  60. PointLightMat();
  61. /**
  62. * Binds the gbuffer used for rendering the light.
  63. */
  64. void setGBuffer(const SPtr<RenderTargets>& gbuffer);
  65. /**
  66. * Updates the parameter buffers used by the material.
  67. */
  68. void setParameters(const LightCore* light);
  69. private:
  70. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  71. MaterialParamTextureCore mGBufferA;
  72. MaterialParamTextureCore mGBufferB;
  73. MaterialParamTextureCore mGBufferDepth;
  74. };
  75. }