BsRendererCamera.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 "BsPostProcessing.h"
  6. #include "BsObjectRendering.h"
  7. #include "BsRenderQueue.h"
  8. #include "BsRendererObject.h"
  9. #include "BsBounds.h"
  10. namespace BansheeEngine
  11. {
  12. /** @addtogroup RenderBeast
  13. * @{
  14. */
  15. /** Contains information about a Camera, used by the Renderer. */
  16. class RendererCamera
  17. {
  18. public:
  19. RendererCamera();
  20. RendererCamera(const CameraCore* camera, StateReduction reductionMode);
  21. /** Updates the internal camera data, usually called after source camera changes. */
  22. void update(StateReduction reductionMode);
  23. /** Updates the internal camera post-processing data. */
  24. void updatePP();
  25. /**
  26. * Prepares camera render targets for rendering. When done call endRendering().
  27. *
  28. * @param[in] useRenderTargets If using the internal render targets containing the GBuffer (retrieved via
  29. * getRenderTargets()) while rendering you must set this to true.
  30. */
  31. void beginRendering(bool useRenderTargets);
  32. /** Ends rendering and frees any acquired resources. */
  33. void endRendering();
  34. /** Returns the camera's renderTargets. Only valid if called in-between beginRendering() and endRendering() calls. */
  35. SPtr<RenderTargets> getRenderTargets() const { return mRenderTargets; }
  36. /**
  37. * Returns a render queue containing all opaque objects. Make sure to call determineVisible() beforehand if camera
  38. * or object transforms changed since the last time it was called.
  39. */
  40. const SPtr<RenderQueue>& getOpaqueQueue() const { return mOpaqueQueue; }
  41. /**
  42. * Returns a render queue containing all transparent objects. Make sure to call determineVisible() beforehand if
  43. * camera or object transforms changed since the last time it was called.
  44. */
  45. const SPtr<RenderQueue>& getTransparentQueue() const { return mTransparentQueue; }
  46. /** Populates camera render queues by determining visible renderable objects. */
  47. void determineVisible(Vector<RendererObject>& renderables, const Vector<Bounds>& renderableBounds);
  48. /**
  49. * Returns a structure containing information about post-processing effects. This structure will be modified and
  50. * maintained by the post-processing system.
  51. */
  52. PostProcessInfo& getPPInfo() { return mPostProcessInfo; }
  53. /** Returns an object with camera's information, used for populating per-camera parameter buffers. */
  54. CameraShaderData getShaderData();
  55. private:
  56. /**
  57. * Extracts the necessary values from the projection matrix that allow you to transform device Z value into
  58. * world Z value.
  59. *
  60. * @param[in] projMatrix Projection matrix that was used to create the device Z value to transform.
  61. * @return Returns two values that can be used to transform device z to world z using this formula:
  62. * z = (deviceZ + y) * x.
  63. */
  64. Vector2 getDeviceZTransform(const Matrix4& projMatrix);
  65. const CameraCore* mCamera;
  66. SPtr<RenderQueue> mOpaqueQueue;
  67. SPtr<RenderQueue> mTransparentQueue;
  68. SPtr<RenderTargets> mRenderTargets;
  69. PostProcessInfo mPostProcessInfo;
  70. bool mUsingRenderTargets;
  71. };
  72. /** @} */
  73. }