Explorar el Código

Added env map to PBS example

BearishSun hace 8 años
padre
commit
6532472e69

+ 6 - 0
Data/Examples/AssetLicences.txt

@@ -0,0 +1,6 @@
+Pistol & Hangar, models and textures
+ - Licensed privately for use in Banshee 3D example projects only. Created by Danijel Ribiæ:
+
+Paper mill HDR environment map
+ - Licensed under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License. Grabbed from http://www.hdrlabs.com/sibl/archive.html.
+ - License terms: https://creativecommons.org/licenses/by-nc-sa/3.0/us/

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4 - 0
Data/Examples/Environments/PaperMill_E_3k.hdr


+ 29 - 8
Source/ExamplePhysicallyBasedShading/Source/Main.cpp

@@ -9,20 +9,17 @@
 #include "BsTextureImportOptions.h"
 #include "BsTextureImportOptions.h"
 #include "BsMeshImportOptions.h"
 #include "BsMeshImportOptions.h"
 #include "BsMaterial.h"
 #include "BsMaterial.h"
-#include "BsShader.h"
 #include "BsVirtualInput.h"
 #include "BsVirtualInput.h"
 #include "BsCCamera.h"
 #include "BsCCamera.h"
 #include "BsCRenderable.h"
 #include "BsCRenderable.h"
 #include "BsCLight.h"
 #include "BsCLight.h"
-#include "BsGUIButton.h"
 #include "BsRenderAPI.h"
 #include "BsRenderAPI.h"
 #include "BsBuiltinResources.h"
 #include "BsBuiltinResources.h"
 #include "BsRTTIType.h"
 #include "BsRTTIType.h"
-#include "BsHString.h"
 #include "BsRenderWindow.h"
 #include "BsRenderWindow.h"
 #include "BsSceneObject.h"
 #include "BsSceneObject.h"
 #include "BsCoreThread.h"
 #include "BsCoreThread.h"
-#include "BsProfilerOverlay.h"
+#include "BsCSkybox.h"
 #include "BsEngineConfig.h"
 #include "BsEngineConfig.h"
 
 
 // Example includes
 // Example includes
@@ -44,9 +41,10 @@ namespace bs
 	
 	
 	/** 
 	/** 
 	 * Imports a texture at the provided path. Textures not in sRGB space (e.g. normal maps) need to be specially marked by
 	 * Imports a texture at the provided path. Textures not in sRGB space (e.g. normal maps) need to be specially marked by
-	 * setting 'isSRGB' to false. 
+	 * setting 'isSRGB' to false. Also allows for conversion of texture to cubemap by setting the 'isCubemap' parameter.
+	 * If the data should be imported in a floating point format, specify 'isHDR' to true.
 	 */
 	 */
-	HTexture loadTexture(const Path& path, bool isSRGB = true);	
+	HTexture loadTexture(const Path& path, bool isSRGB = true, bool isCubemap = false, bool isHDR = false);
 	
 	
 	/** Create a material used by our example model. */
 	/** Create a material used by our example model. */
 	HMaterial createMaterial();
 	HMaterial createMaterial();
@@ -125,6 +123,7 @@ namespace bs
 	Path exampleNormalsTexPath = dataPath + "Examples\\Pistol\\Pistol_NM.png";
 	Path exampleNormalsTexPath = dataPath + "Examples\\Pistol\\Pistol_NM.png";
 	Path exampleRoughnessTexPath = dataPath + "Examples\\Pistol\\Pistol_RGH.png";
 	Path exampleRoughnessTexPath = dataPath + "Examples\\Pistol\\Pistol_RGH.png";
 	Path exampleMetalnessTexPath = dataPath + "Examples\\Pistol\\Pistol_MTL.png";
 	Path exampleMetalnessTexPath = dataPath + "Examples\\Pistol\\Pistol_MTL.png";
+    Path exampleSkyCubemapPath = dataPath + "Examples\\Environments\\PaperMill_E_3k.hdr";
 
 
 	HCamera sceneCamera;
 	HCamera sceneCamera;
 
 
@@ -133,6 +132,7 @@ namespace bs
     HTexture exampleNormalsTex;
     HTexture exampleNormalsTex;
     HTexture exampleRoughnessTex;
     HTexture exampleRoughnessTex;
     HTexture exampleMetalnessTex;
     HTexture exampleMetalnessTex;
+    HTexture exampleSkyCubemap;
     HShader exampleShader;
     HShader exampleShader;
     HMaterial exampleMaterial;
     HMaterial exampleMaterial;
 
 
@@ -159,6 +159,7 @@ namespace bs
         exampleNormalsTex = loadTexture(exampleNormalsTexPath, false);
         exampleNormalsTex = loadTexture(exampleNormalsTexPath, false);
         exampleRoughnessTex = loadTexture(exampleRoughnessTexPath, false);
         exampleRoughnessTex = loadTexture(exampleRoughnessTexPath, false);
         exampleMetalnessTex = loadTexture(exampleMetalnessTexPath, false);
         exampleMetalnessTex = loadTexture(exampleMetalnessTexPath, false);
+        exampleSkyCubemap = loadTexture(exampleSkyCubemapPath, false, true, true);
 
 
 		// Load the default physically based shader for rendering opaque objects
 		// Load the default physically based shader for rendering opaque objects
         exampleShader = BuiltinResources::instance().getBuiltinShader(BuiltinShader::Standard);
         exampleShader = BuiltinResources::instance().getBuiltinShader(BuiltinShader::Standard);
@@ -193,7 +194,7 @@ namespace bs
 		return model;
 		return model;
 	}
 	}
 
 
-	HTexture loadTexture(const Path& path, bool isSRGB)
+	HTexture loadTexture(const Path& path, bool isSRGB, bool isCubemap, bool isHDR)
 	{
 	{
 		Path assetPath = path;
 		Path assetPath = path;
 		assetPath.setExtension(path.getExtension() + ".asset");
 		assetPath.setExtension(path.getExtension() + ".asset");
@@ -218,6 +219,16 @@ namespace bs
 
 
 				// Ensures we can save the texture contents
 				// Ensures we can save the texture contents
 				importOptions->setCPUCached(true);
 				importOptions->setCPUCached(true);
+
+                // Import as cubemap if needed
+                importOptions->setIsCubemap(isCubemap);
+
+                // If importing as cubemap, assume source is a panorama
+                importOptions->setCubemapSourceType(CubemapSourceType::Cylindrical);
+
+                // Importing using a HDR format if requested
+                if (isHDR)
+                    importOptions->setFormat(PF_FLOAT_R11G11B10);
 			}
 			}
 
 
 			// Import texture with specified import options
 			// Import texture with specified import options
@@ -267,7 +278,7 @@ namespace bs
 		renderable->setMaterial(material);
 		renderable->setMaterial(material);
 
 
         /************************************************************************/
         /************************************************************************/
-        /* 									LIGHTS                      		*/
+        /* 									LIGHT                       		*/
         /************************************************************************/
         /************************************************************************/
 
 
         // Add a light so that our object isn't completely in the dark.
         // Add a light so that our object isn't completely in the dark.
@@ -283,6 +294,16 @@ namespace bs
 	    light->setRange(10.0f);
 	    light->setRange(10.0f);
         light->setIntensity(100.0f);
         light->setIntensity(100.0f);
 
 
+        /************************************************************************/
+        /* 									SKYBOX                       		*/
+        /************************************************************************/
+
+        // Add a skybox texture for sky reflections
+        HSceneObject skyboxSO = SceneObject::create("Skybox");
+
+        HSkybox skybox = skyboxSO->addComponent<CSkybox>();
+        skybox->setTexture(exampleSkyCubemap);
+
 		/************************************************************************/
 		/************************************************************************/
 		/* 									CAMERA	                     		*/
 		/* 									CAMERA	                     		*/
 		/************************************************************************/
 		/************************************************************************/

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio