BsLightRendering.h 1.8 KB

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