BsLightRendering.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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(Vector3, 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. /** Manipulates PerLight parameter buffer used in various shaders. */
  16. class PerLightParams
  17. {
  18. public:
  19. /** Updates data in the parameter buffer from the data in the provided light. */
  20. void setParameters(const LightCore* light);
  21. /** Returns the internal parameter buffer that can be bound to the pipeline. */
  22. const SPtr<GpuParamBlockBufferCore>& getBuffer() const;
  23. private:
  24. PerLightParamBuffer mBuffer;
  25. };
  26. /** Shader that renders directional light sources during deferred rendering light pass. */
  27. class DirectionalLightMat : public RendererMaterial<DirectionalLightMat>
  28. {
  29. RMAT_DEF("DeferredDirectionalLightPass.bsl");
  30. public:
  31. DirectionalLightMat();
  32. /** Updates parameters that are common for all lights. */
  33. void setStaticParameters(const SPtr<RenderTargets>& gbuffer, const SPtr<GpuParamBlockBufferCore>& perCamera);
  34. /** Updates the parameter buffers used by the material. */
  35. void setParameters(const LightCore* light);
  36. private:
  37. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  38. MaterialParamTextureCore mGBufferA;
  39. MaterialParamTextureCore mGBufferB;
  40. MaterialParamTextureCore mGBufferDepth;
  41. };
  42. /** Shader that renders point (radial & spot) light sources during deferred rendering light pass. */
  43. class PointLightMat : public RendererMaterial<PointLightMat>
  44. {
  45. RMAT_DEF("DeferredPointLightPass.bsl");
  46. public:
  47. PointLightMat();
  48. /** Updates parameters that are common for all lights. */
  49. void setStaticParameters(const SPtr<RenderTargets>& gbuffer, const SPtr<GpuParamBlockBufferCore>& perCamera);
  50. /** Updates the parameter buffers used by the material. */
  51. void setParameters(const LightCore* light);
  52. private:
  53. PerLightParams mParams; // Note: Should this buffer be shared between both point and directional lights?
  54. MaterialParamTextureCore mGBufferA;
  55. MaterialParamTextureCore mGBufferB;
  56. MaterialParamTextureCore mGBufferDepth;
  57. };
  58. }