BsRendererObject.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsRenderBeastPrerequisites.h"
  5. #include "BsRenderableElement.h"
  6. #include "BsRenderable.h"
  7. #include "BsParamBlocks.h"
  8. #include "BsMaterialParam.h"
  9. namespace bs { namespace ct
  10. {
  11. /** @addtogroup RenderBeast
  12. * @{
  13. */
  14. BS_PARAM_BLOCK_BEGIN(PerObjectParamDef)
  15. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatWorld)
  16. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatInvWorld)
  17. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatWorldNoScale)
  18. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatInvWorldNoScale)
  19. BS_PARAM_BLOCK_ENTRY(float, gWorldDeterminantSign)
  20. BS_PARAM_BLOCK_END
  21. extern PerObjectParamDef gPerObjectParamDef;
  22. BS_PARAM_BLOCK_BEGIN(PerCallParamDef)
  23. BS_PARAM_BLOCK_ENTRY(Matrix4, gMatWorldViewProj)
  24. BS_PARAM_BLOCK_END
  25. extern PerCallParamDef gPerCallParamDef;
  26. struct MaterialSamplerOverrides;
  27. /**
  28. * @copydoc RenderableElement
  29. *
  30. * Contains additional data specific to RenderBeast renderer.
  31. */
  32. class BeastRenderableElement : public RenderableElement
  33. {
  34. public:
  35. /**
  36. * Optional overrides for material sampler states. Used when renderer wants to override certain sampling properties
  37. * on a global scale (for example filtering most commonly).
  38. */
  39. MaterialSamplerOverrides* samplerOverrides;
  40. /** All GPU parameters from the material used by the renderable. */
  41. SPtr<GpuParamsSet> params;
  42. /** Identifier of the owner renderable. */
  43. UINT32 renderableId;
  44. /** Identifier of the animation running on the renderable's mesh. -1 if no animation. */
  45. UINT64 animationId;
  46. /** Type of animation applied to this element, if any. */
  47. RenderableAnimType animType;
  48. /** Index of the technique in the material to render the element with. */
  49. UINT32 techniqueIdx;
  50. /** Index to which should the per-camera param block buffer be bound to. */
  51. UINT32 perCameraBindingIdx;
  52. /** Index to which should the lights param block buffer be bound to. */
  53. UINT32 lightParamsBindingIdx;
  54. /** Parameter to which to bind light buffer used for forward rendering. */
  55. GpuParamBuffer lightsBufferParam;
  56. /** GPU buffer containing element's bone matrices, if it requires any. */
  57. SPtr<GpuBuffer> boneMatrixBuffer;
  58. /** Vertex buffer containing element's morph shape vertices, if it has any. */
  59. SPtr<VertexBuffer> morphShapeBuffer;
  60. /** Vertex declaration used for rendering meshes containing morph shape information. */
  61. SPtr<VertexDeclaration> morphVertexDeclaration;
  62. /** Version of the morph shape vertices in the buffer. */
  63. mutable UINT32 morphShapeVersion;
  64. };
  65. /** Contains information about a Renderable, used by the Renderer. */
  66. struct RendererObject
  67. {
  68. RendererObject();
  69. /** Updates the per-object GPU buffer according to the currently set properties. */
  70. void updatePerObjectBuffer();
  71. /**
  72. * Updates the per-call GPU buffer according to the provided parameters.
  73. *
  74. * @param[in] viewProj Combined view-projection matrix of the current camera.
  75. * @param[in] flush True if the buffer contents should be immediately flushed to the GPU.
  76. */
  77. void updatePerCallBuffer(const Matrix4& viewProj, bool flush = true);
  78. Renderable* renderable;
  79. Vector<BeastRenderableElement> elements;
  80. SPtr<GpuParamBlockBuffer> perObjectParamBuffer;
  81. SPtr<GpuParamBlockBuffer> perCallParamBuffer;
  82. };
  83. /** @} */
  84. }}