Răsfoiți Sursa

Getting rid of MultiRenderTexture as implementation is now merged into RenderTexture class since modern APIs don't make the distinction between the two

BearishSun 9 ani în urmă
părinte
comite
9bfe9675a3
33 a modificat fișierele cu 302 adăugiri și 1170 ștergeri
  1. 10 14
      Documentation/Manuals/Native/renderTargets.md
  2. 0 2
      Source/BansheeCore/CMakeSources.cmake
  3. 0 2
      Source/BansheeCore/Include/BsCorePrerequisites.h
  4. 0 162
      Source/BansheeCore/Include/BsMultiRenderTexture.h
  5. 2 2
      Source/BansheeCore/Include/BsRenderTarget.h
  6. 20 19
      Source/BansheeCore/Include/BsRenderTexture.h
  7. 4 23
      Source/BansheeCore/Include/BsTextureManager.h
  8. 0 300
      Source/BansheeCore/Source/BsMultiRenderTexture.cpp
  9. 135 86
      Source/BansheeCore/Source/BsRenderTexture.cpp
  10. 5 23
      Source/BansheeCore/Source/BsTextureManager.cpp
  11. 0 2
      Source/BansheeD3D11RenderAPI/CMakeSources.cmake
  12. 0 61
      Source/BansheeD3D11RenderAPI/Include/BsD3D11MultiRenderTexture.h
  13. 1 1
      Source/BansheeD3D11RenderAPI/Include/BsD3D11RenderTexture.h
  14. 1 7
      Source/BansheeD3D11RenderAPI/Include/BsD3D11TextureManager.h
  15. 0 54
      Source/BansheeD3D11RenderAPI/Source/BsD3D11MultiRenderTexture.cpp
  16. 12 6
      Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderTexture.cpp
  17. 1 17
      Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureManager.cpp
  18. 1 1
      Source/BansheeEditor/Include/BsScenePicking.h
  19. 8 10
      Source/BansheeEditor/Source/BsScenePicking.cpp
  20. 1 1
      Source/BansheeEngine/Source/BsGUIRenderTexture.cpp
  21. 0 2
      Source/BansheeGLRenderAPI/CMakeSources.cmake
  22. 0 67
      Source/BansheeGLRenderAPI/Include/BsGLMultiRenderTexture.h
  23. 1 1
      Source/BansheeGLRenderAPI/Include/BsGLRenderTexture.h
  24. 1 7
      Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h
  25. 0 117
      Source/BansheeGLRenderAPI/Source/BsGLMultiRenderTexture.cpp
  26. 43 36
      Source/BansheeGLRenderAPI/Source/BsGLRenderTexture.cpp
  27. 1 17
      Source/BansheeGLRenderAPI/Source/BsGLTextureManager.cpp
  28. 1 1
      Source/RenderBeast/Include/BsRenderTargets.h
  29. 2 2
      Source/RenderBeast/Source/BsPostProcessing.cpp
  30. 7 9
      Source/RenderBeast/Source/BsRenderTargets.cpp
  31. 5 5
      Source/RenderBeast/Source/BsRenderTexturePool.cpp
  32. 2 9
      Source/SBansheeEngine/Include/BsScriptRenderTexture2D.h
  33. 38 104
      Source/SBansheeEngine/Source/BsScriptRenderTexture2D.cpp

+ 10 - 14
Documentation/Manuals/Native/renderTargets.md

@@ -6,9 +6,7 @@ Render targets represent destination surfaces onto which objects are rendered. T
 
 
 In Banshee render targets are represented with:
 In Banshee render targets are represented with:
  - Windows - @ref BansheeEngine::RenderWindow "RenderWindow" and @ref BansheeEngine::RenderWindowCore "RenderWindowCore"
  - Windows - @ref BansheeEngine::RenderWindow "RenderWindow" and @ref BansheeEngine::RenderWindowCore "RenderWindowCore"
- - Textures
-  - Single surface: @ref BansheeEngine::RenderTexture "RenderTexture" and @ref BansheeEngine::RenderTextureCore "RenderTextureCore"
-  - Multiple surfaces: @ref BansheeEngine::MultiRenderTexture "MultiRenderTexture" and @ref BansheeEngine::MultiRenderTextureCore "MultiRenderTextureCore"
+ - Textures - @ref BansheeEngine::RenderTexture "RenderTexture" and @ref BansheeEngine::RenderTextureCore "RenderTextureCore"
  
  
 Each type comes in two variants, both of which provide almost equivalent functionality, but the former is for use on the simulation thread, and the latter is for use on the core thread. If you are confused by the dual nature of the objects, read the [core thread](@ref coreThread) manual. 
 Each type comes in two variants, both of which provide almost equivalent functionality, but the former is for use on the simulation thread, and the latter is for use on the core thread. If you are confused by the dual nature of the objects, read the [core thread](@ref coreThread) manual. 
 
 
@@ -66,7 +64,7 @@ Render textures are simpler than windows, but you are given more control over th
 
 
 Render texture must contain at least one texture (color surface), but may optionally also contain a depth-stencil surface. Depth-stencil surface is also a @ref BansheeEngine::Texture "Texture", but one created with the @ref BansheeEngine::TU_DEPTHSTENCIL "TU_DEPTHSTENCIL" flag. Depth stencil surfaces only accept specific pixel formats starting with "D" prefix in @ref BansheeEngine::PixelFormat "PixelFormat". Dimensions of the depth stencil surface must match the color surface.
 Render texture must contain at least one texture (color surface), but may optionally also contain a depth-stencil surface. Depth-stencil surface is also a @ref BansheeEngine::Texture "Texture", but one created with the @ref BansheeEngine::TU_DEPTHSTENCIL "TU_DEPTHSTENCIL" flag. Depth stencil surfaces only accept specific pixel formats starting with "D" prefix in @ref BansheeEngine::PixelFormat "PixelFormat". Dimensions of the depth stencil surface must match the color surface.
 
 
-To create a render texture call @ref BansheeEngine::RenderTexture::create(const RENDER_TEXTURE_DESC&) "RenderTexture::create" with a populated @ref BansheeEngine::RENDER_TEXTURE_DESC "RENDER_TEXTURE_DESC" structure. This structure expects a reference to the color surface texture, and an optional depth-stencil surface texture. For each of those you must also specify the face and mip level onto which to render, in case your texture has multiple.
+To create a render texture call @ref BansheeEngine::RenderTexture::create(const RENDER_TEXTURE_DESC&) "RenderTexture::create" with a populated @ref BansheeEngine::RENDER_TEXTURE_DESC "RENDER_TEXTURE_DESC" structure. This structure expects a reference to one or more color surface textures, and an optional depth-stencil surface texture. For each of those you must also specify the face and mip level onto which to render, in case your texture has multiple.
 
 
 For example:
 For example:
 ~~~~~~~~~~~~~{.cpp}
 ~~~~~~~~~~~~~{.cpp}
@@ -77,9 +75,9 @@ HTexture color = Texture::create(TEX_TYPE_2D, 1280, 720, 1, 0, PF_R8G8B8A8);
 HTexture depthStencil = Texture::create(TEX_TYPE_2D, 1280, 720, 1, 0, PF_D24S8);
 HTexture depthStencil = Texture::create(TEX_TYPE_2D, 1280, 720, 1, 0, PF_D24S8);
 
 
 RENDER_TEXTURE_DESC desc;
 RENDER_TEXTURE_DESC desc;
-desc.colorSurface.texture = color;
-desc.colorSurface.face = 0;
-desc.colorSurface.mipLevel = 0;
+desc.colorSurfaces[0].texture = color;
+desc.colorSurfaces[0].face = 0;
+desc.colorSurfaces[0].mipLevel = 0;
 
 
 desc.depthStencilSurface.texture = depthStencil;
 desc.depthStencilSurface.texture = depthStencil;
 desc.depthStencilSurface.face = 0;
 desc.depthStencilSurface.face = 0;
@@ -95,9 +93,9 @@ SPtr<RenderTexture> renderTexture = RenderTexture::create(TEX_TYPE_2D, 1280, 720
 ~~~~~~~~~~~~~
 ~~~~~~~~~~~~~
 
 
 ## Multiple surfaces {#renderTargets_b_a}
 ## Multiple surfaces {#renderTargets_b_a}
-Render textures can also contain multiple color surfaces (up to 8). Such targets simply allow you to write more data at once, improving performance as you do not need to execute multiple draw calls. To create a texture with multiple color surfaces you must create a @ref BansheeEngine::MultiRenderTexture "MultiRenderTexture" by calling @ref BansheeEngine::MultiRenderTexture::create "MultiRenderTexture::create". 
+Render textures can also contain multiple color surfaces (up to 8). Such targets simply allow you to write more data at once, improving performance as you do not need to execute multiple draw calls. To create a texture with multiple color surfaces simply fill out other entries of @ref BansheeEngine::RENDER_TEXTURE_DESC "RENDER_TEXTURE_DESC::colorSurfaces" array and proceed the same as in the above example.
 
 
-Their creation is identical to normal render textures, only they accept more than one color surface. Use `BS_MAX_MULTIPLE_RENDER_TARGETS` to learn what is the maximum supported number of color surfaces per target (usually 8). All color surfaces (and the depth/stencil surface) must have the same dimensions.
+Use `BS_MAX_MULTIPLE_RENDER_TARGETS` to learn what is the maximum supported number of color surfaces per target (usually 8). All color surfaces (and the depth/stencil surface) must have the same dimensions and sample count.
 
 
 ## Multi-sampled surfaces {#renderTargets_b_c}
 ## Multi-sampled surfaces {#renderTargets_b_c}
 Same as windows, render textures can be created with support for multiple samples per pixel. This allows affects such as multi-sampled antialiasing and similar. To create a multi-sampled render texture simply create a @ref BansheeEngine::Texture "Texture" with its `multisampleCount` parameter larger than one, which you then use to initialize a render texture. Make sure that all surfaces (including depth-stencil) in a render texture have the same number of samples.
 Same as windows, render textures can be created with support for multiple samples per pixel. This allows affects such as multi-sampled antialiasing and similar. To create a multi-sampled render texture simply create a @ref BansheeEngine::Texture "Texture" with its `multisampleCount` parameter larger than one, which you then use to initialize a render texture. Make sure that all surfaces (including depth-stencil) in a render texture have the same number of samples.
@@ -119,11 +117,9 @@ Use @ref BansheeEngine::RenderAPI::setRenderTarget "RenderAPI::setRenderTarget"
 Call @ref BansheeEngine::RenderAPI::clearRenderTarget "RenderAPI::clearRenderTarget" to clear all or portions of a render target to a specific color/value. Read the [render API](@ref renderAPI) manual for more information.
 Call @ref BansheeEngine::RenderAPI::clearRenderTarget "RenderAPI::clearRenderTarget" to clear all or portions of a render target to a specific color/value. Read the [render API](@ref renderAPI) manual for more information.
 
 
 ## Reading from targets {#renderTargets_d_c}
 ## Reading from targets {#renderTargets_d_c}
-If you wish to read render target pixels from the CPU, you can use the normal @ref BansheeEngine::Texture "Texture" read functionality as described in the [texture](@ref textures) manual. To retrieve a @ref BansheeEngine::Texture "Texture" from a @ref BansheeEngine::RenderTexture "RenderTexture" or @ref BansheeEngine::MultiRenderTexture "MultiRenderTexture" call the following methods:
- - @ref BansheeEngine::RenderTexture::getBindableColorTexture "RenderTexture::getBindableColorTexture"
- - @ref BansheeEngine::RenderTexture::getBindableDepthStencilTexture "RenderTexture::getBindableDepthStencilTexture"
- - @ref BansheeEngine::MultiRenderTexture::getBindableColorTexture "MultiRenderTexture::getBindableColorTexture"
- - @ref BansheeEngine::MultiRenderTexture::getBindableDepthStencilTexture "MultiRenderTexture::getBindableDepthStencilTexture"
+If you wish to read render target pixels from the CPU, you can use the normal @ref BansheeEngine::Texture "Texture" read functionality as described in the [texture](@ref textures) manual. To retrieve a @ref BansheeEngine::Texture "Texture" from a @ref BansheeEngine::RenderTexture "RenderTexture" call the following methods:
+ - @ref BansheeEngine::RenderTexture::getColorTexture "RenderTexture::getColorTexture"
+ - @ref BansheeEngine::RenderTexture::getDepthStencilTexture "RenderTexture::getDepthStencilTexture"
  
  
 Before reading you must make sure the render target is not currently bound for rendering otherwise this will fail. You cannot read from a @ref BansheeEngine::RenderWindow "RenderWindow".
 Before reading you must make sure the render target is not currently bound for rendering otherwise this will fail. You cannot read from a @ref BansheeEngine::RenderWindow "RenderWindow".
 
 

+ 0 - 2
Source/BansheeCore/CMakeSources.cmake

@@ -133,7 +133,6 @@ set(BS_BANSHEECORE_INC_RENDERAPI
 	"Include/BsRenderTarget.h"
 	"Include/BsRenderTarget.h"
 	"Include/BsRasterizerState.h"
 	"Include/BsRasterizerState.h"
 	"Include/BsOcclusionQuery.h"
 	"Include/BsOcclusionQuery.h"
-	"Include/BsMultiRenderTexture.h"
 	"Include/BsIndexBuffer.h"
 	"Include/BsIndexBuffer.h"
 	"Include/BsHardwareBuffer.h"
 	"Include/BsHardwareBuffer.h"
 	"Include/BsGpuProgram.h"
 	"Include/BsGpuProgram.h"
@@ -428,7 +427,6 @@ set(BS_BANSHEECORE_SRC_RENDERAPI
 	"Source/BsGpuParams.cpp"
 	"Source/BsGpuParams.cpp"
 	"Source/BsGpuProgram.cpp"
 	"Source/BsGpuProgram.cpp"
 	"Source/BsIndexBuffer.cpp"
 	"Source/BsIndexBuffer.cpp"
-	"Source/BsMultiRenderTexture.cpp"
 	"Source/BsOcclusionQuery.cpp"
 	"Source/BsOcclusionQuery.cpp"
 	"Source/BsRasterizerState.cpp"
 	"Source/BsRasterizerState.cpp"
 	"Source/BsRenderTarget.cpp"
 	"Source/BsRenderTarget.cpp"

+ 0 - 2
Source/BansheeCore/Include/BsCorePrerequisites.h

@@ -237,8 +237,6 @@ namespace BansheeEngine
 	class RenderTargetCore;
 	class RenderTargetCore;
     class RenderTexture;
     class RenderTexture;
 	class RenderTextureCore;
 	class RenderTextureCore;
-	class MultiRenderTexture;
-	class MultiRenderTextureCore;
     class RenderWindow;
     class RenderWindow;
 	class RenderWindowCore;
 	class RenderWindowCore;
 	class RenderTargetProperties;
 	class RenderTargetProperties;

+ 0 - 162
Source/BansheeCore/Include/BsMultiRenderTexture.h

@@ -1,162 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsCorePrerequisites.h"
-#include "BsRenderTarget.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup RenderAPI
-	 *  @{
-	 */
-
-	/**
-	 * Descriptor class used for initializing a MultiRenderTexture. Contains descriptors for each individual color render 
-	 * surface and their common depth/stencil surface.
-	 */
-	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_DESC
-	{
-		Vector<RENDER_SURFACE_DESC> colorSurfaces;
-		RENDER_SURFACE_DESC depthStencilSurface;
-	};
-
-	/**
-	 * @see		MULTI_RENDER_TEXTURE_DESC
-	 *
-	 * @note	References core textures instead of texture handles.
-	 */
-	struct BS_CORE_EXPORT MULTI_RENDER_TEXTURE_CORE_DESC
-	{
-		Vector<RENDER_SURFACE_CORE_DESC> colorSurfaces;
-		RENDER_SURFACE_CORE_DESC depthStencilSurface;
-	};
-
-	/** Contains various properties that describe a render texture. */
-	class BS_CORE_EXPORT MultiRenderTextureProperties : public RenderTargetProperties
-	{
-	public:
-		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
-		MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping);
-		virtual ~MultiRenderTextureProperties() { }
-
-	protected:
-		friend class MultiRenderTextureCore;
-		friend class MultiRenderTexture;
-
-		void construct(const TextureProperties* props, bool requiresFlipping);
-	};
-
-	/**
-	 * Object representing multiple render textures. You may bind this to the pipeline in order to render to all or some of 
-	 * the textures at once.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_CORE_EXPORT MultiRenderTexture : public RenderTarget
-	{
-	public:
-		virtual ~MultiRenderTexture() { }
-
-		/**
-		 * Returns a color surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableColorTexture(UINT32 idx) const { return mBindableColorTex[idx]; }
-
-		/**
-		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
-
-		/** Retrieves a core implementation of a render texture usable only from the core thread. */
-		SPtr<MultiRenderTextureCore> getCore() const;
-
-		/** @copydoc TextureManager::createMultiRenderTexture */
-		static SPtr<MultiRenderTexture> create(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/**	Returns properties that describe the render texture. */
-		const MultiRenderTextureProperties& getProperties() const;
-
-		/**	Returns the number of color surfaces used by the render texture. */
-		UINT32 getColorSurfaceCount() const;
-
-	protected:
-		MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc RenderTarget::createCore */
-		SPtr<CoreObjectCore> createCore() const override;
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		CoreSyncData syncToCore(FrameAlloc* allocator) override;
-
-		MULTI_RENDER_TEXTURE_DESC mDesc;
-		Vector<HTexture> mBindableColorTex;
-		HTexture mBindableDepthStencilTex;
-	};
-
-	/** @} */
-
-	/** @addtogroup RenderAPI-Internal
-	 *  @{
-	 */
-
-	/**
-	 * Object representing multiple render textures. You may bind this to the pipeline in order to render to all or some 
-	 * of the textures at once.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_CORE_EXPORT MultiRenderTextureCore : public RenderTargetCore
-	{
-	public:
-		virtual ~MultiRenderTextureCore();
-
-		/** @copydoc CoreObjectCore::initialize */
-		void initialize() override;
-
-		/** Returns properties that describe the render texture. */
-		const MultiRenderTextureProperties& getProperties() const;
-
-		/**
-		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const SPtr<TextureView> getBindableDepthStencilTexture() const { return mDepthStencilSurface; }
-
-		/**
-		 * Returns a color surface texture you may bind as an input to an GPU program.
-		 *
-		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
-		 */
-		const SPtr<TextureView>& getBindableColorTexture(UINT32 idx) const { return mColorSurfaces[idx]; }
-
-		/** @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&) */
-		static SPtr<MultiRenderTextureCore> create(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-
-	protected:
-		MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-
-		/** @copydoc CoreObjectCore::syncToCore */
-		void syncToCore(const CoreSyncData& data) override;
-
-	private:
-		/** Checks that all render surfaces and depth/stencil surface match. If they do not match an exception is thrown. */
-		void throwIfBuffersDontMatch() const;
-
-		// TODO - Not implemented
-		virtual void copyToMemory(PixelData &dst, FrameBuffer buffer = FB_AUTO);
-
-	protected:
-		Vector<SPtr<TextureView>> mColorSurfaces;
-		SPtr<TextureView> mDepthStencilSurface;
-
-		MULTI_RENDER_TEXTURE_CORE_DESC mDesc;
-	};
-
-	/** @} */
-}

+ 2 - 2
Source/BansheeCore/Include/BsRenderTarget.h

@@ -39,9 +39,9 @@ namespace BansheeEngine
 	 *
 	 *
 	 * @note	References core textures instead of texture handles.
 	 * @note	References core textures instead of texture handles.
 	 */
 	 */
-	struct BS_CORE_EXPORT RENDER_SURFACE_CORE_DESC
+	struct BS_CORE_EXPORT RENDER_SURFACE_DESC_CORE
 	{
 	{
-		RENDER_SURFACE_CORE_DESC() { }
+		RENDER_SURFACE_DESC_CORE() { }
 
 
 		SPtr<TextureCore> texture;
 		SPtr<TextureCore> texture;
 
 

+ 20 - 19
Source/BansheeCore/Include/BsRenderTexture.h

@@ -15,18 +15,18 @@ namespace BansheeEngine
 	/**	Structure that describes a render texture color and depth/stencil surfaces. */
 	/**	Structure that describes a render texture color and depth/stencil surfaces. */
 	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
 	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC
 	{
 	{
-		RENDER_SURFACE_DESC colorSurface;
+		RENDER_SURFACE_DESC colorSurfaces[BS_MAX_MULTIPLE_RENDER_TARGETS];
 		RENDER_SURFACE_DESC depthStencilSurface;
 		RENDER_SURFACE_DESC depthStencilSurface;
 	};
 	};
 
 
-	struct RENDER_TEXTURE_CORE_DESC;
+	struct RENDER_TEXTURE_DESC_CORE;
 
 
 	/**	Contains various properties that describe a render texture. */
 	/**	Contains various properties that describe a render texture. */
 	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
 	class BS_CORE_EXPORT RenderTextureProperties : public RenderTargetProperties
 	{
 	{
 	public:
 	public:
 		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
 		RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping);
-		RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping);
+		RenderTextureProperties(const RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping);
 		virtual ~RenderTextureProperties() { }
 		virtual ~RenderTextureProperties() { }
 
 
 	private:
 	private:
@@ -37,7 +37,8 @@ namespace BansheeEngine
 	};
 	};
 
 
 	/**
 	/**
-	 * Render target specialization that allows you to render into a texture you may later bind in further render operations.
+	 * Render target specialization that allows you to render into one or multiple textures. Such textures can then be used
+	 * in other operations as GPU program input.
 	 *
 	 *
 	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
 	 * @note	Sim thread only. Retrieve core implementation from getCore() for core thread only functionality.
 	 */
 	 */
@@ -47,7 +48,7 @@ namespace BansheeEngine
 		virtual ~RenderTexture() { }
 		virtual ~RenderTexture() { }
 
 
 		/**
 		/**
-		 * Creates a new render texture with color and optionally depth/stencil surfaces.
+		 * Creates a new render texture with a single color and optionally depth/stencil surfaces.
 		 *
 		 *
 		 * @param[in]	textureType			Type of texture to render to.
 		 * @param[in]	textureType			Type of texture to render to.
 		 * @param[in]	width				Width of the render texture, in pixels.
 		 * @param[in]	width				Width of the render texture, in pixels.
@@ -70,14 +71,14 @@ namespace BansheeEngine
 		 *
 		 *
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
-		const HTexture& getBindableColorTexture() const { return mBindableColorTex; }
+		const HTexture& getColorTexture(UINT32 idx) const { return mBindableColorTex[idx]; }
 
 
 		/**
 		/**
 		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
 		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
 		 *
 		 *
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
-		const HTexture& getBindableDepthStencilTexture() const { return mBindableDepthStencilTex; }
+		const HTexture& getDepthStencilTexture() const { return mBindableDepthStencilTex; }
 
 
 		/**
 		/**
 		 * Retrieves a core implementation of a render texture usable only from the core thread.
 		 * Retrieves a core implementation of a render texture usable only from the core thread.
@@ -101,7 +102,7 @@ namespace BansheeEngine
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 		CoreSyncData syncToCore(FrameAlloc* allocator) override;
 
 
 	protected:
 	protected:
-		HTexture mBindableColorTex;
+		HTexture mBindableColorTex[BS_MAX_MULTIPLE_RENDER_TARGETS];
 		HTexture mBindableDepthStencilTex;
 		HTexture mBindableDepthStencilTex;
 
 
 		RENDER_TEXTURE_DESC mDesc;
 		RENDER_TEXTURE_DESC mDesc;
@@ -109,7 +110,7 @@ namespace BansheeEngine
 
 
 	/** @} */
 	/** @} */
 
 
-/** @addtogroup RenderAPI-Internal
+	/** @addtogroup RenderAPI-Internal
 	 *  @{
 	 *  @{
 	 */
 	 */
 
 
@@ -118,10 +119,10 @@ namespace BansheeEngine
 	 *
 	 *
 	 * @note	References core textures instead of texture handles.
 	 * @note	References core textures instead of texture handles.
 	 */
 	 */
-	struct BS_CORE_EXPORT RENDER_TEXTURE_CORE_DESC
+	struct BS_CORE_EXPORT RENDER_TEXTURE_DESC_CORE
 	{
 	{
-		RENDER_SURFACE_CORE_DESC colorSurface;
-		RENDER_SURFACE_CORE_DESC depthStencilSurface;
+		RENDER_SURFACE_DESC_CORE colorSurfaces[BS_MAX_MULTIPLE_RENDER_TARGETS];
+		RENDER_SURFACE_DESC_CORE depthStencilSurface;
 	};
 	};
 
 
 	/**
 	/**
@@ -132,28 +133,28 @@ namespace BansheeEngine
 	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
 	class BS_CORE_EXPORT RenderTextureCore : public RenderTargetCore
 	{
 	{
 	public:
 	public:
-		RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
+		RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc);
 		virtual ~RenderTextureCore();
 		virtual ~RenderTextureCore();
 
 
 		/** @copydoc CoreObjectCore::initialize */
 		/** @copydoc CoreObjectCore::initialize */
 		void initialize() override;
 		void initialize() override;
 
 
-		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_CORE_DESC&) */
-		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_CORE_DESC& desc);
+		/** @copydoc TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC_CORE&) */
+		static SPtr<RenderTextureCore> create(const RENDER_TEXTURE_DESC_CORE& desc);
 
 
 		/**
 		/**
 		 * Returns a color surface texture you may bind as an input to an GPU program.
 		 * Returns a color surface texture you may bind as an input to an GPU program.
 		 *
 		 *
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
-		SPtr<TextureCore> getBindableColorTexture() const { return mDesc.colorSurface.texture; }
+		SPtr<TextureCore> getColorTexture(UINT32 idx) const { return mDesc.colorSurfaces[idx].texture; }
 
 
 		/**
 		/**
 		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
 		 * Returns a depth/stencil surface texture you may bind as an input to an GPU program.
 		 *
 		 *
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 * @note	Be aware that you cannot bind a render texture for reading and writing at the same time.
 		 */
 		 */
-		SPtr<TextureCore> getBindableDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
+		SPtr<TextureCore> getDepthStencilTexture() const { return mDesc.depthStencilSurface.texture; }
 
 
 		/**	Returns properties that describe the render texture. */
 		/**	Returns properties that describe the render texture. */
 		const RenderTextureProperties& getProperties() const;
 		const RenderTextureProperties& getProperties() const;
@@ -169,10 +170,10 @@ namespace BansheeEngine
 	protected:
 	protected:
 		friend class RenderTexture;
 		friend class RenderTexture;
 
 
-		SPtr<TextureView> mColorSurface;
+		SPtr<TextureView> mColorSurfaces[BS_MAX_MULTIPLE_RENDER_TARGETS];
 		SPtr<TextureView> mDepthStencilSurface;
 		SPtr<TextureView> mDepthStencilSurface;
 
 
-		RENDER_TEXTURE_CORE_DESC mDesc;
+		RENDER_TEXTURE_DESC_CORE mDesc;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 4 - 23
Source/BansheeCore/Include/BsTextureManager.h

@@ -5,7 +5,6 @@
 #include "BsCorePrerequisites.h"
 #include "BsCorePrerequisites.h"
 #include "BsTexture.h"
 #include "BsTexture.h"
 #include "BsRenderTexture.h"
 #include "BsRenderTexture.h"
-#include "BsMultiRenderTexture.h"
 #include "BsModule.h"
 #include "BsModule.h"
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
@@ -51,7 +50,8 @@ namespace BansheeEngine
 		SPtr<Texture> _createEmpty();
 		SPtr<Texture> _createEmpty();
 
 
 		/**
 		/**
-		 * Creates a new RenderTexture and automatically generates a color surface and (optionally) a depth/stencil surface.
+		 * Creates a new RenderTexture and automatically generates a single color surface and (optionally) a depth/stencil 
+		 * surface.
 		 *
 		 *
 		 * @param[in]	textureType			Type of the texture.
 		 * @param[in]	textureType			Type of the texture.
 		 * @param[in]	width				Width of the texture in pixels.
 		 * @param[in]	width				Width of the texture in pixels.
@@ -71,12 +71,6 @@ namespace BansheeEngine
 		/** Creates a RenderTexture using the description struct. */
 		/** Creates a RenderTexture using the description struct. */
 		virtual SPtr<RenderTexture> createRenderTexture(const RENDER_TEXTURE_DESC& desc);
 		virtual SPtr<RenderTexture> createRenderTexture(const RENDER_TEXTURE_DESC& desc);
 
 
-		/** 
-		 * Creates a new multi render texture. You may use this type of texture to render to multiple output textures at 
-		 * once.
-		 */
-		virtual SPtr<MultiRenderTexture> createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
 		/**
 		/**
 		 * Gets the format which will be natively used for a requested format given the constraints of the current device.
 		 * Gets the format which will be natively used for a requested format given the constraints of the current device.
 		 *
 		 *
@@ -91,12 +85,6 @@ namespace BansheeEngine
 		 */
 		 */
 		virtual SPtr<RenderTexture> createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) = 0;
 		virtual SPtr<RenderTexture> createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) = 0;
 
 
-		/**
-		 * Creates an empty and uninitialized multi render texture of a specific type. This is to be implemented by render
-		 * systems with their own implementations.
-		 */
-		virtual SPtr<MultiRenderTexture> createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) = 0;
-
 		mutable HTexture mDummyTexture;
 		mutable HTexture mDummyTexture;
     };
     };
 
 
@@ -124,16 +112,12 @@ namespace BansheeEngine
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1);
 
 
 		/** @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
 		/** @copydoc	TextureManager::createRenderTexture(const RENDER_TEXTURE_DESC&) */
-		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_CORE_DESC& desc);
-
-		/** @copydoc	TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC&) */
-		SPtr<MultiRenderTextureCore> createMultiRenderTexture(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
+		SPtr<RenderTextureCore> createRenderTexture(const RENDER_TEXTURE_DESC_CORE& desc);
 
 
 	protected:
 	protected:
 		friend class Texture;
 		friend class Texture;
 		friend class TextureCore;
 		friend class TextureCore;
 		friend class RenderTexture;
 		friend class RenderTexture;
-		friend class MultiRenderTexture;
 
 
 		/**
 		/**
 		 * Creates an empty and uninitialized texture of a specific type. This is to be implemented	by render systems with
 		 * Creates an empty and uninitialized texture of a specific type. This is to be implemented	by render systems with
@@ -144,10 +128,7 @@ namespace BansheeEngine
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) = 0;
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) = 0;
 
 
 		/** @copydoc TextureManager::createRenderTextureImpl */
 		/** @copydoc TextureManager::createRenderTextureImpl */
-		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) = 0;
-
-		/** @copydoc TextureManager::createMultiRenderTextureImpl */
-		virtual SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) = 0;
+		virtual SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc) = 0;
     };
     };
 
 
 	/** @} */
 	/** @} */

+ 0 - 300
Source/BansheeCore/Source/BsMultiRenderTexture.cpp

@@ -1,300 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsMultiRenderTexture.h"
-#include "BsTexture.h"
-#include "BsException.h"
-#include "BsDebug.h"
-#include "BsCoreThread.h"
-#include "BsTextureManager.h"
-#include "BsFrameAlloc.h"
-#include "BsResources.h"
-
-namespace BansheeEngine
-{
-	MultiRenderTextureProperties::MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
-	{
-		for (size_t i = 0; i < desc.colorSurfaces.size(); i++)
-		{
-			HTexture texture = desc.colorSurfaces[i].texture;
-
-			if (texture != nullptr)
-			{
-				const TextureProperties& texProps = texture->getProperties();
-				construct(&texProps, requiresFlipping);
-
-				break;
-			}
-		}
-	}
-
-	MultiRenderTextureProperties::MultiRenderTextureProperties(const MULTI_RENDER_TEXTURE_CORE_DESC& desc, 
-		bool requiresFlipping)
-	{
-		for (size_t i = 0; i < desc.colorSurfaces.size(); i++)
-		{
-			SPtr<TextureCore> texture = desc.colorSurfaces[i].texture;
-
-			if (texture != nullptr)
-			{
-				const TextureProperties& texProps = texture->getProperties();
-				construct(&texProps, requiresFlipping);
-
-				break;
-			}
-		}
-	}
-
-	void MultiRenderTextureProperties::construct(const TextureProperties* props, bool requiresFlipping)
-	{
-		if (props == nullptr)
-			return;
-
-		mWidth = props->getWidth();
-		mHeight = props->getHeight();
-		mColorDepth = PixelUtil::getNumElemBits(props->getFormat());
-		mActive = true;
-		mHwGamma = props->isHardwareGammaEnabled();
-		mMultisampleCount = props->getMultisampleCount();
-		mIsWindow = false;
-		mRequiresTextureFlipping = requiresFlipping;
-	}
-
-	MultiRenderTextureCore::MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-		:mDesc(desc)
-	{ }
-
-	MultiRenderTextureCore::~MultiRenderTextureCore()
-	{
-		for (auto iter = mColorSurfaces.begin(); iter != mColorSurfaces.end(); ++iter)
-		{
-			if (*iter != nullptr)
-				TextureCore::releaseView(*iter);
-		}
-
-		if (mDepthStencilSurface != nullptr)
-			TextureCore::releaseView(mDepthStencilSurface);
-	}
-
-	void MultiRenderTextureCore::initialize()
-	{
-		RenderTargetCore::initialize();
-
-		mColorSurfaces.resize(BS_MAX_MULTIPLE_RENDER_TARGETS);
-
-		for (size_t i = 0; i < mDesc.colorSurfaces.size(); i++)
-		{
-			if (mDesc.colorSurfaces[i].texture != nullptr)
-			{
-				if (i >= BS_MAX_MULTIPLE_RENDER_TARGETS)
-				{
-					LOGWRN("Render texture index is larger than the maximum number of supported render targets. Index: " + toString((int)i) +
-						". Max. number of render targets: " + toString(BS_MAX_MULTIPLE_RENDER_TARGETS));
-
-					continue;
-				}
-
-				SPtr<TextureCore> texture = mDesc.colorSurfaces[i].texture;
-
-				if (texture->getProperties().getUsage() != TU_RENDERTARGET)
-					BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
-
-				mColorSurfaces[i] = TextureCore::requestView(texture, mDesc.colorSurfaces[i].mipLevel, 1,
-					mDesc.colorSurfaces[i].face, mDesc.colorSurfaces[i].numFaces, GVU_RENDERTARGET);
-			}
-		}
-
-		if (mDesc.depthStencilSurface.texture != nullptr)
-		{
-			SPtr<TextureCore> texture = mDesc.depthStencilSurface.texture;
-
-			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
-				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
-
-			mDepthStencilSurface = TextureCore::requestView(texture, mDesc.depthStencilSurface.mipLevel, 1,
-				mDesc.depthStencilSurface.face, 0, GVU_DEPTHSTENCIL);
-		}
-
-		throwIfBuffersDontMatch();
-	}
-
-	void MultiRenderTextureCore::syncToCore(const CoreSyncData& data)
-	{
-		MultiRenderTextureProperties& props = const_cast<MultiRenderTextureProperties&>(getProperties());
-		props = data.getData<MultiRenderTextureProperties>();
-	}
-
-	const MultiRenderTextureProperties& MultiRenderTextureCore::getProperties() const
-	{
-		return static_cast<const MultiRenderTextureProperties&>(getPropertiesInternal());
-	}
-
-	SPtr<MultiRenderTextureCore> MultiRenderTextureCore::create(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-	{
-		return TextureCoreManager::instance().createMultiRenderTexture(desc);
-	}
-
-	void MultiRenderTextureCore::throwIfBuffersDontMatch() const
-	{
-		SPtr<TextureView> firstSurfaceDesc = nullptr;
-		for(size_t i = 0; i < mColorSurfaces.size(); i++)
-		{
-			if(mColorSurfaces[i] == nullptr)
-				continue;
-
-			if(firstSurfaceDesc == nullptr)
-			{
-				firstSurfaceDesc = mColorSurfaces[i];
-				continue;
-			}
-
-			const TextureProperties& curTexProps = mColorSurfaces[i]->getTexture()->getProperties();
-			const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
-
-			UINT32 curMsCount = curTexProps.getMultisampleCount();
-			UINT32 firstMsCount = firstTexProps.getMultisampleCount();
-
-			if (curMsCount == 0)
-				curMsCount = 1;
-
-			if (firstMsCount == 0)
-				firstMsCount = 1;
-
-			if (curTexProps.getWidth() != firstTexProps.getWidth() ||
-				curTexProps.getHeight() != firstTexProps.getHeight() ||
-				curMsCount != firstMsCount)
-			{
-				String errorInfo = "\nWidth: " + toString(curTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
-				errorInfo += "\nHeight: " + toString(curTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
-				errorInfo += "\nMultisample Count: " + toString(curMsCount) + "/" + toString(firstMsCount);
-
-				BS_EXCEPT(InvalidParametersException, "Provided color textures don't match!" + errorInfo);
-			}
-		}
-
-		if (firstSurfaceDesc != nullptr)
-		{
-			const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
-
-			if (firstTexProps.getTextureType() != TEX_TYPE_2D)
-				BS_EXCEPT(NotImplementedException, "Render textures are currently only implemented for 2D surfaces.");
-
-			UINT32 numSlices;
-			if (firstTexProps.getTextureType() == TEX_TYPE_3D)
-				numSlices = firstTexProps.getDepth();
-			else
-				numSlices = firstTexProps.getNumFaces();
-
-			if ((firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) > numSlices)
-			{
-				BS_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
-					toString(firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) + ". Max num faces: " + toString(numSlices));
-			}
-
-			if (firstSurfaceDesc->getMostDetailedMip() > firstTexProps.getNumMipmaps())
-			{
-				BS_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
-					toString(firstSurfaceDesc->getMostDetailedMip()) + ". Max num mipmaps: " + toString(firstTexProps.getNumMipmaps()));
-			}
-
-			if (mDepthStencilSurface == nullptr)
-				return;
-
-			const TextureProperties& depthTexProps = mDepthStencilSurface->getTexture()->getProperties();
-			UINT32 depthMsCount = depthTexProps.getMultisampleCount();
-			UINT32 colorMsCount = firstTexProps.getMultisampleCount();
-
-			if (depthMsCount == 0)
-				depthMsCount = 1;
-
-			if (colorMsCount == 0)
-				colorMsCount = 1;
-
-			if (depthTexProps.getWidth() != firstTexProps.getWidth() ||
-				depthTexProps.getHeight() != firstTexProps.getHeight() ||
-				depthMsCount != colorMsCount)
-			{
-				String errorInfo = "\nWidth: " + toString(depthTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
-				errorInfo += "\nHeight: " + toString(depthTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
-				errorInfo += "\nMultisample Count: " + toString(depthMsCount) + "/" + toString(colorMsCount);
-
-				BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
-			}
-		}
-	}
-
-	void MultiRenderTextureCore::copyToMemory(PixelData &dst, FrameBuffer buffer)
-	{
-		BS_EXCEPT(InternalErrorException,"The method or operation is not implemented.");
-	}
-
-	MultiRenderTexture::MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
-		:mDesc(desc)
-	{
-		for (UINT32 i = 0; i < (UINT32)desc.colorSurfaces.size(); i++)
-		{
-			if (desc.colorSurfaces[i].texture != nullptr)
-				mBindableColorTex.push_back(desc.colorSurfaces[i].texture);
-		}
-
-		if (desc.depthStencilSurface.texture != nullptr)
-			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
-	}
-
-	SPtr<CoreObjectCore> MultiRenderTexture::createCore() const
-	{
-		MULTI_RENDER_TEXTURE_CORE_DESC coreDesc;
-
-		for (auto& colorSurface : mDesc.colorSurfaces)
-		{
-			RENDER_SURFACE_CORE_DESC surfaceDesc;
-			if (colorSurface.texture.isLoaded())
-				surfaceDesc.texture = colorSurface.texture->getCore();
-
-			surfaceDesc.face = colorSurface.face;
-			surfaceDesc.numFaces = colorSurface.numFaces;
-			surfaceDesc.mipLevel = colorSurface.mipLevel;
-
-			coreDesc.colorSurfaces.push_back(surfaceDesc);
-		}
-
-		if (mDesc.depthStencilSurface.texture.isLoaded())
-			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
-
-		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
-		coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
-		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
-
-		return TextureCoreManager::instance().createMultiRenderTextureInternal(coreDesc);
-	}
-
-	SPtr<MultiRenderTextureCore> MultiRenderTexture::getCore() const
-	{
-		return std::static_pointer_cast<MultiRenderTextureCore>(mCoreSpecific);
-	}
-
-	SPtr<MultiRenderTexture> MultiRenderTexture::create(const MULTI_RENDER_TEXTURE_DESC& desc)
-	{
-		return TextureManager::instance().createMultiRenderTexture(desc);
-	}
-
-	CoreSyncData MultiRenderTexture::syncToCore(FrameAlloc* allocator)
-	{
-		UINT32 size = sizeof(MultiRenderTextureProperties);
-		UINT8* buffer = allocator->alloc(size);
-
-		MultiRenderTextureProperties& props = const_cast<MultiRenderTextureProperties&>(getProperties());
-
-		memcpy(buffer, (void*)&props, size);
-		return CoreSyncData(buffer, size);
-	}
-
-	const MultiRenderTextureProperties& MultiRenderTexture::getProperties() const
-	{
-		return static_cast<const MultiRenderTextureProperties&>(getPropertiesInternal());
-	}
-
-	UINT32 MultiRenderTexture::getColorSurfaceCount() const
-	{
-		return (UINT32)mDesc.colorSurfaces.size();
-	}
-}

+ 135 - 86
Source/BansheeCore/Source/BsRenderTexture.cpp

@@ -12,28 +12,34 @@ namespace BansheeEngine
 {
 {
 	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
 	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC& desc, bool requiresFlipping)
 	{
 	{
-		HTexture texture = desc.colorSurface.texture;
-
-		if (texture.isLoaded())
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		{
 		{
-			const TextureProperties& props = texture->getProperties();
-			construct(&props, requiresFlipping);
+			HTexture texture = desc.colorSurfaces[i].texture;
+
+			if (texture.isLoaded())
+			{
+				const TextureProperties& texProps = texture->getProperties();
+				construct(&texProps, requiresFlipping);
+
+				break;
+			}
 		}
 		}
-		else
-			construct(nullptr, requiresFlipping);
 	}
 	}
 
 
-	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_CORE_DESC& desc, bool requiresFlipping)
+	RenderTextureProperties::RenderTextureProperties(const RENDER_TEXTURE_DESC_CORE& desc, bool requiresFlipping)
 	{
 	{
-		SPtr<TextureCore> texture = desc.colorSurface.texture;
-
-		if (texture != nullptr)
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		{
 		{
-			const TextureProperties& props = texture->getProperties();
-			construct(&props, requiresFlipping);
+			SPtr<TextureCore> texture = desc.colorSurfaces[i].texture;
+
+			if (texture != nullptr)
+			{
+				const TextureProperties& texProps = texture->getProperties();
+				construct(&texProps, requiresFlipping);
+
+				break;
+			}
 		}
 		}
-		else
-			construct(nullptr, requiresFlipping);
 	}
 	}
 
 
 	void RenderTextureProperties::construct(const TextureProperties* textureProps, bool requiresFlipping)
 	void RenderTextureProperties::construct(const TextureProperties* textureProps, bool requiresFlipping)
@@ -52,14 +58,17 @@ namespace BansheeEngine
 		mRequiresTextureFlipping = requiresFlipping;
 		mRequiresTextureFlipping = requiresFlipping;
 	}
 	}
 
 
-	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
-		:mColorSurface(nullptr), mDepthStencilSurface(nullptr), mDesc(desc)
+	RenderTextureCore::RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc)
+		:mDesc(desc)
 	{ }
 	{ }
 
 
 	RenderTextureCore::~RenderTextureCore()
 	RenderTextureCore::~RenderTextureCore()
 	{ 
 	{ 
-		if (mColorSurface != nullptr)
-			TextureCore::releaseView(mColorSurface);
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
+		{
+			if (mColorSurfaces[i] != nullptr)
+				TextureCore::releaseView(mColorSurfaces[i]);
+		}
 
 
 		if (mDepthStencilSurface != nullptr)
 		if (mDepthStencilSurface != nullptr)
 			TextureCore::releaseView(mDepthStencilSurface);
 			TextureCore::releaseView(mDepthStencilSurface);
@@ -69,61 +78,35 @@ namespace BansheeEngine
 	{
 	{
 		RenderTargetCore::initialize();
 		RenderTargetCore::initialize();
 
 
-		const RENDER_SURFACE_CORE_DESC& colorSurface = mDesc.colorSurface;
-		if (colorSurface.texture != nullptr)
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		{
 		{
-			SPtr<TextureCore> texture = colorSurface.texture;
+			if (mDesc.colorSurfaces[i].texture != nullptr)
+			{
+				SPtr<TextureCore> texture = mDesc.colorSurfaces[i].texture;
 
 
-			if (texture->getProperties().getUsage() != TU_RENDERTARGET)
-				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
+				if (texture->getProperties().getUsage() != TU_RENDERTARGET)
+					BS_EXCEPT(InvalidParametersException, "Provided texture is not created with render target usage.");
 
 
-			mColorSurface = TextureCore::requestView(texture, colorSurface.mipLevel, 1,
-				colorSurface.face, colorSurface.numFaces, GVU_RENDERTARGET);
+				mColorSurfaces[i] = TextureCore::requestView(texture, mDesc.colorSurfaces[i].mipLevel, 1,
+					mDesc.colorSurfaces[i].face, mDesc.colorSurfaces[i].numFaces, GVU_RENDERTARGET);
+			}
 		}
 		}
 
 
-		const RENDER_SURFACE_CORE_DESC& depthStencilSurface = mDesc.depthStencilSurface;
-		if (depthStencilSurface.texture != nullptr)
+		if (mDesc.depthStencilSurface.texture != nullptr)
 		{
 		{
-			SPtr<TextureCore> texture = depthStencilSurface.texture;
+			SPtr<TextureCore> texture = mDesc.depthStencilSurface.texture;
 
 
 			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
 			if (texture->getProperties().getUsage() != TU_DEPTHSTENCIL)
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
 				BS_EXCEPT(InvalidParametersException, "Provided texture is not created with depth stencil usage.");
 
 
-			mDepthStencilSurface = TextureCore::requestView(texture, depthStencilSurface.mipLevel, 1,
-				depthStencilSurface.face, 0, GVU_DEPTHSTENCIL);
+			mDepthStencilSurface = TextureCore::requestView(texture, mDesc.depthStencilSurface.mipLevel, 1,
+				mDesc.depthStencilSurface.face, 0, GVU_DEPTHSTENCIL);
 		}
 		}
 
 
 		throwIfBuffersDontMatch();
 		throwIfBuffersDontMatch();
-
-		if (mColorSurface != nullptr)
-		{
-			assert(mColorSurface->getTexture() != nullptr);
-
-			SPtr<TextureCore> colorTexture = mColorSurface->getTexture();
-			const TextureProperties& texProps = colorTexture->getProperties();
-
-			UINT32 numSlices;
-			if (texProps.getTextureType() == TEX_TYPE_3D)
-				numSlices = texProps.getDepth();
-			else
-				numSlices = texProps.getNumFaces();
-
-			if ((mColorSurface->getFirstArraySlice() + mColorSurface->getNumArraySlices()) > numSlices)
-			{
-				BS_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
-					toString(mColorSurface->getFirstArraySlice() + mColorSurface->getNumArraySlices()) +
-					". Max num faces: " + toString(numSlices));
-			}
-
-			if (mColorSurface->getMostDetailedMip() > texProps.getNumMipmaps())
-			{
-				BS_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
-					toString(mColorSurface->getMostDetailedMip()) + ". Max num mipmaps: " + toString(texProps.getNumMipmaps()));
-			}
-		}
 	}
 	}
 
 
-	SPtr<RenderTextureCore> RenderTextureCore::create(const RENDER_TEXTURE_CORE_DESC& desc)
+	SPtr<RenderTextureCore> RenderTextureCore::create(const RENDER_TEXTURE_DESC_CORE& desc)
 	{
 	{
 		return TextureCoreManager::instance().createRenderTexture(desc);
 		return TextureCoreManager::instance().createRenderTexture(desc);
 	}
 	}
@@ -141,30 +124,87 @@ namespace BansheeEngine
 
 
 	void RenderTextureCore::throwIfBuffersDontMatch() const
 	void RenderTextureCore::throwIfBuffersDontMatch() const
 	{
 	{
-		if (mColorSurface == nullptr || mDepthStencilSurface == nullptr)
-			return;
+		SPtr<TextureView> firstSurfaceDesc = nullptr;
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
+		{
+			if (mColorSurfaces[i] == nullptr)
+				continue;
 
 
-		const TextureProperties& colorProps = mColorSurface->getTexture()->getProperties();
-		const TextureProperties& depthProps = mDepthStencilSurface->getTexture()->getProperties();
+			if (firstSurfaceDesc == nullptr)
+			{
+				firstSurfaceDesc = mColorSurfaces[i];
+				continue;
+			}
 
 
-		UINT32 colorMsCount = colorProps.getMultisampleCount();
-		UINT32 depthMsCount = depthProps.getMultisampleCount();
+			const TextureProperties& curTexProps = mColorSurfaces[i]->getTexture()->getProperties();
+			const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
 
 
-		if (colorMsCount == 0)
-			colorMsCount = 1;
+			UINT32 curMsCount = curTexProps.getMultisampleCount();
+			UINT32 firstMsCount = firstTexProps.getMultisampleCount();
 
 
-		if (depthMsCount == 0)
-			depthMsCount = 1;
+			if (curMsCount == 0)
+				curMsCount = 1;
 
 
-		if (colorProps.getWidth() != depthProps.getWidth() ||
-			colorProps.getHeight() != depthProps.getHeight() ||
-			colorMsCount != depthMsCount)
+			if (firstMsCount == 0)
+				firstMsCount = 1;
+
+			if (curTexProps.getWidth() != firstTexProps.getWidth() ||
+				curTexProps.getHeight() != firstTexProps.getHeight() ||
+				curMsCount != firstMsCount)
+			{
+				String errorInfo = "\nWidth: " + toString(curTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
+				errorInfo += "\nHeight: " + toString(curTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
+				errorInfo += "\nMultisample Count: " + toString(curMsCount) + "/" + toString(firstMsCount);
+
+				BS_EXCEPT(InvalidParametersException, "Provided color textures don't match!" + errorInfo);
+			}
+		}
+
+		if (firstSurfaceDesc != nullptr)
 		{
 		{
-			String errorInfo = "\nWidth: " + toString(colorProps.getWidth()) + "/" + toString(depthProps.getWidth());
-			errorInfo += "\nHeight: " + toString(colorProps.getHeight()) + "/" + toString(depthProps.getHeight());
-			errorInfo += "\nMultisample Count: " + toString(colorMsCount) + "/" + toString(depthMsCount);
+			const TextureProperties& firstTexProps = firstSurfaceDesc->getTexture()->getProperties();
+
+			UINT32 numSlices;
+			if (firstTexProps.getTextureType() == TEX_TYPE_3D)
+				numSlices = firstTexProps.getDepth();
+			else
+				numSlices = firstTexProps.getNumFaces();
+
+			if ((firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) > numSlices)
+			{
+				BS_EXCEPT(InvalidParametersException, "Provided number of faces is out of range. Face: " +
+					toString(firstSurfaceDesc->getFirstArraySlice() + firstSurfaceDesc->getNumArraySlices()) + ". Max num faces: " + toString(numSlices));
+			}
 
 
-			BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
+			if (firstSurfaceDesc->getMostDetailedMip() > firstTexProps.getNumMipmaps())
+			{
+				BS_EXCEPT(InvalidParametersException, "Provided number of mip maps is out of range. Mip level: " +
+					toString(firstSurfaceDesc->getMostDetailedMip()) + ". Max num mipmaps: " + toString(firstTexProps.getNumMipmaps()));
+			}
+
+			if (mDepthStencilSurface == nullptr)
+				return;
+
+			const TextureProperties& depthTexProps = mDepthStencilSurface->getTexture()->getProperties();
+			UINT32 depthMsCount = depthTexProps.getMultisampleCount();
+			UINT32 colorMsCount = firstTexProps.getMultisampleCount();
+
+			if (depthMsCount == 0)
+				depthMsCount = 1;
+
+			if (colorMsCount == 0)
+				colorMsCount = 1;
+
+			if (depthTexProps.getWidth() != firstTexProps.getWidth() ||
+				depthTexProps.getHeight() != firstTexProps.getHeight() ||
+				depthMsCount != colorMsCount)
+			{
+				String errorInfo = "\nWidth: " + toString(depthTexProps.getWidth()) + "/" + toString(firstTexProps.getWidth());
+				errorInfo += "\nHeight: " + toString(depthTexProps.getHeight()) + "/" + toString(firstTexProps.getHeight());
+				errorInfo += "\nMultisample Count: " + toString(depthMsCount) + "/" + toString(colorMsCount);
+
+				BS_EXCEPT(InvalidParametersException, "Provided texture and depth stencil buffer don't match!" + errorInfo);
+			}
 		}
 		}
 	}
 	}
 
 
@@ -187,11 +227,13 @@ namespace BansheeEngine
 	}
 	}
 
 
 	RenderTexture::RenderTexture(const RENDER_TEXTURE_DESC& desc)
 	RenderTexture::RenderTexture(const RENDER_TEXTURE_DESC& desc)
+		:mDesc(desc)
 	{
 	{
-		mDesc = desc;
-
-		if (desc.colorSurface.texture != nullptr)
-			mBindableColorTex = desc.colorSurface.texture;
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
+		{
+			if (desc.colorSurfaces[i].texture != nullptr)
+				mBindableColorTex[i] = desc.colorSurfaces[i].texture;
+		}
 
 
 		if (desc.depthStencilSurface.texture != nullptr)
 		if (desc.depthStencilSurface.texture != nullptr)
 			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
 			mBindableDepthStencilTex = desc.depthStencilSurface.texture;
@@ -199,17 +241,24 @@ namespace BansheeEngine
 
 
 	SPtr<CoreObjectCore> RenderTexture::createCore() const
 	SPtr<CoreObjectCore> RenderTexture::createCore() const
 	{
 	{
-		RENDER_TEXTURE_CORE_DESC coreDesc;
+		RENDER_TEXTURE_DESC_CORE coreDesc;
 
 
-		if (mDesc.colorSurface.texture.isLoaded())
-			coreDesc.colorSurface.texture = mDesc.colorSurface.texture->getCore();
+		for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
+		{
+			RENDER_SURFACE_DESC_CORE surfaceDesc;
+			if (mDesc.colorSurfaces[i].texture.isLoaded())
+				surfaceDesc.texture = mDesc.colorSurfaces[i].texture->getCore();
+
+			surfaceDesc.face = mDesc.colorSurfaces[i].face;
+			surfaceDesc.numFaces = mDesc.colorSurfaces[i].numFaces;
+			surfaceDesc.mipLevel = mDesc.colorSurfaces[i].mipLevel;
+
+			coreDesc.colorSurfaces[i] = surfaceDesc;
+		}
 
 
 		if (mDesc.depthStencilSurface.texture.isLoaded())
 		if (mDesc.depthStencilSurface.texture.isLoaded())
 			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
 			coreDesc.depthStencilSurface.texture = mDesc.depthStencilSurface.texture->getCore();
 
 
-		coreDesc.colorSurface.face = mDesc.colorSurface.face;
-		coreDesc.colorSurface.numFaces = mDesc.colorSurface.numFaces;
-		coreDesc.colorSurface.mipLevel = mDesc.colorSurface.mipLevel;
 		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
 		coreDesc.depthStencilSurface.face = mDesc.depthStencilSurface.face;
 		coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
 		coreDesc.depthStencilSurface.numFaces = mDesc.depthStencilSurface.numFaces;
 		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;
 		coreDesc.depthStencilSurface.mipLevel = mDesc.depthStencilSurface.mipLevel;

+ 5 - 23
Source/BansheeCore/Source/BsTextureManager.cpp

@@ -3,7 +3,6 @@
 #include "BsTextureManager.h"
 #include "BsTextureManager.h"
 #include "BsException.h"
 #include "BsException.h"
 #include "BsPixelUtil.h"
 #include "BsPixelUtil.h"
-#include "BsMultiRenderTexture.h"
 #include "BsRenderAPI.h"
 #include "BsRenderAPI.h"
 
 
 namespace BansheeEngine 
 namespace BansheeEngine 
@@ -53,10 +52,10 @@ namespace BansheeEngine
 		}
 		}
 
 
 		RENDER_TEXTURE_DESC desc;
 		RENDER_TEXTURE_DESC desc;
-		desc.colorSurface.texture = texture;
-		desc.colorSurface.face = 0;
-		desc.colorSurface.numFaces = 1;
-		desc.colorSurface.mipLevel = 0;
+		desc.colorSurfaces[0].texture = texture;
+		desc.colorSurfaces[0].face = 0;
+		desc.colorSurfaces[0].numFaces = 1;
+		desc.colorSurfaces[0].mipLevel = 0;
 
 
 		desc.depthStencilSurface.texture = depthStencil;
 		desc.depthStencilSurface.texture = depthStencil;
 		desc.depthStencilSurface.face = 0;
 		desc.depthStencilSurface.face = 0;
@@ -77,15 +76,6 @@ namespace BansheeEngine
 		return newRT;
 		return newRT;
 	}
 	}
 
 
-	SPtr<MultiRenderTexture> TextureManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
-	{
-		SPtr<MultiRenderTexture> newRT = createMultiRenderTextureImpl(desc);
-		newRT->_setThisPtr(newRT);
-		newRT->initialize();
-
-		return newRT;
-	}
-
 	void TextureCoreManager::onStartUp()
 	void TextureCoreManager::onStartUp()
     {
     {
 		// White built-in texture
 		// White built-in texture
@@ -144,19 +134,11 @@ namespace BansheeEngine
 		return newRT;
 		return newRT;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_CORE_DESC& desc)
+	SPtr<RenderTextureCore> TextureCoreManager::createRenderTexture(const RENDER_TEXTURE_DESC_CORE& desc)
 	{
 	{
 		SPtr<RenderTextureCore> newRT = createRenderTextureInternal(desc);
 		SPtr<RenderTextureCore> newRT = createRenderTextureInternal(desc);
 		newRT->initialize();
 		newRT->initialize();
 
 
 		return newRT;
 		return newRT;
 	}
 	}
-
-	SPtr<MultiRenderTextureCore> TextureCoreManager::createMultiRenderTexture(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-	{
-		SPtr<MultiRenderTextureCore> newRT = createMultiRenderTextureInternal(desc);
-		newRT->initialize();
-
-		return newRT;
-	}
 }
 }

+ 0 - 2
Source/BansheeD3D11RenderAPI/CMakeSources.cmake

@@ -15,7 +15,6 @@ set(BS_BANSHEED3D11RENDERAPI_INC_NOFILTER
 	"Include/BsD3D11QueryManager.h"
 	"Include/BsD3D11QueryManager.h"
 	"Include/BsD3D11Prerequisites.h"
 	"Include/BsD3D11Prerequisites.h"
 	"Include/BsD3D11OcclusionQuery.h"
 	"Include/BsD3D11OcclusionQuery.h"
-	"Include/BsD3D11MultiRenderTexture.h"
 	"Include/BsD3D11Mappings.h"
 	"Include/BsD3D11Mappings.h"
 	"Include/BsD3D11InputLayoutManager.h"
 	"Include/BsD3D11InputLayoutManager.h"
 	"Include/BsD3D11IndexBuffer.h"
 	"Include/BsD3D11IndexBuffer.h"
@@ -56,7 +55,6 @@ set(BS_BANSHEED3D11RENDERAPI_SRC_NOFILTER
 	"Source/BsD3D11QueryManager.cpp"
 	"Source/BsD3D11QueryManager.cpp"
 	"Source/BsD3D11Plugin.cpp"
 	"Source/BsD3D11Plugin.cpp"
 	"Source/BsD3D11OcclusionQuery.cpp"
 	"Source/BsD3D11OcclusionQuery.cpp"
-	"Source/BsD3D11MultiRenderTexture.cpp"
 	"Source/BsD3D11Mappings.cpp"
 	"Source/BsD3D11Mappings.cpp"
 	"Source/BsD3D11InputLayoutManager.cpp"
 	"Source/BsD3D11InputLayoutManager.cpp"
 	"Source/BsD3D11IndexBuffer.cpp"
 	"Source/BsD3D11IndexBuffer.cpp"

+ 0 - 61
Source/BansheeD3D11RenderAPI/Include/BsD3D11MultiRenderTexture.h

@@ -1,61 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsD3D11Prerequisites.h"
-#include "BsMultiRenderTexture.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup D3D11
-	 *  @{
-	 */
-
-	class D3D11MultiRenderTexture;
-
-	/**
-	 * DirectX 11 implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_D3D11_EXPORT D3D11MultiRenderTextureCore : public MultiRenderTextureCore
-	{
-	public:
-		D3D11MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~D3D11MultiRenderTextureCore();
-		
-		/** @copydoc MultiRenderTextureCore::getCustomAttribute */
-		void getCustomAttribute(const String& name, void* pData) const override;
-
-	protected:
-		friend class D3D11MultiRenderTexture;
-
-		/** @copydoc MultiRenderTextureCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
-
-	/**
-	 * DirectX 11 implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_D3D11_EXPORT D3D11MultiRenderTexture : public MultiRenderTexture
-	{
-	public:
-		virtual ~D3D11MultiRenderTexture() { }
-
-	protected:
-		friend class D3D11TextureManager;
-
-		D3D11MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc MultiRenderTexture::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
-
-	/** @} */
-}

+ 1 - 1
Source/BansheeD3D11RenderAPI/Include/BsD3D11RenderTexture.h

@@ -22,7 +22,7 @@ namespace BansheeEngine
 	class D3D11RenderTextureCore : public RenderTextureCore
 	class D3D11RenderTextureCore : public RenderTextureCore
 	{
 	{
 	public:
 	public:
-		D3D11RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
+		D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc);
 		virtual ~D3D11RenderTextureCore() { }
 		virtual ~D3D11RenderTextureCore() { }
 
 
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		/** @copydoc RenderTextureCore::getCustomAttribute */

+ 1 - 7
Source/BansheeD3D11RenderAPI/Include/BsD3D11TextureManager.h

@@ -21,9 +21,6 @@ namespace BansheeEngine
 	protected:		
 	protected:		
 		/** @copydoc TextureManager::createRenderTextureImpl */
 		/** @copydoc TextureManager::createRenderTextureImpl */
 		SPtr<RenderTexture> createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
 		SPtr<RenderTexture> createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
-
-		/** @copydoc TextureManager::createMultiRenderTextureImpl */
-		SPtr<MultiRenderTexture> createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) override;
 	};
 	};
 
 
 	/**	Handles creation of DirectX 11 textures. */
 	/**	Handles creation of DirectX 11 textures. */
@@ -36,10 +33,7 @@ namespace BansheeEngine
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) override;
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) override;
 
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) override;
-
-		/** @copydoc TextureCoreManager::createMultiRenderTextureInternal */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) override;
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc) override;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 0 - 54
Source/BansheeD3D11RenderAPI/Source/BsD3D11MultiRenderTexture.cpp

@@ -1,54 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsD3D11MultiRenderTexture.h"
-#include "BsD3D11Texture.h"
-#include "BsD3D11RenderTexture.h"
-#include "BsD3D11TextureView.h"
-
-namespace BansheeEngine
-{
-	D3D11MultiRenderTextureCore::D3D11MultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-		:MultiRenderTextureCore(desc), mProperties(desc, false)
-	{
-
-	}
-
-	D3D11MultiRenderTextureCore::~D3D11MultiRenderTextureCore()
-	{
-
-	}
-
-	void D3D11MultiRenderTextureCore::getCustomAttribute(const String& name, void* pData) const
-	{
-		if(name == "RTV")
-		{
-			ID3D11RenderTargetView** rtvs = (ID3D11RenderTargetView **)pData;
-			for(UINT32 i = 0; i < (UINT32)mColorSurfaces.size(); ++i)		
-			{
-				if (mColorSurfaces[i] == nullptr)
-					continue;
-
-				D3D11TextureView* textureView = static_cast<D3D11TextureView*>(mColorSurfaces[i].get());
-				rtvs[i] = textureView->getRTV();	
-			}
-		}
-		else if(name == "DSV")
-		{
-			ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView **)pData;
-
-			D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
-			*dsv = depthStencilView->getDSV(false);
-		}
-		else if (name == "RODSV")
-		{
-			ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView **)pData;
-
-			D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
-			*dsv = depthStencilView->getDSV(true);
-		}
-	}
-
-	D3D11MultiRenderTexture::D3D11MultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
-		:MultiRenderTexture(desc), mProperties(desc, false)
-	{ }
-}

+ 12 - 6
Source/BansheeD3D11RenderAPI/Source/BsD3D11RenderTexture.cpp

@@ -5,7 +5,7 @@
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
+	D3D11RenderTextureCore::D3D11RenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc)
 		:RenderTextureCore(desc), mProperties(desc, false)
 		:RenderTextureCore(desc), mProperties(desc, false)
 	{ 
 	{ 
 
 
@@ -15,16 +15,22 @@ namespace BansheeEngine
 	{
 	{
 		if(name == "RTV")
 		if(name == "RTV")
 		{
 		{
-			ID3D11RenderTargetView** rtvs = (ID3D11RenderTargetView **)data;			
-			D3D11TextureView* textureView = static_cast<D3D11TextureView*>(mColorSurface.get());
-			*rtvs = textureView->getRTV();		
+			ID3D11RenderTargetView** rtvs = (ID3D11RenderTargetView**)data;
+			for (UINT32 i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; ++i)
+			{
+				if (mColorSurfaces[i] == nullptr)
+					continue;
+
+				D3D11TextureView* textureView = static_cast<D3D11TextureView*>(mColorSurfaces[i].get());
+				rtvs[i] = textureView->getRTV();
+			}
 		}
 		}
 		else if(name == "DSV")
 		else if(name == "DSV")
 		{
 		{
 			if (mDepthStencilSurface == nullptr)
 			if (mDepthStencilSurface == nullptr)
 				return;
 				return;
 
 
-			ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView **)data;
+			ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
 			D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
 			D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
 
 
 			*dsv = depthStencilView->getDSV(false);
 			*dsv = depthStencilView->getDSV(false);
@@ -34,7 +40,7 @@ namespace BansheeEngine
 			if (mDepthStencilSurface == nullptr)
 			if (mDepthStencilSurface == nullptr)
 				return;
 				return;
 
 
-			ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView **)data;
+			ID3D11DepthStencilView** dsv = (ID3D11DepthStencilView**)data;
 			D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
 			D3D11TextureView* depthStencilView = static_cast<D3D11TextureView*>(mDepthStencilSurface.get());
 
 
 			*dsv = depthStencilView->getDSV(true);
 			*dsv = depthStencilView->getDSV(true);

+ 1 - 17
Source/BansheeD3D11RenderAPI/Source/BsD3D11TextureManager.cpp

@@ -5,7 +5,6 @@
 #include "BsD3D11RenderTexture.h"
 #include "BsD3D11RenderTexture.h"
 #include "BsD3D11Mappings.h"
 #include "BsD3D11Mappings.h"
 #include "BsD3D11RenderAPI.h"
 #include "BsD3D11RenderAPI.h"
-#include "BsD3D11MultiRenderTexture.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
@@ -16,13 +15,6 @@ namespace BansheeEngine
 		return bs_core_ptr<D3D11RenderTexture>(tex);
 		return bs_core_ptr<D3D11RenderTexture>(tex);
 	}
 	}
 
 
-	SPtr<MultiRenderTexture> D3D11TextureManager::createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc)
-	{
-		D3D11MultiRenderTexture* tex = new (bs_alloc<D3D11MultiRenderTexture>()) D3D11MultiRenderTexture(desc);
-
-		return bs_core_ptr<D3D11MultiRenderTexture>(tex);
-	}
-
 	PixelFormat D3D11TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
 	PixelFormat D3D11TextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
 	{
 	{
 		// Basic filtering
 		// Basic filtering
@@ -43,19 +35,11 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> D3D11TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc)
+	SPtr<RenderTextureCore> D3D11TextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc)
 	{
 	{
 		SPtr<D3D11RenderTextureCore> texPtr = bs_shared_ptr_new<D3D11RenderTextureCore>(desc);
 		SPtr<D3D11RenderTextureCore> texPtr = bs_shared_ptr_new<D3D11RenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
 
 
 		return texPtr;
 		return texPtr;
 	}
 	}
-
-	SPtr<MultiRenderTextureCore> D3D11TextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-	{
-		SPtr<D3D11MultiRenderTextureCore> texPtr = bs_shared_ptr_new<D3D11MultiRenderTextureCore>(desc);
-		texPtr->_setThisPtr(texPtr);
-
-		return texPtr;
-	}
 }
 }

+ 1 - 1
Source/BansheeEditor/Include/BsScenePicking.h

@@ -158,7 +158,7 @@ namespace BansheeEngine
 		static const float ALPHA_CUTOFF;
 		static const float ALPHA_CUTOFF;
 
 
 		MaterialData mMaterialData[3];
 		MaterialData mMaterialData[3];
-		SPtr<MultiRenderTextureCore> mPickingTexture;
+		SPtr<RenderTextureCore> mPickingTexture;
 	};
 	};
 
 
 	/** @} */
 	/** @} */

+ 8 - 10
Source/BansheeEditor/Source/BsScenePicking.cpp

@@ -16,8 +16,7 @@
 #include "BsMaterial.h"
 #include "BsMaterial.h"
 #include "BsPass.h"
 #include "BsPass.h"
 #include "BsRasterizerState.h"
 #include "BsRasterizerState.h"
-#include "BsRenderTarget.h"
-#include "BsMultiRenderTexture.h"
+#include "BsRenderTexture.h"
 #include "BsPixelData.h"
 #include "BsPixelData.h"
 #include "BsGpuParams.h"
 #include "BsGpuParams.h"
 #include "BsGpuParamsSet.h"
 #include "BsGpuParamsSet.h"
@@ -287,15 +286,14 @@ namespace BansheeEngine
 
 
 		SPtr<RenderTextureCore> rtt = std::static_pointer_cast<RenderTextureCore>(target);
 		SPtr<RenderTextureCore> rtt = std::static_pointer_cast<RenderTextureCore>(target);
 
 
-		SPtr<TextureCore> outputTexture = rtt->getBindableColorTexture();
+		SPtr<TextureCore> outputTexture = rtt->getColorTexture(0);
 		TextureProperties outputTextureProperties = outputTexture->getProperties();
 		TextureProperties outputTextureProperties = outputTexture->getProperties();
 
 
 		SPtr<TextureCore> normalsTexture = TextureCore::create(TEX_TYPE_2D, outputTextureProperties.getWidth(),
 		SPtr<TextureCore> normalsTexture = TextureCore::create(TEX_TYPE_2D, outputTextureProperties.getWidth(),
 			outputTextureProperties.getHeight(), 0, PF_R8G8B8A8, TU_RENDERTARGET, false, 1);
 			outputTextureProperties.getHeight(), 0, PF_R8G8B8A8, TU_RENDERTARGET, false, 1);
-		SPtr<TextureCore> depthTexture = rtt->getBindableDepthStencilTexture();
+		SPtr<TextureCore> depthTexture = rtt->getDepthStencilTexture();
 
 
-		MULTI_RENDER_TEXTURE_CORE_DESC pickingMRT;
-		pickingMRT.colorSurfaces.resize(2);
+		RENDER_TEXTURE_DESC_CORE pickingMRT;
 		pickingMRT.colorSurfaces[0].face = 0;
 		pickingMRT.colorSurfaces[0].face = 0;
 		pickingMRT.colorSurfaces[0].texture = outputTexture;
 		pickingMRT.colorSurfaces[0].texture = outputTexture;
 		pickingMRT.colorSurfaces[1].face = 0;
 		pickingMRT.colorSurfaces[1].face = 0;
@@ -304,7 +302,7 @@ namespace BansheeEngine
 		pickingMRT.depthStencilSurface.face = 0;
 		pickingMRT.depthStencilSurface.face = 0;
 		pickingMRT.depthStencilSurface.texture = depthTexture;
 		pickingMRT.depthStencilSurface.texture = depthTexture;
 		
 		
-		mPickingTexture = MultiRenderTextureCore::create(pickingMRT);
+		mPickingTexture = RenderTextureCore::create(pickingMRT);
 
 
 		rs.beginFrame();
 		rs.beginFrame();
 		rs.setRenderTarget(mPickingTexture);
 		rs.setRenderTarget(mPickingTexture);
@@ -372,9 +370,9 @@ namespace BansheeEngine
 			BS_EXCEPT(NotImplementedException, "Picking is not supported on render windows as framebuffer readback methods aren't implemented");
 			BS_EXCEPT(NotImplementedException, "Picking is not supported on render windows as framebuffer readback methods aren't implemented");
 		}
 		}
 
 
-		SPtr<TextureCore> outputTexture = mPickingTexture->getBindableColorTexture(0)->getTexture();
-		SPtr<TextureCore> normalsTexture = mPickingTexture->getBindableColorTexture(1)->getTexture();
-		SPtr<TextureCore> depthTexture = mPickingTexture->getBindableDepthStencilTexture()->getTexture();
+		SPtr<TextureCore> outputTexture = mPickingTexture->getColorTexture(0);
+		SPtr<TextureCore> normalsTexture = mPickingTexture->getColorTexture(1);
+		SPtr<TextureCore> depthTexture = mPickingTexture->getDepthStencilTexture();
 
 
 		if (position.x < 0 || position.x >= (INT32)outputTexture->getProperties().getWidth() ||
 		if (position.x < 0 || position.x >= (INT32)outputTexture->getProperties().getWidth() ||
 			position.y < 0 || position.y >= (INT32)outputTexture->getProperties().getHeight())
 			position.y < 0 || position.y >= (INT32)outputTexture->getProperties().getHeight())

+ 1 - 1
Source/BansheeEngine/Source/BsGUIRenderTexture.cpp

@@ -62,7 +62,7 @@ namespace BansheeEngine
 				mDesc.uvScale = Vector2(1.0f, -1.0f);
 				mDesc.uvScale = Vector2(1.0f, -1.0f);
 			}
 			}
 
 
-			setTexture(SpriteTexture::create(texture->getBindableColorTexture()));
+			setTexture(SpriteTexture::create(texture->getColorTexture(0)));
 
 
 			GUIManager::instance().setInputBridge(mSourceTexture.get(), this);
 			GUIManager::instance().setInputBridge(mSourceTexture.get(), this);
 		}
 		}

+ 0 - 2
Source/BansheeGLRenderAPI/CMakeSources.cmake

@@ -19,7 +19,6 @@ set(BS_BANSHEEGLRENDERAPI_INC_NOFILTER
 	"Include/BsGLPixelFormat.h"
 	"Include/BsGLPixelFormat.h"
 	"Include/BsGLPixelBuffer.h"
 	"Include/BsGLPixelBuffer.h"
 	"Include/BsGLOcclusionQuery.h"
 	"Include/BsGLOcclusionQuery.h"
-	"Include/BsGLMultiRenderTexture.h"
 	"Include/BsGLIndexBuffer.h"
 	"Include/BsGLIndexBuffer.h"
 	"Include/BsGLHardwareBufferManager.h"
 	"Include/BsGLHardwareBufferManager.h"
 	"Include/BsGLGpuParamBlockBuffer.h"
 	"Include/BsGLGpuParamBlockBuffer.h"
@@ -56,7 +55,6 @@ set(BS_BANSHEEGLRENDERAPI_SRC_NOFILTER
 	"Source/BsGLPixelFormat.cpp"
 	"Source/BsGLPixelFormat.cpp"
 	"Source/BsGLPixelBuffer.cpp"
 	"Source/BsGLPixelBuffer.cpp"
 	"Source/BsGLOcclusionQuery.cpp"
 	"Source/BsGLOcclusionQuery.cpp"
-	"Source/BsGLMultiRenderTexture.cpp"
 	"Source/BsGLIndexBuffer.cpp"
 	"Source/BsGLIndexBuffer.cpp"
 	"Source/BsGLHardwareBufferManager.cpp"
 	"Source/BsGLHardwareBufferManager.cpp"
 	"Source/BsGLGpuParamBlockBuffer.cpp"
 	"Source/BsGLGpuParamBlockBuffer.cpp"

+ 0 - 67
Source/BansheeGLRenderAPI/Include/BsGLMultiRenderTexture.h

@@ -1,67 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#pragma once
-
-#include "BsGLPrerequisites.h"
-#include "BsMultiRenderTexture.h"
-#include "BsGLFrameBufferObject.h"
-
-namespace BansheeEngine
-{
-	/** @addtogroup GL
-	 *  @{
-	 */
-
-	class GLMultiRenderTexture;
-
-	/**
-	 * OpenGL implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Core thread only.
-	 */
-	class BS_RSGL_EXPORT GLMultiRenderTextureCore : public MultiRenderTextureCore
-	{
-	public:
-		GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc);
-		virtual ~GLMultiRenderTextureCore();
-
-		/** @copydoc MultiRenderTextureCore::getCustomAttribute */
-		void getCustomAttribute(const String& name, void* pData) const override;
-	protected:
-		friend class GLTextureManager;
-
-		/** @copydoc CoreObjectCore::initialize */
-		virtual void initialize() override;
-
-	private:
-		GLFrameBufferObject* mFB;
-
-		/** @copydoc MultiRenderTextureCore::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
-
-	/**
-	 * OpenGL implementation of a render texture with multiple color surfaces.
-	 *
-	 * @note	Sim thread only.
-	 */
-	class BS_RSGL_EXPORT GLMultiRenderTexture : public MultiRenderTexture
-	{
-	public:
-		virtual ~GLMultiRenderTexture() { }
-
-	protected:
-		friend class GLTextureManager;
-
-		GLMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc);
-
-		/** @copydoc MultiRenderTexture::getProperties */
-		const RenderTargetProperties& getPropertiesInternal() const override { return mProperties; }
-
-		MultiRenderTextureProperties mProperties;
-	};
-
-	/** @} */
-}

+ 1 - 1
Source/BansheeGLRenderAPI/Include/BsGLRenderTexture.h

@@ -25,7 +25,7 @@ namespace BansheeEngine
     class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
     class BS_RSGL_EXPORT GLRenderTextureCore : public RenderTextureCore
     {
     {
 	public:
 	public:
-		GLRenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc);
+		GLRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc);
 		virtual ~GLRenderTextureCore();
 		virtual ~GLRenderTextureCore();
 
 
 		/** @copydoc RenderTextureCore::getCustomAttribute */
 		/** @copydoc RenderTextureCore::getCustomAttribute */

+ 1 - 7
Source/BansheeGLRenderAPI/Include/BsGLTextureManager.h

@@ -29,9 +29,6 @@ namespace BansheeEngine
 		/** @copydoc TextureManager::createRenderTextureImpl */
 		/** @copydoc TextureManager::createRenderTextureImpl */
 		SPtr<RenderTexture> createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
 		SPtr<RenderTexture> createRenderTextureImpl(const RENDER_TEXTURE_DESC& desc) override;
 
 
-		/** @copydoc TextureManager::createMultiRenderTextureImpl */
-		SPtr<MultiRenderTexture> createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc) override;
-
         GLSupport& mGLSupport;
         GLSupport& mGLSupport;
     };
     };
 
 
@@ -48,10 +45,7 @@ namespace BansheeEngine
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) override;
 			UINT32 multisampleCount = 0, UINT32 numArraySlices = 1, const SPtr<PixelData>& initialData = nullptr) override;
 
 
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
 		/** @copydoc TextureCoreManager::createRenderTextureInternal */
-		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc) override;
-
-		/** @copydoc TextureCoreManager::createMultiRenderTextureInternal */
-		SPtr<MultiRenderTextureCore> createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc) override;
+		SPtr<RenderTextureCore> createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc) override;
 
 
 		GLSupport& mGLSupport;
 		GLSupport& mGLSupport;
 	};
 	};

+ 0 - 117
Source/BansheeGLRenderAPI/Source/BsGLMultiRenderTexture.cpp

@@ -1,117 +0,0 @@
-//********************************** Banshee Engine (www.banshee3d.com) **************************************************//
-//**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
-#include "BsGLMultiRenderTexture.h"
-#include "BsGLTexture.h"
-
-namespace BansheeEngine
-{
-	GLMultiRenderTextureCore::GLMultiRenderTextureCore(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-		:MultiRenderTextureCore(desc), mFB(nullptr), mProperties(desc, true)
-	{ }
-
-	GLMultiRenderTextureCore::~GLMultiRenderTextureCore()
-	{ 
-		if (mFB != nullptr)
-			bs_delete(mFB);
-	}
-
-	void GLMultiRenderTextureCore::initialize()
-	{
-		MultiRenderTextureCore::initialize();
-
-		if (mFB != nullptr)
-			bs_delete(mFB);
-
-		mFB = bs_new<GLFrameBufferObject>();
-
-		for (size_t i = 0; i < mColorSurfaces.size(); i++)
-		{
-			if (mColorSurfaces[i] != nullptr)
-			{
-				GLTextureCore* glColorSurface = static_cast<GLTextureCore*>(mColorSurfaces[i]->getTexture().get());
-				GLSurfaceDesc surfaceDesc;
-				surfaceDesc.numSamples = getProperties().getMultisampleCount();
-
-				if (mColorSurfaces[i]->getNumArraySlices() == 1) // Binding a single texture layer
-				{
-					surfaceDesc.allLayers = glColorSurface->getProperties().getNumFaces() == 1;
-
-					if (glColorSurface->getProperties().getTextureType() != TEX_TYPE_3D)
-					{
-						surfaceDesc.zoffset = 0;
-						surfaceDesc.buffer = glColorSurface->getBuffer(mColorSurfaces[i]->getFirstArraySlice(),
-							mColorSurfaces[i]->getMostDetailedMip());
-					}
-					else
-					{
-						surfaceDesc.zoffset = mColorSurfaces[i]->getFirstArraySlice();
-						surfaceDesc.buffer = glColorSurface->getBuffer(0, mColorSurfaces[i]->getMostDetailedMip());
-					}
-				}
-				else // Binding an array of textures or a range of 3D texture slices
-				{
-					surfaceDesc.allLayers = true;
-
-					if (glColorSurface->getProperties().getTextureType() != TEX_TYPE_3D)
-					{
-						if (mColorSurfaces[i]->getNumArraySlices() != glColorSurface->getProperties().getNumFaces())
-							LOGWRN("OpenGL doesn't support binding of arbitrary ranges for array textures. The entire range will be bound instead.");
-
-						surfaceDesc.zoffset = 0;
-						surfaceDesc.buffer = glColorSurface->getBuffer(0, mColorSurfaces[i]->getMostDetailedMip());
-					}
-					else
-					{
-						if (mColorSurfaces[i]->getNumArraySlices() != glColorSurface->getProperties().getDepth())
-							LOGWRN("OpenGL doesn't support binding of arbitrary ranges for array textures. The entire range will be bound instead.");
-
-						surfaceDesc.zoffset = 0;
-						surfaceDesc.buffer = glColorSurface->getBuffer(0, mColorSurfaces[i]->getMostDetailedMip());
-					}
-
-					
-				}
-
-				mFB->bindSurface((UINT32)i, surfaceDesc);
-			}
-			else
-			{
-				mFB->unbindSurface((UINT32)i);
-			}
-		}
-
-		if (mDepthStencilSurface != nullptr)
-		{
-			GLTextureCore* glDepthStencilSurface = static_cast<GLTextureCore*>(mDepthStencilSurface->getTexture().get());
-			SPtr<GLPixelBuffer> depthStencilBuffer = nullptr;
-
-			if (glDepthStencilSurface->getProperties().getTextureType() != TEX_TYPE_3D)
-			{
-				depthStencilBuffer = glDepthStencilSurface->getBuffer(mDepthStencilSurface->getDesc().firstArraySlice,
-					mDepthStencilSurface->getDesc().mostDetailMip);
-			}
-
-			mFB->bindDepthStencil(depthStencilBuffer);
-		}
-		else
-		{
-			mFB->unbindDepthStencil();
-		}
-	}
-
-	void GLMultiRenderTextureCore::getCustomAttribute(const String& name, void* pData) const
-	{
-		if(name=="FBO")
-		{
-			*static_cast<GLFrameBufferObject **>(pData) = mFB;
-		}
-		else if (name == "GL_FBOID" || name == "GL_MULTISAMPLEFBOID")
-		{
-			*static_cast<GLuint*>(pData) = mFB->getGLFBOID();
-		}
-	}
-
-	GLMultiRenderTexture::GLMultiRenderTexture(const MULTI_RENDER_TEXTURE_DESC& desc)
-		:MultiRenderTexture(desc), mProperties(desc, true)
-	{ }
-}

+ 43 - 36
Source/BansheeGLRenderAPI/Source/BsGLRenderTexture.cpp

@@ -20,7 +20,7 @@ namespace BansheeEngine
 
 
 #define DEPTHFORMAT_COUNT (sizeof(depthFormats)/sizeof(GLenum))
 #define DEPTHFORMAT_COUNT (sizeof(depthFormats)/sizeof(GLenum))
 
 
-	GLRenderTextureCore::GLRenderTextureCore(const RENDER_TEXTURE_CORE_DESC& desc)
+	GLRenderTextureCore::GLRenderTextureCore(const RENDER_TEXTURE_DESC_CORE& desc)
 		:RenderTextureCore(desc), mProperties(desc, true), mFB(nullptr)
 		:RenderTextureCore(desc), mProperties(desc, true), mFB(nullptr)
 	{ }
 	{ }
 
 
@@ -39,51 +39,58 @@ namespace BansheeEngine
 
 
 		mFB = bs_new<GLFrameBufferObject>();
 		mFB = bs_new<GLFrameBufferObject>();
 
 
-		if (mColorSurface != nullptr && mColorSurface->getTexture() != nullptr)
+		for (size_t i = 0; i < BS_MAX_MULTIPLE_RENDER_TARGETS; i++)
 		{
 		{
-			GLTextureCore* glTexture = static_cast<GLTextureCore*>(mColorSurface->getTexture().get());
-
-			GLSurfaceDesc surfaceDesc;
-			surfaceDesc.numSamples = getProperties().getMultisampleCount();
-
-			if (mColorSurface->getNumArraySlices() == 1) // Binding a single texture layer
+			if (mColorSurfaces[i] != nullptr)
 			{
 			{
-				surfaceDesc.allLayers = glTexture->getProperties().getNumFaces() == 1;
+				GLTextureCore* glColorSurface = static_cast<GLTextureCore*>(mColorSurfaces[i]->getTexture().get());
+				GLSurfaceDesc surfaceDesc;
+				surfaceDesc.numSamples = getProperties().getMultisampleCount();
 
 
-				if (glTexture->getProperties().getTextureType() != TEX_TYPE_3D)
+				if (mColorSurfaces[i]->getNumArraySlices() == 1) // Binding a single texture layer
 				{
 				{
-					surfaceDesc.zoffset = 0;
-					surfaceDesc.buffer = glTexture->getBuffer(mColorSurface->getFirstArraySlice(), mColorSurface->getMostDetailedMip());
+					surfaceDesc.allLayers = glColorSurface->getProperties().getNumFaces() == 1;
+
+					if (glColorSurface->getProperties().getTextureType() != TEX_TYPE_3D)
+					{
+						surfaceDesc.zoffset = 0;
+						surfaceDesc.buffer = glColorSurface->getBuffer(mColorSurfaces[i]->getFirstArraySlice(),
+							mColorSurfaces[i]->getMostDetailedMip());
+					}
+					else
+					{
+						surfaceDesc.zoffset = mColorSurfaces[i]->getFirstArraySlice();
+						surfaceDesc.buffer = glColorSurface->getBuffer(0, mColorSurfaces[i]->getMostDetailedMip());
+					}
 				}
 				}
-				else
+				else // Binding an array of textures or a range of 3D texture slices
 				{
 				{
-					surfaceDesc.zoffset = mColorSurface->getFirstArraySlice();
-					surfaceDesc.buffer = glTexture->getBuffer(0, mColorSurface->getMostDetailedMip());
+					surfaceDesc.allLayers = true;
+
+					if (glColorSurface->getProperties().getTextureType() != TEX_TYPE_3D)
+					{
+						if (mColorSurfaces[i]->getNumArraySlices() != glColorSurface->getProperties().getNumFaces())
+							LOGWRN("OpenGL doesn't support binding of arbitrary ranges for array textures. The entire range will be bound instead.");
+
+						surfaceDesc.zoffset = 0;
+						surfaceDesc.buffer = glColorSurface->getBuffer(0, mColorSurfaces[i]->getMostDetailedMip());
+					}
+					else
+					{
+						if (mColorSurfaces[i]->getNumArraySlices() != glColorSurface->getProperties().getDepth())
+							LOGWRN("OpenGL doesn't support binding of arbitrary ranges for array textures. The entire range will be bound instead.");
+
+						surfaceDesc.zoffset = 0;
+						surfaceDesc.buffer = glColorSurface->getBuffer(0, mColorSurfaces[i]->getMostDetailedMip());
+					}
 				}
 				}
+
+				mFB->bindSurface((UINT32)i, surfaceDesc);
 			}
 			}
-			else // Binding an array of textures or a range of 3D texture slices
+			else
 			{
 			{
-				surfaceDesc.allLayers = true;
-
-				if (glTexture->getProperties().getTextureType() != TEX_TYPE_3D)
-				{
-					if (mColorSurface->getNumArraySlices() != glTexture->getProperties().getNumFaces())
-						LOGWRN("OpenGL doesn't support binding of arbitrary ranges for array textures. The entire range will be bound instead.");
-
-					surfaceDesc.zoffset = 0;
-					surfaceDesc.buffer = glTexture->getBuffer(0, mColorSurface->getMostDetailedMip());
-				}
-				else
-				{
-					if (mColorSurface->getNumArraySlices() != glTexture->getProperties().getDepth())
-						LOGWRN("OpenGL doesn't support binding of arbitrary ranges for array textures. The entire range will be bound instead.");
-
-					surfaceDesc.zoffset = 0;
-					surfaceDesc.buffer = glTexture->getBuffer(0, mColorSurface->getMostDetailedMip());
-				}
+				mFB->unbindSurface((UINT32)i);
 			}
 			}
-
-			mFB->bindSurface(0, surfaceDesc);
 		}
 		}
 
 
 		if (mDepthStencilSurface != nullptr && mDepthStencilSurface->getTexture() != nullptr)
 		if (mDepthStencilSurface != nullptr && mDepthStencilSurface->getTexture() != nullptr)

+ 1 - 17
Source/BansheeGLRenderAPI/Source/BsGLTextureManager.cpp

@@ -3,7 +3,6 @@
 #include "BsGLTextureManager.h"
 #include "BsGLTextureManager.h"
 #include "BsRenderAPI.h"
 #include "BsRenderAPI.h"
 #include "BsGLRenderTexture.h"
 #include "BsGLRenderTexture.h"
-#include "BsGLMultiRenderTexture.h"
 #include "BsGLPixelFormat.h"
 #include "BsGLPixelFormat.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
@@ -26,13 +25,6 @@ namespace BansheeEngine
 		return bs_core_ptr<GLRenderTexture>(tex);
 		return bs_core_ptr<GLRenderTexture>(tex);
 	}
 	}
 
 
-	SPtr<MultiRenderTexture> GLTextureManager::createMultiRenderTextureImpl(const MULTI_RENDER_TEXTURE_DESC& desc)
-	{
-		GLMultiRenderTexture* tex = new (bs_alloc<GLMultiRenderTexture>()) GLMultiRenderTexture(desc);
-
-		return bs_core_ptr<GLMultiRenderTexture>(tex);
-	}
-
 	PixelFormat GLTextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
 	PixelFormat GLTextureManager::getNativeFormat(TextureType ttype, PixelFormat format, int usage, bool hwGamma)
 	{
 	{
 		// Adjust requested parameters to capabilities
 		// Adjust requested parameters to capabilities
@@ -78,19 +70,11 @@ namespace BansheeEngine
 		return texPtr;
 		return texPtr;
 	}
 	}
 
 
-	SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_CORE_DESC& desc)
+	SPtr<RenderTextureCore> GLTextureCoreManager::createRenderTextureInternal(const RENDER_TEXTURE_DESC_CORE& desc)
 	{
 	{
 		SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr_new<GLRenderTextureCore>(desc);
 		SPtr<GLRenderTextureCore> texPtr = bs_shared_ptr_new<GLRenderTextureCore>(desc);
 		texPtr->_setThisPtr(texPtr);
 		texPtr->_setThisPtr(texPtr);
 
 
 		return texPtr;
 		return texPtr;
 	}
 	}
-
-	SPtr<MultiRenderTextureCore> GLTextureCoreManager::createMultiRenderTextureInternal(const MULTI_RENDER_TEXTURE_CORE_DESC& desc)
-	{
-		SPtr<GLMultiRenderTextureCore> texPtr = bs_shared_ptr_new<GLMultiRenderTextureCore>(desc);
-		texPtr->_setThisPtr(texPtr);
-
-		return texPtr;
-	}
 }
 }

+ 1 - 1
Source/RenderBeast/Include/BsRenderTargets.h

@@ -84,7 +84,7 @@ namespace BansheeEngine
 		SPtr<PooledRenderTexture> mNormalTex;
 		SPtr<PooledRenderTexture> mNormalTex;
 		SPtr<PooledRenderTexture> mDepthTex;
 		SPtr<PooledRenderTexture> mDepthTex;
 
 
-		SPtr<MultiRenderTextureCore> mGBufferRT;
+		SPtr<RenderTextureCore> mGBufferRT;
 		SPtr<RenderTextureCore> mSceneColorRT;
 		SPtr<RenderTextureCore> mSceneColorRT;
 
 
 		PixelFormat mSceneColorFormat;
 		PixelFormat mSceneColorFormat;

+ 2 - 2
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -24,7 +24,7 @@ namespace BansheeEngine
 	void DownsampleMat::execute(const SPtr<RenderTextureCore>& target, PostProcessInfo& ppInfo)
 	void DownsampleMat::execute(const SPtr<RenderTextureCore>& target, PostProcessInfo& ppInfo)
 	{
 	{
 		// Set parameters
 		// Set parameters
-		SPtr<TextureCore> colorTexture = target->getBindableColorTexture();
+		SPtr<TextureCore> colorTexture = target->getColorTexture(0);
 		mInputTexture.set(colorTexture);
 		mInputTexture.set(colorTexture);
 
 
 		const RenderTextureProperties& rtProps = target->getProperties();
 		const RenderTextureProperties& rtProps = target->getProperties();
@@ -372,7 +372,7 @@ namespace BansheeEngine
 		mParams.gManualExposureScale.set(Math::pow(2.0f, ppInfo.settings->exposureScale));
 		mParams.gManualExposureScale.set(Math::pow(2.0f, ppInfo.settings->exposureScale));
 
 
 		// Set parameters
 		// Set parameters
-		SPtr<TextureCore> colorTexture = sceneColor->getBindableColorTexture();
+		SPtr<TextureCore> colorTexture = sceneColor->getColorTexture(0);
 		mInputTex.set(colorTexture);
 		mInputTex.set(colorTexture);
 
 
 		SPtr<TextureCore> colorLUT;
 		SPtr<TextureCore> colorLUT;

+ 7 - 9
Source/RenderBeast/Source/BsRenderTargets.cpp

@@ -52,9 +52,7 @@ namespace BansheeEngine
 
 
 		if (mGBufferRT == nullptr || mSceneColorRT == nullptr || rebuildTargets)
 		if (mGBufferRT == nullptr || mSceneColorRT == nullptr || rebuildTargets)
 		{
 		{
-			MULTI_RENDER_TEXTURE_CORE_DESC gbufferDesc;
-			gbufferDesc.colorSurfaces.resize(3);
-
+			RENDER_TEXTURE_DESC_CORE gbufferDesc;
 			gbufferDesc.colorSurfaces[0].texture = mSceneColorTex->texture;
 			gbufferDesc.colorSurfaces[0].texture = mSceneColorTex->texture;
 			gbufferDesc.colorSurfaces[0].face = 0;
 			gbufferDesc.colorSurfaces[0].face = 0;
 			gbufferDesc.colorSurfaces[0].numFaces = 1;
 			gbufferDesc.colorSurfaces[0].numFaces = 1;
@@ -74,13 +72,13 @@ namespace BansheeEngine
 			gbufferDesc.depthStencilSurface.face = 0;
 			gbufferDesc.depthStencilSurface.face = 0;
 			gbufferDesc.depthStencilSurface.mipLevel = 0;
 			gbufferDesc.depthStencilSurface.mipLevel = 0;
 
 
-			mGBufferRT = TextureCoreManager::instance().createMultiRenderTexture(gbufferDesc);
+			mGBufferRT = RenderTextureCore::create(gbufferDesc);
 
 
-			RENDER_TEXTURE_CORE_DESC sceneColorDesc;
-			sceneColorDesc.colorSurface.texture = mSceneColorTex->texture;
-			sceneColorDesc.colorSurface.face = 0;
-			sceneColorDesc.colorSurface.numFaces = 1;
-			sceneColorDesc.colorSurface.mipLevel = 0;
+			RENDER_TEXTURE_DESC_CORE sceneColorDesc;
+			sceneColorDesc.colorSurfaces[0].texture = mSceneColorTex->texture;
+			sceneColorDesc.colorSurfaces[0].face = 0;
+			sceneColorDesc.colorSurfaces[0].numFaces = 1;
+			sceneColorDesc.colorSurfaces[0].mipLevel = 0;
 
 
 			sceneColorDesc.depthStencilSurface.texture = mDepthTex->texture;
 			sceneColorDesc.depthStencilSurface.texture = mDepthTex->texture;
 			sceneColorDesc.depthStencilSurface.face = 0;
 			sceneColorDesc.depthStencilSurface.face = 0;

+ 5 - 5
Source/RenderBeast/Source/BsRenderTexturePool.cpp

@@ -50,14 +50,14 @@ namespace BansheeEngine
 		
 		
 		if ((desc.flag & (TU_RENDERTARGET | TU_DEPTHSTENCIL)) != 0)
 		if ((desc.flag & (TU_RENDERTARGET | TU_DEPTHSTENCIL)) != 0)
 		{
 		{
-			RENDER_TEXTURE_CORE_DESC rtDesc;
+			RENDER_TEXTURE_DESC_CORE rtDesc;
 
 
 			if ((desc.flag & TU_RENDERTARGET) != 0)
 			if ((desc.flag & TU_RENDERTARGET) != 0)
 			{
 			{
-				rtDesc.colorSurface.texture = newTextureData->texture;
-				rtDesc.colorSurface.face = 0;
-				rtDesc.colorSurface.numFaces = desc.depth;
-				rtDesc.colorSurface.mipLevel = 0;
+				rtDesc.colorSurfaces[0].texture = newTextureData->texture;
+				rtDesc.colorSurfaces[0].face = 0;
+				rtDesc.colorSurfaces[0].numFaces = desc.depth;
+				rtDesc.colorSurfaces[0].mipLevel = 0;
 			}
 			}
 
 
 			if ((desc.flag & TU_DEPTHSTENCIL) != 0)
 			if ((desc.flag & TU_DEPTHSTENCIL) != 0)

+ 2 - 9
Source/SBansheeEngine/Include/BsScriptRenderTexture2D.h

@@ -21,20 +21,13 @@ namespace BansheeEngine
 		/** @copydoc ScriptRenderTargetBase::getNativeValue */
 		/** @copydoc ScriptRenderTargetBase::getNativeValue */
 		SPtr<RenderTarget> getNativeValue() const override { return mRenderTarget; }
 		SPtr<RenderTarget> getNativeValue() const override { return mRenderTarget; }
 
 
-		/** Returns the internal wrapped render texture. Returns null if this object instead wraps a multi render target. */
+		/** Returns the internal wrapped render texture. */
 		SPtr<RenderTexture> getRenderTexture() const;
 		SPtr<RenderTexture> getRenderTexture() const;
 
 
-		/** 
-		 * Returns the internal wrapped multi render texture. Returns null if this object instead wraps a single render
-		 * target.
-		 */
-		SPtr<MultiRenderTexture> getMultiRenderTexture() const;
-
 	private:
 	private:
-		ScriptRenderTexture2D(const SPtr<RenderTarget>& target, bool isMulti, MonoObject* instance);
+		ScriptRenderTexture2D(const SPtr<RenderTarget>& target, MonoObject* instance);
 
 
 		SPtr<RenderTarget> mRenderTarget;
 		SPtr<RenderTarget> mRenderTarget;
-		bool mIsMulti;
 
 
 		/************************************************************************/
 		/************************************************************************/
 		/* 								CLR HOOKS						   		*/
 		/* 								CLR HOOKS						   		*/

+ 38 - 104
Source/SBansheeEngine/Source/BsScriptRenderTexture2D.cpp

@@ -7,14 +7,13 @@
 #include "BsMonoManager.h"
 #include "BsMonoManager.h"
 #include "BsRenderTexture.h"
 #include "BsRenderTexture.h"
 #include "BsScriptTexture2D.h"
 #include "BsScriptTexture2D.h"
-#include "BsMultiRenderTexture.h"
 #include "BsMonoUtil.h"
 #include "BsMonoUtil.h"
 #include "BsScriptResourceManager.h"
 #include "BsScriptResourceManager.h"
 
 
 namespace BansheeEngine
 namespace BansheeEngine
 {
 {
-	ScriptRenderTexture2D::ScriptRenderTexture2D(const SPtr<RenderTarget>& target, bool isMulti, MonoObject* instance)
-		:ScriptObject(instance), mRenderTarget(target), mIsMulti(isMulti)
+	ScriptRenderTexture2D::ScriptRenderTexture2D(const SPtr<RenderTarget>& target, MonoObject* instance)
+		:ScriptObject(instance), mRenderTarget(target)
 	{
 	{
 
 
 	}
 	}
@@ -29,26 +28,16 @@ namespace BansheeEngine
 
 
 	SPtr<RenderTexture> ScriptRenderTexture2D::getRenderTexture() const
 	SPtr<RenderTexture> ScriptRenderTexture2D::getRenderTexture() const
 	{
 	{
-		if (!mIsMulti)
-			return std::static_pointer_cast<RenderTexture>(mRenderTarget);
-
-		return nullptr;
-	}
-
-	SPtr<MultiRenderTexture> ScriptRenderTexture2D::getMultiRenderTexture() const
-	{
-		if (mIsMulti)
-			return std::static_pointer_cast<MultiRenderTexture>(mRenderTarget);
-
-		return nullptr;
+		return std::static_pointer_cast<RenderTexture>(mRenderTarget);
 	}
 	}
 
 
 	void ScriptRenderTexture2D::internal_createDetailed(MonoObject* instance, PixelFormat format, UINT32 width, UINT32 height,
 	void ScriptRenderTexture2D::internal_createDetailed(MonoObject* instance, PixelFormat format, UINT32 width, UINT32 height,
 		UINT32 numSamples, bool gammaCorrection, bool createDepth, PixelFormat depthStencilFormat)
 		UINT32 numSamples, bool gammaCorrection, bool createDepth, PixelFormat depthStencilFormat)
 	{
 	{
-		SPtr<RenderTexture> tex = RenderTexture::create(TEX_TYPE_2D, width, height, format, gammaCorrection, numSamples, createDepth, depthStencilFormat);
+		SPtr<RenderTexture> tex = RenderTexture::create(TEX_TYPE_2D, width, height, format, gammaCorrection, numSamples, 
+			createDepth, depthStencilFormat);
 
 
-		new (bs_alloc<ScriptRenderTexture2D>()) ScriptRenderTexture2D(tex, false, instance);
+		new (bs_alloc<ScriptRenderTexture2D>()) ScriptRenderTexture2D(tex, instance);
 	}
 	}
 
 
 	void ScriptRenderTexture2D::internal_create(MonoObject* instance, MonoArray* colorSurfaces, MonoObject* depthStencilSurface)
 	void ScriptRenderTexture2D::internal_create(MonoObject* instance, MonoArray* colorSurfaces, MonoObject* depthStencilSurface)
@@ -72,126 +61,71 @@ namespace BansheeEngine
 				depthStencilSurfaceDesc.texture = textureHandle;
 				depthStencilSurfaceDesc.texture = textureHandle;
 		}
 		}
 
 
-		SPtr<RenderTarget> tex;
-
-		UINT32 numSurfaces = colorSurfacesList.size();
-		bool isMulti = numSurfaces > 1;
-		if (isMulti)
-		{
-			MULTI_RENDER_TEXTURE_DESC desc;
-
-			for (UINT32 i = 0; i < numSurfaces; i++)
-			{
-				RENDER_SURFACE_DESC surfaceDesc;
-				surfaceDesc.face = 0;
-				surfaceDesc.mipLevel = 0;
-				surfaceDesc.numFaces = 1;
+		UINT32 numSurfaces = std::min(colorSurfacesList.size(), (UINT32)BS_MAX_MULTIPLE_RENDER_TARGETS);
 
 
-				MonoObject* surfaceObj = colorSurfacesList.get<MonoObject*>(i);
-				ScriptTexture2D* scriptSurface = ScriptTexture2D::toNative(surfaceObj);
-
-				if (scriptSurface != nullptr)
-				{
-					HTexture textureHandle = scriptSurface->getHandle();
-					if (!textureHandle.isLoaded())
-					{
-						LOGERR("Render texture must be created using a fully loaded texture.");
-					}
-					else
-						surfaceDesc.texture = textureHandle;
-				}
-
-				desc.colorSurfaces.push_back(surfaceDesc);
-			}
-
-			desc.depthStencilSurface = depthStencilSurfaceDesc;
-
-			tex = MultiRenderTexture::create(desc);
-		}
-		else
+		RENDER_TEXTURE_DESC desc;
+		for (UINT32 i = 0; i < numSurfaces; i++)
 		{
 		{
 			RENDER_SURFACE_DESC surfaceDesc;
 			RENDER_SURFACE_DESC surfaceDesc;
 			surfaceDesc.face = 0;
 			surfaceDesc.face = 0;
 			surfaceDesc.mipLevel = 0;
 			surfaceDesc.mipLevel = 0;
 			surfaceDesc.numFaces = 1;
 			surfaceDesc.numFaces = 1;
 
 
-			if (colorSurfacesList.size() > 0)
-			{
-				MonoObject* surfaceObj = colorSurfacesList.get<MonoObject*>(0);
-				ScriptTexture2D* scriptSurface = ScriptTexture2D::toNative(surfaceObj);
+			MonoObject* surfaceObj = colorSurfacesList.get<MonoObject*>(i);
+			ScriptTexture2D* scriptSurface = ScriptTexture2D::toNative(surfaceObj);
 
 
-				if (scriptSurface != nullptr)
+			if (scriptSurface != nullptr)
+			{
+				HTexture textureHandle = scriptSurface->getHandle();
+				if (!textureHandle.isLoaded())
 				{
 				{
-					HTexture textureHandle = scriptSurface->getHandle();
-					if (!textureHandle.isLoaded())
-					{
-						LOGERR("Render texture must be created using a fully loaded texture.");
-					}
-					else
-						surfaceDesc.texture = textureHandle;
+					LOGERR("Render texture must be created using a fully loaded texture.");
 				}
 				}
+				else
+					surfaceDesc.texture = textureHandle;
 			}
 			}
 
 
-			RENDER_TEXTURE_DESC desc;
-			desc.colorSurface = surfaceDesc;
-			desc.depthStencilSurface = depthStencilSurfaceDesc;
-			tex = RenderTexture::create(desc);
+			desc.colorSurfaces[i] = surfaceDesc;
 		}
 		}
 
 
-		new (bs_alloc<ScriptRenderTexture2D>()) ScriptRenderTexture2D(tex, isMulti, instance);
+		desc.depthStencilSurface = depthStencilSurfaceDesc;
+
+		SPtr<RenderTarget> tex = RenderTexture::create(desc);
+		new (bs_alloc<ScriptRenderTexture2D>()) ScriptRenderTexture2D(tex, instance);
 	}
 	}
 
 
 	void ScriptRenderTexture2D::internal_getColorSurfaces(ScriptRenderTexture2D* thisPtr, MonoArray** value)
 	void ScriptRenderTexture2D::internal_getColorSurfaces(ScriptRenderTexture2D* thisPtr, MonoArray** value)
 	{
 	{
-		if (thisPtr->mIsMulti)
-		{
-			SPtr<MultiRenderTexture> tex = thisPtr->getMultiRenderTexture();
+		SPtr<RenderTexture> tex = thisPtr->getRenderTexture();
 
 
-			UINT32 numColorSurfaces = tex->getColorSurfaceCount();
-			ScriptArray outArray = ScriptArray::create<ScriptTexture2D>(numColorSurfaces);
+		UINT32 numColorSurfaces = BS_MAX_MULTIPLE_RENDER_TARGETS;
+		ScriptArray outArray = ScriptArray::create<ScriptTexture2D>(numColorSurfaces);
 
 
-			for (UINT32 i = 0; i < numColorSurfaces; i++)
-			{
-				HTexture colorTex = tex->getBindableColorTexture(i);
+		for (UINT32 i = 0; i < numColorSurfaces; i++)
+		{
+			HTexture colorTex = tex->getColorTexture(i);
 
 
+			if (colorTex != nullptr)
+			{
 				ScriptTexture2D* scriptSurface;
 				ScriptTexture2D* scriptSurface;
 				ScriptResourceManager::instance().getScriptResource(colorTex, &scriptSurface, true);
 				ScriptResourceManager::instance().getScriptResource(colorTex, &scriptSurface, true);
 
 
-				outArray.set(i, scriptSurface->getManagedInstance());
-				*value = outArray.getInternal();
+				outArray.set<MonoObject*>(i, scriptSurface->getManagedInstance());
 			}
 			}
+			else
+				outArray.set<MonoObject*>(i, nullptr);
 		}
 		}
-		else
-		{
-			SPtr<RenderTexture> tex = thisPtr->getRenderTexture();
-			ScriptArray outArray = ScriptArray::create<ScriptTexture2D>(1);
-
-			HTexture colorTex = tex->getBindableColorTexture();
 
 
-			ScriptTexture2D* scriptSurface;
-			ScriptResourceManager::instance().getScriptResource(colorTex, &scriptSurface, true);
-
-			outArray.set(0, scriptSurface->getManagedInstance());
-			*value = outArray.getInternal();
-		}
+		*value = outArray.getInternal();
 	}
 	}
 
 
 	void ScriptRenderTexture2D::internal_getDepthStencilSurface(ScriptRenderTexture2D* thisPtr, MonoObject** value)
 	void ScriptRenderTexture2D::internal_getDepthStencilSurface(ScriptRenderTexture2D* thisPtr, MonoObject** value)
 	{
 	{
-		HTexture colorTex;
-		if (thisPtr->mIsMulti)
-		{
-			SPtr<MultiRenderTexture> tex = thisPtr->getMultiRenderTexture();
-			colorTex = tex->getBindableDepthStencilTexture();
-		}
-		else
-		{
-			SPtr<RenderTexture> tex = thisPtr->getRenderTexture();
-			colorTex = tex->getBindableDepthStencilTexture();
-		}
+		SPtr<RenderTexture> tex = thisPtr->getRenderTexture();
+		HTexture depthTex = tex->getDepthStencilTexture();
 
 
 		ScriptTexture2D* scriptSurface;
 		ScriptTexture2D* scriptSurface;
-		ScriptResourceManager::instance().getScriptResource(colorTex, &scriptSurface, true);
+		ScriptResourceManager::instance().getScriptResource(depthTex, &scriptSurface, true);
 
 
 		*value = scriptSurface->getManagedInstance();
 		*value = scriptSurface->getManagedInstance();
 	}
 	}