BsLightRendering.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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_ENTRY(Matrix4, gMatConeTransform)
  14. BS_PARAM_BLOCK_END
  15. /**
  16. * Manipulates PerLight parameter buffer used in various shaders.
  17. */
  18. class PerLightParams
  19. {
  20. public:
  21. /**
  22. * Updates data in the parameter buffer from the data in the provided light.
  23. */
  24. void setParameters(const LightCore* light);
  25. /**
  26. * Returns the internal parameter buffer that can be bound to the pipeline.
  27. */
  28. const SPtr<GpuParamBlockBufferCore>& getBuffer() const;
  29. private:
  30. PerLightParamBuffer mBuffer;
  31. };
  32. /**
  33. * Shader that renders directional light sources during deferred rendering light pass.
  34. */
  35. class DirectionalLightMat : public RendererMaterial<DirectionalLightMat>
  36. {
  37. RMAT_DEF("DeferredDirectionalLightPass.bsl");
  38. public:
  39. DirectionalLightMat();
  40. /**
  41. * Binds the gbuffer used for rendering the light.
  42. */
  43. void setGBuffer(const SPtr<RenderTargets>& gbuffer);
  44. /**
  45. * Updates the parameter buffers used by the material.
  46. */
  47. void setParameters(const LightCore* light);
  48. private:
  49. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  50. MaterialParamTextureCore mGBufferA;
  51. MaterialParamTextureCore mGBufferB;
  52. MaterialParamTextureCore mGBufferDepth;
  53. };
  54. /**
  55. * Shader that renders point (radial & spot) light sources during deferred rendering light pass.
  56. */
  57. class PointLightMat : public RendererMaterial<PointLightMat>
  58. {
  59. RMAT_DEF("DeferredPointLightPass.bsl");
  60. public:
  61. PointLightMat();
  62. /**
  63. * Binds the gbuffer used for rendering the light.
  64. */
  65. void setGBuffer(const SPtr<RenderTargets>& gbuffer);
  66. /**
  67. * Updates the parameter buffers used by the material.
  68. */
  69. void setParameters(const LightCore* light);
  70. private:
  71. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  72. MaterialParamTextureCore mGBufferA;
  73. MaterialParamTextureCore mGBufferB;
  74. MaterialParamTextureCore mGBufferDepth;
  75. };
  76. }