Просмотр исходного кода

Removed unused depth buffers or windows and high level render textures

BearishSun 9 лет назад
Родитель
Сommit
0eba22a68d

+ 2 - 2
Source/BansheeEditor/Include/BsMainEditorWindow.h

@@ -21,7 +21,7 @@ namespace BansheeEngine
 		void update() override;
 
 		/** @copydoc EditorWindowBase::isMain */
-		virtual bool isMain() const override { return true; }
+		bool isMain() const override { return true; }
 
 		/**	Gets the DockManager that is responsible for docking and placement of EditorWidget%s on the main window. */
 		DockManager& getDockManager() const { return *mDockManager; }
@@ -45,7 +45,7 @@ namespace BansheeEngine
 
 	protected:
 		/** @copydoc EditorWindowBase::resized */
-		virtual void resized() override;
+		void resized() override;
 
 		/**
 		 * Updates the placement of child GUI elements and their non-client areas (used for OS move/resize operations). 

+ 1 - 0
Source/BansheeEditor/Source/BsEditorApplication.cpp

@@ -44,6 +44,7 @@ namespace BansheeEngine
 		renderWindowDesc.fullscreen = false;
 		renderWindowDesc.border = WindowBorder::None;
 		renderWindowDesc.hideUntilSwap = true;
+		renderWindowDesc.depthBuffer = false;
 
 		return renderWindowDesc;
 	}

+ 1 - 0
Source/BansheeEditor/Source/BsEditorWindowBase.cpp

@@ -41,6 +41,7 @@ namespace BansheeEngine
 		renderWindowDesc.hideUntilSwap = true;
 		renderWindowDesc.left = left;
 		renderWindowDesc.top = top;
+		renderWindowDesc.depthBuffer = false;
 
 		mRenderWindow = RenderWindow::create(renderWindowDesc, gCoreApplication().getPrimaryWindow());
 

+ 1 - 0
Source/ExampleProject/Source/Main.cpp

@@ -80,6 +80,7 @@ int CALLBACK WinMain(
 	renderWindowDesc.videoMode = VideoMode(windowResWidth, windowResHeight);
 	renderWindowDesc.title = "Banshee Example App";
 	renderWindowDesc.fullscreen = false;
+	renderWindowDesc.depthBuffer = false;
 
 	// List of importer plugins we plan on using for importing various resources
 	Vector<String> importers;

+ 1 - 0
Source/Game/Source/Main.cpp

@@ -71,6 +71,7 @@ void runApplication()
 	renderWindowDesc.title = toString(gameSettings->titleBarText);
 	renderWindowDesc.fullscreen = false;
 	renderWindowDesc.hidden = gameSettings->fullscreen;
+	renderWindowDesc.depthBuffer = false;
 
 	Application::startUp(renderWindowDesc, RenderAPIPlugin::DX11);
 

+ 1 - 1
Source/MBansheeEditor/Windows/GameWindow.cs

@@ -167,7 +167,7 @@ namespace BansheeEditor
                 }
             }
 
-            RenderTexture2D renderTexture = new RenderTexture2D(PixelFormat.R8G8B8A8, rtWidth, rtHeight) {Priority = 1};
+            RenderTexture2D renderTexture = new RenderTexture2D(PixelFormat.R8G8B8A8, rtWidth, rtHeight) { Priority = 1};
 
             EditorApplication.MainRenderTarget = renderTexture;
             renderTextureGUI.RenderTexture = renderTexture;

+ 1 - 1
Source/MBansheeEngine/Rendering/RenderTexture2D.cs

@@ -27,7 +27,7 @@ namespace BansheeEngine
         /// <param name="depthStencilFormat">Format of the depth/stencil buffer, if <paramref name="createDepth"/> is
         ///                                  enabled. Format must be a valid depth/stencil format.</param>
         public RenderTexture2D(PixelFormat format, int width, int height, int numSamples = 1, 
-            bool gammaCorrection = false, bool createDepth = true, PixelFormat depthStencilFormat = PixelFormat.D24S8)
+            bool gammaCorrection = false, bool createDepth = false, PixelFormat depthStencilFormat = PixelFormat.D24S8)
         {
             Internal_CreateDetailed(this, format, width, height, numSamples, gammaCorrection, createDepth, depthStencilFormat);
         }

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

@@ -424,5 +424,7 @@ namespace BansheeEngine
 			else
 				mTonemapping_GO.execute(sceneColor, outputViewport, ppInfo);
 		}
+
+		// TODO - External code depends on the main RT being bound when this exits, make this clearer
 	}
 }

+ 59 - 57
Source/RenderBeast/Source/BsRenderBeast.cpp

@@ -572,82 +572,84 @@ namespace BansheeEngine
 		camData.target->bindSceneColor(true);
 
 		// Render light pass
-		SPtr<GpuParamBlockBufferCore> perCameraBuffer = mStaticHandler->getPerCameraParams().getBuffer();
+		{
+			SPtr<GpuParamBlockBufferCore> perCameraBuffer = mStaticHandler->getPerCameraParams().getBuffer();
 
-		SPtr<MaterialCore> dirMaterial = mDirLightMat->getMaterial();
-		SPtr<PassCore> dirPass = dirMaterial->getPass(0);
+			SPtr<MaterialCore> dirMaterial = mDirLightMat->getMaterial();
+			SPtr<PassCore> dirPass = dirMaterial->getPass(0);
 
-		setPass(dirPass);
-		mDirLightMat->setStaticParameters(camData.target, perCameraBuffer);
+			setPass(dirPass);
+			mDirLightMat->setStaticParameters(camData.target, perCameraBuffer);
 
-		for (auto& light : mDirectionalLights)
-		{
-			if (!light.internal->getIsActive())
-				continue;
+			for (auto& light : mDirectionalLights)
+			{
+				if (!light.internal->getIsActive())
+					continue;
 
-			mDirLightMat->setParameters(light.internal);
+				mDirLightMat->setParameters(light.internal);
 
-			// TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
-			//  - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
-			setPassParams(dirMaterial->getPassParameters(0), nullptr);
-			gRendererUtility().drawScreenQuad();
-		}
+				// TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
+				//  - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
+				setPassParams(dirMaterial->getPassParameters(0), nullptr);
+				gRendererUtility().drawScreenQuad();
+			}
 
-		// Draw point lights which our camera is within
-		SPtr<MaterialCore> pointInsideMaterial = mPointLightInMat->getMaterial();
-		SPtr<PassCore> pointInsidePass = pointInsideMaterial->getPass(0);
+			// Draw point lights which our camera is within
+			SPtr<MaterialCore> pointInsideMaterial = mPointLightInMat->getMaterial();
+			SPtr<PassCore> pointInsidePass = pointInsideMaterial->getPass(0);
 
-		// TODO - Possibly use instanced drawing here as only two meshes are drawn with various properties
-		setPass(pointInsidePass);
-		mPointLightInMat->setStaticParameters(camData.target, perCameraBuffer);
+			// TODO - Possibly use instanced drawing here as only two meshes are drawn with various properties
+			setPass(pointInsidePass);
+			mPointLightInMat->setStaticParameters(camData.target, perCameraBuffer);
 
-		// TODO - Cull lights based on visibility, right now I just iterate over all of them. 
-		for (auto& light : mPointLights)
-		{
-			if (!light.internal->getIsActive())
-				continue;
+			// TODO - Cull lights based on visibility, right now I just iterate over all of them. 
+			for (auto& light : mPointLights)
+			{
+				if (!light.internal->getIsActive())
+					continue;
 
-			float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
-			float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
+				float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
+				float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
 
-			bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
-			if (!cameraInLightGeometry)
-				continue;
+				bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
+				if (!cameraInLightGeometry)
+					continue;
 
-			mPointLightInMat->setParameters(light.internal);
+				mPointLightInMat->setParameters(light.internal);
 
-			// TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
-			//  - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
-			setPassParams(pointInsideMaterial->getPassParameters(0), nullptr);
-			SPtr<MeshCore> mesh = light.internal->getMesh();
-			gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
-		}
+				// TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
+				//  - I can't think of a good way to do this automatically. Probably best to do it in setParameters()
+				setPassParams(pointInsideMaterial->getPassParameters(0), nullptr);
+				SPtr<MeshCore> mesh = light.internal->getMesh();
+				gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
+			}
 
-		// Draw other point lights
-		SPtr<MaterialCore> pointOutsideMaterial = mPointLightOutMat->getMaterial();
-		SPtr<PassCore> pointOutsidePass = pointOutsideMaterial->getPass(0);
+			// Draw other point lights
+			SPtr<MaterialCore> pointOutsideMaterial = mPointLightOutMat->getMaterial();
+			SPtr<PassCore> pointOutsidePass = pointOutsideMaterial->getPass(0);
 
-		setPass(pointOutsidePass);
-		mPointLightOutMat->setStaticParameters(camData.target, perCameraBuffer);
+			setPass(pointOutsidePass);
+			mPointLightOutMat->setStaticParameters(camData.target, perCameraBuffer);
 
-		for (auto& light : mPointLights)
-		{
-			if (!light.internal->getIsActive())
-				continue;
+			for (auto& light : mPointLights)
+			{
+				if (!light.internal->getIsActive())
+					continue;
 
-			float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
-			float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
+				float distToLight = (light.internal->getBounds().getCenter() - camera->getPosition()).squaredLength();
+				float boundRadius = light.internal->getBounds().getRadius() * 1.05f + camera->getNearClipDistance() * 2.0f;
 
-			bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
-			if (cameraInLightGeometry)
-				continue;
+				bool cameraInLightGeometry = distToLight < boundRadius * boundRadius;
+				if (cameraInLightGeometry)
+					continue;
 
-			mPointLightOutMat->setParameters(light.internal);
+				mPointLightOutMat->setParameters(light.internal);
 
-			// TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
-			setPassParams(pointOutsideMaterial->getPassParameters(0), nullptr);
-			SPtr<MeshCore> mesh = light.internal->getMesh();
-			gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
+				// TODO - Bind parameters to the pipeline manually as I don't need to re-bind gbuffer textures for every light
+				setPassParams(pointOutsideMaterial->getPassParameters(0), nullptr);
+				SPtr<MeshCore> mesh = light.internal->getMesh();
+				gRendererUtility().draw(mesh, mesh->getProperties().getSubMesh(0));
+			}
 		}
 
 		camData.target->bindSceneColor(false);