ソースを参照

WIP - more work on post-processing
Fixed render material define settings

BearishSun 9 年 前
コミット
eb84ea1f6d

+ 1 - 1
Build/VS2015/BansheeEngine.sln

@@ -7,7 +7,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Notes", "_Notes", "{1D081E
 	ProjectSection(SolutionItems) = preProject
 		..\..\Documentation\CompilingDependenciesManually.txt = ..\..\Documentation\CompilingDependenciesManually.txt
 		..\..\Documentation\Mono-3.8.0-IntegrationGuide.txt = ..\..\Documentation\Mono-3.8.0-IntegrationGuide.txt
-		Mono-4.4.0.40-IntegrationGuide.txt = Mono-4.4.0.40-IntegrationGuide.txt
+		Mono-4.4.0-IntegrationGuide.txt = Mono-4.4.0-IntegrationGuide.txt
 		..\..\Documentation\NVTTCompilationGuide.txt = ..\..\Documentation\NVTTCompilationGuide.txt
 	EndProjectSection
 EndProject

+ 0 - 0
Build/VS2015/Mono-4.4.0.40-IntegrationGuide.txt → Build/VS2015/Mono-4.4.0-IntegrationGuide.txt


+ 5 - 13
Documentation/CompilingDependenciesManually.txt

@@ -2,10 +2,8 @@ This document lists all Banshee 3rd party libraries and provides information on
 as a guide if you wish to recompile all the dependencies manually. Normally dependencies will be pre-compiled for all
 supported platforms and environments.
 
-BansheeEngine relies on the following 3rd party libraries:
- - Mono 3.8.0
-    - http://www.mono-project.com
-	- See MonoIntegrationGuide.txt on how to compile & integrate Mono
+----------------------------------------------------------------------------------
+Core dependencies
 
 BansheeCore relies on the following 3rd party libraries:
  - NVIDIA Texture Tools 2.0.8
@@ -18,8 +16,7 @@ Place dependency files in:
  - Dynamic library files in (BansheeRootDir)/bin/(Platform)/(Configuration)
 
 ----------------------------------------------------------------------------------
-
-Banshee plug-in dependencies:
+Plug-in dependencies:
 
 Use the list below to find all dependencies used by specific projects in Banshee. Compilation of dependencies themselves are not explained unless there is something specific to take note of.
 All dependencies listed are shown with a specific version (the one Banshee was tested against), although many should work with newer versions as well, but that is up to you to test.
@@ -61,20 +58,15 @@ BansheeSL (optional) relies on:
   - http://sourceforge.net/projects/winflexbison/files/
 
 BansheeMono (optional if not using scripting or editor) relies on:
- - Mono 3.8.0
+ - Mono 4.4.0
   - http://www.mono-project.com/
-  - See Mono-3.8.0-IntegrationGuide.txt for instructions how to compile and set it up
+  - See Mono-4.4.0-IntegrationGuide.txt for instructions how to compile and set it up
 
 BansheePhysX (optional) relies on:
  - PhysX 3.3
   - https://github.com/NVIDIAGameWorks/PhysX-3.3
   - You will need PhysX3, PhysX3Common, PhysX3Cooking and PhysX3CharacterKinematic libraries
 
-BansheeCore relies on:
- - nVidia Texture Tools 2.0.8
-  - https://github.com/castano/nvidia-texture-tools
-  - See NVTTCompilationGuide.txt for instructions on how to compile
-
 Place plug-in specific dependency files in:
  - Library include files in (BansheeRootDir)/(PluginDir)/Dependencies/Include
  - Static library files in (BansheeRootDir)/(PluginDir)/Dependencies/lib/(Platform)/(Configuration)

+ 3 - 2
License/Third Party/Mono.txt

@@ -1,4 +1,5 @@
 Banshee uses Mono (www.mono-project.com) runtime and class libraries.
 
-Runtime libraries are under GNU Library GPL 2.0 license - http://www.gnu.org/copyleft/library.html#TOC1
-Class libraries are under MIT X11 license - http://opensource.org/licenses/mit-license.html
+Mono is licensed under the MIT license: 
+http://opensource.org/licenses/mit-license.html
+http://www.mono-project.com/docs/faq/licensing/

+ 9 - 8
Source/BansheeEngine/Source/BsBuiltinResources.cpp

@@ -1141,7 +1141,8 @@ namespace BansheeEngine
 
 			{
 				Path relativePath = filePath.getRelative(inputFolder);
-				relativePath.setFilename(relativePath.getWFilename() + L".asset");
+				Path relativeAssetPath = relativePath;
+				relativeAssetPath.setFilename(relativeAssetPath.getWFilename() + L".asset");
 
 				ImportOptionsPtr importOptions = gImporter().createImportOptions(filePath);
 				if (importOptions != nullptr)
@@ -1151,7 +1152,7 @@ namespace BansheeEngine
 						SPtr<TextureImportOptions> texImportOptions = std::static_pointer_cast<TextureImportOptions>(importOptions);
 						texImportOptions->setGenerateMipmaps(false);
 
-						resourcesToSave.push_back(std::make_pair(relativePath, texImportOptions));
+						resourcesToSave.push_back(std::make_pair(relativeAssetPath, texImportOptions));
 					}
 					else if (rtti_is_of_type<ShaderImportOptions>(importOptions))
 					{
@@ -1161,7 +1162,7 @@ namespace BansheeEngine
 
 						if(variations.size() == 0) // Not a renderer material or no variations, save normally
 						{
-							resourcesToSave.push_back(std::make_pair(relativePath, nullptr));
+							resourcesToSave.push_back(std::make_pair(relativeAssetPath, nullptr));
 						}
 						else // Renderer material, save a copy for each variation
 						{
@@ -1177,19 +1178,19 @@ namespace BansheeEngine
 
 								shaderImportOptions->getDefines() = variation.getAll();
 
-								Path uniquePath = relativePath;
-								uniquePath.setFilename(relativePath.getFilename() + "_" + toString(variationIdx));
-								resourcesToSave.push_back(std::make_pair(relativePath, shaderImportOptions));
+								Path uniquePath = relativeAssetPath;
+								uniquePath.setFilename(relativeAssetPath.getFilename() + "_" + toString(variationIdx));
+								resourcesToSave.push_back(std::make_pair(relativeAssetPath, shaderImportOptions));
 							}
 
 							variationIdx++;
 						}
 					}
 					else
-						resourcesToSave.push_back(std::make_pair(relativePath, nullptr));
+						resourcesToSave.push_back(std::make_pair(relativeAssetPath, nullptr));
 				}
 				else
-					resourcesToSave.push_back(std::make_pair(relativePath, nullptr));
+					resourcesToSave.push_back(std::make_pair(relativeAssetPath, nullptr));
 			}
 
 			for(auto& entry : resourcesToSave)

+ 1 - 0
Source/BansheeSL/Source/BsASTFX.c

@@ -221,6 +221,7 @@ void beginCodeBlock(ParseState* parseState)
 
 		if (parseState->defines[i].expr != 0)
 		{
+			appendCodeBlock(parseState, " ", 1);
 			appendCodeBlock(parseState, parseState->defines[i].expr, (int)strlen(parseState->defines[i].expr));
 			appendCodeBlock(parseState, "\n", 1);
 		}

+ 63 - 13
Source/RenderBeast/Include/BsRenderTexturePool.h

@@ -5,6 +5,7 @@
 #include "BsRenderBeastPrerequisites.h"
 #include "BsModule.h"
 #include "BsPixelUtil.h"
+#include "BsTexture.h"
 
 namespace BansheeEngine
 {
@@ -13,6 +14,7 @@ namespace BansheeEngine
 	 */
 
 	class RenderTexturePool;
+	struct POOLED_RENDER_TEXTURE_DESC;
 
 	/**	Contains data about a single render texture in the texture pool. */
 	struct PooledRenderTexture
@@ -39,14 +41,9 @@ namespace BansheeEngine
 		 * Attempts to find the unused render texture with the specified parameters in the pool, or creates a new texture
 		 * otherwise. When done with the texture make sure to call release().
 		 *
-		 * @param[in]	format		Pixel format used by the texture color surface.
-		 * @param[in]	width		Width of the render texture, in pixels.
-		 * @param[in]	height		Height of the render texture, in pixels.
-		 * @param[in]	hwGamma		Should the written pixels be gamma corrected.
-		 * @param[in]	samples		If higher than 1, texture containing multiple samples per pixel is created.
+		 * @param[in]	desc		Descriptor structure that describes what kind of texture to retrieve.
 		 */
-		SPtr<PooledRenderTexture> get(PixelFormat format, UINT32 width, UINT32 height, bool hwGamma = false, 
-			UINT32 samples = 0);
+		SPtr<PooledRenderTexture> get(const POOLED_RENDER_TEXTURE_DESC& desc);
 
 		/**
 		 * Releases a texture previously allocated with get(). The texture is returned to the pool so that it may be reused
@@ -70,17 +67,70 @@ namespace BansheeEngine
 		/**
 		 * Checks does the provided texture match the parameters.
 		 * 
-		 * @param[in]	texture		Texture to match against the parameters.
-		 * @param[in]	format		Pixel format used by the texture color surface.
+		 * @param[in]	desc	Descriptor structure that describes what kind of texture to match.
+		 * @return				True if the texture matches the descriptor, false otherwise.
+		 */
+		static bool matches(const SPtr<TextureCore>& texture, const POOLED_RENDER_TEXTURE_DESC& desc);
+
+		Map<PooledRenderTexture*, std::weak_ptr<PooledRenderTexture>> mTextures;
+	};
+
+	/** Structure used for creating a new pooled render texture. */
+	struct POOLED_RENDER_TEXTURE_DESC
+	{
+	public:
+		/**
+		 * Creates a descriptor for a two dimensional render texture.
+		 *
+		 * @param[in]	format		Pixel format used by the texture surface.
 		 * @param[in]	width		Width of the render texture, in pixels.
 		 * @param[in]	height		Height of the render texture, in pixels.
-		 * @param[in]	hwGamma		Should the written pixels be gamma corrected.
+		 * @param[in]	usage		Usage flags that control in which way is the texture going to be used.
 		 * @param[in]	samples		If higher than 1, texture containing multiple samples per pixel is created.
+		 * @param[in]	hwGamma		Should the written pixels be gamma corrected.
+		 * @return					Descriptor that is accepted by RenderTexturePool.
 		 */
-		bool matches(const SPtr<TextureCore>& texture, PixelFormat format, UINT32 width, UINT32 height, bool hwGamma,
-			UINT32 samples);
+		static POOLED_RENDER_TEXTURE_DESC create2D(PixelFormat format, UINT32 width, UINT32 height, 
+			INT32 usage = TU_STATIC, UINT32 samples = 0, bool hwGamma = false);
 
-		Map<PooledRenderTexture*, std::weak_ptr<PooledRenderTexture>> mTextures;
+		/**
+		 * Creates a descriptor for a three dimensional render texture.
+		 *
+		 * @param[in]	format		Pixel format used by the texture surface.
+		 * @param[in]	width		Width of the render texture, in pixels.
+		 * @param[in]	height		Height of the render texture, in pixels.
+		 * @param[in]	depth		Depth of the render texture, in pixels.
+		 * @param[in]	usage		Usage flags that control in which way is the texture going to be used.
+		 * @return					Descriptor that is accepted by RenderTexturePool.
+		 */
+		static POOLED_RENDER_TEXTURE_DESC create3D(PixelFormat format, UINT32 width, UINT32 height, UINT32 depth,
+			INT32 usage = TU_STATIC);
+
+		/**
+		 * Creates a descriptor for a cube render texture.
+		 *
+		 * @param[in]	format		Pixel format used by the texture surface.
+		 * @param[in]	width		Width of the render texture, in pixels.
+		 * @param[in]	height		Height of the render texture, in pixels.
+		 * @param[in]	usage		Usage flags that control in which way is the texture going to be used.
+		 * @return					Descriptor that is accepted by RenderTexturePool.
+		 */
+		static POOLED_RENDER_TEXTURE_DESC createCube(PixelFormat format, UINT32 width, UINT32 height,
+			INT32 usage = TU_STATIC);
+
+	private:
+		friend class RenderTexturePool;
+
+		POOLED_RENDER_TEXTURE_DESC() { }
+
+		UINT32 width;
+		UINT32 height;
+		UINT32 depth;
+		UINT32 numSamples;
+		PixelFormat format;
+		TextureUsage flag;
+		TextureType type;
+		bool hwGamma;
 	};
 
 	/** @} */

+ 17 - 5
Source/RenderBeast/Source/BsPostProcessing.cpp

@@ -2,6 +2,7 @@
 //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
 #include "BsPostProcessing.h"
 #include "BsRenderTexture.h"
+#include "BsRenderTexturePool.h"
 
 namespace BansheeEngine
 {
@@ -20,14 +21,25 @@ namespace BansheeEngine
 
 	void DownsampleMat::setParameters(const SPtr<RenderTextureCore>& target)
 	{
-		mInputTexture.set(target->getBindableColorTexture());
+		SPtr<TextureCore> colorTexture = target->getBindableColorTexture();
+		mInputTexture.set(colorTexture);
 
-		const RenderTextureProperties& props = target->getProperties();
-		Vector2 invTextureSize(1.0f / props.getWidth(), 1.0f / props.getHeight());
+		const RenderTextureProperties& rtProps = target->getProperties();
+		Vector2 invTextureSize(1.0f / rtProps.getWidth(), 1.0f / rtProps.getHeight());
 
 		mParams.gInvTexSize.set(invTextureSize);
 
-		// TODO - Output
+		const TextureProperties& colorProps = colorTexture->getProperties();
+
+		UINT32 width = std::max(1, Math::ceilToInt(colorProps.getWidth() * 0.5f));
+		UINT32 height = std::max(1, Math::ceilToInt(colorProps.getHeight() * 0.5f));
+
+		POOLED_RENDER_TEXTURE_DESC outputDesc = POOLED_RENDER_TEXTURE_DESC::create2D(colorProps.getFormat(), width, height, 
+			TU_RENDERTARGET);
+
+		SPtr<PooledRenderTexture> outputRT = RenderTexturePool::instance().get(outputDesc);
+		// TODO - Actually send params to GPU.
+		// TODO - keep reference to output RT, Release output RT, actually render to it
 	}
 
 	EyeAdaptHistogramMat::EyeAdaptHistogramMat()
@@ -76,7 +88,7 @@ namespace BansheeEngine
 	{
 		RenderAPICore& rapi = RenderAPICore::instance();
 
-
+		// TODO - Use plain white for initial eye adaptation tex needed for histogram reduce
 
 		// TODO - Downsample
 	}

+ 8 - 4
Source/RenderBeast/Source/BsRenderTargets.cpp

@@ -32,9 +32,12 @@ namespace BansheeEngine
 		UINT32 width = getWidth();
 		UINT32 height = getHeight();
 
-		SPtr<PooledRenderTexture> newAlbedoRT = texPool.get(mDiffuseFormat, width, height, false, mNumSamples);
-		SPtr<PooledRenderTexture> newNormalRT = texPool.get(mNormalFormat, width, height, false, mNumSamples);
-		SPtr<PooledRenderTexture> newDepthRT = texPool.get(PF_D24S8, width, height, false, mNumSamples);
+		SPtr<PooledRenderTexture> newAlbedoRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mDiffuseFormat, width, 
+			height, TU_RENDERTARGET, mNumSamples, false));
+		SPtr<PooledRenderTexture> newNormalRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(mNormalFormat, width, 
+			height, TU_RENDERTARGET, mNumSamples, false));
+		SPtr<PooledRenderTexture> newDepthRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(PF_D24S8, width, height, 
+			TU_DEPTHSTENCIL, mNumSamples, false));
 
 		SPtr<PooledRenderTexture> newColorRT = nullptr;
 
@@ -49,7 +52,8 @@ namespace BansheeEngine
 			resolvedRTProps.getMultisampleCount() == mNumSamples);
 
 		if (!useResolvedColor)
-			newColorRT = texPool.get(PF_B8G8R8X8, width, height, false, mNumSamples);
+			newColorRT = texPool.get(POOLED_RENDER_TEXTURE_DESC::create2D(PF_B8G8R8X8, width, height, TU_RENDERTARGET, 
+				mNumSamples, false));
 
 		bool rebuildTargets = newColorRT != mSceneColorTex || newAlbedoRT != mAlbedoTex || newNormalRT != mNormalTex || newDepthRT != mDepthTex;
 

+ 70 - 9
Source/RenderBeast/Source/BsRenderTexturePool.cpp

@@ -23,10 +23,8 @@ namespace BansheeEngine
 			texture.second.lock()->mPool = nullptr;
 	}
 
-	SPtr<PooledRenderTexture> RenderTexturePool::get(PixelFormat format, UINT32 width, UINT32 height, bool hwGamma, UINT32 samples)
+	SPtr<PooledRenderTexture> RenderTexturePool::get(const POOLED_RENDER_TEXTURE_DESC& desc)
 	{
-		bool depth = PixelUtil::isDepth(format);
-
 		for (auto& texturePair : mTextures)
 		{
 			SPtr<PooledRenderTexture> textureData = texturePair.second.lock();
@@ -37,7 +35,7 @@ namespace BansheeEngine
 			if (textureData->texture == nullptr)
 				continue;
 
-			if (matches(textureData->texture, format, width, height, hwGamma, samples))
+			if (matches(textureData->texture, desc))
 			{
 				textureData->mIsFree = false;
 				return textureData;
@@ -47,8 +45,8 @@ namespace BansheeEngine
 		SPtr<PooledRenderTexture> newTextureData = bs_shared_ptr_new<PooledRenderTexture>(this);
 		_registerTexture(newTextureData);
 
-		newTextureData->texture = TextureCoreManager::instance().createTexture(TEX_TYPE_2D, width, height, 1, 0,
-			format, depth ? TU_DEPTHSTENCIL : TU_RENDERTARGET, hwGamma, samples);
+		newTextureData->texture = TextureCoreManager::instance().createTexture(desc.type, desc.width, desc.height, 
+			desc.depth, 0, desc.format, desc.flag, desc.hwGamma, desc.numSamples);
 		
 		return newTextureData;
 	}
@@ -59,11 +57,26 @@ namespace BansheeEngine
 		iterFind->second.lock()->mIsFree = true;
 	}
 
-	bool RenderTexturePool::matches(const SPtr<TextureCore>& texture, PixelFormat format, UINT32 width, UINT32 height, bool hwGamma, UINT32 samples)
+	bool RenderTexturePool::matches(const SPtr<TextureCore>& texture, const POOLED_RENDER_TEXTURE_DESC& desc)
 	{
 		const TextureProperties& texProps = texture->getProperties();
-		return texProps.getFormat() == format && texProps.getWidth() == width && texProps.getHeight() == height &&
-			texProps.isHardwareGammaEnabled() == hwGamma && texProps.getMultisampleCount() == samples;
+
+		bool match = texProps.getTextureType() == desc.type && texProps.getFormat() == desc.format && 
+			texProps.getWidth() == desc.width && texProps.getHeight() == desc.height && texProps.getUsage() == desc.flag;
+
+		if (!match)
+			return false;
+
+		if(desc.type == TEX_TYPE_2D)
+			return texProps.isHardwareGammaEnabled() == desc.hwGamma && texProps.getMultisampleCount() == desc.numSamples;
+
+		if(desc.type == TEX_TYPE_3D)
+			return texProps.getDepth() == desc.depth;
+
+		if (desc.type == TEX_TYPE_CUBE_MAP)
+			return true;
+
+		return false;
 	}
 
 	void RenderTexturePool::_registerTexture(const SPtr<PooledRenderTexture>& texture)
@@ -75,4 +88,52 @@ namespace BansheeEngine
 	{
 		mTextures.erase(texture);
 	}
+
+	POOLED_RENDER_TEXTURE_DESC POOLED_RENDER_TEXTURE_DESC::create2D(PixelFormat format, UINT32 width, UINT32 height,
+		INT32 usage, UINT32 samples, bool hwGamma)
+	{
+		POOLED_RENDER_TEXTURE_DESC desc;
+		desc.width = width;
+		desc.height = height;
+		desc.depth = 1;
+		desc.format = format;
+		desc.numSamples = samples;
+		desc.flag = (TextureUsage)usage;
+		desc.hwGamma = hwGamma;
+		desc.type = TEX_TYPE_2D;
+
+		return desc;
+	}
+
+	POOLED_RENDER_TEXTURE_DESC POOLED_RENDER_TEXTURE_DESC::create3D(PixelFormat format, UINT32 width, UINT32 height, 
+		UINT32 depth, INT32 usage)
+	{
+		POOLED_RENDER_TEXTURE_DESC desc;
+		desc.width = width;
+		desc.height = height;
+		desc.depth = depth;
+		desc.format = format;
+		desc.numSamples = 1;
+		desc.flag = (TextureUsage)usage;
+		desc.hwGamma = false;
+		desc.type = TEX_TYPE_3D;
+
+		return desc;
+	}
+
+	POOLED_RENDER_TEXTURE_DESC POOLED_RENDER_TEXTURE_DESC::createCube(PixelFormat format, UINT32 width, UINT32 height,
+		INT32 usage)
+	{
+		POOLED_RENDER_TEXTURE_DESC desc;
+		desc.width = width;
+		desc.height = height;
+		desc.depth = 1;
+		desc.format = format;
+		desc.numSamples = 1;
+		desc.flag = (TextureUsage)usage;
+		desc.hwGamma = false;
+		desc.type = TEX_TYPE_CUBE_MAP;
+
+		return desc;
+	}
 }