BsLightRendering.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. /**
  39. * Updates the parameter buffers used by the material.
  40. */
  41. void setParameters(const LightCore* light);
  42. private:
  43. /**
  44. * @copydoc RendererMaterial::initialize
  45. */
  46. void initialize() override;
  47. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  48. };
  49. /**
  50. * Shader that renders point (radial & spot) light sources during deferred rendering light pass.
  51. */
  52. class PointLightMat : public RendererMaterial<PointLightMat>
  53. {
  54. RMAT_DEF("DeferredPointLightPass.bsl");
  55. public:
  56. /**
  57. * Updates the parameter buffers used by the material.
  58. */
  59. void setParameters(const LightCore* light);
  60. private:
  61. /**
  62. * @copydoc RendererMaterial::initialize
  63. */
  64. void initialize() override;
  65. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  66. };
  67. }