BsBansheeLitTexRenderableController.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #include "BsBansheeRendererPrerequisites.h"
  3. #include "BsRenderableController.h"
  4. #include "BsMaterialProxy.h"
  5. #include "BsGpuParamDesc.h"
  6. #include "BsGpuParam.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief Renderer handler that manages initializing, updating
  11. * and rendering of renderable objects with a single texture
  12. * and a single light.
  13. *
  14. * @note This class is DEBUG ONLY. Until a better renderer is complete.
  15. */
  16. class BS_BSRND_EXPORT LitTexRenderableController : public RenderableController
  17. {
  18. public:
  19. /**
  20. * @brief Contains lit tex renderable data unique for each object.
  21. */
  22. struct PerObjectData
  23. {
  24. GpuParamBlockBufferPtr perObjectParamBuffer;
  25. bool hasWVPParam = false;
  26. GpuParamMat4 wvpParam;
  27. Vector<MaterialProxy::BufferBindInfo> perObjectBuffers;
  28. };
  29. LitTexRenderableController();
  30. /**
  31. * @copydoc RenderableHandler::initializeRenderElem
  32. */
  33. void initializeRenderElem(RenderableElement* element);
  34. /**
  35. * @copydoc RenderableHandler::bindPerObjectBuffers
  36. */
  37. void bindPerObjectBuffers(const RenderableElement* element);
  38. /**
  39. * @brief Updates global parameter buffers with new values.
  40. * To be called whenever global values change.
  41. */
  42. void updateGlobalBuffers(float time);
  43. /**
  44. * @brief Updates object specific parameter buffers with new values.
  45. * To be called whenever object specific values change.
  46. */
  47. void updatePerObjectBuffers(RenderableElement* element, const Matrix4& wvpMatrix);
  48. protected:
  49. /**
  50. * @brief Creates a new default shader used for lit textured renderables.
  51. * It is used for matching custom shaders and determining if they
  52. * comply with lit textured renderable requirements.
  53. */
  54. ShaderPtr createDefaultShader();
  55. ShaderPtr defaultShader;
  56. GpuParamBlockDesc staticParamBlockDesc;
  57. GpuParamBlockDesc perFrameParamBlockDesc;
  58. GpuParamBlockDesc perObjectParamBlockDesc;
  59. GpuParamDataDesc timeParamDesc;
  60. GpuParamDataDesc lightDirParamDesc;
  61. GpuParamDataDesc wvpParamDesc;
  62. GpuParamBlockBufferPtr staticParamBuffer;
  63. GpuParamBlockBufferPtr perFrameParamBuffer;
  64. GpuParamsPtr staticParams;
  65. GpuParamsPtr perFrameParams;
  66. GpuParamVec4 lightDirParam;
  67. GpuParamFloat timeParam;
  68. };
  69. }