Jelajahi Sumber

Moved camera to core layer so animation manager has access to it

BearishSun 9 tahun lalu
induk
melakukan
8d74761ad7
37 mengubah file dengan 2228 tambahan dan 1270 penghapusan
  1. 9 0
      Source/BansheeCore/CMakeSources.cmake
  2. 1 1
      Source/BansheeCore/Include/BsAnimationManager.h
  3. 261 261
      Source/BansheeCore/Include/BsCCamera.h
  4. 47 47
      Source/BansheeCore/Include/BsCCameraRTTI.h
  5. 606 606
      Source/BansheeCore/Include/BsCamera.h
  6. 80 79
      Source/BansheeCore/Include/BsCameraRTTI.h
  7. 10 1
      Source/BansheeCore/Include/BsCorePrerequisites.h
  8. 5 0
      Source/BansheeCore/Include/BsCoreRenderer.h
  9. 46 0
      Source/BansheeCore/Include/BsCoreSceneManager.h
  10. 1 1
      Source/BansheeCore/Include/BsMaterialParams.h
  11. 55 0
      Source/BansheeCore/Include/BsPostProcessSettings.h
  12. 43 0
      Source/BansheeCore/Include/BsPostProcessSettingsRTTI.h
  13. 15 2
      Source/BansheeCore/Source/BsAnimationManager.cpp
  14. 4 4
      Source/BansheeCore/Source/BsCCamera.cpp
  15. 29 3
      Source/BansheeCore/Source/BsCamera.cpp
  16. 1 1
      Source/BansheeCore/Source/BsCoreApplication.cpp
  17. 91 0
      Source/BansheeCore/Source/BsCoreSceneManager.cpp
  18. 17 0
      Source/BansheeCore/Source/BsPostProcessSettings.cpp
  19. 3 8
      Source/BansheeEngine/CMakeSources.cmake
  20. 8 7
      Source/BansheeEngine/Include/BsPrerequisites.h
  21. 1 46
      Source/BansheeEngine/Include/BsSceneManager.h
  22. 53 12
      Source/BansheeEngine/Include/BsStandardPostProcessSettings.h
  23. 187 0
      Source/BansheeEngine/Include/BsStandardPostProcessSettingsRTTI.h
  24. 0 29
      Source/BansheeEngine/Source/BsPostProcessSettings.cpp
  25. 0 89
      Source/BansheeEngine/Source/BsSceneManager.cpp
  26. 193 0
      Source/BansheeEngine/Source/BsStandardPostProcessSettings.cpp
  27. 4 9
      Source/MBansheeEngine/Interop/NativeCamera.cs
  28. 12 15
      Source/MBansheeEngine/Rendering/PostProcessSettings.cs
  29. 2 2
      Source/RenderBeast/Include/BsPostProcessing.h
  30. 3 0
      Source/RenderBeast/Include/BsRenderBeast.h
  31. 27 23
      Source/RenderBeast/Source/BsPostProcessing.cpp
  32. 5 0
      Source/RenderBeast/Source/BsRenderBeast.cpp
  33. 9 1
      Source/RenderBeast/Source/BsRendererCamera.cpp
  34. 2 2
      Source/SBansheeEngine/Include/BsScriptCamera.h
  35. 123 2
      Source/SBansheeEngine/Include/BsScriptPostProcessSettings.h
  36. 21 4
      Source/SBansheeEngine/Source/BsScriptCamera.cpp
  37. 254 15
      Source/SBansheeEngine/Source/BsScriptPostProcessSettings.cpp

+ 9 - 0
Source/BansheeCore/CMakeSources.cmake

@@ -16,6 +16,7 @@ set(BS_BANSHEECORE_INC_COMPONENTS
 	"Include/BsCCharacterController.h"
 	"Include/BsCAudioSource.h"
 	"Include/BsCAudioListener.h"
+	"Include/BsCCamera.h"
 )
 
 set(BS_BANSHEECORE_INC_PHYSICS
@@ -97,6 +98,8 @@ set(BS_BANSHEECORE_INC_RENDERER
 	"Include/BsCoreRenderer.h"
 	"Include/BsRendererMeshData.h"
 	"Include/BsParamBlocks.h"
+	"Include/BsCamera.h"
+	"Include/BsPostProcessSettings.h"
 )
 
 set(BS_BANSHEECORE_SRC_LOCALIZATION
@@ -249,6 +252,7 @@ set(BS_BANSHEECORE_SRC_COMPONENTS
 	"Source/BsCCharacterController.cpp"
 	"Source/BsCAudioSource.cpp"
 	"Source/BsCAudioListener.cpp"
+	"Source/BsCCamera.cpp"
 )
 
 set(BS_BANSHEECORE_SRC_PLATFORM
@@ -341,12 +345,17 @@ set(BS_BANSHEECORE_INC_RTTI
 	"Include/BsAnimationClipRTTI.h"
 	"Include/BsAnimationCurveRTTI.h"
 	"Include/BsSkeletonRTTI.h"
+	"Include/BsCCameraRTTI.h"
+	"Include/BsCameraRTTI.h"
+	"Include/BsPostProcessSettingsRTTI.h"
 )
 
 set(BS_BANSHEECORE_SRC_RENDERER
 	"Source/BsRendererManager.cpp"
 	"Source/BsCoreRenderer.cpp"
 	"Source/BsRendererMeshData.cpp"
+	"Source/BsCamera.cpp"
+	"Source/BsPostProcessSettings.cpp"
 )
 
 set(BS_BANSHEECORE_SRC_RESOURCES

+ 1 - 1
Source/BansheeCore/Include/BsAnimationManager.h

@@ -63,7 +63,7 @@ namespace BansheeEngine
 		 * Synchronizes animation data to the animation thread, advances animation time and queues new animation evaluation
 		 * task.
 		 */
-		void postUpdate(const Vector<ConvexVolume>& cullFrustums);
+		void postUpdate();
 
 		/** 
 		 * Gets skeleton poses required by the renderer to display all the animations. This will block the animation thread

+ 261 - 261
Source/BansheeEngine/Include/BsCCamera.h → Source/BansheeCore/Include/BsCCamera.h

@@ -1,262 +1,262 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsCamera.h"
-#include "BsComponent.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup Components
-	 *  @{
-	 */
-
-	/**
-	 * @copydoc	Camera
-	 * 			
-	 * Wraps a Camera as a Component.
-	 */
-    class BS_EXPORT CCamera : public Component
-    {
-    public:
-		CCamera(const HSceneObject& parent, SPtr<RenderTarget> target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-        virtual ~CCamera();
-
-		/** @copydoc Camera::getViewport */
-		SPtr<Viewport> getViewport() const { return mInternal->getViewport(); }
-
-		/** @copydoc Camera::setHorzFOV */
-		virtual void setHorzFOV(const Radian& fovy) { mInternal->setHorzFOV(fovy); }
-
-		/** @copydoc Camera::getHorzFOV */
-		virtual const Radian& getHorzFOV() const { return mInternal->getHorzFOV(); }
-
-		/** @copydoc Camera::setNearClipDistance */
-		virtual void setNearClipDistance(float nearDist) { mInternal->setNearClipDistance(nearDist); }
-
-		/** @copydoc Camera::getNearClipDistance */
-		virtual float getNearClipDistance() const { return mInternal->getNearClipDistance(); }
-
-		/** @copydoc Camera::setFarClipDistance */
-		virtual void setFarClipDistance(float farDist) { mInternal->setFarClipDistance(farDist); }
-
-		/** @copydoc Camera::getFarClipDistance */
-		virtual float getFarClipDistance() const { return mInternal->getFarClipDistance(); }
-
-		/** @copydoc Camera::setAspectRatio */
-		virtual void setAspectRatio(float ratio) { mInternal->setAspectRatio(ratio); }
-
-		/** @copydoc Camera::getAspectRatio */
-		virtual float getAspectRatio() const { return mInternal->getAspectRatio(); }
-
-		/** @copydoc Camera::setFrustumExtents */
-		virtual void setFrustumExtents(float left, float right, float top, float bottom)
-		{
-			mInternal->setFrustumExtents(left, right, top, bottom);
-		}
-
-		/** @copydoc Camera::resetFrustumExtents */
-		virtual void resetFrustumExtents() { mInternal->resetFrustumExtents(); }
-
-		/** @copydoc Camera::getFrustumExtents */
-		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
-		{
-			mInternal->getFrustumExtents(outleft, outright, outtop, outbottom);
-		}
-
-		/** @copydoc Camera::getProjectionMatrixRS */
-		virtual const Matrix4& getProjectionMatrixRS() const { return mInternal->getProjectionMatrixRS(); }
-
-		/** @copydoc Camera::getProjectionMatrix */
-		virtual const Matrix4& getProjectionMatrix() const { return mInternal->getProjectionMatrix(); }
-
-		/** @copydoc Camera::getViewMatrix */
-		virtual const Matrix4& getViewMatrix() const { updateView(); return mInternal->getViewMatrix(); }
-
-		/** @copydoc Camera::setCustomViewMatrix */
-		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY)
-		{
-			mInternal->setCustomViewMatrix(enable, viewMatrix);
-		}
-
-		/** @copydoc Camera::isCustomViewMatrixEnabled */
-		virtual bool isCustomViewMatrixEnabled() const { return mInternal->isCustomViewMatrixEnabled(); }
-		
-		/** @copydoc Camera::setCustomProjectionMatrix */
-		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY)
-		{
-			mInternal->setCustomProjectionMatrix(enable, projectionMatrix);
-		}
-
-		/** @copydoc Camera::isCustomProjectionMatrixEnabled */
-		virtual bool isCustomProjectionMatrixEnabled() const { return mInternal->isCustomProjectionMatrixEnabled(); }
-
-		/** @copydoc Camera::getFrustum */
-		virtual const ConvexVolume& getFrustum() const { return mInternal->getFrustum(); }
-
-		/** @copydoc Camera::getWorldFrustum */
-        virtual ConvexVolume getWorldFrustum() const;
-
-		/** @copydoc Camera::getBoundingBox */
-		const AABox& getBoundingBox() const { return mInternal->getBoundingBox(); }
-
-		/** @copydoc Camera::setProjectionType */
-		virtual void setProjectionType(ProjectionType pt) { mInternal->setProjectionType(pt); }
-
-		/** @copydoc Camera::getProjectionType */
-		virtual ProjectionType getProjectionType() const { return mInternal->getProjectionType(); }
-
-		/** @copydoc Camera::setOrthoWindow */
-		virtual void setOrthoWindow(float w, float h) { mInternal->setOrthoWindow(w, h); }
-
-		/** @copydoc Camera::setOrthoWindowHeight */
-		virtual void setOrthoWindowHeight(float h) { mInternal->setOrthoWindowHeight(h); }
-
-		/** @copydoc Camera::setOrthoWindowWidth */
-		virtual void setOrthoWindowWidth(float w) { mInternal->setOrthoWindowWidth(w); }
-
-		/** @copydoc Camera::getOrthoWindowHeight */
-		virtual float getOrthoWindowHeight() const { return mInternal->getOrthoWindowHeight(); }
-
-		/** @copydoc Camera::getOrthoWindowWidth */
-		virtual float getOrthoWindowWidth() const { return mInternal->getOrthoWindowWidth(); }
-
-		/** @copydoc Camera::getPriority */
-		INT32 getPriority() const { return mInternal->getPriority(); }
-
-		/** @copydoc Camera::setPriority */
-		void setPriority(INT32 priority) { mInternal->setPriority(priority); }
-
-		/** @copydoc Camera::getLayers */
-		UINT64 getLayers() const { return mInternal->getLayers(); }
-
-		/** @copydoc Camera::setLayers */
-		void setLayers(UINT64 layers) { mInternal->setLayers(layers); }
-
-		/** Returns number of samples if the camera uses multiple samples per pixel. */
-		UINT32 getMSAACount() const { return mInternal->getMSAACount(); }
-
-		/**
-		* Enables or disables multi-sampled anti-aliasing. Set to zero or one to disable, or to the required number of
-		* samples to enable.
-		*/
-		void setMSAACount(UINT32 count) { mInternal->setMSAACount(count); }
-
-		/** Returns settings that are used for controling post-process operations like tonemapping. */
-		const PostProcessSettings& getPostProcessSettings() const { return mInternal->getPostProcessSettings(); }
-
-		/** Sets settings that are used for controling post-process operations like tonemapping. */
-		void setPostProcessSettings(const PostProcessSettings& settings) { mInternal->setPostProcessSettings(settings); }
-
-		/** @copydoc Camera::getFlags */
-		CameraFlags getFlags() const { return mInternal->getFlags(); }
-
-		/** @copydoc Camera::setFlag */
-		void setFlag(const CameraFlag& flag, bool enable) { mInternal->setFlag(flag, enable); }
-
-		/** @copydoc Camera::worldToScreenPoint */
-		Vector2I worldToScreenPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToScreenPoint(worldPoint); }
-
-		/** @copydoc Camera::worldToNdcPoint */
-		Vector2 worldToNdcPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToNdcPoint(worldPoint); }
-
-		/** @copydoc Camera::worldToViewPoint */
-		Vector3 worldToViewPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToViewPoint(worldPoint); }
-
-		/** @copydoc Camera::screenToWorldPoint */
-		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const { updateView(); return mInternal->screenToWorldPoint(screenPoint, depth); }
-
-		/** @copydoc Camera::screenToViewPoint */
-		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const { return mInternal->screenToViewPoint(screenPoint, depth); }
-
-		/** @copydoc Camera::screenToNdcPoint */
-		Vector2 screenToNdcPoint(const Vector2I& screenPoint) const { return mInternal->screenToNdcPoint(screenPoint); }
-
-		/** @copydoc Camera::viewToWorldPoint */
-		Vector3 viewToWorldPoint(const Vector3& viewPoint) const { updateView(); return mInternal->viewToWorldPoint(viewPoint); }
-
-		/** @copydoc Camera::viewToScreenPoint */
-		Vector2I viewToScreenPoint(const Vector3& viewPoint) const { return mInternal->viewToScreenPoint(viewPoint); }
-
-		/** @copydoc Camera::viewToNdcPoint */
-		Vector2 viewToNdcPoint(const Vector3& viewPoint) const { return mInternal->viewToNdcPoint(viewPoint); }
-
-		/** @copydoc Camera::ndcToWorldPoint */
-		Vector3 ndcToWorldPoint(const Vector2& ndcPoint, float depth = 0.5f) const { updateView(); return mInternal->ndcToWorldPoint(ndcPoint, depth); }
-
-		/** @copydoc Camera::ndcToViewPoint */
-		Vector3 ndcToViewPoint(const Vector2& ndcPoint, float depth = 0.5f) const { return mInternal->ndcToViewPoint(ndcPoint, depth); }
-
-		/** @copydoc Camera::ndcToScreenPoint */
-		Vector2I ndcToScreenPoint(const Vector2& ndcPoint) const { return mInternal->ndcToScreenPoint(ndcPoint); }
-
-		/** @copydoc Camera::screenPointToRay */
-		Ray screenPointToRay(const Vector2I& screenPoint) const { updateView(); return mInternal->screenPointToRay(screenPoint); }
-
-		/** @copydoc Camera::projectPoint */
-		Vector3 projectPoint(const Vector3& point) const { return mInternal->projectPoint(point); }
-
-		/** @copydoc Camera::unprojectPoint */
-		Vector3 unprojectPoint(const Vector3& point) const { return mInternal->unprojectPoint(point); }
-
-		/** @copydoc Camera::isMain */	
-		bool isMain() const { return mInternal->isMain(); }
-
-		/** @copydoc Camera::setMain */	
-		void setMain(bool main);
-
-		/** @name Internal 
-		 *  @{
-		 */
-
-		/** Returns the internal camera that is used for majority of operations by this component. */
-		SPtr<Camera> _getCamera() const { updateView(); return mInternal; }
-
-		/** @} */
-
-    protected:
-		/** Checks if the world transform of the camera changed, and if needed updates the view matrix. */
-		void updateView() const;
-
-		mutable SPtr<Camera> mInternal;
-
-		// Only valid during construction
-		SPtr<RenderTarget> mTarget;
-		float mLeft;
-		float mTop;
-		float mWidth;
-		float mHeight;
-
-		/************************************************************************/
-		/* 						COMPONENT OVERRIDES                      		*/
-		/************************************************************************/
-	protected:
-		friend class SceneObject;
-
-		/** @copydoc Component::onInitialized */
-		void onInitialized() override;
-
-		/** @copydoc Component::onDestroyed */
-		void onDestroyed() override;
-
-	public:
-		/** @copydoc Component::update */
-		virtual void update() override;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class CCameraRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		virtual RTTITypeBase* getRTTI() const override;
-
-	protected:
-		CCamera() {} // Serialization only
-     };
-
-	 /** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsCamera.h"
+#include "BsComponent.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup Components
+	 *  @{
+	 */
+
+	/**
+	 * @copydoc	Camera
+	 * 			
+	 * Wraps a Camera as a Component.
+	 */
+    class BS_CORE_EXPORT CCamera : public Component
+    {
+    public:
+		CCamera(const HSceneObject& parent, SPtr<RenderTarget> target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+        virtual ~CCamera();
+
+		/** @copydoc Camera::getViewport */
+		SPtr<Viewport> getViewport() const { return mInternal->getViewport(); }
+
+		/** @copydoc Camera::setHorzFOV */
+		virtual void setHorzFOV(const Radian& fovy) { mInternal->setHorzFOV(fovy); }
+
+		/** @copydoc Camera::getHorzFOV */
+		virtual const Radian& getHorzFOV() const { return mInternal->getHorzFOV(); }
+
+		/** @copydoc Camera::setNearClipDistance */
+		virtual void setNearClipDistance(float nearDist) { mInternal->setNearClipDistance(nearDist); }
+
+		/** @copydoc Camera::getNearClipDistance */
+		virtual float getNearClipDistance() const { return mInternal->getNearClipDistance(); }
+
+		/** @copydoc Camera::setFarClipDistance */
+		virtual void setFarClipDistance(float farDist) { mInternal->setFarClipDistance(farDist); }
+
+		/** @copydoc Camera::getFarClipDistance */
+		virtual float getFarClipDistance() const { return mInternal->getFarClipDistance(); }
+
+		/** @copydoc Camera::setAspectRatio */
+		virtual void setAspectRatio(float ratio) { mInternal->setAspectRatio(ratio); }
+
+		/** @copydoc Camera::getAspectRatio */
+		virtual float getAspectRatio() const { return mInternal->getAspectRatio(); }
+
+		/** @copydoc Camera::setFrustumExtents */
+		virtual void setFrustumExtents(float left, float right, float top, float bottom)
+		{
+			mInternal->setFrustumExtents(left, right, top, bottom);
+		}
+
+		/** @copydoc Camera::resetFrustumExtents */
+		virtual void resetFrustumExtents() { mInternal->resetFrustumExtents(); }
+
+		/** @copydoc Camera::getFrustumExtents */
+		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const
+		{
+			mInternal->getFrustumExtents(outleft, outright, outtop, outbottom);
+		}
+
+		/** @copydoc Camera::getProjectionMatrixRS */
+		virtual const Matrix4& getProjectionMatrixRS() const { return mInternal->getProjectionMatrixRS(); }
+
+		/** @copydoc Camera::getProjectionMatrix */
+		virtual const Matrix4& getProjectionMatrix() const { return mInternal->getProjectionMatrix(); }
+
+		/** @copydoc Camera::getViewMatrix */
+		virtual const Matrix4& getViewMatrix() const { updateView(); return mInternal->getViewMatrix(); }
+
+		/** @copydoc Camera::setCustomViewMatrix */
+		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY)
+		{
+			mInternal->setCustomViewMatrix(enable, viewMatrix);
+		}
+
+		/** @copydoc Camera::isCustomViewMatrixEnabled */
+		virtual bool isCustomViewMatrixEnabled() const { return mInternal->isCustomViewMatrixEnabled(); }
+		
+		/** @copydoc Camera::setCustomProjectionMatrix */
+		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY)
+		{
+			mInternal->setCustomProjectionMatrix(enable, projectionMatrix);
+		}
+
+		/** @copydoc Camera::isCustomProjectionMatrixEnabled */
+		virtual bool isCustomProjectionMatrixEnabled() const { return mInternal->isCustomProjectionMatrixEnabled(); }
+
+		/** @copydoc Camera::getFrustum */
+		virtual const ConvexVolume& getFrustum() const { return mInternal->getFrustum(); }
+
+		/** @copydoc Camera::getWorldFrustum */
+        virtual ConvexVolume getWorldFrustum() const;
+
+		/** @copydoc Camera::getBoundingBox */
+		const AABox& getBoundingBox() const { return mInternal->getBoundingBox(); }
+
+		/** @copydoc Camera::setProjectionType */
+		virtual void setProjectionType(ProjectionType pt) { mInternal->setProjectionType(pt); }
+
+		/** @copydoc Camera::getProjectionType */
+		virtual ProjectionType getProjectionType() const { return mInternal->getProjectionType(); }
+
+		/** @copydoc Camera::setOrthoWindow */
+		virtual void setOrthoWindow(float w, float h) { mInternal->setOrthoWindow(w, h); }
+
+		/** @copydoc Camera::setOrthoWindowHeight */
+		virtual void setOrthoWindowHeight(float h) { mInternal->setOrthoWindowHeight(h); }
+
+		/** @copydoc Camera::setOrthoWindowWidth */
+		virtual void setOrthoWindowWidth(float w) { mInternal->setOrthoWindowWidth(w); }
+
+		/** @copydoc Camera::getOrthoWindowHeight */
+		virtual float getOrthoWindowHeight() const { return mInternal->getOrthoWindowHeight(); }
+
+		/** @copydoc Camera::getOrthoWindowWidth */
+		virtual float getOrthoWindowWidth() const { return mInternal->getOrthoWindowWidth(); }
+
+		/** @copydoc Camera::getPriority */
+		INT32 getPriority() const { return mInternal->getPriority(); }
+
+		/** @copydoc Camera::setPriority */
+		void setPriority(INT32 priority) { mInternal->setPriority(priority); }
+
+		/** @copydoc Camera::getLayers */
+		UINT64 getLayers() const { return mInternal->getLayers(); }
+
+		/** @copydoc Camera::setLayers */
+		void setLayers(UINT64 layers) { mInternal->setLayers(layers); }
+
+		/** Returns number of samples if the camera uses multiple samples per pixel. */
+		UINT32 getMSAACount() const { return mInternal->getMSAACount(); }
+
+		/**
+		* Enables or disables multi-sampled anti-aliasing. Set to zero or one to disable, or to the required number of
+		* samples to enable.
+		*/
+		void setMSAACount(UINT32 count) { mInternal->setMSAACount(count); }
+
+		/** Returns settings that are used for controling post-process operations like tonemapping. */
+		const SPtr<PostProcessSettings>& getPostProcessSettings() const { return mInternal->getPostProcessSettings(); }
+
+		/** Sets settings that are used for controling post-process operations like tonemapping. */
+		void setPostProcessSettings(const SPtr<PostProcessSettings>& settings) { mInternal->setPostProcessSettings(settings); }
+
+		/** @copydoc Camera::getFlags */
+		CameraFlags getFlags() const { return mInternal->getFlags(); }
+
+		/** @copydoc Camera::setFlag */
+		void setFlag(const CameraFlag& flag, bool enable) { mInternal->setFlag(flag, enable); }
+
+		/** @copydoc Camera::worldToScreenPoint */
+		Vector2I worldToScreenPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToScreenPoint(worldPoint); }
+
+		/** @copydoc Camera::worldToNdcPoint */
+		Vector2 worldToNdcPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToNdcPoint(worldPoint); }
+
+		/** @copydoc Camera::worldToViewPoint */
+		Vector3 worldToViewPoint(const Vector3& worldPoint) const { updateView(); return mInternal->worldToViewPoint(worldPoint); }
+
+		/** @copydoc Camera::screenToWorldPoint */
+		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const { updateView(); return mInternal->screenToWorldPoint(screenPoint, depth); }
+
+		/** @copydoc Camera::screenToViewPoint */
+		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const { return mInternal->screenToViewPoint(screenPoint, depth); }
+
+		/** @copydoc Camera::screenToNdcPoint */
+		Vector2 screenToNdcPoint(const Vector2I& screenPoint) const { return mInternal->screenToNdcPoint(screenPoint); }
+
+		/** @copydoc Camera::viewToWorldPoint */
+		Vector3 viewToWorldPoint(const Vector3& viewPoint) const { updateView(); return mInternal->viewToWorldPoint(viewPoint); }
+
+		/** @copydoc Camera::viewToScreenPoint */
+		Vector2I viewToScreenPoint(const Vector3& viewPoint) const { return mInternal->viewToScreenPoint(viewPoint); }
+
+		/** @copydoc Camera::viewToNdcPoint */
+		Vector2 viewToNdcPoint(const Vector3& viewPoint) const { return mInternal->viewToNdcPoint(viewPoint); }
+
+		/** @copydoc Camera::ndcToWorldPoint */
+		Vector3 ndcToWorldPoint(const Vector2& ndcPoint, float depth = 0.5f) const { updateView(); return mInternal->ndcToWorldPoint(ndcPoint, depth); }
+
+		/** @copydoc Camera::ndcToViewPoint */
+		Vector3 ndcToViewPoint(const Vector2& ndcPoint, float depth = 0.5f) const { return mInternal->ndcToViewPoint(ndcPoint, depth); }
+
+		/** @copydoc Camera::ndcToScreenPoint */
+		Vector2I ndcToScreenPoint(const Vector2& ndcPoint) const { return mInternal->ndcToScreenPoint(ndcPoint); }
+
+		/** @copydoc Camera::screenPointToRay */
+		Ray screenPointToRay(const Vector2I& screenPoint) const { updateView(); return mInternal->screenPointToRay(screenPoint); }
+
+		/** @copydoc Camera::projectPoint */
+		Vector3 projectPoint(const Vector3& point) const { return mInternal->projectPoint(point); }
+
+		/** @copydoc Camera::unprojectPoint */
+		Vector3 unprojectPoint(const Vector3& point) const { return mInternal->unprojectPoint(point); }
+
+		/** @copydoc Camera::isMain */	
+		bool isMain() const { return mInternal->isMain(); }
+
+		/** @copydoc Camera::setMain */	
+		void setMain(bool main);
+
+		/** @name Internal 
+		 *  @{
+		 */
+
+		/** Returns the internal camera that is used for majority of operations by this component. */
+		SPtr<Camera> _getCamera() const { updateView(); return mInternal; }
+
+		/** @} */
+
+    protected:
+		/** Checks if the world transform of the camera changed, and if needed updates the view matrix. */
+		void updateView() const;
+
+		mutable SPtr<Camera> mInternal;
+
+		// Only valid during construction
+		SPtr<RenderTarget> mTarget;
+		float mLeft;
+		float mTop;
+		float mWidth;
+		float mHeight;
+
+		/************************************************************************/
+		/* 						COMPONENT OVERRIDES                      		*/
+		/************************************************************************/
+	protected:
+		friend class SceneObject;
+
+		/** @copydoc Component::onInitialized */
+		void onInitialized() override;
+
+		/** @copydoc Component::onDestroyed */
+		void onDestroyed() override;
+
+	public:
+		/** @copydoc Component::update */
+		void update() override;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CCameraRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
+
+	protected:
+		CCamera() {} // Serialization only
+     };
+
+	 /** @} */
 }

+ 47 - 47
Source/BansheeEngine/Include/BsCCameraRTTI.h → Source/BansheeCore/Include/BsCCameraRTTI.h

@@ -1,48 +1,48 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsCCamera.h"
-#include "BsGameObjectRTTI.h"
-
-namespace BansheeEngine
-{
-	/** @cond RTTI */
-	/** @addtogroup RTTI-Impl-Engine
-	 *  @{
-	 */
-
-	class BS_EXPORT CCameraRTTI : public RTTIType<CCamera, Component, CCameraRTTI>
-	{
-	private:
-		SPtr<Camera> getInternal(CCamera* obj) { return obj->mInternal; }
-		void setInternal(CCamera* obj, SPtr<Camera> val) { obj->mInternal = val; }
-
-	public:
-		CCameraRTTI()
-		{
-			addReflectablePtrField("mInternal", 0, &CCameraRTTI::getInternal, &CCameraRTTI::setInternal);
-		}
-
-		const String& getRTTIName() override
-		{
-			static String name = "CCamera";
-			return name;
-		}
-
-		UINT32 getRTTIId() override
-		{
-			return TID_CCamera;
-		}
-
-		SPtr<IReflectable> newRTTIObject() override
-		{
-			return GameObjectRTTI::createGameObject<CCamera>();
-		}
-	};
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsCCamera.h"
+#include "BsGameObjectRTTI.h"
+
+namespace BansheeEngine
+{
+	/** @cond RTTI */
+	/** @addtogroup RTTI-Impl-Engine
+	 *  @{
+	 */
+
+	class BS_CORE_EXPORT CCameraRTTI : public RTTIType<CCamera, Component, CCameraRTTI>
+	{
+	private:
+		SPtr<Camera> getInternal(CCamera* obj) { return obj->mInternal; }
+		void setInternal(CCamera* obj, SPtr<Camera> val) { obj->mInternal = val; }
+
+	public:
+		CCameraRTTI()
+		{
+			addReflectablePtrField("mInternal", 0, &CCameraRTTI::getInternal, &CCameraRTTI::setInternal);
+		}
+
+		const String& getRTTIName() override
+		{
+			static String name = "CCamera";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_CCamera;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return GameObjectRTTI::createGameObject<CCamera>();
+		}
+	};
+
+	/** @} */
+	/** @endcond */
 }

+ 606 - 606
Source/BansheeEngine/Include/BsCamera.h → Source/BansheeCore/Include/BsCamera.h

@@ -1,607 +1,607 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsIReflectable.h"
-#include "BsMatrix4.h"
-#include "BsVector3.h"
-#include "BsVector2.h"
-#include "BsVector2I.h"
-#include "BsAABox.h"
-#include "BsQuaternion.h"
-#include "BsRay.h"
-#include "BsCoreObject.h"
-#include "BsConvexVolume.h"
-#include "BsPostProcessSettings.h"
-
-namespace BansheeEngine 
-{
-	/** @addtogroup Renderer-Engine-Internal
-	 *  @{
-	 */
-
-	/**	Signals which portion of a Camera is dirty. */
-	enum class CameraDirtyFlag
-	{
-		Transform = 1<<0,
-		Everything = 1<<1,
-		PostProcess = 1<<2
-	};
-
-	/**	Projection type to use by the camera. */
-    enum ProjectionType
-    {
-		PT_ORTHOGRAPHIC, /**< Projection type where object size remains constant and parallel lines remain parallel. */
-		PT_PERSPECTIVE /**< Projection type that emulates human vision. Objects farther away appear smaller. */
-    };
-
-	/**	Clip planes that form the camera frustum (visible area). */
-    enum FrustumPlane
-    {
-        FRUSTUM_PLANE_NEAR = 0,
-        FRUSTUM_PLANE_FAR = 1,
-        FRUSTUM_PLANE_LEFT = 2,
-        FRUSTUM_PLANE_RIGHT = 3,
-        FRUSTUM_PLANE_TOP = 4,
-        FRUSTUM_PLANE_BOTTOM = 5
-    };
-
-	/**	Flags that describe a camera. */
-	enum class CameraFlag
-	{
-		/** 
-		 * This flag is a signal to the renderer that his camera will only render overlays and doesn't require depth   
-		 * buffer or multi-sampled render targets. This can improve performance and memory usage. 
-		 */
-		Overlay = 1,
-		/** 
-		 * High dynamic range allows light intensity to be more correctly recorded when rendering by allowing for a larger
-		 * range of values. The stored light is then converted into visible color range using exposure and a tone mapping 
-		 * operator.
-		 */
-		HDR = 2
-	};
-
-	typedef Flags<CameraFlag> CameraFlags;
-	BS_FLAGS_OPERATORS(CameraFlag);
-
-	/** @} */
-	/** @addtogroup Implementation
-	 *  @{
-	 */
-
-	/**
-	 * Camera determines how is world geometry projected onto a 2D surface. You may position and orient it in space, set
-	 * options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
-	 *
-	 * This class contains funcionality common to both core and non-core versions of the camera.
-	 */
-	class BS_EXPORT CameraBase
-    {
-    public:
-		virtual ~CameraBase() { }
-
-		/**
-		 * Sets the camera horizontal field of view. This determines how wide the camera viewing angle is along the
-		 * horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
-		 */
-        virtual void setHorzFOV(const Radian& fovy);
-
-		/**	Retrieves the camera horizontal field of view. */
-        virtual const Radian& getHorzFOV() const;
-
-		/**
-		 * Sets the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane will
-		 * not be rendered. Decreasing this value decreases depth buffer precision.
-		 */
-        virtual void setNearClipDistance(float nearDist);
-
-		/**
-		 * Retrieves the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane
-		 * will not be rendered. Decreasing this value decreases depth buffer precision.
-		 */
-        virtual float getNearClipDistance() const;
-
-		/**
-		 * Sets the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane will
-		 * not be rendered. Increasing this value decreases depth buffer precision.
-		 */
-        virtual void setFarClipDistance(float farDist);
-
-		/**
-		 * Retrieves the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane
-		 * will not be rendered. Increasing this value decreases depth buffer precision.
-		 */
-        virtual float getFarClipDistance() const;
-
-		/**	Sets the current viewport aspect ratio (width / height). */
-        virtual void setAspectRatio(float ratio);
-
-		/**	Returns current viewport aspect ratio (width / height). */
-        virtual float getAspectRatio() const;
-
-		/**	Sets camera world space position. */
-		virtual void setPosition(const Vector3& position);
-
-		/**	Retrieves camera world space position. */
-		virtual Vector3 getPosition() const { return mPosition; }
-
-		/**	Sets should the camera be rendered to or not. */
-		void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
-		
-		/**	Gets whether the camera be rendered to or not. */
-		bool getIsActive() const { return mIsActive; }
-
-		/**
-		 * Gets the Z (forward) axis of the object, in world space.
-		 *
-		 * @return	Forward axis of the object.
-		 */
-		Vector3 getForward() const { return getRotation().rotate(-Vector3::UNIT_Z); }
-
-		/**	Sets camera world space rotation. */
-		virtual void setRotation(const Quaternion& rotation);
-
-		/**	Retrieves camera world space rotation. */
-		virtual Quaternion getRotation() const { return mRotation; }
-
-		/** Manually set the extents of the frustum that will be used when calculating the projection matrix. This will
-		 * prevents extents for being automatically calculated from aspect and near plane so it is up to the caller to keep
-		 * these values accurate.
-		 *
-		 * @param[in] left		The position where the left clip plane intersect the near clip plane, in view space.
-		 * @param[in] right		The position where the right clip plane intersect the near clip plane, in view space.
-		 * @param[in] top		The position where the top clip plane intersect the near clip plane, in view space.
-		 * @param[in] bottom	The position where the bottom clip plane intersect the near clip plane, in view space.
-		*/
-		virtual void setFrustumExtents(float left, float right, float top, float bottom);
-
-		/** 
-		 * Resets frustum extents so they are automatically derived from other values. This is only relevant if you have
-		 * previously set custom extents.
-		 */
-		virtual void resetFrustumExtents(); 
-
-		/** Returns the extents of the frustum in view space at the near plane. */
-		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
-
-		/** 
-		 * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. The layout
-		 * of this matrix depends on currently used render system.
-		 *
-		 * @note	
-		 * You should use this matrix when sending the matrix to the render system to make sure everything works 
-		 * consistently when other render systems are used.
-		 */
-        virtual const Matrix4& getProjectionMatrixRS() const;
-
-		/** 
-		 * Returns the inverse of the render-system specific projection matrix.
-		 *
-		 * @see		getProjectionMatrixRS
-		 */
-        virtual const Matrix4& getProjectionMatrixRSInv() const;
-
-		/** 
-		 * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. Returned
-		 * matrix is standard following right-hand rules and depth range of [-1, 1]. 
-		 *
-		 * @note	
-		 * Different render systems will expect different projection matrix layouts, in which case use 
-		 * getProjectionMatrixRS().
-         */
-        virtual const Matrix4& getProjectionMatrix() const;
-
-		/** 
-		 * Returns the inverse of the projection matrix.
-		 *
-		 * @see		getProjectionMatrix
-		 */
-        virtual const Matrix4& getProjectionMatrixInv() const;
-
-		/** Gets the camera view matrix. Used for positioning/orienting the camera. */
-        virtual const Matrix4& getViewMatrix() const;
-
-		/** 
-		 * Returns the inverse of the view matrix.
-		 *
-		 * @see		getViewMatrix
-		 */
-		virtual const Matrix4& getViewMatrixInv() const;
-
-		/** 
-		 * Sets whether the camera should use the custom view matrix. When this is enabled camera will no longer calculate
-		 * its view matrix based on position/orientation and caller will be resonsible to keep the view matrix up to date.
-         */
-		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
-
-		/** Returns true if a custom view matrix is used. */
-		virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
-		
-		/** 
-		 * Sets whether the camera should use the custom projection matrix. When this is enabled camera will no longer
-		 * calculate its projection matrix based on field of view, aspect and other parameters and caller will be resonsible
-		 * to keep the projection matrix up to date.
-         */
-		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
-
-		/** Returns true if a custom projection matrix is used. */
-		virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
-
-		/** Returns a convex volume representing the visible area of the camera, in local space. */
-        virtual const ConvexVolume& getFrustum() const;
-
-		/** Returns a convex volume representing the visible area of the camera, in world space. */
-        virtual ConvexVolume getWorldFrustum() const;
-
-		/**	Returns the bounding of the frustum. */
-        const AABox& getBoundingBox() const;
-
-		/**
-		 * Sets the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a 
-		 * 2D plane.
-		 */
-        virtual void setProjectionType(ProjectionType pt);
-
-		/**
-		 * Returns the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
-		 * 2D plane.
-		 */
-        virtual ProjectionType getProjectionType() const;
-
-		/**
-		 * Sets the orthographic window height, for use with orthographic rendering only. 
-		 *
-		 * @param[in]	w	Width of the window in world units.
-		 * @param[in]	h	Height of the window in world units.
-		 *
-		 * @note	
-		 * Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight() or setOrthoWindowWidth() alone
-		 * if you wish to preserve the aspect ratio but just fit one or other dimension to a particular size.
-		 */
-		virtual void setOrthoWindow(float w, float h);
-
-		/**
-		 * Sets the orthographic window height, for use with orthographic rendering only. 
-		 *
-		 * @param[in]	h	Height of the window in world units.
-		 *
-		 * @note	The width of the window will be calculated from the aspect ratio. 
-		 */
-		virtual void setOrthoWindowHeight(float h);
-
-		/**
-		 * Sets the orthographic window width, for use with orthographic rendering only. 
-		 *
-		 * @param[in]	w	Width of the window in world units.
-		 *
-		 * @note	The height of the window will be calculated from the aspect ratio. 
-		 */
-		virtual void setOrthoWindowWidth(float w);
-
-		/** Gets the orthographic window width in world units, for use with orthographic rendering only. */
-		virtual float getOrthoWindowHeight() const;
-
-		/**
-		 * Gets the orthographic window width in world units, for use with orthographic rendering only. 
-		 *
-		 * @note	This is calculated from the orthographic height and the aspect ratio.
-		 */
-		virtual float getOrthoWindowWidth() const;
-
-		/**
-		 * Gets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
-		 * to the same render target. 
-		 */
-		INT32 getPriority() const { return mPriority; }
-
-		/**
-		 * Sets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
-		 * to the same render target. 
-		 *
-		 * @param[in]	priority	The priority. Higher value means the camera will be rendered sooner.
-		 */
-		void setPriority(INT32 priority) { mPriority = priority; _markCoreDirty(); }
-
-		/**	Retrieves layer bitfield that is used when determining which object should the camera render. */
-		UINT64 getLayers() const { return mLayers; }
-
-		/**	Sets layer bitfield that is used when determining which object should the camera render. */
-		void setLayers(UINT64 layers) { mLayers = layers; _markCoreDirty(); }
-
-		/** Returns number of samples if the camera uses multiple samples per pixel. */
-		UINT32 getMSAACount() const { return mMSAA; }
-
-		/** 
-		 * Enables or disables multi-sampled anti-aliasing. Set to zero or one to disable, or to the required number of
-		 * samples to enable.
-		 */
-		void setMSAACount(UINT32 count) { mMSAA = count; _markCoreDirty(); }
-
-		/** Returns settings that are used for controling post-process operations like tonemapping. */
-		const PostProcessSettings& getPostProcessSettings() const { return mPPSettings; }
-
-		/** Sets settings that are used for controling post-process operations like tonemapping. */
-		void setPostProcessSettings(const PostProcessSettings& settings) { mPPSettings = settings; _markCoreDirty(CameraDirtyFlag::PostProcess); }
-
-		/**	Retrieves flags that define the camera. */
-		CameraFlags getFlags() const { return mCameraFlags; }
-
-		/**	Enables or disables flags that define the camera's behaviour. */
-		void setFlag(const CameraFlag& flag, bool enable);
-
-		/**
-		 * Converts a point in world space to screen coordinates (in pixels corresponding to the render target attached to
-		 * the camera).
-		 */
-		Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
-
-		/**	Converts a point in world space to normalized device coordinates (in [-1, 1] range). */
-		Vector2 worldToNdcPoint(const Vector3& worldPoint) const;
-
-		/** Converts a point in world space to point relative to camera's coordinate system (view space). */
-		Vector3 worldToViewPoint(const Vector3& worldPoint) const;
-
-		/**
-		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point in
-		 * world space.
-		 *
-		 * @param[in]	screenPoint	Point to transform.
-		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
-		 *							origin to the point on the near plane.
-		 */
-		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
-
-		/**
-		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point
-		 * relative to camera's coordinate system (view space).
-		 *
-		 * @param[in]	screenPoint	Point to transform.
-		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
-		 *							origin to the point on the near plane.
-		 */
-		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
-
-		/**
-		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to normalized 
-		 * device coordinates (in [-1, 1] range).
-		 */
-		Vector2 screenToNdcPoint(const Vector2I& screenPoint) const;
-
-		/** Converts a point relative to camera's coordinate system (view space) into a point in world space. */
-		Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
-
-		/**
-		 * Converts a point relative to camera's coordinate system (view space) into a point in screen space (pixels 
-		 * corresponding to render target attached to the camera).
-		 */
-		Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
-
-		/**
-		 * Converts a point relative to camera's coordinate system (view space) into normalized device coordinates 
-		 * (in [-1, 1] range).
-		 */
-		Vector2 viewToNdcPoint(const Vector3& viewPoint) const;
-
-		/**
-		 * Converts a point in normalized device coordinates ([-1, 1] range) to a point in world space.
-		 *
-		 * @param[in]	ndcPoint	Point to transform.
-		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
-		 *							origin to the point on the near plane.
-		 */
-		Vector3 ndcToWorldPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
-
-		/**
-		 * Converts a point in normalized device coordinates ([-1, 1] range) to a point relative to camera's coordinate system
-		 * (view space).
-		 *
-		 * @param[in]	ndcPoint	Point to transform.
-		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
-		 *							origin to the point on the near plane.
-		 */
-		Vector3 ndcToViewPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
-
-		/**
-		 * Converts a point in normalized device coordinates ([-1, 1] range) to a point in screen space (pixels corresponding
-		 * to render target attached to the camera).
-		 */
-		Vector2I ndcToScreenPoint(const Vector2& ndcPoint) const;
-
-		/**
-		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a ray in world
-		 * space originating at the selected point on the camera near plane.
-		 */
-		Ray screenPointToRay(const Vector2I& screenPoint) const;
-
-		/**	Projects a point from view to normalized device space. */
-		Vector3 projectPoint(const Vector3& point) const;
-
-		/**	Un-projects a point in normalized device space to view space. */
-		Vector3 unprojectPoint(const Vector3& point) const;
-
-        static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
-
-	protected:
-		CameraBase();
-
-		/**	Calculate projection parameters that are used when constructing the projection matrix. */
-		virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
-
-		/**	Recalculate frustum if dirty. */
-		virtual void updateFrustum() const;
-
-		/**	Recalculate frustum planes if dirty. */
-		virtual void updateFrustumPlanes() const;
-
-		/**
-		 * Update view matrix from parent position/orientation.
-		 *
-		 * @note	Does nothing when custom view matrix is set.
-		 */
-		virtual void updateView() const;
-
-		/**	Checks if the frustum requires updating. */
-		virtual bool isFrustumOutOfDate() const;
-
-		/**	Notify camera that the frustum requires to be updated. */
-		virtual void invalidateFrustum() const;
-
-		/**	Returns a rectangle that defines the viewport position and size, in pixels. */
-		virtual Rect2I getViewportRect() const = 0;
-
-		/** 
-		 * Marks the simulation thread object as dirty and notifies the system its data should be synced with its core 
-		 * thread counterpart. 
-		 */
-		virtual void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) { }
-
-    protected:
-		UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
-		CameraFlags mCameraFlags; /**< Flags that further determine type of camera. */
-
-		Vector3 mPosition; /**< World space position. */
-		Quaternion mRotation; /**< World space rotation. */
-		bool mIsActive; /**< Is camera being rendered to. */
-
-		ProjectionType mProjType; /**< Type of camera projection. */
-		Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
-		float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
-		float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
-		float mAspect; /**< Width/height viewport ratio. */
-		float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
-		INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
-
-		bool mCustomViewMatrix; /**< Is custom view matrix set. */
-		bool mCustomProjMatrix; /**< Is custom projection matrix set. */
-		UINT8 mMSAA; /**< Number of samples to render the scene with. */
-
-		PostProcessSettings mPPSettings; /**< Settings used to control post-process operations. */
-
-		bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
-
-		mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
-		mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
-		mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
-		mutable Matrix4 mProjMatrixRSInv;
-		mutable Matrix4 mProjMatrixInv;
-		mutable Matrix4 mViewMatrixInv;
-
-		mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
-		mutable bool mRecalcFrustum : 1; /**< Should frustum be recalculated. */
-		mutable bool mRecalcFrustumPlanes : 1; /**< Should frustum planes be recalculated. */
-		mutable bool mRecalcView : 1; /**< Should view matrix be recalculated. */
-		mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
-		mutable AABox mBoundingBox; /**< Frustum bounding box. */
-     };
-
-	/** @} */
-	/** @addtogroup Renderer-Engine-Internal
-	 *  @{
-	 */
-
-	/** @copydoc CameraBase */
-	class BS_EXPORT CameraCore : public CoreObjectCore, public CameraBase
-	{
-	public:
-		~CameraCore();
-
-		/**	Returns the viewport used by the camera. */	
-		SPtr<ViewportCore> getViewport() const { return mViewport; }
-
-	protected:
-		friend class Camera;
-
-		CameraCore(SPtr<RenderTargetCore> target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		CameraCore(const SPtr<ViewportCore>& viewport);
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/** @copydoc CameraBase */
-		Rect2I getViewportRect() const override;
-
-		/** @copydoc CoreObject::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-
-		SPtr<ViewportCore> mViewport;
-	};
-
-	/** @copydoc CameraBase */
-	class BS_EXPORT Camera : public IReflectable, public CoreObject, public CameraBase
-    {
-    public:
-		/**	Returns the viewport used by the camera. */	
-		SPtr<Viewport> getViewport() const { return mViewport; }
-
-		/**
-		 * Determines whether this is the main application camera. Main camera controls the final render surface that is
-		 * displayed to the user.
-		 */	
-		bool isMain() const { return mMain; }
-
-		/**
-		 * Marks or unmarks this camera as the main application camera. Main camera controls the final render surface that
-		 * is displayed to the user.
-		 */	
-		void setMain(bool main) { mMain = main; }
-
-		/** Retrieves an implementation of a camera handler usable only from the core thread. */
-		SPtr<CameraCore> getCore() const;
-
-		/**	Creates a new camera that renders to the specified portion of the provided render target. */
-		static SPtr<Camera> create(SPtr<RenderTarget> target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		/** @name Internal
-		 *  @{
-		 */
-
-		/**	Returns the hash value that can be used to identify if the internal data needs an update. */
-		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
-
-		/**	Sets the hash value that can be used to identify if the internal data needs an update. */
-		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
-
-		/** @} */
-
-	protected:
-		Camera(SPtr<RenderTarget> target = nullptr,
-			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
-
-		/** @copydoc CameraBase */
-		Rect2I getViewportRect() const override;
-
-		/** @copydoc CoreObject::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc CameraBase::_markCoreDirty */
-		void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) override;
-
-		/** @copydoc CoreObject::syncToCore */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		/** @copydoc CoreObject::getCoreDependencies */
-		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
-
-		/**	Creates a new camera without initializing it. */
-		static SPtr<Camera> createEmpty();
-
-		SPtr<Viewport> mViewport; /**< Viewport that describes 2D rendering surface. */
-		bool mMain;
-		UINT32 mLastUpdateHash;
-
-		/************************************************************************/
-		/* 								RTTI		                     		*/
-		/************************************************************************/
-	public:
-		friend class CameraRTTI;
-		static RTTITypeBase* getRTTIStatic();
-		RTTITypeBase* getRTTI() const override;
-     };
-
-	/** @} */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+#include "BsMatrix4.h"
+#include "BsVector3.h"
+#include "BsVector2.h"
+#include "BsVector2I.h"
+#include "BsAABox.h"
+#include "BsQuaternion.h"
+#include "BsRay.h"
+#include "BsCoreObject.h"
+#include "BsConvexVolume.h"
+#include "BsPostProcessSettings.h"
+
+namespace BansheeEngine 
+{
+	/** @addtogroup Renderer-Internal
+	 *  @{
+	 */
+
+	/**	Signals which portion of a Camera is dirty. */
+	enum class CameraDirtyFlag
+	{
+		Transform = 1<<0,
+		Everything = 1<<1,
+		PostProcess = 1<<2
+	};
+
+	/**	Projection type to use by the camera. */
+    enum ProjectionType
+    {
+		PT_ORTHOGRAPHIC, /**< Projection type where object size remains constant and parallel lines remain parallel. */
+		PT_PERSPECTIVE /**< Projection type that emulates human vision. Objects farther away appear smaller. */
+    };
+
+	/**	Clip planes that form the camera frustum (visible area). */
+    enum FrustumPlane
+    {
+        FRUSTUM_PLANE_NEAR = 0,
+        FRUSTUM_PLANE_FAR = 1,
+        FRUSTUM_PLANE_LEFT = 2,
+        FRUSTUM_PLANE_RIGHT = 3,
+        FRUSTUM_PLANE_TOP = 4,
+        FRUSTUM_PLANE_BOTTOM = 5
+    };
+
+	/**	Flags that describe a camera. */
+	enum class CameraFlag
+	{
+		/** 
+		 * This flag is a signal to the renderer that his camera will only render overlays and doesn't require depth   
+		 * buffer or multi-sampled render targets. This can improve performance and memory usage. 
+		 */
+		Overlay = 1,
+		/** 
+		 * High dynamic range allows light intensity to be more correctly recorded when rendering by allowing for a larger
+		 * range of values. The stored light is then converted into visible color range using exposure and a tone mapping 
+		 * operator.
+		 */
+		HDR = 2
+	};
+
+	typedef Flags<CameraFlag> CameraFlags;
+	BS_FLAGS_OPERATORS(CameraFlag);
+
+	/** @} */
+	/** @addtogroup Implementation
+	 *  @{
+	 */
+
+	/**
+	 * Camera determines how is world geometry projected onto a 2D surface. You may position and orient it in space, set
+	 * options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
+	 *
+	 * This class contains funcionality common to both core and non-core versions of the camera.
+	 */
+	class BS_CORE_EXPORT CameraBase
+    {
+    public:
+		virtual ~CameraBase() { }
+
+		/**
+		 * Sets the camera horizontal field of view. This determines how wide the camera viewing angle is along the
+		 * horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
+		 */
+        virtual void setHorzFOV(const Radian& fovy);
+
+		/**	Retrieves the camera horizontal field of view. */
+        virtual const Radian& getHorzFOV() const;
+
+		/**
+		 * Sets the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane will
+		 * not be rendered. Decreasing this value decreases depth buffer precision.
+		 */
+        virtual void setNearClipDistance(float nearDist);
+
+		/**
+		 * Retrieves the distance from the frustum to the near clipping plane. Anything closer than the near clipping plane
+		 * will not be rendered. Decreasing this value decreases depth buffer precision.
+		 */
+        virtual float getNearClipDistance() const;
+
+		/**
+		 * Sets the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane will
+		 * not be rendered. Increasing this value decreases depth buffer precision.
+		 */
+        virtual void setFarClipDistance(float farDist);
+
+		/**
+		 * Retrieves the distance from the frustum to the far clipping plane. Anything farther than the far clipping plane
+		 * will not be rendered. Increasing this value decreases depth buffer precision.
+		 */
+        virtual float getFarClipDistance() const;
+
+		/**	Sets the current viewport aspect ratio (width / height). */
+        virtual void setAspectRatio(float ratio);
+
+		/**	Returns current viewport aspect ratio (width / height). */
+        virtual float getAspectRatio() const;
+
+		/**	Sets camera world space position. */
+		virtual void setPosition(const Vector3& position);
+
+		/**	Retrieves camera world space position. */
+		virtual Vector3 getPosition() const { return mPosition; }
+
+		/**	Sets should the camera be rendered to or not. */
+		void setIsActive(bool active) { mIsActive = active; _markCoreDirty(); }
+		
+		/**	Gets whether the camera be rendered to or not. */
+		bool getIsActive() const { return mIsActive; }
+
+		/**
+		 * Gets the Z (forward) axis of the object, in world space.
+		 *
+		 * @return	Forward axis of the object.
+		 */
+		Vector3 getForward() const { return getRotation().rotate(-Vector3::UNIT_Z); }
+
+		/**	Sets camera world space rotation. */
+		virtual void setRotation(const Quaternion& rotation);
+
+		/**	Retrieves camera world space rotation. */
+		virtual Quaternion getRotation() const { return mRotation; }
+
+		/** Manually set the extents of the frustum that will be used when calculating the projection matrix. This will
+		 * prevents extents for being automatically calculated from aspect and near plane so it is up to the caller to keep
+		 * these values accurate.
+		 *
+		 * @param[in] left		The position where the left clip plane intersect the near clip plane, in view space.
+		 * @param[in] right		The position where the right clip plane intersect the near clip plane, in view space.
+		 * @param[in] top		The position where the top clip plane intersect the near clip plane, in view space.
+		 * @param[in] bottom	The position where the bottom clip plane intersect the near clip plane, in view space.
+		*/
+		virtual void setFrustumExtents(float left, float right, float top, float bottom);
+
+		/** 
+		 * Resets frustum extents so they are automatically derived from other values. This is only relevant if you have
+		 * previously set custom extents.
+		 */
+		virtual void resetFrustumExtents(); 
+
+		/** Returns the extents of the frustum in view space at the near plane. */
+		virtual void getFrustumExtents(float& outleft, float& outright, float& outtop, float& outbottom) const;
+
+		/** 
+		 * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. The layout
+		 * of this matrix depends on currently used render system.
+		 *
+		 * @note	
+		 * You should use this matrix when sending the matrix to the render system to make sure everything works 
+		 * consistently when other render systems are used.
+		 */
+        virtual const Matrix4& getProjectionMatrixRS() const;
+
+		/** 
+		 * Returns the inverse of the render-system specific projection matrix.
+		 *
+		 * @see		getProjectionMatrixRS
+		 */
+        virtual const Matrix4& getProjectionMatrixRSInv() const;
+
+		/** 
+		 * Returns the standard projection matrix that determines how are 3D points projected to two dimensions. Returned
+		 * matrix is standard following right-hand rules and depth range of [-1, 1]. 
+		 *
+		 * @note	
+		 * Different render systems will expect different projection matrix layouts, in which case use 
+		 * getProjectionMatrixRS().
+         */
+        virtual const Matrix4& getProjectionMatrix() const;
+
+		/** 
+		 * Returns the inverse of the projection matrix.
+		 *
+		 * @see		getProjectionMatrix
+		 */
+        virtual const Matrix4& getProjectionMatrixInv() const;
+
+		/** Gets the camera view matrix. Used for positioning/orienting the camera. */
+        virtual const Matrix4& getViewMatrix() const;
+
+		/** 
+		 * Returns the inverse of the view matrix.
+		 *
+		 * @see		getViewMatrix
+		 */
+		virtual const Matrix4& getViewMatrixInv() const;
+
+		/** 
+		 * Sets whether the camera should use the custom view matrix. When this is enabled camera will no longer calculate
+		 * its view matrix based on position/orientation and caller will be resonsible to keep the view matrix up to date.
+         */
+		virtual void setCustomViewMatrix(bool enable, const Matrix4& viewMatrix = Matrix4::IDENTITY);
+
+		/** Returns true if a custom view matrix is used. */
+		virtual bool isCustomViewMatrixEnabled() const { return mCustomViewMatrix; }
+		
+		/** 
+		 * Sets whether the camera should use the custom projection matrix. When this is enabled camera will no longer
+		 * calculate its projection matrix based on field of view, aspect and other parameters and caller will be resonsible
+		 * to keep the projection matrix up to date.
+         */
+		virtual void setCustomProjectionMatrix(bool enable, const Matrix4& projectionMatrix = Matrix4::IDENTITY);
+
+		/** Returns true if a custom projection matrix is used. */
+		virtual bool isCustomProjectionMatrixEnabled() const { return mCustomProjMatrix; }
+
+		/** Returns a convex volume representing the visible area of the camera, in local space. */
+        virtual const ConvexVolume& getFrustum() const;
+
+		/** Returns a convex volume representing the visible area of the camera, in world space. */
+        virtual ConvexVolume getWorldFrustum() const;
+
+		/**	Returns the bounding of the frustum. */
+        const AABox& getBoundingBox() const;
+
+		/**
+		 * Sets the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a 
+		 * 2D plane.
+		 */
+        virtual void setProjectionType(ProjectionType pt);
+
+		/**
+		 * Returns the type of projection used by the camera. Projection type controls how is 3D geometry projected onto a
+		 * 2D plane.
+		 */
+        virtual ProjectionType getProjectionType() const;
+
+		/**
+		 * Sets the orthographic window height, for use with orthographic rendering only. 
+		 *
+		 * @param[in]	w	Width of the window in world units.
+		 * @param[in]	h	Height of the window in world units.
+		 *
+		 * @note	
+		 * Calling this method will recalculate the aspect ratio, use setOrthoWindowHeight() or setOrthoWindowWidth() alone
+		 * if you wish to preserve the aspect ratio but just fit one or other dimension to a particular size.
+		 */
+		virtual void setOrthoWindow(float w, float h);
+
+		/**
+		 * Sets the orthographic window height, for use with orthographic rendering only. 
+		 *
+		 * @param[in]	h	Height of the window in world units.
+		 *
+		 * @note	The width of the window will be calculated from the aspect ratio. 
+		 */
+		virtual void setOrthoWindowHeight(float h);
+
+		/**
+		 * Sets the orthographic window width, for use with orthographic rendering only. 
+		 *
+		 * @param[in]	w	Width of the window in world units.
+		 *
+		 * @note	The height of the window will be calculated from the aspect ratio. 
+		 */
+		virtual void setOrthoWindowWidth(float w);
+
+		/** Gets the orthographic window width in world units, for use with orthographic rendering only. */
+		virtual float getOrthoWindowHeight() const;
+
+		/**
+		 * Gets the orthographic window width in world units, for use with orthographic rendering only. 
+		 *
+		 * @note	This is calculated from the orthographic height and the aspect ratio.
+		 */
+		virtual float getOrthoWindowWidth() const;
+
+		/**
+		 * Gets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
+		 * to the same render target. 
+		 */
+		INT32 getPriority() const { return mPriority; }
+
+		/**
+		 * Sets a priority that determines in which orders the cameras are rendered. This only applies to cameras rendering
+		 * to the same render target. 
+		 *
+		 * @param[in]	priority	The priority. Higher value means the camera will be rendered sooner.
+		 */
+		void setPriority(INT32 priority) { mPriority = priority; _markCoreDirty(); }
+
+		/**	Retrieves layer bitfield that is used when determining which object should the camera render. */
+		UINT64 getLayers() const { return mLayers; }
+
+		/**	Sets layer bitfield that is used when determining which object should the camera render. */
+		void setLayers(UINT64 layers) { mLayers = layers; _markCoreDirty(); }
+
+		/** Returns number of samples if the camera uses multiple samples per pixel. */
+		UINT32 getMSAACount() const { return mMSAA; }
+
+		/** 
+		 * Enables or disables multi-sampled anti-aliasing. Set to zero or one to disable, or to the required number of
+		 * samples to enable.
+		 */
+		void setMSAACount(UINT32 count) { mMSAA = count; _markCoreDirty(); }
+
+		/** Returns settings that are used for controling post-process operations like tonemapping. */
+		const SPtr<PostProcessSettings>& getPostProcessSettings() const { return mPPSettings; }
+
+		/** Sets settings that are used for controling post-process operations like tonemapping. */
+		void setPostProcessSettings(const SPtr<PostProcessSettings>& settings) { mPPSettings = settings; _markCoreDirty(CameraDirtyFlag::PostProcess); }
+
+		/**	Retrieves flags that define the camera. */
+		CameraFlags getFlags() const { return mCameraFlags; }
+
+		/**	Enables or disables flags that define the camera's behaviour. */
+		void setFlag(const CameraFlag& flag, bool enable);
+
+		/**
+		 * Converts a point in world space to screen coordinates (in pixels corresponding to the render target attached to
+		 * the camera).
+		 */
+		Vector2I worldToScreenPoint(const Vector3& worldPoint) const;
+
+		/**	Converts a point in world space to normalized device coordinates (in [-1, 1] range). */
+		Vector2 worldToNdcPoint(const Vector3& worldPoint) const;
+
+		/** Converts a point in world space to point relative to camera's coordinate system (view space). */
+		Vector3 worldToViewPoint(const Vector3& worldPoint) const;
+
+		/**
+		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point in
+		 * world space.
+		 *
+		 * @param[in]	screenPoint	Point to transform.
+		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
+		 *							origin to the point on the near plane.
+		 */
+		Vector3 screenToWorldPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
+
+		/**
+		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point
+		 * relative to camera's coordinate system (view space).
+		 *
+		 * @param[in]	screenPoint	Point to transform.
+		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
+		 *							origin to the point on the near plane.
+		 */
+		Vector3 screenToViewPoint(const Vector2I& screenPoint, float depth = 0.5f) const;
+
+		/**
+		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to normalized 
+		 * device coordinates (in [-1, 1] range).
+		 */
+		Vector2 screenToNdcPoint(const Vector2I& screenPoint) const;
+
+		/** Converts a point relative to camera's coordinate system (view space) into a point in world space. */
+		Vector3 viewToWorldPoint(const Vector3& viewPoint) const;
+
+		/**
+		 * Converts a point relative to camera's coordinate system (view space) into a point in screen space (pixels 
+		 * corresponding to render target attached to the camera).
+		 */
+		Vector2I viewToScreenPoint(const Vector3& viewPoint) const;
+
+		/**
+		 * Converts a point relative to camera's coordinate system (view space) into normalized device coordinates 
+		 * (in [-1, 1] range).
+		 */
+		Vector2 viewToNdcPoint(const Vector3& viewPoint) const;
+
+		/**
+		 * Converts a point in normalized device coordinates ([-1, 1] range) to a point in world space.
+		 *
+		 * @param[in]	ndcPoint	Point to transform.
+		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
+		 *							origin to the point on the near plane.
+		 */
+		Vector3 ndcToWorldPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
+
+		/**
+		 * Converts a point in normalized device coordinates ([-1, 1] range) to a point relative to camera's coordinate system
+		 * (view space).
+		 *
+		 * @param[in]	ndcPoint	Point to transform.
+		 * @param[in]	depth		Depth to place the world point at. The depth is applied to the vector going from camera
+		 *							origin to the point on the near plane.
+		 */
+		Vector3 ndcToViewPoint(const Vector2& ndcPoint, float depth = 0.5f) const;
+
+		/**
+		 * Converts a point in normalized device coordinates ([-1, 1] range) to a point in screen space (pixels corresponding
+		 * to render target attached to the camera).
+		 */
+		Vector2I ndcToScreenPoint(const Vector2& ndcPoint) const;
+
+		/**
+		 * Converts a point in screen space (pixels corresponding to render target attached to the camera) to a ray in world
+		 * space originating at the selected point on the camera near plane.
+		 */
+		Ray screenPointToRay(const Vector2I& screenPoint) const;
+
+		/**	Projects a point from view to normalized device space. */
+		Vector3 projectPoint(const Vector3& point) const;
+
+		/**	Un-projects a point in normalized device space to view space. */
+		Vector3 unprojectPoint(const Vector3& point) const;
+
+        static const float INFINITE_FAR_PLANE_ADJUST; /**< Small constant used to reduce far plane projection to avoid inaccuracies. */
+
+	protected:
+		CameraBase();
+
+		/**	Calculate projection parameters that are used when constructing the projection matrix. */
+		virtual void calcProjectionParameters(float& left, float& right, float& bottom, float& top) const;
+
+		/**	Recalculate frustum if dirty. */
+		virtual void updateFrustum() const;
+
+		/**	Recalculate frustum planes if dirty. */
+		virtual void updateFrustumPlanes() const;
+
+		/**
+		 * Update view matrix from parent position/orientation.
+		 *
+		 * @note	Does nothing when custom view matrix is set.
+		 */
+		virtual void updateView() const;
+
+		/**	Checks if the frustum requires updating. */
+		virtual bool isFrustumOutOfDate() const;
+
+		/**	Notify camera that the frustum requires to be updated. */
+		virtual void invalidateFrustum() const;
+
+		/**	Returns a rectangle that defines the viewport position and size, in pixels. */
+		virtual Rect2I getViewportRect() const = 0;
+
+		/** 
+		 * Marks the simulation thread object as dirty and notifies the system its data should be synced with its core 
+		 * thread counterpart. 
+		 */
+		virtual void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) { }
+
+    protected:
+		UINT64 mLayers; /**< Bitfield that can be used for filtering what objects the camera sees. */
+		CameraFlags mCameraFlags; /**< Flags that further determine type of camera. */
+
+		Vector3 mPosition; /**< World space position. */
+		Quaternion mRotation; /**< World space rotation. */
+		bool mIsActive; /**< Is camera being rendered to. */
+
+		ProjectionType mProjType; /**< Type of camera projection. */
+		Radian mHorzFOV; /**< Horizontal field of view represents how wide is the camera angle. */
+		float mFarDist; /**< Clip any objects further than this. Larger value decreases depth precision at smaller depths. */
+		float mNearDist; /**< Clip any objects close than this. Smaller value decreases depth precision at larger depths. */
+		float mAspect; /**< Width/height viewport ratio. */
+		float mOrthoHeight; /**< Height in world units used for orthographic cameras. */
+		INT32 mPriority; /**< Determines in what order will the camera be rendered. Higher priority means the camera will be rendered sooner. */
+
+		bool mCustomViewMatrix; /**< Is custom view matrix set. */
+		bool mCustomProjMatrix; /**< Is custom projection matrix set. */
+		UINT8 mMSAA; /**< Number of samples to render the scene with. */
+
+		SPtr<PostProcessSettings> mPPSettings; /**< Settings used to control post-process operations. */
+
+		bool mFrustumExtentsManuallySet; /**< Are frustum extents manually set. */
+
+		mutable Matrix4 mProjMatrixRS; /**< Cached render-system specific projection matrix. */
+		mutable Matrix4 mProjMatrix; /**< Cached projection matrix that determines how are 3D points projected to a 2D viewport. */
+		mutable Matrix4 mViewMatrix; /**< Cached view matrix that determines camera position/orientation. */
+		mutable Matrix4 mProjMatrixRSInv;
+		mutable Matrix4 mProjMatrixInv;
+		mutable Matrix4 mViewMatrixInv;
+
+		mutable ConvexVolume mFrustum; /**< Main clipping planes describing cameras visible area. */
+		mutable bool mRecalcFrustum : 1; /**< Should frustum be recalculated. */
+		mutable bool mRecalcFrustumPlanes : 1; /**< Should frustum planes be recalculated. */
+		mutable bool mRecalcView : 1; /**< Should view matrix be recalculated. */
+		mutable float mLeft, mRight, mTop, mBottom; /**< Frustum extents. */
+		mutable AABox mBoundingBox; /**< Frustum bounding box. */
+     };
+
+	/** @} */
+	/** @addtogroup Renderer-Engine-Internal
+	 *  @{
+	 */
+
+	/** @copydoc CameraBase */
+	class BS_CORE_EXPORT CameraCore : public CoreObjectCore, public CameraBase
+	{
+	public:
+		~CameraCore();
+
+		/**	Returns the viewport used by the camera. */	
+		SPtr<ViewportCore> getViewport() const { return mViewport; }
+
+	protected:
+		friend class Camera;
+
+		CameraCore(SPtr<RenderTargetCore> target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+		CameraCore(const SPtr<ViewportCore>& viewport);
+
+		/** @copydoc CoreObjectCore::initialize */
+		void initialize() override;
+
+		/** @copydoc CameraBase */
+		Rect2I getViewportRect() const override;
+
+		/** @copydoc CoreObject::syncToCore */
+		void syncToCore(const CoreSyncData& data) override;
+
+		SPtr<ViewportCore> mViewport;
+	};
+
+	/** @copydoc CameraBase */
+	class BS_CORE_EXPORT Camera : public IReflectable, public CoreObject, public CameraBase
+    {
+    public:
+		/**	Returns the viewport used by the camera. */	
+		SPtr<Viewport> getViewport() const { return mViewport; }
+
+		/**
+		 * Determines whether this is the main application camera. Main camera controls the final render surface that is
+		 * displayed to the user.
+		 */	
+		bool isMain() const { return mMain; }
+
+		/**
+		 * Marks or unmarks this camera as the main application camera. Main camera controls the final render surface that
+		 * is displayed to the user.
+		 */	
+		void setMain(bool main) { mMain = main; }
+
+		/** Retrieves an implementation of a camera handler usable only from the core thread. */
+		SPtr<CameraCore> getCore() const;
+
+		/**	Creates a new camera that renders to the specified portion of the provided render target. */
+		static SPtr<Camera> create(SPtr<RenderTarget> target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+		/** @name Internal
+		 *  @{
+		 */
+
+		/**	Returns the hash value that can be used to identify if the internal data needs an update. */
+		UINT32 _getLastModifiedHash() const { return mLastUpdateHash; }
+
+		/**	Sets the hash value that can be used to identify if the internal data needs an update. */
+		void _setLastModifiedHash(UINT32 hash) { mLastUpdateHash = hash; }
+
+		/** @} */
+
+	protected:
+		Camera(SPtr<RenderTarget> target = nullptr,
+			float left = 0.0f, float top = 0.0f, float width = 1.0f, float height = 1.0f);
+
+		/** @copydoc CameraBase */
+		Rect2I getViewportRect() const override;
+
+		/** @copydoc CoreObject::createCore */
+		SPtr<CoreObjectCore> createCore() const override;
+
+		/** @copydoc CameraBase::_markCoreDirty */
+		void _markCoreDirty(CameraDirtyFlag flag = CameraDirtyFlag::Everything) override;
+
+		/** @copydoc CoreObject::syncToCore */
+		CoreSyncData syncToCore(FrameAlloc* allocator) override;
+
+		/** @copydoc CoreObject::getCoreDependencies */
+		void getCoreDependencies(Vector<CoreObject*>& dependencies) override;
+
+		/**	Creates a new camera without initializing it. */
+		static SPtr<Camera> createEmpty();
+
+		SPtr<Viewport> mViewport; /**< Viewport that describes 2D rendering surface. */
+		bool mMain;
+		UINT32 mLastUpdateHash;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class CameraRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
+     };
+
+	/** @} */
 }

+ 80 - 79
Source/BansheeEngine/Include/BsCameraRTTI.h → Source/BansheeCore/Include/BsCameraRTTI.h

@@ -1,80 +1,81 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsPrerequisites.h"
-#include "BsRTTIType.h"
-#include "BsCamera.h"
-
-namespace BansheeEngine
-{
-	/** @cond RTTI */
-	/** @addtogroup RTTI-Impl-Engine
-	 *  @{
-	 */
-
-	class BS_EXPORT CameraRTTI : public RTTIType <Camera, IReflectable, CameraRTTI>
-	{
-	private:
-		BS_BEGIN_RTTI_MEMBERS
-			BS_RTTI_MEMBER_REFLPTR(mViewport, 0)
-			BS_RTTI_MEMBER_PLAIN(mLayers, 1)
-			BS_RTTI_MEMBER_PLAIN(mPosition, 2)
-			BS_RTTI_MEMBER_PLAIN(mRotation, 3)
-			BS_RTTI_MEMBER_PLAIN(mProjType, 4)
-			BS_RTTI_MEMBER_PLAIN(mHorzFOV, 5)
-			BS_RTTI_MEMBER_PLAIN(mFarDist, 6)
-			BS_RTTI_MEMBER_PLAIN(mNearDist, 7)
-			BS_RTTI_MEMBER_PLAIN(mAspect, 8)
-			BS_RTTI_MEMBER_PLAIN(mOrthoHeight, 9)
-			BS_RTTI_MEMBER_PLAIN(mPriority, 10)
-			BS_RTTI_MEMBER_PLAIN(mCustomViewMatrix, 11)
-			BS_RTTI_MEMBER_PLAIN(mCustomProjMatrix, 12)
-			BS_RTTI_MEMBER_PLAIN(mFrustumExtentsManuallySet, 13)
-			BS_RTTI_MEMBER_PLAIN(mProjMatrixRS, 15)
-			BS_RTTI_MEMBER_PLAIN(mProjMatrix, 16)
-			BS_RTTI_MEMBER_PLAIN(mViewMatrix, 17)
-			BS_RTTI_MEMBER_PLAIN(mLeft, 18)
-			BS_RTTI_MEMBER_PLAIN(mRight, 19)
-			BS_RTTI_MEMBER_PLAIN(mTop, 20)
-			BS_RTTI_MEMBER_PLAIN(mBottom, 21)
-			BS_RTTI_MEMBER_PLAIN(mCameraFlags, 22)
-			BS_RTTI_MEMBER_PLAIN(mMSAA, 23)
-			BS_RTTI_MEMBER_PLAIN(mPPSettings, 24)
-		BS_END_RTTI_MEMBERS
-			
-	public:
-		CameraRTTI()
-			:mInitMembers(this)
-		{ }
-
-		void onDeserializationEnded(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override
-		{
-			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
-			// but since this specific type is used in Components we delay initialization until Component
-			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
-			// purposes (you'll need to call initialize manually).
-		}
-
-		const String& getRTTIName() override
-		{
-			static String name = "Camera";
-			return name;
-		}
-
-		UINT32 getRTTIId() override
-		{
-			return TID_Camera;
-		}
-
-		SPtr<IReflectable> newRTTIObject() override
-		{
-			return Camera::createEmpty();
-		}
-	};
-
-	BS_ALLOW_MEMCPY_SERIALIZATION(CameraFlags);
-
-	/** @} */
-	/** @endcond */
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsCamera.h"
+
+namespace BansheeEngine
+{
+	/** @cond RTTI */
+	/** @addtogroup RTTI-Impl-Engine
+	 *  @{
+	 */
+
+	class BS_CORE_EXPORT CameraRTTI : public RTTIType <Camera, IReflectable, CameraRTTI>
+	{
+	private:
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_REFLPTR(mViewport, 0)
+			BS_RTTI_MEMBER_PLAIN(mLayers, 1)
+			BS_RTTI_MEMBER_PLAIN(mPosition, 2)
+			BS_RTTI_MEMBER_PLAIN(mRotation, 3)
+			BS_RTTI_MEMBER_PLAIN(mProjType, 4)
+			BS_RTTI_MEMBER_PLAIN(mHorzFOV, 5)
+			BS_RTTI_MEMBER_PLAIN(mFarDist, 6)
+			BS_RTTI_MEMBER_PLAIN(mNearDist, 7)
+			BS_RTTI_MEMBER_PLAIN(mAspect, 8)
+			BS_RTTI_MEMBER_PLAIN(mOrthoHeight, 9)
+			BS_RTTI_MEMBER_PLAIN(mPriority, 10)
+			BS_RTTI_MEMBER_PLAIN(mCustomViewMatrix, 11)
+			BS_RTTI_MEMBER_PLAIN(mCustomProjMatrix, 12)
+			BS_RTTI_MEMBER_PLAIN(mFrustumExtentsManuallySet, 13)
+			BS_RTTI_MEMBER_PLAIN(mProjMatrixRS, 15)
+			BS_RTTI_MEMBER_PLAIN(mProjMatrix, 16)
+			BS_RTTI_MEMBER_PLAIN(mViewMatrix, 17)
+			BS_RTTI_MEMBER_PLAIN(mLeft, 18)
+			BS_RTTI_MEMBER_PLAIN(mRight, 19)
+			BS_RTTI_MEMBER_PLAIN(mTop, 20)
+			BS_RTTI_MEMBER_PLAIN(mBottom, 21)
+			BS_RTTI_MEMBER_PLAIN(mCameraFlags, 22)
+			BS_RTTI_MEMBER_PLAIN(mMSAA, 23)
+			/** BS_RTTI_MEMBER_PLAIN(mPPSettings, 24) */
+			BS_RTTI_MEMBER_REFLPTR(mPPSettings, 25)
+		BS_END_RTTI_MEMBERS
+			
+	public:
+		CameraRTTI()
+			:mInitMembers(this)
+		{ }
+
+		void onDeserializationEnded(IReflectable* obj, const UnorderedMap<String, UINT64>& params) override
+		{
+			// Note: Since this is a CoreObject I should call initialize() right after deserialization,
+			// but since this specific type is used in Components we delay initialization until Component
+			// itself does it. Keep this is mind in case this ever needs to be deserialized for non-Component 
+			// purposes (you'll need to call initialize manually).
+		}
+
+		const String& getRTTIName() override
+		{
+			static String name = "Camera";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_Camera;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return Camera::createEmpty();
+		}
+	};
+
+	BS_ALLOW_MEMCPY_SERIALIZATION(CameraFlags);
+
+	/** @} */
+	/** @endcond */
 }

+ 10 - 1
Source/BansheeCore/Include/BsCorePrerequisites.h

@@ -365,6 +365,7 @@ namespace BansheeEngine
 	class AudioSource;
 	class AudioClipImportOptions;
 	class AnimationClip;
+	class CCamera;
 	template <class T> class TAnimationCurve;
 	struct AnimationCurves;
 	class Skeleton;
@@ -372,6 +373,8 @@ namespace BansheeEngine
 	class GpuParamsSet;
 	class GpuParamsSetCore;
 	class MaterialParamsCore;
+	class Camera;
+	class CameraCore;
 	// Asset import
 	class SpecificImporter;
 	class Importer;
@@ -534,7 +537,12 @@ namespace BansheeEngine
 		TID_AnimationEvent = 1123,
 		TID_ImportedAnimationEvents = 1124,
 		TID_CBone = 1125,
-		TID_MaterialParamData = 1126
+		TID_MaterialParamData = 1126,
+		TID_PostProcessSettings = 1127,
+
+		// Moved from Engine layer
+		TID_CCamera = 30000,
+		TID_Camera = 30003,
 	};
 }
 
@@ -579,6 +587,7 @@ namespace BansheeEngine
 	typedef GameObjectHandle<GameObject> HGameObject;
 	typedef GameObjectHandle<SceneObject> HSceneObject;
 	typedef GameObjectHandle<Component> HComponent;
+	typedef GameObjectHandle<CCamera> HCamera;
 	typedef GameObjectHandle<CRigidbody> HRigidbody;
 	typedef GameObjectHandle<CCollider> HCollider;
 	typedef GameObjectHandle<CBoxCollider> HBoxCollider;

+ 5 - 0
Source/BansheeCore/Include/BsCoreRenderer.h

@@ -8,6 +8,8 @@
 
 namespace BansheeEngine
 {
+	struct PostProcessSettings;
+
 	/** @addtogroup Renderer-Internal
 	 *  @{
 	 */
@@ -135,6 +137,9 @@ namespace BansheeEngine
 		/**	Returns current set of options used for controlling the rendering. */
 		virtual SPtr<CoreRendererOptions> getOptions() const { return SPtr<CoreRendererOptions>(); }
 
+		/** Creates post process settings that can be attached to a camera and processed by the active renderer. */
+		virtual SPtr<PostProcessSettings> createPostProcessSettings() const = 0;
+
 	protected:
 		/**	Contains information about a render callback. */
 		struct RenderCallbackData

+ 46 - 0
Source/BansheeCore/Include/BsCoreSceneManager.h

@@ -12,6 +12,19 @@ namespace BansheeEngine
 	 *  @{
 	 */
 
+	/**	Contains information about a camera managed by the scene manager. */
+	struct SceneCameraData
+	{
+		SceneCameraData() { }
+
+		SceneCameraData(const SPtr<Camera>& camera, const HSceneObject& sceneObject)
+			:camera(camera), sceneObject(sceneObject)
+		{ }
+
+		SPtr<Camera> camera;
+		HSceneObject sceneObject;
+	};
+
 	/**
 	 * Manages all objects in the scene and provides various query methods for finding objects. This is just the base class
 	 * with basic query functionality. You should override it with your own version.
@@ -32,6 +45,30 @@ namespace BansheeEngine
 		 */
 		void clearScene(bool forceAll = false);
 
+		/** Returns all cameras in the scene. */
+		const Map<Camera*, SceneCameraData>& getAllCameras() const { return mCameras; }
+
+		/**
+		 * Returns the camera in the scene marked as main. Main camera controls the final render surface that is displayed
+		 * to the user. If there are multiple main cameras, the first one found returned.
+		 */
+		SceneCameraData getMainCamera() const;
+
+		/**
+		 * Sets the render target that the main camera in the scene (if any) will render its view to. This generally means
+		 * the main game window when running standalone, or the Game viewport when running in editor.
+		 */
+		void setMainRenderTarget(const SPtr<RenderTarget>& rt);
+
+		/**	Notifies the scene manager that a new camera was created. */
+		void _registerCamera(const SPtr<Camera>& camera, const HSceneObject& so);
+
+		/**	Notifies the scene manager that a camera was removed. */
+		void _unregisterCamera(const SPtr<Camera>& camera);
+
+		/**	Notifies the scene manager that a camera either became the main camera, or has stopped being main camera. */
+		void _notifyMainCameraStateChanged(const SPtr<Camera>& camera);
+
 		/** Changes the root scene object. Any persistent objects will remain in the scene, now parented to the new root. */
 		void _setRootNode(const HSceneObject& root);
 
@@ -57,8 +94,17 @@ namespace BansheeEngine
 		 */
 		void registerNewSO(const HSceneObject& node);
 
+		/**	Callback that is triggered when the main render target size is changed. */
+		void onMainRenderTargetResized();
+
 	protected:
 		HSceneObject mRootNode;
+
+		Map<Camera*, SceneCameraData> mCameras;
+		Vector<SceneCameraData> mMainCameras;
+
+		SPtr<RenderTarget> mMainRT;
+		HEvent mMainRTResizedConn;
 	};
 
 	/**

+ 1 - 1
Source/BansheeCore/Include/BsMaterialParams.h

@@ -560,7 +560,7 @@ namespace BansheeEngine
 		MaterialParamsCore(const SPtr<ShaderCore>& shader);
 
 		/** 
-		 * Updates the stored parameters from the provided buffer, allowing changed to be transfered between the sim and 
+		 * Updates the stored parameters from the provided buffer, allowing changes to be transfered between the sim and 
 		 * core thread material param objects. Buffer must be retrieved from MaterialParams::getSyncData. 
 		 *
 		 * @param[in]		buffer		Buffer containing the dirty data.

+ 55 - 0
Source/BansheeCore/Include/BsPostProcessSettings.h

@@ -0,0 +1,55 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsIReflectable.h"
+
+namespace BansheeEngine
+{
+	/** @addtogroup Renderer
+	 *  @{
+	 */
+	
+	/** Base class whose implementations contain settings that control post-process operations during rendering. */
+	struct BS_CORE_EXPORT PostProcessSettings : public IReflectable
+	{
+		PostProcessSettings() { }
+		virtual ~PostProcessSettings() { }
+
+		/** @name Internal
+		 *  @{
+		 */
+
+		/** 
+		 * Populates the provided buffer with data that can be used for syncing between two versions of this object.
+		 * Apply the retrieved buffer via _setSyncData().
+		 *
+		 * @param[in]		buffer		Pre-allocated buffer to store the sync data in. Set to null to calculate the size
+		 *								of the required buffer.
+		 * @param[in, out]	size		Size of the provided allocated buffer. Or if the buffer is null, this parameter will
+		 *								contain the required buffer size when the method executes.
+		 */
+		virtual void _getSyncData(UINT8* buffer, UINT32& size) = 0;
+
+		/** 
+		 * Updates the stored data from the provided buffer, allowing changes to be transfered between two versions of this
+		 * object. Buffer must be retrieved from _getSyncData(). 
+		 *
+		 * @param[in]		buffer		Buffer containing the dirty data.
+		 * @param[in, out]	size		Size of the provided buffer.
+		 */
+		virtual void _setSyncData(UINT8* buffer, UINT32 size) = 0;
+
+		/** @} */
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class PostProcessSettingsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
+	};
+
+	/** @} */
+}

+ 43 - 0
Source/BansheeCore/Include/BsPostProcessSettingsRTTI.h

@@ -0,0 +1,43 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsCorePrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsPostProcessSettings.h"
+
+namespace BansheeEngine
+{
+	/** @cond RTTI */
+	/** @addtogroup RTTI-Impl-Engine
+	 *  @{
+	 */
+
+	class BS_CORE_EXPORT PostProcessSettingsRTTI : public RTTIType<PostProcessSettings, IReflectable, PostProcessSettingsRTTI>
+	{
+	private:
+
+	public:
+		PostProcessSettingsRTTI() { }
+
+		const String& getRTTIName() override
+		{
+			static String name = "PostProcessSettings";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_PostProcessSettings;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			assert(false); // Abstract class
+			return nullptr;
+		}
+	};
+
+	/** @} */
+	/** @endcond */
+}

+ 15 - 2
Source/BansheeCore/Source/BsAnimationManager.cpp

@@ -6,6 +6,7 @@
 #include "BsTaskScheduler.h"
 #include "BsTime.h"
 #include "BsCoreSceneManager.h"
+#include "BsCamera.h"
 
 namespace BansheeEngine
 {
@@ -50,7 +51,7 @@ namespace BansheeEngine
 		mWorkerRunning = false;
 	}
 
-	void AnimationManager::postUpdate(const Vector<ConvexVolume>& cullFrustums)
+	void AnimationManager::postUpdate()
 	{
 		if (mPaused)
 			return;
@@ -74,7 +75,19 @@ namespace BansheeEngine
 			mProxies.push_back(anim.second->mAnimProxy);
 		}
 
-		mCullFrustums = cullFrustums;
+		mCullFrustums.clear();
+
+		auto& allCameras = gCoreSceneManager().getAllCameras();
+		for(auto& entry : allCameras)
+		{
+			bool isOverlayCamera = entry.second.camera->getFlags().isSet(CameraFlag::Overlay);
+			if (isOverlayCamera)
+				continue;
+
+			// TODO: Not checking if camera and animation renderable's layers match. If we checked more animations could
+			// be culled.
+			mCullFrustums.push_back(entry.second.camera->getWorldFrustum());
+		}
 
 		// Make sure thread finishes writing all changes to the anim proxies as they will be read by the animation thread
 		std::atomic_thread_fence(std::memory_order_release);

+ 4 - 4
Source/BansheeEngine/Source/BsCCamera.cpp → Source/BansheeCore/Source/BsCCamera.cpp

@@ -3,7 +3,7 @@
 #include "BsCCamera.h"
 #include "BsCCameraRTTI.h"
 #include "BsSceneObject.h"
-#include "BsSceneManager.h"
+#include "BsCoreSceneManager.h"
 
 namespace BansheeEngine 
 {
@@ -50,7 +50,7 @@ namespace BansheeEngine
 	{
 		mInternal->setMain(main);
 
-		gSceneManager()._notifyMainCameraStateChanged(mInternal);
+		gCoreSceneManager()._notifyMainCameraStateChanged(mInternal);
 	}
 
 	void CCamera::update() 
@@ -70,12 +70,12 @@ namespace BansheeEngine
 			mTarget = nullptr;
 		}
 
-		gSceneManager()._registerCamera(mInternal, SO());
+		gCoreSceneManager()._registerCamera(mInternal, SO());
 	}
 
 	void CCamera::onDestroyed()
 	{
-		gSceneManager()._unregisterCamera(mInternal);
+		gCoreSceneManager()._unregisterCamera(mInternal);
 	}
 
 	RTTITypeBase* CCamera::getRTTIStatic()

+ 29 - 3
Source/BansheeEngine/Source/BsCamera.cpp → Source/BansheeCore/Source/BsCamera.cpp

@@ -24,6 +24,8 @@ namespace BansheeEngine
 		, mPriority(0), mCustomViewMatrix(false), mCustomProjMatrix(false), mMSAA(1), mFrustumExtentsManuallySet(false)
 		, mRecalcFrustum(true), mRecalcFrustumPlanes(true), mRecalcView(true)
 	{
+		mPPSettings = RendererManager::instance().getActive()->createPostProcessSettings();
+
 		mViewMatrix = Matrix4::ZERO;
 		mProjMatrixRS = Matrix4::ZERO;
 		mViewMatrixInv = Matrix4::ZERO;
@@ -760,7 +762,18 @@ namespace BansheeEngine
 			dataPtr = rttiReadElem(mCameraFlags, dataPtr);
 			dataPtr = rttiReadElem(mIsActive, dataPtr);
 			dataPtr = rttiReadElem(mMSAA, dataPtr);
-			dataPtr = rttiReadElem(mPPSettings, dataPtr);
+
+			UINT32 ppSize = 0;
+			dataPtr = rttiReadElem(ppSize, dataPtr);
+
+			if(ppSize > 0)
+			{
+				if (mPPSettings == nullptr)
+					mPPSettings = RendererManager::instance().getActive()->createPostProcessSettings();
+
+				mPPSettings->_setSyncData((UINT8*)dataPtr, ppSize);
+				dataPtr += ppSize;
+			}
 		}
 
 		RendererManager::instance().getActive()->notifyCameraUpdated(this, (UINT32)dirtyFlag);
@@ -822,6 +835,7 @@ namespace BansheeEngine
 		size += rttiGetElemSize(mPosition);
 		size += rttiGetElemSize(mRotation);
 
+		UINT32 ppSize = 0;
 		if (dirtyFlag != (UINT32)CameraDirtyFlag::Transform)
 		{
 			size += rttiGetElemSize(mLayers);
@@ -838,7 +852,14 @@ namespace BansheeEngine
 			size += rttiGetElemSize(mCameraFlags);
 			size += rttiGetElemSize(mIsActive);
 			size += rttiGetElemSize(mMSAA);
-			size += rttiGetElemSize(mPPSettings);
+
+			size += sizeof(UINT32);
+
+			if(mPPSettings != nullptr)
+			{
+				mPPSettings->_getSyncData(nullptr, ppSize);
+				size += ppSize;
+			}
 		}
 
 		UINT8* buffer = allocator->alloc(size);
@@ -864,7 +885,12 @@ namespace BansheeEngine
 			dataPtr = rttiWriteElem(mCameraFlags, dataPtr);
 			dataPtr = rttiWriteElem(mIsActive, dataPtr);
 			dataPtr = rttiWriteElem(mMSAA, dataPtr);
-			dataPtr = rttiWriteElem(mPPSettings, dataPtr);
+			dataPtr = rttiWriteElem(ppSize, dataPtr);
+
+			if(mPPSettings != nullptr)
+				mPPSettings->_getSyncData((UINT8*)dataPtr, ppSize);
+
+			dataPtr += ppSize;
 		}
 
 		return CoreSyncData(buffer, size);

+ 1 - 1
Source/BansheeCore/Source/BsCoreApplication.cpp

@@ -224,7 +224,7 @@ namespace BansheeEngine
 			PROFILE_CALL(gCoreSceneManager()._update(), "SceneManager");
 			gAudio()._update();
 			gPhysics().update();
-			AnimationManager::instance().postUpdate({}); // TODO
+			AnimationManager::instance().postUpdate();
 
 			// Update plugins
 			for (auto& pluginUpdateFunc : mPluginUpdateFunctions)

+ 91 - 0
Source/BansheeCore/Source/BsCoreSceneManager.cpp

@@ -3,7 +3,10 @@
 #include "BsCoreSceneManager.h"
 #include "BsSceneObject.h"
 #include "BsComponent.h"
+#include "BsCamera.h"
+#include "BsViewport.h"
 #include "BsGameObjectManager.h"
+#include "BsRenderTarget.h"
 
 namespace BansheeEngine
 {
@@ -73,6 +76,85 @@ namespace BansheeEngine
 		oldRoot->destroy();
 	}
 
+	void CoreSceneManager::_registerCamera(const SPtr<Camera>& camera, const HSceneObject& so)
+	{
+		mCameras[camera.get()] = SceneCameraData(camera, so);
+	}
+
+	void CoreSceneManager::_unregisterCamera(const SPtr<Camera>& camera)
+	{
+		mCameras.erase(camera.get());
+
+		auto iterFind = std::find_if(mMainCameras.begin(), mMainCameras.end(),
+			[&](const SceneCameraData& x)
+		{
+			return x.camera == camera;
+		});
+
+		if (iterFind != mMainCameras.end())
+			mMainCameras.erase(iterFind);
+	}
+
+	void CoreSceneManager::_notifyMainCameraStateChanged(const SPtr<Camera>& camera)
+	{
+		auto iterFind = std::find_if(mMainCameras.begin(), mMainCameras.end(),
+			[&](const SceneCameraData& entry)
+		{
+			return entry.camera == camera;
+		});
+
+		SPtr<Viewport> viewport = camera->getViewport();
+		if (camera->isMain())
+		{
+			if (iterFind == mMainCameras.end())
+				mMainCameras.push_back(mCameras[camera.get()]);
+
+			viewport->setTarget(mMainRT);
+		}
+		else
+		{
+			if (iterFind != mMainCameras.end())
+				mMainCameras.erase(iterFind);
+
+			if (viewport->getTarget() == mMainRT)
+				viewport->setTarget(nullptr);
+		}
+	}
+
+	SceneCameraData CoreSceneManager::getMainCamera() const
+	{
+		if (mMainCameras.size() > 0)
+			return mMainCameras[0];
+
+		return SceneCameraData();
+	}
+
+	void CoreSceneManager::setMainRenderTarget(const SPtr<RenderTarget>& rt)
+	{
+		if (mMainRT == rt)
+			return;
+
+		mMainRTResizedConn.disconnect();
+
+		if (rt != nullptr)
+			mMainRTResizedConn = rt->onResized.connect(std::bind(&CoreSceneManager::onMainRenderTargetResized, this));
+
+		mMainRT = rt;
+
+		float aspect = 1.0f;
+		if (rt != nullptr)
+		{
+			auto& rtProps = rt->getProperties();
+			aspect = rtProps.getWidth() / (float)rtProps.getHeight();
+		}
+
+		for (auto& entry : mMainCameras)
+		{
+			entry.camera->getViewport()->setTarget(rt);
+			entry.camera->setAspectRatio(aspect);
+		}
+	}
+
 	void CoreSceneManager::_update()
 	{
 		Stack<HSceneObject> todo;
@@ -106,6 +188,15 @@ namespace BansheeEngine
 			node->setParent(mRootNode);
 	}
 
+	void CoreSceneManager::onMainRenderTargetResized()
+	{
+		auto& rtProps = mMainRT->getProperties();
+		float aspect = rtProps.getWidth() / (float)rtProps.getHeight();
+
+		for (auto& entry : mMainCameras)
+			entry.camera->setAspectRatio(aspect);
+	}
+
 	CoreSceneManager& gCoreSceneManager()
 	{
 		return CoreSceneManager::instance();

+ 17 - 0
Source/BansheeCore/Source/BsPostProcessSettings.cpp

@@ -0,0 +1,17 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsPostProcessSettings.h"
+#include "BsPostProcessSettingsRTTI.h"
+
+namespace BansheeEngine
+{
+	RTTITypeBase* PostProcessSettings::getRTTIStatic()
+	{
+		return PostProcessSettingsRTTI::instance();
+	}
+
+	RTTITypeBase* PostProcessSettings::getRTTI() const
+	{
+		return PostProcessSettings::getRTTIStatic();
+	}
+}

+ 3 - 8
Source/BansheeEngine/CMakeSources.cmake

@@ -1,5 +1,4 @@
 set(BS_BANSHEEENGINE_INC_COMPONENTS
-	"Include/BsCCamera.h"
 	"Include/BsCRenderable.h"
 	"Include/BsCLight.h"
 	"Include/BsCAnimation.h"
@@ -89,7 +88,6 @@ set(BS_BANSHEEENGINE_INC_PLATFORM
 )
 
 set(BS_BANSHEEENGINE_INC_RENDERER
-	"Include/BsCamera.h"
 	"Include/BsLight.h"
 	"Include/BsRenderable.h"
 	"Include/BsRenderableElement.h"
@@ -99,7 +97,7 @@ set(BS_BANSHEEENGINE_INC_RENDERER
 	"Include/BsRenderQueue.h"
 	"Include/BsSceneManager.h"
 	"Include/BsRendererUtility.h"
-	"Include/BsPostProcessSettings.h"	
+	"Include/BsStandardPostProcessSettings.h"	
 )
 
 set(BS_BANSHEEENGINE_SRC_RTTI
@@ -143,10 +141,8 @@ set(BS_BANSHEEENGINE_INC_RTTI
 	"Include/BsGUIElementStyleRTTI.h"
 	"Include/BsGUISkinRTTI.h"
 	"Include/BsProfilerOverlayRTTI.h"
-	"Include/BsCCameraRTTI.h"
 	"Include/BsCRenderableRTTI.h"
 	"Include/BsCLightRTTI.h"
-	"Include/BsCameraRTTI.h"
 	"Include/BsRenderableRTTI.h"
 	"Include/BsLightRTTI.h"
 	"Include/BsCGUIWidgetRTTI.h"
@@ -154,6 +150,7 @@ set(BS_BANSHEEENGINE_INC_RTTI
 	"Include/BsResourceMappingRTTI.h"
 	"Include/BsCAnimationRTTI.h"
 	"Include/BsCBoneRTTI.h"
+	"Include/BsStandardPostProcessSettingsRTTI.h"
 )
 
 set(BS_BANSHEEENGINE_INC_NOFILTER
@@ -173,7 +170,6 @@ set(BS_BANSHEEENGINE_INC_RESOURCES
 )
 
 set(BS_BANSHEEENGINE_SRC_COMPONENTS
-	"Source/BsCCamera.cpp"
 	"Source/BsCRenderable.cpp"
 	"Source/BsCLight.cpp"
 	"Source/BsCAnimation.cpp"
@@ -196,7 +192,6 @@ set(BS_BANSHEEENGINE_INC_UTILITY
 )
 
 set(BS_BANSHEEENGINE_SRC_RENDERER
-	"Source/BsCamera.cpp"
 	"Source/BsLight.cpp"
 	"Source/BsRenderable.cpp"
 	"Source/BsRenderer.cpp"
@@ -205,7 +200,7 @@ set(BS_BANSHEEENGINE_SRC_RENDERER
 	"Source/BsRenderQueue.cpp"
 	"Source/BsSceneManager.cpp"
 	"Source/BsRendererUtility.cpp"
-	"Source/BsPostProcessSettings.cpp"	
+	"Source/BsStandardPostProcessSettings.cpp"	
 )
 
 set(BS_BANSHEEENGINE_SRC_INPUT

+ 8 - 7
Source/BansheeEngine/Include/BsPrerequisites.h

@@ -179,9 +179,7 @@ namespace BansheeEngine
 	class ProfilerOverlay;
 	class ProfilerOverlayInternal;
 	class DrawHelper;
-	class Camera;
 	class Renderable;
-	class CameraCore;
 	class RenderableCore;
 	class PlainText;
 	class ScriptCode;
@@ -197,13 +195,11 @@ namespace BansheeEngine
 
 	// Components
 	class CRenderable;
-	class CCamera;
 	class CLight;
 	class CAnimation;
 	class CBone;
 
 	typedef GameObjectHandle<CGUIWidget> HGUIWidget;
-	typedef GameObjectHandle<CCamera> HCamera;
 	typedef GameObjectHandle<CRenderable> HRenderable;
 	typedef GameObjectHandle<CAnimation> HAnimation;
 	typedef GameObjectHandle<CBone> HBone;
@@ -217,10 +213,10 @@ namespace BansheeEngine
 	/**	RTTI types. */
 	enum TypeID_Banshee
 	{
-		TID_CCamera = 30000,
+		/* TID_CCamera = 30000, */
 		TID_CRenderable = 30001,
 		TID_SpriteTexture = 30002,
-		TID_Camera = 30003,
+		/* TID_Camera = 30003, */
 		TID_Renderable = 30004,
 		TID_PlainText = 30005,
 		TID_ScriptCode = 30006,
@@ -231,6 +227,11 @@ namespace BansheeEngine
 		TID_Light = 30011,
 		TID_CLight = 30012,
 		TID_GameSettings = 30013,
-		TID_ResourceMapping = 30014
+		TID_ResourceMapping = 30014,
+		TID_StandardPostProcessSettings = 30015,
+		TID_AutoExposureSettings = 30016,
+		TID_TonemappingSettings = 30017,
+		TID_WhiteBalanceSettings = 30018,
+		TID_ColorGradingSettings = 30019
 	};
 }

+ 1 - 46
Source/BansheeEngine/Include/BsSceneManager.h

@@ -11,19 +11,6 @@ namespace BansheeEngine
 	 *  @{
 	 */
 
-	/**	Contains information about a camera managed by the scene manager. */
-	struct SceneCameraData
-	{
-		SceneCameraData() { }
-
-		SceneCameraData(const SPtr<Camera>& camera, const HSceneObject& sceneObject)
-			:camera(camera), sceneObject(sceneObject)
-		{ }
-
-		SPtr<Camera> camera;
-		HSceneObject sceneObject;
-	};
-
 	/**	Contains information about a renderable managed by the scene manager. */
 	struct SceneRenderableData
 	{
@@ -71,39 +58,15 @@ namespace BansheeEngine
 		SceneManager() { }
 		virtual ~SceneManager() {}
 
-		/** Returns all cameras in the scene. */
-		const Map<Camera*, SceneCameraData>& getAllCameras() const { return mCameras; }
-
 		/**	Returns all renderables in the scene. */
 		const Map<Renderable*, SceneRenderableData>& getAllRenderables() const { return mRenderables; }
 
-		/**
-		 * Returns the camera in the scene marked as main. Main camera controls the final render surface that is displayed
-		 * to the user. If there are multiple main cameras, the first one found returned.
-		 */
-		SceneCameraData getMainCamera() const;
-
-		/**
-		 * Sets the render target that the main camera in the scene (if any) will render its view to. This generally means
-		 * the main game window when running standalone, or the Game viewport when running in editor.
-		 */
-		void setMainRenderTarget(const SPtr<RenderTarget>& rt);
-
 		/** Notifies the scene manager that a new renderable was created. */
 		void _registerRenderable(const SPtr<Renderable>& renderable, const HSceneObject& so);
 
 		/**	Notifies the scene manager that a renderable was removed. */
 		void _unregisterRenderable(const SPtr<Renderable>& renderable);
 
-		/**	Notifies the scene manager that a new camera was created. */
-		void _registerCamera(const SPtr<Camera>& camera, const HSceneObject& so);
-
-		/**	Notifies the scene manager that a camera was removed. */
-		void _unregisterCamera(const SPtr<Camera>& camera);
-
-		/**	Notifies the scene manager that a camera either became the main camera, or has stopped being main camera. */
-		void _notifyMainCameraStateChanged(const SPtr<Camera>& camera);
-
 		/**	Notifies the scene manager that a new light was created. */
 		void _registerLight(const SPtr<Light>& light, const HSceneObject& so);
 
@@ -111,7 +74,7 @@ namespace BansheeEngine
 		void _unregisterLight(const SPtr<Light>& light);
 
 		/** @copydoc CoreSceneManager::_updateCoreObjectTransforms */
-		virtual void _updateCoreObjectTransforms() override;
+		void _updateCoreObjectTransforms() override;
 
 		/** @copydoc CoreSceneManager::instance */
 		static SceneManager& instance();
@@ -120,16 +83,8 @@ namespace BansheeEngine
 		static SceneManager* instancePtr();
 
 	private:
-		/**	Callback that is triggered when the main render target size is changed. */
-		void onMainRenderTargetResized();
-
-		Map<Camera*, SceneCameraData> mCameras;
 		Map<Renderable*, SceneRenderableData> mRenderables;
 		Map<Light*, SceneLightData> mLights;
-		Vector<SceneCameraData> mMainCameras;
-		SPtr<RenderTarget> mMainRT;
-
-		HEvent mMainRTResizedConn;
 
 		volatile static InitOnStart DoInitOnStart;
 	};

+ 53 - 12
Source/BansheeEngine/Include/BsPostProcessSettings.h → Source/BansheeEngine/Include/BsStandardPostProcessSettings.h

@@ -3,6 +3,7 @@
 #pragma once
 
 #include "BsPrerequisites.h"
+#include "BsPostProcessSettings.h"
 #include "BsVector3.h"
 
 namespace BansheeEngine
@@ -12,7 +13,7 @@ namespace BansheeEngine
 	 */
 
 	/** Settings that control automatic exposure (eye adaptation) post-process. */
-	struct BS_EXPORT AutoExposureSettings
+	struct BS_EXPORT AutoExposureSettings : public IReflectable
 	{
 		AutoExposureSettings();
 
@@ -73,10 +74,18 @@ namespace BansheeEngine
 		 * automatic exposure changes when the scene brightness decreases. In range [0.01f, 20.0f].
 		 */
 		float eyeAdaptationSpeedDown;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class AutoExposureSettingsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
 	};
 
 	/** Settings that control tonemap post-process. */
-	struct BS_EXPORT TonemappingSettings
+	struct BS_EXPORT TonemappingSettings : public IReflectable
 	{
 		TonemappingSettings();
 
@@ -112,10 +121,18 @@ namespace BansheeEngine
 
 		/** Controls the white point of the filmic curve used for tonemapping. Affects the entire curve. */
 		float filmicCurveLinearWhitePoint;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class TonemappingSettingsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
 	};
 
 	/** Settings that control white balance post-process. */
-	struct BS_EXPORT WhiteBalanceSettings
+	struct BS_EXPORT WhiteBalanceSettings : public IReflectable
 	{
 		WhiteBalanceSettings();
 
@@ -134,10 +151,18 @@ namespace BansheeEngine
 		 * In range [-1.0f, 1.0f].
 		 */
 		float tint;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class WhiteBalanceSettingsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
 	};
 
 	/** Settings that control color grading post-process. */
-	struct BS_EXPORT ColorGradingSettings
+	struct BS_EXPORT ColorGradingSettings : public IReflectable
 	{
 		ColorGradingSettings();
 
@@ -164,12 +189,20 @@ namespace BansheeEngine
 		 * In range [-1.0f, 1.0f].
 		 */
 		Vector3 offset;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class ColorGradingSettingsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
 	};
 
 	/** Settings that control the post-process operations. */
-	struct BS_EXPORT PostProcessSettings
+	struct BS_EXPORT StandardPostProcessSettings : public PostProcessSettings
 	{
-		PostProcessSettings();
+		StandardPostProcessSettings();
 
 		/**
 		 * Determines should automatic exposure be applied to the HDR image. When turned on the average scene brightness
@@ -229,13 +262,21 @@ namespace BansheeEngine
 		 * that curve. If tonemapping is turned off this is the exact value of the gamma curve that will be applied.
 		 */
 		float gamma;
+
+		/** @copydoc PostProcessSettings::_getSyncData */
+		void _getSyncData(UINT8* buffer, UINT32& size) override;
+
+		/** @copydoc PostProcessSettings::_setSyncData */
+		void _setSyncData(UINT8* buffer, UINT32 size) override;
+
+		/************************************************************************/
+		/* 								RTTI		                     		*/
+		/************************************************************************/
+	public:
+		friend class StandardPostProcessSettingsRTTI;
+		static RTTITypeBase* getRTTIStatic();
+		RTTITypeBase* getRTTI() const override;
 	};
 
 	/** @} */
-
-	BS_ALLOW_MEMCPY_SERIALIZATION(AutoExposureSettings);
-	BS_ALLOW_MEMCPY_SERIALIZATION(WhiteBalanceSettings);
-	BS_ALLOW_MEMCPY_SERIALIZATION(ColorGradingSettings);
-	BS_ALLOW_MEMCPY_SERIALIZATION(TonemappingSettings);
-	BS_ALLOW_MEMCPY_SERIALIZATION(PostProcessSettings);
 }

+ 187 - 0
Source/BansheeEngine/Include/BsStandardPostProcessSettingsRTTI.h

@@ -0,0 +1,187 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#pragma once
+
+#include "BsPrerequisites.h"
+#include "BsRTTIType.h"
+#include "BsStandardPostProcessSettings.h"
+
+namespace BansheeEngine
+{
+	/** @cond RTTI */
+	/** @addtogroup RTTI-Impl-Engine
+	 *  @{
+	 */
+
+	class BS_EXPORT AutoExposureSettingsRTTI : public RTTIType <AutoExposureSettings, IReflectable, AutoExposureSettingsRTTI>
+	{
+	private:
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_PLAIN(histogramLog2Min, 0)
+			BS_RTTI_MEMBER_PLAIN(histogramLog2Max, 1)
+			BS_RTTI_MEMBER_PLAIN(histogramPctLow, 2)
+			BS_RTTI_MEMBER_PLAIN(histogramPctHigh, 3)
+			BS_RTTI_MEMBER_PLAIN(minEyeAdaptation, 4)
+			BS_RTTI_MEMBER_PLAIN(maxEyeAdaptation, 5)
+			BS_RTTI_MEMBER_PLAIN(eyeAdaptationSpeedUp, 6)
+			BS_RTTI_MEMBER_PLAIN(eyeAdaptationSpeedDown, 7)
+		BS_END_RTTI_MEMBERS
+
+	public:
+		AutoExposureSettingsRTTI()
+			:mInitMembers(this)
+		{ }
+
+		const String& getRTTIName() override
+		{
+			static String name = "AutoExposureSettings";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_AutoExposureSettings;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return bs_shared_ptr_new<AutoExposureSettings>();
+		}
+	};
+
+	class BS_EXPORT TonemappingSettingsRTTI : public RTTIType <TonemappingSettings, IReflectable, TonemappingSettingsRTTI>
+	{
+	private:
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_PLAIN(filmicCurveShoulderStrength, 0)
+			BS_RTTI_MEMBER_PLAIN(filmicCurveLinearStrength, 1)
+			BS_RTTI_MEMBER_PLAIN(filmicCurveLinearAngle, 2)
+			BS_RTTI_MEMBER_PLAIN(filmicCurveToeStrength, 3)
+			BS_RTTI_MEMBER_PLAIN(filmicCurveToeNumerator, 4)
+			BS_RTTI_MEMBER_PLAIN(filmicCurveToeDenominator, 5)
+			BS_RTTI_MEMBER_PLAIN(filmicCurveLinearWhitePoint, 6)
+		BS_END_RTTI_MEMBERS
+
+	public:
+		TonemappingSettingsRTTI()
+			:mInitMembers(this)
+		{ }
+
+		const String& getRTTIName() override
+		{
+			static String name = "TonemappingSettings";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_TonemappingSettings;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return bs_shared_ptr_new<TonemappingSettings>();
+		}
+	};
+
+	class BS_EXPORT WhiteBalanceSettingsRTTI : public RTTIType <WhiteBalanceSettings, IReflectable, WhiteBalanceSettingsRTTI>
+	{
+	private:
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_PLAIN(temperature, 0)
+			BS_RTTI_MEMBER_PLAIN(tint, 1)
+		BS_END_RTTI_MEMBERS
+
+	public:
+		WhiteBalanceSettingsRTTI()
+			:mInitMembers(this)
+		{ }
+
+		const String& getRTTIName() override
+		{
+			static String name = "WhiteBalanceSettings";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_WhiteBalanceSettings;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return bs_shared_ptr_new<WhiteBalanceSettings>();
+		}
+	};
+
+	class BS_EXPORT ColorGradingSettingsRTTI : public RTTIType <ColorGradingSettings, IReflectable, ColorGradingSettingsRTTI>
+	{
+	private:
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_PLAIN(saturation, 0)
+			BS_RTTI_MEMBER_PLAIN(contrast, 1)
+			BS_RTTI_MEMBER_PLAIN(gain, 2)
+			BS_RTTI_MEMBER_PLAIN(offset, 3)
+		BS_END_RTTI_MEMBERS
+
+	public:
+		ColorGradingSettingsRTTI()
+			:mInitMembers(this)
+		{ }
+
+		const String& getRTTIName() override
+		{
+			static String name = "ColorGradingSettings";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_ColorGradingSettings;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return bs_shared_ptr_new<ColorGradingSettings>();
+		}
+	};
+
+	class BS_EXPORT StandardPostProcessSettingsRTTI : public RTTIType <StandardPostProcessSettings, PostProcessSettings, StandardPostProcessSettingsRTTI>
+	{
+	private:
+		BS_BEGIN_RTTI_MEMBERS
+			BS_RTTI_MEMBER_PLAIN(enableAutoExposure, 0)
+			BS_RTTI_MEMBER_REFL(autoExposure, 1)
+			BS_RTTI_MEMBER_PLAIN(enableTonemapping, 2)
+			BS_RTTI_MEMBER_REFL(tonemapping, 3)
+			BS_RTTI_MEMBER_REFL(whiteBalance, 4)
+			BS_RTTI_MEMBER_REFL(colorGrading, 5)
+			BS_RTTI_MEMBER_PLAIN(exposureScale, 6)
+			BS_RTTI_MEMBER_PLAIN(gamma, 7)
+		BS_END_RTTI_MEMBERS
+			
+	public:
+		StandardPostProcessSettingsRTTI()
+			:mInitMembers(this)
+		{ }
+
+		const String& getRTTIName() override
+		{
+			static String name = "StandardPostProcessSettings";
+			return name;
+		}
+
+		UINT32 getRTTIId() override
+		{
+			return TID_StandardPostProcessSettings;
+		}
+
+		SPtr<IReflectable> newRTTIObject() override
+		{
+			return bs_shared_ptr_new<StandardPostProcessSettings>();
+		}
+	};
+
+	/** @} */
+	/** @endcond */
+}

+ 0 - 29
Source/BansheeEngine/Source/BsPostProcessSettings.cpp

@@ -1,29 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsPostProcessSettings.h"
-
-namespace BansheeEngine
-{
-	AutoExposureSettings::AutoExposureSettings()
-		: histogramLog2Min(-8.0f), histogramLog2Max(4.0f), histogramPctLow(0.8f), histogramPctHigh(0.985f)
-		, minEyeAdaptation(0.3f), maxEyeAdaptation(2.0f), eyeAdaptationSpeedUp(3.0f), eyeAdaptationSpeedDown(3.0f)
-	{ }
-
-	TonemappingSettings::TonemappingSettings()
-		: filmicCurveShoulderStrength(0.15f), filmicCurveLinearStrength(0.5f), filmicCurveLinearAngle(0.1f)
-		, filmicCurveToeStrength(0.2f), filmicCurveToeNumerator(0.02f), filmicCurveToeDenominator(0.3f)
-		, filmicCurveLinearWhitePoint(11.2f)
-	{ }
-
-	WhiteBalanceSettings::WhiteBalanceSettings()
-		: temperature(6500.0f), tint(0.0f)
-	{ }
-
-	ColorGradingSettings::ColorGradingSettings()
-		: saturation(Vector3::ONE), contrast(Vector3::ONE), gain(Vector3::ONE), offset(Vector3::ZERO)
-	{ }
-
-	PostProcessSettings::PostProcessSettings()
-		: enableAutoExposure(true), enableTonemapping(true), exposureScale(0.0f), gamma(2.2f)
-	{ }
-}

+ 0 - 89
Source/BansheeEngine/Source/BsSceneManager.cpp

@@ -5,7 +5,6 @@
 #include "BsRenderable.h"
 #include "BsCamera.h"
 #include "BsLight.h"
-#include "BsRenderTarget.h"
 
 namespace BansheeEngine
 {
@@ -21,51 +20,6 @@ namespace BansheeEngine
 		mRenderables.erase(renderable.get());
 	}
 
-	void SceneManager::_registerCamera(const SPtr<Camera>& camera, const HSceneObject& so)
-	{
-		mCameras[camera.get()] = SceneCameraData(camera, so);
-	}
-
-	void SceneManager::_unregisterCamera(const SPtr<Camera>& camera)
-	{
-		mCameras.erase(camera.get());
-
-		auto iterFind = std::find_if(mMainCameras.begin(), mMainCameras.end(), 
-			[&](const SceneCameraData& x)
-		{
-			return x.camera == camera;
-		});
-
-		if (iterFind != mMainCameras.end())
-			mMainCameras.erase(iterFind);
-	}
-
-	void SceneManager::_notifyMainCameraStateChanged(const SPtr<Camera>& camera)
-	{
-		auto iterFind = std::find_if(mMainCameras.begin(), mMainCameras.end(),
-			[&](const SceneCameraData& entry)
-		{
-			return entry.camera == camera;
-		});
-
-		SPtr<Viewport> viewport = camera->getViewport();
-		if (camera->isMain())
-		{
-			if (iterFind == mMainCameras.end())
-				mMainCameras.push_back(mCameras[camera.get()]);
-
-			viewport->setTarget(mMainRT);
-		}
-		else
-		{
-			if (iterFind != mMainCameras.end())
-				mMainCameras.erase(iterFind);
-
-			if (viewport->getTarget() == mMainRT)
-				viewport->setTarget(nullptr);
-		}
-	}
-
 	void SceneManager::_registerLight(const SPtr<Light>& light, const HSceneObject& so)
 	{
 		mLights[light.get()] = SceneLightData(light, so);
@@ -130,49 +84,6 @@ namespace BansheeEngine
 		}
 	}
 
-	SceneCameraData SceneManager::getMainCamera() const
-	{
-		if (mMainCameras.size() > 0)
-			return mMainCameras[0];
-
-		return SceneCameraData();
-	}
-
-	void SceneManager::setMainRenderTarget(const SPtr<RenderTarget>& rt)
-	{
-		if (mMainRT == rt)
-			return;
-
-		mMainRTResizedConn.disconnect();
-
-		if (rt != nullptr)
-			mMainRTResizedConn = rt->onResized.connect(std::bind(&SceneManager::onMainRenderTargetResized, this));
-		
-		mMainRT = rt;
-
-		float aspect = 1.0f;
-		if (rt != nullptr)
-		{
-			auto& rtProps = rt->getProperties();
-			aspect = rtProps.getWidth() / (float)rtProps.getHeight();
-		}
-
-		for (auto& entry : mMainCameras)
-		{
-			entry.camera->getViewport()->setTarget(rt);
-			entry.camera->setAspectRatio(aspect);
-		}
-	}
-
-	void SceneManager::onMainRenderTargetResized()
-	{
-		auto& rtProps = mMainRT->getProperties();
-		float aspect = rtProps.getWidth() / (float)rtProps.getHeight();
-
-		for (auto& entry : mMainCameras)
-			entry.camera->setAspectRatio(aspect);
-	}
-
 	SceneManager& SceneManager::instance()
 	{
 		return static_cast<SceneManager&>(CoreSceneManager::instance());

+ 193 - 0
Source/BansheeEngine/Source/BsStandardPostProcessSettings.cpp

@@ -0,0 +1,193 @@
+//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
+//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
+#include "BsStandardPostProcessSettings.h"
+#include "BsBinarySerializer.h"
+#include "BsStandardPostProcessSettingsRTTI.h"
+
+namespace BansheeEngine
+{
+	AutoExposureSettings::AutoExposureSettings()
+		: histogramLog2Min(-8.0f), histogramLog2Max(4.0f), histogramPctLow(0.8f), histogramPctHigh(0.985f)
+		, minEyeAdaptation(0.3f), maxEyeAdaptation(2.0f), eyeAdaptationSpeedUp(3.0f), eyeAdaptationSpeedDown(3.0f)
+	{ }
+
+	RTTITypeBase* AutoExposureSettings::getRTTIStatic()
+	{
+		return AutoExposureSettingsRTTI::instance();
+	}
+
+	RTTITypeBase* AutoExposureSettings::getRTTI() const
+	{
+		return AutoExposureSettings::getRTTIStatic();
+	}
+
+	TonemappingSettings::TonemappingSettings()
+		: filmicCurveShoulderStrength(0.15f), filmicCurveLinearStrength(0.5f), filmicCurveLinearAngle(0.1f)
+		, filmicCurveToeStrength(0.2f), filmicCurveToeNumerator(0.02f), filmicCurveToeDenominator(0.3f)
+		, filmicCurveLinearWhitePoint(11.2f)
+	{ }
+
+	RTTITypeBase* TonemappingSettings::getRTTIStatic()
+	{
+		return TonemappingSettingsRTTI::instance();
+	}
+
+	RTTITypeBase* TonemappingSettings::getRTTI() const
+	{
+		return TonemappingSettings::getRTTIStatic();
+	}
+
+	WhiteBalanceSettings::WhiteBalanceSettings()
+		: temperature(6500.0f), tint(0.0f)
+	{ }
+
+	RTTITypeBase* WhiteBalanceSettings::getRTTIStatic()
+	{
+		return WhiteBalanceSettingsRTTI::instance();
+	}
+
+	RTTITypeBase* WhiteBalanceSettings::getRTTI() const
+	{
+		return WhiteBalanceSettings::getRTTIStatic();
+	}
+
+	ColorGradingSettings::ColorGradingSettings()
+		: saturation(Vector3::ONE), contrast(Vector3::ONE), gain(Vector3::ONE), offset(Vector3::ZERO)
+	{ }
+
+	RTTITypeBase* ColorGradingSettings::getRTTIStatic()
+	{
+		return ColorGradingSettingsRTTI::instance();
+	}
+
+	RTTITypeBase* ColorGradingSettings::getRTTI() const
+	{
+		return ColorGradingSettings::getRTTIStatic();
+	}
+
+	StandardPostProcessSettings::StandardPostProcessSettings()
+		: enableAutoExposure(true), enableTonemapping(true), exposureScale(0.0f), gamma(2.2f)
+	{ }
+
+	RTTITypeBase* StandardPostProcessSettings::getRTTIStatic()
+	{
+		return StandardPostProcessSettingsRTTI::instance();
+	}
+
+	RTTITypeBase* StandardPostProcessSettings::getRTTI() const
+	{
+		return StandardPostProcessSettings::getRTTIStatic();
+	}
+
+	void StandardPostProcessSettings::_getSyncData(UINT8* buffer, UINT32& size)
+	{
+		UINT32 bufferSize = 0;
+		bufferSize += rttiGetElemSize(enableAutoExposure);
+		bufferSize += rttiGetElemSize(enableTonemapping);
+		bufferSize += rttiGetElemSize(exposureScale);
+		bufferSize += rttiGetElemSize(gamma);
+
+		bufferSize += rttiGetElemSize(autoExposure.histogramLog2Min);
+		bufferSize += rttiGetElemSize(autoExposure.histogramLog2Max);
+		bufferSize += rttiGetElemSize(autoExposure.histogramPctLow);
+		bufferSize += rttiGetElemSize(autoExposure.histogramPctHigh);
+		bufferSize += rttiGetElemSize(autoExposure.minEyeAdaptation);
+		bufferSize += rttiGetElemSize(autoExposure.maxEyeAdaptation);
+		bufferSize += rttiGetElemSize(autoExposure.eyeAdaptationSpeedUp);
+		bufferSize += rttiGetElemSize(autoExposure.eyeAdaptationSpeedDown);
+
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveShoulderStrength);
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveLinearStrength);
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveLinearAngle);
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveToeStrength);
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveToeNumerator);
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveToeDenominator);
+		bufferSize += rttiGetElemSize(tonemapping.filmicCurveLinearWhitePoint);
+
+		bufferSize += rttiGetElemSize(whiteBalance.temperature);
+		bufferSize += rttiGetElemSize(whiteBalance.tint);
+
+		bufferSize += rttiGetElemSize(colorGrading.saturation);
+		bufferSize += rttiGetElemSize(colorGrading.contrast);
+		bufferSize += rttiGetElemSize(colorGrading.gain);
+		bufferSize += rttiGetElemSize(colorGrading.offset);
+
+		if (buffer == nullptr)
+		{
+			size = bufferSize;
+			return;
+		}
+		
+		if(bufferSize != size)
+		{
+			LOGERR("Invalid buffer size");
+			return;
+		}
+
+		char* writeDst = (char*)buffer;
+		writeDst = rttiWriteElem(enableAutoExposure, writeDst);
+		writeDst = rttiWriteElem(enableTonemapping, writeDst);
+		writeDst = rttiWriteElem(exposureScale, writeDst);
+		writeDst = rttiWriteElem(gamma, writeDst);
+
+		writeDst = rttiWriteElem(autoExposure.histogramLog2Min, writeDst);
+		writeDst = rttiWriteElem(autoExposure.histogramLog2Max, writeDst);
+		writeDst = rttiWriteElem(autoExposure.histogramPctLow, writeDst);
+		writeDst = rttiWriteElem(autoExposure.histogramPctHigh, writeDst);
+		writeDst = rttiWriteElem(autoExposure.minEyeAdaptation, writeDst);
+		writeDst = rttiWriteElem(autoExposure.maxEyeAdaptation, writeDst);
+		writeDst = rttiWriteElem(autoExposure.eyeAdaptationSpeedUp, writeDst);
+		writeDst = rttiWriteElem(autoExposure.eyeAdaptationSpeedDown, writeDst);
+
+		writeDst = rttiWriteElem(tonemapping.filmicCurveShoulderStrength, writeDst);
+		writeDst = rttiWriteElem(tonemapping.filmicCurveLinearStrength, writeDst);
+		writeDst = rttiWriteElem(tonemapping.filmicCurveLinearAngle, writeDst);
+		writeDst = rttiWriteElem(tonemapping.filmicCurveToeStrength, writeDst);
+		writeDst = rttiWriteElem(tonemapping.filmicCurveToeNumerator, writeDst);
+		writeDst = rttiWriteElem(tonemapping.filmicCurveToeDenominator, writeDst);
+		writeDst = rttiWriteElem(tonemapping.filmicCurveLinearWhitePoint, writeDst);
+
+		writeDst = rttiWriteElem(whiteBalance.temperature, writeDst);
+		writeDst = rttiWriteElem(whiteBalance.tint, writeDst);
+
+		writeDst = rttiWriteElem(colorGrading.saturation, writeDst);
+		writeDst = rttiWriteElem(colorGrading.contrast, writeDst);
+		writeDst = rttiWriteElem(colorGrading.gain, writeDst);
+		writeDst = rttiWriteElem(colorGrading.offset, writeDst);
+	}
+
+	void StandardPostProcessSettings::_setSyncData(UINT8* buffer, UINT32 size)
+	{
+		char* readSource = (char*)buffer;
+
+		readSource = rttiReadElem(enableAutoExposure, readSource);
+		readSource = rttiReadElem(enableTonemapping, readSource);
+		readSource = rttiReadElem(exposureScale, readSource);
+		readSource = rttiReadElem(gamma, readSource);
+
+		readSource = rttiReadElem(autoExposure.histogramLog2Min, readSource);
+		readSource = rttiReadElem(autoExposure.histogramLog2Max, readSource);
+		readSource = rttiReadElem(autoExposure.histogramPctLow, readSource);
+		readSource = rttiReadElem(autoExposure.histogramPctHigh, readSource);
+		readSource = rttiReadElem(autoExposure.minEyeAdaptation, readSource);
+		readSource = rttiReadElem(autoExposure.maxEyeAdaptation, readSource);
+		readSource = rttiReadElem(autoExposure.eyeAdaptationSpeedUp, readSource);
+		readSource = rttiReadElem(autoExposure.eyeAdaptationSpeedDown, readSource);
+
+		readSource = rttiReadElem(tonemapping.filmicCurveShoulderStrength, readSource);
+		readSource = rttiReadElem(tonemapping.filmicCurveLinearStrength, readSource);
+		readSource = rttiReadElem(tonemapping.filmicCurveLinearAngle, readSource);
+		readSource = rttiReadElem(tonemapping.filmicCurveToeStrength, readSource);
+		readSource = rttiReadElem(tonemapping.filmicCurveToeNumerator, readSource);
+		readSource = rttiReadElem(tonemapping.filmicCurveToeDenominator, readSource);
+		readSource = rttiReadElem(tonemapping.filmicCurveLinearWhitePoint, readSource);
+
+		readSource = rttiReadElem(whiteBalance.temperature, readSource);
+		readSource = rttiReadElem(whiteBalance.tint, readSource);
+
+		readSource = rttiReadElem(colorGrading.saturation, readSource);
+		readSource = rttiReadElem(colorGrading.contrast, readSource);
+		readSource = rttiReadElem(colorGrading.gain, readSource);
+		readSource = rttiReadElem(colorGrading.offset, readSource);
+	}
+}

+ 4 - 9
Source/MBansheeEngine/Interop/NativeCamera.cs

@@ -133,13 +133,8 @@ namespace BansheeEngine
 
         internal PostProcessSettings PostProcess
         {
-            get
-            {
-                PostProcessSettings value;
-                Internal_GetPostProcessSettings(mCachedPtr, out value);
-                return value;
-            }
-            set { Internal_SetPostProcessSettings(mCachedPtr, ref value); }
+            get { return Internal_GetPostProcessSettings(mCachedPtr); }
+            set { Internal_SetPostProcessSettings(mCachedPtr, value); }
         }
 
         internal ulong layers
@@ -434,9 +429,9 @@ namespace BansheeEngine
         private static extern void Internal_SetHDR(IntPtr instance, bool value);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_GetPostProcessSettings(IntPtr instance, out PostProcessSettings value);
+        private static extern PostProcessSettings Internal_GetPostProcessSettings(IntPtr instance);
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_SetPostProcessSettings(IntPtr instance, ref PostProcessSettings value);
+        private static extern void Internal_SetPostProcessSettings(IntPtr instance, PostProcessSettings value);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         private static extern ulong Internal_GetLayers(IntPtr instance);

+ 12 - 15
Source/MBansheeEngine/Rendering/PostProcessSettings.cs

@@ -9,8 +9,8 @@ namespace BansheeEngine
     /// <summary>
     /// Settings that control automatic exposure (eye adaptation) post-process.
     /// </summary>
-    [StructLayout(LayoutKind.Sequential), SerializeObject]
-    public struct AutoExposureSettings // Note: Must match C++ struct AutoExposureSettings
+    [SerializeObject]
+    public class AutoExposureSettings
     {
         /// <summary>
         /// Determines minimum luminance value in the eye adaptation histogram. The histogram is used for calculating the
@@ -74,8 +74,8 @@ namespace BansheeEngine
     /// <summary>
     /// Settings that control tonemap post-process.
     /// </summary>
-    [StructLayout(LayoutKind.Sequential), SerializeObject]
-    public struct TonemappingSettings // Note: Must match C++ struct TonemappingSettings
+    [SerializeObject]
+    public class TonemappingSettings
     {
         /// <summary>
         /// Controls the shoulder (upper non-linear) section of the filmic curve used for tonemapping. Mostly affects bright
@@ -120,8 +120,8 @@ namespace BansheeEngine
     /// <summary>
     /// Settings that control white balance post-process.
     /// </summary>
-    [StructLayout(LayoutKind.Sequential), SerializeObject]
-    public struct WhiteBalanceSettings // Note: Must match C++ struct WhiteBalanceSettings
+    [SerializeObject]
+    public class WhiteBalanceSettings
     {
         /// <summary>
         /// Temperature used for white balancing, in Kelvins.
@@ -143,8 +143,8 @@ namespace BansheeEngine
     /// <summary>
     /// Settings that control color grading post-process.
     /// </summary>
-    [StructLayout(LayoutKind.Sequential), SerializeObject]
-    public struct ColorGradingSettings // Note: Must match C++ struct ColorGradingSettings
+    [SerializeObject]
+    public class ColorGradingSettings
     {
         /// <summary>
         /// Saturation to be applied during color grading. Larger values increase vibrancy of the image. 
@@ -174,8 +174,8 @@ namespace BansheeEngine
     /// <summary>
     /// Settings that control the post-process operations.
     /// </summary>
-    [StructLayout(LayoutKind.Sequential), SerializeObject]
-    public struct PostProcessSettings
+    [SerializeObject]
+    public class PostProcessSettings
     {
         /// <summary>
         /// Determines should automatic exposure be applied to the HDR image. When turned on the average scene brightness
@@ -240,13 +240,10 @@ namespace BansheeEngine
         /// <returns>New instance of post process settings.</returns>
         public static PostProcessSettings CreateDefault()
         {
-            PostProcessSettings output;
-            Internal_CreateDefault(out output);
-
-            return output;
+            return Internal_CreateDefault();
         }
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        private static extern void Internal_CreateDefault(out PostProcessSettings value);
+        private static extern PostProcessSettings Internal_CreateDefault();
     }
 }

+ 2 - 2
Source/RenderBeast/Include/BsPostProcessing.h

@@ -6,7 +6,7 @@
 #include "BsRendererMaterial.h"
 #include "BsParamBlocks.h"
 #include "BsRenderTexturePool.h"
-#include "BsPostProcessSettings.h"
+#include "BsStandardPostProcessSettings.h"
 
 namespace BansheeEngine
 {
@@ -17,7 +17,7 @@ namespace BansheeEngine
 	/** Contains per-camera data used by post process effects. */
 	struct PostProcessInfo
 	{
-		PostProcessSettings settings;
+		SPtr<StandardPostProcessSettings> settings;
 		bool settingDirty = true;
 
 		SPtr<PooledRenderTexture> downsampledSceneTex;

+ 3 - 0
Source/RenderBeast/Include/BsRenderBeast.h

@@ -89,6 +89,9 @@ namespace BansheeEngine
 		/** @copydoc Renderer::destroy */
 		void destroy() override;
 
+		/** @copydoc Renderer::createPostProcessSettings */
+		SPtr<PostProcessSettings> createPostProcessSettings() const override;
+
 	private:
 		/** @copydoc Renderer::notifyCameraAdded */
 		void notifyCameraAdded(const CameraCore* camera) override;

+ 27 - 23
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -139,7 +139,7 @@ namespace BansheeEngine
 
 	Vector2 EyeAdaptHistogramMat::getHistogramScaleOffset(const PostProcessInfo& ppInfo)
 	{
-		const PostProcessSettings& settings = ppInfo.settings;
+		const StandardPostProcessSettings& settings = *ppInfo.settings;
 
 		float diff = settings.autoExposure.histogramLog2Max - settings.autoExposure.histogramLog2Min;
 		float scale = 1.0f / diff;
@@ -239,7 +239,7 @@ namespace BansheeEngine
 
 		Vector2 histogramScaleAndOffset = EyeAdaptHistogramMat::getHistogramScaleOffset(ppInfo);
 
-		const PostProcessSettings& settings = ppInfo.settings;
+		const StandardPostProcessSettings& settings = *ppInfo.settings;
 
 		Vector4 eyeAdaptationParams[3];
 		eyeAdaptationParams[0].x = histogramScaleAndOffset.x;
@@ -289,36 +289,38 @@ namespace BansheeEngine
 
 	void CreateTonemapLUTMat::execute(PostProcessInfo& ppInfo)
 	{
+		const StandardPostProcessSettings& settings = *ppInfo.settings;
+
 		// Set parameters
-		mParams.gGammaAdjustment.set(2.2f / ppInfo.settings.gamma);
+		mParams.gGammaAdjustment.set(2.2f / settings.gamma);
 
 		// Note: Assuming sRGB (PC monitor) for now, change to Rec.709 when running on console (value 1), or to raw 2.2
 		// gamma when running on Mac (value 2)
 		mParams.gGammaCorrectionType.set(0);
 
 		Vector4 tonemapParams[2];
-		tonemapParams[0].x = ppInfo.settings.tonemapping.filmicCurveShoulderStrength;
-		tonemapParams[0].y = ppInfo.settings.tonemapping.filmicCurveLinearStrength;
-		tonemapParams[0].z = ppInfo.settings.tonemapping.filmicCurveLinearAngle;
-		tonemapParams[0].w = ppInfo.settings.tonemapping.filmicCurveToeStrength;
-
-		tonemapParams[1].x = ppInfo.settings.tonemapping.filmicCurveToeNumerator;
-		tonemapParams[1].y = ppInfo.settings.tonemapping.filmicCurveToeDenominator;
-		tonemapParams[1].z = ppInfo.settings.tonemapping.filmicCurveLinearWhitePoint;
+		tonemapParams[0].x = settings.tonemapping.filmicCurveShoulderStrength;
+		tonemapParams[0].y = settings.tonemapping.filmicCurveLinearStrength;
+		tonemapParams[0].z = settings.tonemapping.filmicCurveLinearAngle;
+		tonemapParams[0].w = settings.tonemapping.filmicCurveToeStrength;
+
+		tonemapParams[1].x = settings.tonemapping.filmicCurveToeNumerator;
+		tonemapParams[1].y = settings.tonemapping.filmicCurveToeDenominator;
+		tonemapParams[1].z = settings.tonemapping.filmicCurveLinearWhitePoint;
 		tonemapParams[1].w = 0.0f; // Unused
 
 		mParams.gTonemapParams.set(tonemapParams[0], 0);
 		mParams.gTonemapParams.set(tonemapParams[1], 1);
 
 		// Set color grading params
-		mParams.gSaturation.set(ppInfo.settings.colorGrading.saturation);
-		mParams.gContrast.set(ppInfo.settings.colorGrading.contrast);
-		mParams.gGain.set(ppInfo.settings.colorGrading.gain);
-		mParams.gOffset.set(ppInfo.settings.colorGrading.offset);
+		mParams.gSaturation.set(settings.colorGrading.saturation);
+		mParams.gContrast.set(settings.colorGrading.contrast);
+		mParams.gGain.set(settings.colorGrading.gain);
+		mParams.gOffset.set(settings.colorGrading.offset);
 
 		// Set white balance params
-		mWhiteBalanceParams.gWhiteTemp.set(ppInfo.settings.whiteBalance.temperature);
-		mWhiteBalanceParams.gWhiteOffset.set(ppInfo.settings.whiteBalance.tint);
+		mWhiteBalanceParams.gWhiteTemp.set(settings.whiteBalance.temperature);
+		mWhiteBalanceParams.gWhiteOffset.set(settings.whiteBalance.tint);
 
 		// Set output
 		POOLED_RENDER_TEXTURE_DESC outputDesc = POOLED_RENDER_TEXTURE_DESC::create3D(PF_B8G8R8X8, 
@@ -370,8 +372,8 @@ namespace BansheeEngine
 	void TonemappingMat<GammaOnly, AutoExposure>::execute(const SPtr<RenderTextureCore>& sceneColor, const SPtr<ViewportCore>& outputViewport,
 		PostProcessInfo& ppInfo)
 	{
-		mParams.gRawGamma.set(1.0f / ppInfo.settings.gamma);
-		mParams.gManualExposureScale.set(Math::pow(2.0f, ppInfo.settings.exposureScale));
+		mParams.gRawGamma.set(1.0f / ppInfo.settings->gamma);
+		mParams.gManualExposureScale.set(Math::pow(2.0f, ppInfo.settings->exposureScale));
 
 		// Set parameters
 		SPtr<TextureCore> colorTexture = sceneColor->getBindableColorTexture();
@@ -409,10 +411,12 @@ namespace BansheeEngine
 	void PostProcessing::postProcess(const SPtr<RenderTextureCore>& sceneColor, const CameraCore* camera, 
 		PostProcessInfo& ppInfo, float frameDelta)
 	{
+		const StandardPostProcessSettings& settings = *ppInfo.settings;
+
 		SPtr<ViewportCore> outputViewport = camera->getViewport();
 		bool hdr = camera->getFlags().isSet(CameraFlag::HDR);
 
-		if(hdr && ppInfo.settings.enableAutoExposure)
+		if(hdr && settings.enableAutoExposure)
 		{
 			mDownsample.execute(sceneColor, ppInfo);
 			mEyeAdaptHistogram.execute(ppInfo);
@@ -425,19 +429,19 @@ namespace BansheeEngine
 			mEyeAdaptHistogramReduce.release(ppInfo);
 		}
 
-		if (hdr && ppInfo.settings.enableTonemapping)
+		if (hdr && settings.enableTonemapping)
 		{
 			if (ppInfo.settingDirty) // Rebuild LUT if PP settings changed
 				mCreateLUT.execute(ppInfo);
 
-			if (ppInfo.settings.enableAutoExposure)
+			if (settings.enableAutoExposure)
 				mTonemapping_AE.execute(sceneColor, outputViewport, ppInfo);
 			else
 				mTonemapping.execute(sceneColor, outputViewport, ppInfo);
 		}
 		else
 		{
-			if (hdr && ppInfo.settings.enableAutoExposure)
+			if (hdr && settings.enableAutoExposure)
 				mTonemapping_AE_GO.execute(sceneColor, outputViewport, ppInfo);
 			else
 				mTonemapping_GO.execute(sceneColor, outputViewport, ppInfo);

+ 5 - 0
Source/RenderBeast/Source/BsRenderBeast.cpp

@@ -392,6 +392,11 @@ namespace BansheeEngine
 		updateCameraData(camera, true);
 	}
 
+	SPtr<PostProcessSettings> RenderBeast::createPostProcessSettings() const
+	{
+		return bs_shared_ptr_new<StandardPostProcessSettings>();
+	}
+
 	void RenderBeast::updateCameraData(const CameraCore* camera, bool forceRemove)
 	{
 		SPtr<RenderTargetCore> renderTarget = camera->getViewport()->getTarget();

+ 9 - 1
Source/RenderBeast/Source/BsRendererCamera.cpp

@@ -33,7 +33,15 @@ namespace BansheeEngine
 
 	void RendererCamera::updatePP()
 	{
-		mPostProcessInfo.settings = mCamera->getPostProcessSettings();
+		if (mPostProcessInfo.settings == nullptr)
+			mPostProcessInfo.settings = bs_shared_ptr_new<StandardPostProcessSettings>();
+
+		SPtr<StandardPostProcessSettings> ppSettings = std::static_pointer_cast<StandardPostProcessSettings>(mCamera->getPostProcessSettings());
+		if (ppSettings != nullptr)
+			*mPostProcessInfo.settings = *ppSettings;
+		else
+			*mPostProcessInfo.settings = StandardPostProcessSettings();
+
 		mPostProcessInfo.settingDirty = true;
 	}
 

+ 2 - 2
Source/SBansheeEngine/Include/BsScriptCamera.h

@@ -90,8 +90,8 @@ namespace BansheeEngine
 		static bool internal_GetHDR(ScriptCamera* instance);
 		static void internal_SetHDR(ScriptCamera* instance, bool value);
 
-		static void internal_GetPostProcessSettings(ScriptCamera* instance, PostProcessSettings* value);
-		static void internal_SetPostProcessSettings(ScriptCamera* instance, PostProcessSettings* value);
+		static MonoObject* internal_GetPostProcessSettings(ScriptCamera* instance);
+		static void internal_SetPostProcessSettings(ScriptCamera* instance, MonoObject* value);
 
 		static UINT64 internal_GetLayers(ScriptCamera* instance);
 		static void internal_SetLayers(ScriptCamera* instance, UINT64 value);

+ 123 - 2
Source/SBansheeEngine/Include/BsScriptPostProcessSettings.h

@@ -4,27 +4,148 @@
 
 #include "BsScriptEnginePrerequisites.h"
 #include "BsScriptObject.h"
-#include "BsPostProcessSettings.h"
 
 namespace BansheeEngine
 {
+	struct StandardPostProcessSettings;
+	struct AutoExposureSettings;
+	struct TonemappingSettings;
+	struct WhiteBalanceSettings;
+	struct ColorGradingSettings;
+
 	/** @addtogroup ScriptInteropEngine
 	 *  @{
 	 */
 
+	/**	Interop class between C++ & CLR for AutoExposureSettings. */
+	class BS_SCR_BE_EXPORT ScriptAutoExposureSettings : public ScriptObject<ScriptAutoExposureSettings>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "AutoExposureSettings")
+
+		/** Converts managed object its native counterpart. */
+		static SPtr<AutoExposureSettings> toNative(MonoObject* object);
+
+		/** Converts native object to its managed counterpart. */
+		static MonoObject* toManaged(AutoExposureSettings& value);
+
+	private:
+		ScriptAutoExposureSettings(MonoObject* instance);
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static MonoField* sHistogramLog2Min;
+		static MonoField* sHistogramLog2Max;
+		static MonoField* sHistogramPctLow;
+		static MonoField* sHistogramPctHigh;
+		static MonoField* sMinEyeAdaptation;
+		static MonoField* sMaxEyeAdaptation;
+		static MonoField* sEyeAdaptationSpeedUp;
+		static MonoField* sEyeAdaptationSpeedDown;
+	};
+
+	/**	Interop class between C++ & CLR for TonemappingSettings. */
+	class BS_SCR_BE_EXPORT ScriptTonemappingSettings : public ScriptObject<ScriptTonemappingSettings>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "TonemappingSettings")
+
+		/** Converts managed object its native counterpart. */
+		static SPtr<TonemappingSettings> toNative(MonoObject* object);
+
+		/** Converts native object to its managed counterpart. */
+		static MonoObject* toManaged(TonemappingSettings& value);
+
+	private:
+		ScriptTonemappingSettings(MonoObject* instance);
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static MonoField* sFilmicCurveShoulderStrength;
+		static MonoField* sFilmicCurveLinearStrength;
+		static MonoField* sFilmicCurveLinearAngle;
+		static MonoField* sFilmicCurveToeStrength;
+		static MonoField* sFilmicCurveToeNumerator;
+		static MonoField* sFilmicCurveToeDenominator;
+		static MonoField* sFilmicCurveLinearWhitePoint;
+	};
+
+	/**	Interop class between C++ & CLR for WhiteBalanceSettings. */
+	class BS_SCR_BE_EXPORT ScriptWhiteBalanceSettings : public ScriptObject<ScriptWhiteBalanceSettings>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "WhiteBalanceSettings")
+
+		/** Converts managed object its native counterpart. */
+		static SPtr<WhiteBalanceSettings> toNative(MonoObject* object);
+
+		/** Converts native object to its managed counterpart. */
+		static MonoObject* toManaged(WhiteBalanceSettings& value);
+
+	private:
+		ScriptWhiteBalanceSettings(MonoObject* instance);
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static MonoField* sTemperature;
+		static MonoField* sTint;
+	};
+
+	/**	Interop class between C++ & CLR for ColorGradingSettings. */
+	class BS_SCR_BE_EXPORT ScriptColorGradingSettings : public ScriptObject<ScriptColorGradingSettings>
+	{
+	public:
+		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "ColorGradingSettings")
+
+		/** Converts managed object its native counterpart. */
+		static SPtr<ColorGradingSettings> toNative(MonoObject* object);
+
+		/** Converts native object to its managed counterpart. */
+		static MonoObject* toManaged(ColorGradingSettings& value);
+
+	private:
+		ScriptColorGradingSettings(MonoObject* instance);
+
+		/************************************************************************/
+		/* 								CLR HOOKS						   		*/
+		/************************************************************************/
+		static MonoField* sSaturation;
+		static MonoField* sContrast;
+		static MonoField* sGain;
+		static MonoField* sOffset;
+	};
+
 	/**	Interop class between C++ & CLR for PostProcessSettings. */
 	class BS_SCR_BE_EXPORT ScriptPostProcessSettings : public ScriptObject<ScriptPostProcessSettings>
 	{
 	public:
 		SCRIPT_OBJ(ENGINE_ASSEMBLY, "BansheeEngine", "PostProcessSettings")
 
+		/** Converts managed object its native counterpart. */
+		static SPtr<StandardPostProcessSettings> toNative(MonoObject* object);
+
+		/** Converts native object to its managed counterpart. */
+		static MonoObject* toManaged(const SPtr<StandardPostProcessSettings>& value);
+
 	private:
 		ScriptPostProcessSettings(MonoObject* instance);
 
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/************************************************************************/
-		static void internal_CreateDefault(PostProcessSettings* output);
+		static MonoObject* internal_CreateDefault();
+
+		static MonoField* sEnableAutoExposure;;
+		static MonoField* sAutoExposure;
+		static MonoField* sEnableTonemapping;
+		static MonoField* sTonemapping;
+		static MonoField* sWhiteBalance;
+		static MonoField* sColorGrading;
+		static MonoField* sExposureScale;
+		static MonoField* sGamma;
 	};
 
 	/** @} */

+ 21 - 4
Source/SBansheeEngine/Source/BsScriptCamera.cpp

@@ -15,6 +15,8 @@
 #include "BsRenderWindow.h"
 #include "BsRenderTexture.h"
 #include "BsGUIManager.h"
+#include "BsStandardPostProcessSettings.h"
+#include "BsScriptPostProcessSettings.h"
 
 namespace BansheeEngine
 {
@@ -299,14 +301,29 @@ namespace BansheeEngine
 		instance->mCamera->setFlag(CameraFlag::HDR, value);
 	}
 
-	void ScriptCamera::internal_GetPostProcessSettings(ScriptCamera* instance, PostProcessSettings* value)
+	MonoObject* ScriptCamera::internal_GetPostProcessSettings(ScriptCamera* instance)
 	{
-		*value = instance->mCamera->getPostProcessSettings();
+		SPtr<PostProcessSettings> ppSettings = instance->mCamera->getPostProcessSettings();
+		SPtr<StandardPostProcessSettings> standardPPSettings;
+		if(ppSettings != nullptr)
+		{
+			if (!rtti_is_of_type<StandardPostProcessSettings>(ppSettings))
+			{
+				assert(false && "Invalid post process settings type.");
+			}
+			else
+				standardPPSettings = std::static_pointer_cast<StandardPostProcessSettings>(ppSettings);
+		}
+
+		if (standardPPSettings == nullptr)
+			standardPPSettings = bs_shared_ptr_new<StandardPostProcessSettings>();
+
+		return ScriptPostProcessSettings::toManaged(standardPPSettings);
 	}
 
-	void ScriptCamera::internal_SetPostProcessSettings(ScriptCamera* instance, PostProcessSettings* value)
+	void ScriptCamera::internal_SetPostProcessSettings(ScriptCamera* instance, MonoObject* value)
 	{
-		instance->mCamera->setPostProcessSettings(*value);
+		instance->mCamera->setPostProcessSettings(ScriptPostProcessSettings::toNative(value));
 	}
 
 	UINT64 ScriptCamera::internal_GetLayers(ScriptCamera* instance)

+ 254 - 15
Source/SBansheeEngine/Source/BsScriptPostProcessSettings.cpp

@@ -6,9 +6,203 @@
 #include "BsMonoClass.h"
 #include "BsMonoUtil.h"
 #include "BsCoreThread.h"
+#include "BsStandardPostProcessSettings.h"
 
 namespace BansheeEngine
 {
+	MonoField* ScriptAutoExposureSettings::sHistogramLog2Min = nullptr;
+	MonoField* ScriptAutoExposureSettings::sHistogramLog2Max = nullptr;
+	MonoField* ScriptAutoExposureSettings::sHistogramPctLow = nullptr;
+	MonoField* ScriptAutoExposureSettings::sHistogramPctHigh = nullptr;
+	MonoField* ScriptAutoExposureSettings::sMinEyeAdaptation = nullptr;
+	MonoField* ScriptAutoExposureSettings::sMaxEyeAdaptation = nullptr;
+	MonoField* ScriptAutoExposureSettings::sEyeAdaptationSpeedUp = nullptr;
+	MonoField* ScriptAutoExposureSettings::sEyeAdaptationSpeedDown = nullptr;
+
+	ScriptAutoExposureSettings::ScriptAutoExposureSettings(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+
+	void ScriptAutoExposureSettings::initRuntimeData()
+	{
+		sHistogramLog2Min = metaData.scriptClass->getField("HistogramLog2Min");
+		sHistogramLog2Max = metaData.scriptClass->getField("HistogramLog2Max");
+		sHistogramPctLow = metaData.scriptClass->getField("HistogramPctLow");
+		sHistogramPctHigh = metaData.scriptClass->getField("HistogramPctHigh");
+		sMinEyeAdaptation = metaData.scriptClass->getField("MinEyeAdaptation");
+		sMaxEyeAdaptation = metaData.scriptClass->getField("MaxEyeAdaptation");
+		sEyeAdaptationSpeedUp = metaData.scriptClass->getField("EyeAdaptationSpeedUp");
+		sEyeAdaptationSpeedDown = metaData.scriptClass->getField("EyeAdaptationSpeedDown");
+	}
+
+	SPtr<AutoExposureSettings> ScriptAutoExposureSettings::toNative(MonoObject* object)
+	{
+		SPtr<AutoExposureSettings> output = bs_shared_ptr_new<AutoExposureSettings>();
+
+		sHistogramLog2Min->getValue(object, &output->histogramLog2Min);
+		sHistogramLog2Max->getValue(object, &output->histogramLog2Max);
+		sHistogramPctLow->getValue(object, &output->histogramPctLow);
+		sHistogramPctHigh->getValue(object, &output->histogramPctHigh);
+		sMinEyeAdaptation->getValue(object, &output->minEyeAdaptation);
+		sMaxEyeAdaptation->getValue(object, &output->maxEyeAdaptation);
+		sEyeAdaptationSpeedUp->getValue(object, &output->eyeAdaptationSpeedUp);
+		sEyeAdaptationSpeedDown->getValue(object, &output->eyeAdaptationSpeedDown);
+
+		return output;
+	}
+
+	MonoObject* ScriptAutoExposureSettings::toManaged(AutoExposureSettings& value)
+	{
+		MonoObject* object = metaData.scriptClass->createInstance();
+
+		sHistogramLog2Min->setValue(object, &value.histogramLog2Min);
+		sHistogramLog2Max->setValue(object, &value.histogramLog2Max);
+		sHistogramPctLow->setValue(object, &value.histogramPctLow);
+		sHistogramPctHigh->setValue(object, &value.histogramPctHigh);
+		sMinEyeAdaptation->setValue(object, &value.minEyeAdaptation);
+		sMaxEyeAdaptation->setValue(object, &value.maxEyeAdaptation);
+		sEyeAdaptationSpeedUp->setValue(object, &value.eyeAdaptationSpeedUp);
+		sEyeAdaptationSpeedDown->setValue(object, &value.eyeAdaptationSpeedDown);
+
+		return object;
+	}
+
+	MonoField* ScriptTonemappingSettings::sFilmicCurveShoulderStrength = nullptr;
+	MonoField* ScriptTonemappingSettings::sFilmicCurveLinearStrength = nullptr;
+	MonoField* ScriptTonemappingSettings::sFilmicCurveLinearAngle = nullptr;
+	MonoField* ScriptTonemappingSettings::sFilmicCurveToeStrength = nullptr;
+	MonoField* ScriptTonemappingSettings::sFilmicCurveToeNumerator = nullptr;
+	MonoField* ScriptTonemappingSettings::sFilmicCurveToeDenominator = nullptr;
+	MonoField* ScriptTonemappingSettings::sFilmicCurveLinearWhitePoint = nullptr;
+
+	ScriptTonemappingSettings::ScriptTonemappingSettings(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+
+	void ScriptTonemappingSettings::initRuntimeData()
+	{
+		sFilmicCurveShoulderStrength = metaData.scriptClass->getField("FilmicCurveShoulderStrength");
+		sFilmicCurveLinearStrength = metaData.scriptClass->getField("FilmicCurveLinearStrength");
+		sFilmicCurveLinearAngle = metaData.scriptClass->getField("FilmicCurveLinearAngle");
+		sFilmicCurveToeStrength = metaData.scriptClass->getField("FilmicCurveToeStrength");
+		sFilmicCurveToeNumerator = metaData.scriptClass->getField("FilmicCurveToeNumerator");
+		sFilmicCurveToeDenominator = metaData.scriptClass->getField("FilmicCurveToeDenominator");
+		sFilmicCurveLinearWhitePoint = metaData.scriptClass->getField("FilmicCurveLinearWhitePoint");
+	}
+
+	SPtr<TonemappingSettings> ScriptTonemappingSettings::toNative(MonoObject* object)
+	{
+		SPtr<TonemappingSettings> output = bs_shared_ptr_new<TonemappingSettings>();
+
+		sFilmicCurveShoulderStrength->getValue(object, &output->filmicCurveShoulderStrength);
+		sFilmicCurveLinearStrength->getValue(object, &output->filmicCurveLinearStrength);
+		sFilmicCurveLinearAngle->getValue(object, &output->filmicCurveLinearAngle);
+		sFilmicCurveToeStrength->getValue(object, &output->filmicCurveToeStrength);
+		sFilmicCurveToeNumerator->getValue(object, &output->filmicCurveToeNumerator);
+		sFilmicCurveToeDenominator->getValue(object, &output->filmicCurveToeDenominator);
+		sFilmicCurveLinearWhitePoint->getValue(object, &output->filmicCurveLinearWhitePoint);
+
+		return output;
+	}
+
+	MonoObject* ScriptTonemappingSettings::toManaged(TonemappingSettings& value)
+	{
+		MonoObject* object = metaData.scriptClass->createInstance();
+
+		sFilmicCurveShoulderStrength->setValue(object, &value.filmicCurveShoulderStrength);
+		sFilmicCurveLinearStrength->setValue(object, &value.filmicCurveLinearStrength);
+		sFilmicCurveLinearAngle->setValue(object, &value.filmicCurveLinearAngle);
+		sFilmicCurveToeStrength->setValue(object, &value.filmicCurveToeStrength);
+		sFilmicCurveToeNumerator->setValue(object, &value.filmicCurveToeNumerator);
+		sFilmicCurveToeDenominator->setValue(object, &value.filmicCurveToeDenominator);
+		sFilmicCurveLinearWhitePoint->setValue(object, &value.filmicCurveLinearWhitePoint);
+
+		return object;
+	}
+
+	MonoField* ScriptWhiteBalanceSettings::sTemperature = nullptr;
+	MonoField* ScriptWhiteBalanceSettings::sTint = nullptr;
+
+	ScriptWhiteBalanceSettings::ScriptWhiteBalanceSettings(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+
+	void ScriptWhiteBalanceSettings::initRuntimeData()
+	{
+		sTemperature = metaData.scriptClass->getField("Temperature");
+		sTint = metaData.scriptClass->getField("Tint");
+	}
+
+	SPtr<WhiteBalanceSettings> ScriptWhiteBalanceSettings::toNative(MonoObject* object)
+	{
+		SPtr<WhiteBalanceSettings> output = bs_shared_ptr_new<WhiteBalanceSettings>();
+
+		sTemperature->getValue(object, &output->temperature);
+		sTint->getValue(object, &output->tint);
+
+		return output;
+	}
+
+	MonoObject* ScriptWhiteBalanceSettings::toManaged(WhiteBalanceSettings& value)
+	{
+		MonoObject* object = metaData.scriptClass->createInstance();
+
+		sTemperature->setValue(object, &value.temperature);
+		sTint->setValue(object, &value.tint);
+
+		return object;
+	}
+
+	MonoField* ScriptColorGradingSettings::sSaturation = nullptr;
+	MonoField* ScriptColorGradingSettings::sContrast = nullptr;
+	MonoField* ScriptColorGradingSettings::sGain = nullptr;
+	MonoField* ScriptColorGradingSettings::sOffset = nullptr;
+
+	ScriptColorGradingSettings::ScriptColorGradingSettings(MonoObject* instance)
+		:ScriptObject(instance)
+	{ }
+
+	void ScriptColorGradingSettings::initRuntimeData()
+	{
+		sSaturation = metaData.scriptClass->getField("Saturation");
+		sContrast = metaData.scriptClass->getField("Contrast");
+		sGain = metaData.scriptClass->getField("Gain");
+		sOffset = metaData.scriptClass->getField("Offset");
+	}
+
+	SPtr<ColorGradingSettings> ScriptColorGradingSettings::toNative(MonoObject* object)
+	{
+		SPtr<ColorGradingSettings> output = bs_shared_ptr_new<ColorGradingSettings>();
+
+		sSaturation->getValue(object, &output->saturation);
+		sContrast->getValue(object, &output->contrast);
+		sGain->getValue(object, &output->gain);
+		sOffset->getValue(object, &output->offset);
+
+		return output;
+	}
+
+	MonoObject* ScriptColorGradingSettings::toManaged(ColorGradingSettings& value)
+	{
+		MonoObject* object = metaData.scriptClass->createInstance();
+
+		sSaturation->setValue(object, &value.saturation);
+		sContrast->setValue(object, &value.contrast);
+		sGain->setValue(object, &value.gain);
+		sOffset->setValue(object, &value.offset);
+
+		return object;
+	}
+
+	MonoField* ScriptPostProcessSettings::sEnableAutoExposure = nullptr;
+	MonoField* ScriptPostProcessSettings::sAutoExposure = nullptr;
+	MonoField* ScriptPostProcessSettings::sEnableTonemapping = nullptr;
+	MonoField* ScriptPostProcessSettings::sTonemapping = nullptr;
+	MonoField* ScriptPostProcessSettings::sWhiteBalance = nullptr;
+	MonoField* ScriptPostProcessSettings::sColorGrading = nullptr;
+	MonoField* ScriptPostProcessSettings::sExposureScale = nullptr;
+	MonoField* ScriptPostProcessSettings::sGamma = nullptr;
+
 	ScriptPostProcessSettings::ScriptPostProcessSettings(MonoObject* instance)
 		:ScriptObject(instance)
 	{ }
@@ -17,25 +211,70 @@ namespace BansheeEngine
 	{
 		metaData.scriptClass->addInternalCall("Internal_CreateDefault", &ScriptPostProcessSettings::internal_CreateDefault);
 
-		// Validation
-#if BS_DEBUG_MODE
-		MonoAssembly* engineAssembly = MonoManager::instance().getAssembly(ENGINE_ASSEMBLY);
+		sEnableAutoExposure = metaData.scriptClass->getField("EnableAutoExposure");
+		sAutoExposure = metaData.scriptClass->getField("AutoExposure");
+		sEnableTonemapping = metaData.scriptClass->getField("EnableTonemapping");
+		sTonemapping = metaData.scriptClass->getField("Tonemapping");
+		sWhiteBalance = metaData.scriptClass->getField("WhiteBalance");
+		sColorGrading = metaData.scriptClass->getField("ColorGrading");
+		sExposureScale = metaData.scriptClass->getField("ExposureScale");
+		sGamma = metaData.scriptClass->getField("Gamma");
+	}
+
+	SPtr<StandardPostProcessSettings> ScriptPostProcessSettings::toNative(MonoObject* object)
+	{
+		SPtr<StandardPostProcessSettings> output = bs_shared_ptr_new<StandardPostProcessSettings>();
+
+		sEnableAutoExposure->getValue(object, &output->enableAutoExposure);
+		sEnableTonemapping->getValue(object, &output->enableTonemapping);
+		sExposureScale->getValue(object, &output->exposureScale);
+		sGamma->getValue(object, &output->gamma);
+
+		MonoObject* autoExposureMono;
+		sAutoExposure->getValue(object, &autoExposureMono);
+		output->autoExposure = *ScriptAutoExposureSettings::toNative(autoExposureMono);
+
+		MonoObject* tonemappingMono;
+		sTonemapping->getValue(object, &tonemappingMono);
+		output->tonemapping = *ScriptTonemappingSettings::toNative(tonemappingMono);
+
+		MonoObject* whiteBalanceMono;
+		sWhiteBalance->getValue(object, &whiteBalanceMono);
+		output->whiteBalance = *ScriptWhiteBalanceSettings::toNative(whiteBalanceMono);
+
+		MonoObject* colorGradingMono;
+		sColorGrading->getValue(object, &colorGradingMono);
+		output->colorGrading = *ScriptColorGradingSettings::toNative(colorGradingMono);
+
+		return output;
+	}
+
+	MonoObject* ScriptPostProcessSettings::toManaged(const SPtr<StandardPostProcessSettings>& value)
+	{
+		MonoObject* object = metaData.scriptClass->createInstance();
+
+		sEnableAutoExposure->setValue(object, &value->enableAutoExposure);
+		sEnableTonemapping->setValue(object, &value->enableTonemapping);
+		sExposureScale->setValue(object, &value->exposureScale);
+		sGamma->setValue(object, &value->gamma);
+
+		MonoObject* autoExposureMono = ScriptAutoExposureSettings::toManaged(value->autoExposure);
+		sAutoExposure->setValue(object, autoExposureMono);
+
+		MonoObject* tonemappingMono = ScriptTonemappingSettings::toManaged(value->tonemapping);
+		sTonemapping->setValue(object, tonemappingMono);
+
+		MonoObject* whiteBalanceMono = ScriptWhiteBalanceSettings::toManaged(value->whiteBalance);
+		sWhiteBalance->setValue(object, whiteBalanceMono);
 
-		MonoClass* autoExposureSettingsClass = engineAssembly->getClass("BansheeEngine", "AutoExposureSettings");
-		MonoClass* tonemappingSettingsClass = engineAssembly->getClass("BansheeEngine", "TonemappingSettings");
-		MonoClass* whieBalanceSettingsClass = engineAssembly->getClass("BansheeEngine", "WhiteBalanceSettings");
-		MonoClass* colorGradingSettingsClass = engineAssembly->getClass("BansheeEngine", "ColorGradingSettings");
+		MonoObject* colorGradingMono = ScriptColorGradingSettings::toManaged(value->colorGrading);
+		sColorGrading->setValue(object, colorGradingMono);
 
-		assert(metaData.scriptClass->getInstanceSize() == sizeof(PostProcessSettings));
-		assert(autoExposureSettingsClass->getInstanceSize() == sizeof(AutoExposureSettings));
-		assert(tonemappingSettingsClass->getInstanceSize() == sizeof(TonemappingSettings));
-		assert(whieBalanceSettingsClass->getInstanceSize() == sizeof(WhiteBalanceSettings));
-		assert(colorGradingSettingsClass->getInstanceSize() == sizeof(ColorGradingSettings));
-#endif
+		return object;
 	}
 
-	void ScriptPostProcessSettings::internal_CreateDefault(PostProcessSettings* output)
+	MonoObject* ScriptPostProcessSettings::internal_CreateDefault()
 	{
-		*output = PostProcessSettings();
+		return toManaged(bs_shared_ptr_new<StandardPostProcessSettings>());
 	}
 }