Browse Source

Squashed commit of the following:

commit 8197605c1c6c660c71727db8472bf9a9ac2ae76d
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 23:55:05 2016 +0300

    Convert cubemap to DDS.

commit a06cf912e3a106f66137241722c7fd49c1805e2b
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 23:42:56 2016 +0300

    Fix D3D11 crash if trying to assign color texture as a depth stencil or vice versa. Remove mistaken assignment of the 4th rendertarget output from PBRDeferredHWDepth.xml.

commit de765127b10c8cef45689fd8117875930af7031a
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 23:17:37 2016 +0300

    Add possibility to configure default material technique in Renderer.

commit d876a081932f423a42adcc1371a6fac622e8d585
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 23:10:32 2016 +0300

    Refer to Utilities/Rotator.as script in the PBR scene.

commit 9e4078c9a1cfa4be040a523d3b51aaf55a332c40
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 23:06:00 2016 +0300

    Readd deleted Flare.dds.

commit 1f606cc883e89e15e32272f6d47877c6e511b74b
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 22:31:04 2016 +0300

    Remove NinjaSnowWar copypasta.

commit 745937646f3638a208e58c3cce76df7afbab8416
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 22:11:28 2016 +0300

    Separate skybox2 material. Remove unused materials. Fix typo in material name.

commit 258d0325d4bed282f28d8ec8364ee64700e4f025
Author: Lasse Öörni <[email protected]>
Date:   Thu Apr 14 22:04:48 2016 +0300

    Squashed commit of the following:

    commit a329abe9a2a0f77dcb415bafd15c6e309261e7cc
    Author: dragonCASTjosh <[email protected]>
    Date:   Thu Apr 14 15:08:26 2016 +0100

        removed white space

    commit 434b1d8599ce2d0828acfc2939b94b33cd821fad
    Author: dragonCASTjosh <[email protected]>
    Date:   Thu Apr 14 15:06:36 2016 +0100

        Updated Licence

    commit f89a2369c83791c43762ca2b34f8b3aeeb562b24
    Author: dragonCASTjosh <[email protected]>
    Date:   Thu Apr 14 15:03:57 2016 +0100

        Converted texture formats

    commit 028cd1da4d7ac226e1943a70abfd6037912c86b0
    Author: dragonCASTjosh <[email protected]>
    Date:   Thu Apr 14 14:55:31 2016 +0100

        Updated Licence

    commit ecc288b3cbc046a678bbc2d0df408b2f29220b30
    Author: dragonCASTjosh <[email protected]>
    Date:   Wed Apr 13 00:02:34 2016 +0100

        Added basic licence

    commit ce34c0496e80043e3e79f4273468a66463ed13cb
    Author: dragonCASTjosh <[email protected]>
    Date:   Tue Apr 12 14:00:52 2016 +0100

        Cleaned Up Data and Reverted Default Technique

    commit a9e08bbd3a4f08c09baa477a0ce06cef517d506e
    Merge: 53c53ae d009f11
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 9 11:10:30 2016 +0100

        Merge pull request #11 from hdunderscore/typoFix_Metallic

        Fix metallic typo

    commit 53c53aec4c1d935b31cbc0ce5eac93faaa5b9f89
    Merge: 851487e 9c1d728
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 9 11:08:17 2016 +0100

        Merge pull request #10 from cosmy1/patch-10

        Remove extra float casts

    commit d009f11865dfdf9634fa9c297f2cc339164724de
    Author: hdunderscore <[email protected]>
    Date:   Sat Apr 9 15:07:44 2016 +1000

        Fix metallic typo

    commit 9c1d728be919a74dfee8973b146f312121daed9e
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 9 04:50:36 2016 +0200

        Remove extra float casts

    commit 851487ea63c181eb45c5988eb71dd526e2c12852
    Merge: 3142270 8edbae9
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 8 19:32:06 2016 +0100

        Merge pull request #9 from hdunderscore/PBRChangesR

        Updates to IBL

    commit 8edbae92c5e454727126c444b49075ef07e36ab8
    Author: hdunderscore <[email protected]>
    Date:   Fri Apr 8 20:01:33 2016 +1000

        - Updated glsl shaders
        - Fixed a potential bug with direct lighting.
        - Introduced a new define &#39;PBRFAST' that will allow the IBL to take a short-cut for significantly higher frame-rate, but lower quality.

    commit e63a5d4faedb22710f28dbfdff3705fdfb3b1d22
    Author: hdunderscore <[email protected]>
    Date:   Fri Apr 8 10:06:18 2016 +1000

        Fixed a divide-by-zero in the CookTorranceBRDF, which was causing a visual issue in DX11.

    commit 37d30d906c93ebb2e4165f91db5adc7e7893edc4
    Author: hdunderscore <[email protected]>
    Date:   Fri Apr 8 00:30:26 2016 +1000

        Fixed specular IBL energy conservation.

    commit 4643342079dce76c3b26ac101745e49cabad7b68
    Author: hdunderscore <[email protected]>
    Date:   Thu Apr 7 21:27:16 2016 +1000

        - Exposed tangents and bi-tangents to the IBL.
        - Removed unused calculations in deferred first pass.
        - Added a simpler image sampling calculation.

    commit b7ea9b89fe455d8e9c62fc3a1dd441a8860c9708
    Author: hdunderscore <[email protected]>
    Date:   Wed Apr 6 22:44:09 2016 +1000

        - Fixed a few errors in the BRDF functions
        - Fixed the specular calculations
        - Small code refactor to allow for more consistency and easier experimentation.
        - Implemented the ImageSampling algorithm as described in Epic's 2013 paper, with improvements.
        - Implemented a true working deferred renderer.
        - Updated the concrete normal map (reversed the direction).
        - Changed the sRGB setting of the diffuse textures and cubemap, to perform calculations in linear space.
        - Added post-process effects to the PBR sample.

    commit 314227053b26c6ba70d7de32b2c5894d60d25784
    Author: dragonCASTjosh <[email protected]>
    Date:   Wed Apr 6 01:35:52 2016 +0100

        Missing OpenGL changes (reverted from commit 4169cfca4abe7b23b5f2a84aa391992fe22e3a8b)

    commit 9cd441c413f4742bca3889d3cdf9f2c290462e3d
    Author: dragonCASTjosh <[email protected]>
    Date:   Wed Apr 6 01:27:42 2016 +0100

        - Fix Metallic typo
        - Fix HLSL specular metallic bug
        - Fix indentation.
        - Fix BRDF typo.
        - Fix sample scene material to use normal maps.
        - Revert IBL Importance sample to use Epic described method.
        - Removed incorrect application of split sum on top of importance sample method.
        - Added diffuse IBL calculation. (reverted from commit 143379cee9968588974879e1ce53123f45d8741a)

    commit 143379cee9968588974879e1ce53123f45d8741a
    Author: dragonCASTjosh <[email protected]>
    Date:   Wed Apr 6 01:10:37 2016 +0100

        - Fix Metallic typo
        - Fix HLSL specular metallic bug
        - Fix indentation.
        - Fix BRDF typo.
        - Fix sample scene material to use normal maps.
        - Revert IBL Importance sample to use Epic described method.
        - Removed incorrect application of split sum on top of importance sample method.
        - Added diffuse IBL calculation.

    commit fbba0f389b571d0b3814254c16b05279bfd29a58
    Merge: 4169cfc c9ba2ec
    Author: dragonCASTjosh <[email protected]>
    Date:   Tue Apr 5 14:03:40 2016 +0100

        Merge pull request #5 from cosmy1/patch-6

        Update BDRF.hlsl

    commit 4169cfca4abe7b23b5f2a84aa391992fe22e3a8b
    Author: dragonCASTjosh <[email protected]>
    Date:   Mon Apr 4 22:55:56 2016 +0100

        Missing OpenGL changes

    commit 62491b160cd356cdf4bc292815862fbdea2be22a
    Author: dragonCASTjosh <[email protected]>
    Date:   Mon Apr 4 22:54:50 2016 +0100

        Fixed OpenGL PBR

    commit a453cfea1a061900c9de604b5d422d5915cf1712
    Author: dragonCASTjosh <[email protected]>
    Date:   Mon Apr 4 02:37:53 2016 +0100

        Fixed IBL function taking metallic

    commit e33efba25b455a6c77679941c489619a02fa1098
    Author: dragonCASTjosh <[email protected]>
    Date:   Mon Apr 4 02:35:28 2016 +0100

        Improve IBL and fixed specular color

    commit 4c7058f1c41bbed32c96df550cb93a14b17ec07d
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 2 01:43:18 2016 +0100

        Fixed HLSL

    commit 9d095a14ac64e34fa2c016e4503b2b076e64b025
    Merge: 2de2597 0a9ea24
    Author: dragonCASTjosh <[email protected]>
    Date:   Sun Apr 3 14:22:46 2016 +0100

        Merge pull request #6 from cosmy1/patch-8

        Update PBRExample.xml

    commit 2de259781a588c80117744892083065fbe5bb5c8
    Merge: 92ab68c 12bd826
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 2 20:51:30 2016 +0100

        Merge pull request #4 from cosmy1/patch-4

        Update IBL.glsl

    commit 92ab68ce3b94a092ad96d9cd0e577d1b7fedf61c
    Merge: 295a23e e1f5ac2
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 2 20:51:05 2016 +0100

        Merge pull request #3 from cosmy1/patch-3

        Update BRDF.glsl

    commit 0a9ea24b6681bac8e3deab58081ee9462b6ada31
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 2 11:54:33 2016 +0200

        Update PBRExample.xml

    commit c9ba2ec10f34da559c6148cb0d8d9cbc2ca62ff0
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 2 11:50:30 2016 +0200

        Update BDRF.hlsl

    commit 12bd826c73092b8e96782c91b9cc7d925e77708f
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 2 11:47:29 2016 +0200

        Update IBL.glsl

    commit e1f5ac27606295bf81c07d3d46fda1dae6f191a7
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 2 11:43:37 2016 +0200

        Update BRDF.glsl

    commit 295a23e96f3dcdf05aac8d4e9057e8e6c67b3607
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 2 00:19:01 2016 +0100

        Updated Example

    commit 9b105230ecd33082bb82a8963057d635ffbe41ac
    Author: dragonCASTjosh <[email protected]>
    Date:   Sat Apr 2 00:15:55 2016 +0100

        Fixed IBL and indentation

    commit 185d31b6a0af7d084e7305d783e407d354274cac
    Merge: 6b7b5be dad5c04
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 23:55:46 2016 +0100

        Merge pull request #2 from cosmy1/patch-2

        Update BRDF.glsl

    commit dad5c042fc3272accbb9c26f2e17214ece66ebf8
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 2 00:39:35 2016 +0200

        Update BRDF.glsl

    commit 6b7b5bee9c56304aa92a4009d15282b6456d77c6
    Merge: a5b6b93 c398e82
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 23:34:40 2016 +0100

        Merge pull request #1 from cosmy1/patch-1

        Fix whitespaces in Material

    commit c398e82153ac0d0ab2b29f61d4345d747be3d40c
    Author: cosmy1 <[email protected]>
    Date:   Sat Apr 2 00:33:27 2016 +0200

        Fix whitespaces in Material

    commit a5b6b93b96a053f304b7326b4fa3930d60195051
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 21:33:52 2016 +0100

        fixed indentation

    commit 5b402e75092e680975435384ecb8b0af0292139d
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 21:32:35 2016 +0100

        Fixed issue with deletion of wrong values

    commit 4ca39ec5bfb905621de8c80999cf640a8ad6d5e0
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 21:28:59 2016 +0100

        removed nolonger needed licence

    commit d2ab0f9a048d594d7115c41c2dbea2ce2d39e31b
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 21:28:18 2016 +0100

        Improve PBR and moved forward PBR into new shader

    commit cdaae6e2cf234f28cef90f244e2e24e6b7d0d915
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 21:26:57 2016 +0100

        Removed remaining area lighting and fixed pbr in deferred rendering

    commit 6fca9d3b98fc2cacea2a11129eb1fc69a7e2fd2f
    Author: dragonCASTjosh <[email protected]>
    Date:   Fri Apr 1 13:19:48 2016 +0100

        Replaced data folder with one from mater to avoid commit revert errors

    commit 543c30f0b3b035df13ce09cc127117fb160bfe5f
    Author: dragonCASTjosh <[email protected]>
    Date:   Thu Mar 31 20:52:47 2016 +0100

        Complete PBR work
Lasse Öörni 9 years ago
parent
commit
2e44b0b350
83 changed files with 3965 additions and 3 deletions
  1. 2 0
      Source/Urho3D/AngelScript/GraphicsAPI.cpp
  2. 4 2
      Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp
  3. 2 0
      Source/Urho3D/Graphics/GraphicsDefs.cpp
  4. 2 0
      Source/Urho3D/Graphics/GraphicsDefs.h
  5. 6 1
      Source/Urho3D/Graphics/Material.cpp
  6. 14 0
      Source/Urho3D/Graphics/Renderer.cpp
  7. 7 0
      Source/Urho3D/Graphics/Renderer.h
  8. 3 0
      Source/Urho3D/LuaScript/pkgs/Graphics/Renderer.pkg
  9. 18 0
      bin/Autoload/LargeData/Materials/PBR/ColorGrid.xml
  10. 20 0
      bin/Autoload/LargeData/Materials/PBR/Concrete.xml
  11. 21 0
      bin/Autoload/LargeData/Materials/PBR/EmissivePannel.xml
  12. 17 0
      bin/Autoload/LargeData/Materials/PBR/Metallic0.xml
  13. 17 0
      bin/Autoload/LargeData/Materials/PBR/Metallic10.xml
  14. 17 0
      bin/Autoload/LargeData/Materials/PBR/Metallic3.xml
  15. 17 0
      bin/Autoload/LargeData/Materials/PBR/Metallic5.xml
  16. 17 0
      bin/Autoload/LargeData/Materials/PBR/Metallic7.xml
  17. 17 0
      bin/Autoload/LargeData/Materials/PBR/Metallic9.xml
  18. 17 0
      bin/Autoload/LargeData/Materials/PBR/Roughness0.xml
  19. 17 0
      bin/Autoload/LargeData/Materials/PBR/Roughness10.xml
  20. 17 0
      bin/Autoload/LargeData/Materials/PBR/Roughness3.xml
  21. 17 0
      bin/Autoload/LargeData/Materials/PBR/Roughness5.xml
  22. 17 0
      bin/Autoload/LargeData/Materials/PBR/Roughness7.xml
  23. 20 0
      bin/Autoload/LargeData/Materials/PBR/Tile.xml
  24. 5 0
      bin/Autoload/LargeData/Materials/Skybox2.xml
  25. BIN
      bin/Autoload/LargeData/Textures/PBR/Concrete/Albedo.jpg
  26. 3 0
      bin/Autoload/LargeData/Textures/PBR/Concrete/Albedo.xml
  27. BIN
      bin/Autoload/LargeData/Textures/PBR/Concrete/Normal.jpg
  28. BIN
      bin/Autoload/LargeData/Textures/PBR/Concrete/PBR.jpg
  29. BIN
      bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Albedo.jpg
  30. 3 0
      bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Albedo.xml
  31. BIN
      bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Emissive.jpg
  32. BIN
      bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Normal.jpg
  33. BIN
      bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/PBR.jpg
  34. 8 0
      bin/Autoload/LargeData/Textures/PBR/PBRTextureLicence.txt
  35. BIN
      bin/Autoload/LargeData/Textures/PBR/Pannel/Albedo.jpg
  36. 3 0
      bin/Autoload/LargeData/Textures/PBR/Pannel/Albedo.xml
  37. BIN
      bin/Autoload/LargeData/Textures/PBR/Pannel/Normal.jpg
  38. BIN
      bin/Autoload/LargeData/Textures/PBR/Pannel/PBR.jpg
  39. 10 0
      bin/Autoload/LargeData/Textures/Skybox2.xml
  40. BIN
      bin/Autoload/LargeData/Textures/T_ColorGrid.png
  41. 3 0
      bin/Autoload/LargeData/Textures/T_ColorGrid.xml
  42. BIN
      bin/Autoload/LargeData/Textures/output_skybox_negx.dds
  43. BIN
      bin/Autoload/LargeData/Textures/output_skybox_negy.dds
  44. BIN
      bin/Autoload/LargeData/Textures/output_skybox_negz.dds
  45. BIN
      bin/Autoload/LargeData/Textures/output_skybox_posx.dds
  46. BIN
      bin/Autoload/LargeData/Textures/output_skybox_posy.dds
  47. BIN
      bin/Autoload/LargeData/Textures/output_skybox_posz.dds
  48. 30 0
      bin/CoreData/RenderPaths/PBRDeferred.xml
  49. 29 0
      bin/CoreData/RenderPaths/PBRDeferredHWDepth.xml
  50. 193 0
      bin/CoreData/Shaders/GLSL/BRDF.glsl
  51. 7 0
      bin/CoreData/Shaders/GLSL/Constants.glsl
  52. 256 0
      bin/CoreData/Shaders/GLSL/IBL.glsl
  53. 124 0
      bin/CoreData/Shaders/GLSL/PBRDeferred.glsl
  54. 257 0
      bin/CoreData/Shaders/GLSL/PBRLitSolid.glsl
  55. 8 0
      bin/CoreData/Shaders/GLSL/Uniforms.glsl
  56. 191 0
      bin/CoreData/Shaders/HLSL/BDRF.hlsl
  57. 7 0
      bin/CoreData/Shaders/HLSL/Constants.hlsl
  58. 272 0
      bin/CoreData/Shaders/HLSL/IBL.hlsl
  59. 129 0
      bin/CoreData/Shaders/HLSL/PBRDeferred.hlsl
  60. 342 0
      bin/CoreData/Shaders/HLSL/PBRLitSolid.hlsl
  61. 5 0
      bin/CoreData/Shaders/HLSL/Samplers.hlsl
  62. 8 0
      bin/CoreData/Shaders/HLSL/Uniforms.hlsl
  63. 9 0
      bin/CoreData/Techniques/PBR/DiffNormalSpecEmissive.xml
  64. 5 0
      bin/CoreData/Techniques/PBR/DiffNormalSpecEmissiveAlpha.xml
  65. 8 0
      bin/CoreData/Techniques/PBR/PBRDiff.xml
  66. 5 0
      bin/CoreData/Techniques/PBR/PBRDiffAlpha.xml
  67. 8 0
      bin/CoreData/Techniques/PBR/PBRDiffNormal.xml
  68. 5 0
      bin/CoreData/Techniques/PBR/PBRDiffNormalAlpha.xml
  69. 7 0
      bin/CoreData/Techniques/PBR/PBRDiffNormalEmissive.xml
  70. 5 0
      bin/CoreData/Techniques/PBR/PBRDiffNormalEmissiveAlpha.xml
  71. 8 0
      bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffNormalSpec.xml
  72. 8 0
      bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissive.xml
  73. 5 0
      bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissiveAlpha.xml
  74. 8 0
      bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffSpec.xml
  75. 5 0
      bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffSpecAlpha.xml
  76. 9 0
      bin/CoreData/Techniques/PBR/PBRNoTexture.xml
  77. 5 0
      bin/CoreData/Techniques/PBR/PBRNoTextureAlpha.xml
  78. 1528 0
      bin/Data/Scenes/PBRExample.xml
  79. 128 0
      bin/Data/Scripts/42_PBRMaterials.as
  80. 3 0
      bin/PBRDemo.bat
  81. 1 0
      bin/PBRDemo.sh
  82. 3 0
      bin/PBRDemoDeferred.bat
  83. 3 0
      bin/PBRDemoDeferredHWDepth.bat

+ 2 - 0
Source/Urho3D/AngelScript/GraphicsAPI.cpp

@@ -1738,6 +1738,8 @@ static void RegisterRenderer(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Renderer", "void SetVSMShadowParameters(float, float)", asMETHOD(Renderer, SetVSMShadowParameters), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "void set_defaultRenderPath(RenderPath@+)", asMETHODPR(Renderer, SetDefaultRenderPath, (RenderPath*), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "RenderPath@+ get_defaultRenderPath() const", asMETHOD(Renderer, GetDefaultRenderPath), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Renderer", "void set_defaultTechnique(Technique@+)", asMETHOD(Renderer, SetDefaultTechnique), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Renderer", "Technique@+ get_defaultTechnique() const", asMETHOD(Renderer, GetDefaultTechnique), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "Zone@+ get_defaultZone() const", asMETHOD(Renderer, GetDefaultZone), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "Material@+ get_defaultMaterial() const", asMETHOD(Renderer, GetDefaultMaterial), asCALL_THISCALL);
     engine->RegisterObjectMethod("Renderer", "Material@+ get_defaultLightRamp() const", asMETHOD(Renderer, GetDefaultLightRamp), asCALL_THISCALL);

+ 4 - 2
Source/Urho3D/Graphics/Direct3D11/D3D11Graphics.cpp

@@ -2484,7 +2484,8 @@ void Graphics::PrepareDraw()
     if (renderTargetsDirty_)
     {
         impl_->depthStencilView_ =
-            depthStencil_ ? (ID3D11DepthStencilView*)depthStencil_->GetRenderTargetView() : impl_->defaultDepthStencilView_;
+            (depthStencil_ && depthStencil_->GetUsage() == TEXTURE_DEPTHSTENCIL) ?
+                (ID3D11DepthStencilView*)depthStencil_->GetRenderTargetView() : impl_->defaultDepthStencilView_;
 
         // If possible, bind a read-only depth stencil view to allow reading depth in shader
         if (!depthWrite_ && depthStencil_ && depthStencil_->GetReadOnlyView())
@@ -2492,7 +2493,8 @@ void Graphics::PrepareDraw()
 
         for (unsigned i = 0; i < MAX_RENDERTARGETS; ++i)
             impl_->renderTargetViews_[i] =
-                renderTargets_[i] ? (ID3D11RenderTargetView*)renderTargets_[i]->GetRenderTargetView() : 0;
+                (renderTargets_[i] && renderTargets_[i]->GetUsage() == TEXTURE_RENDERTARGET) ?
+                    (ID3D11RenderTargetView*)renderTargets_[i]->GetRenderTargetView() : 0;
         // If rendertarget 0 is null and not doing depth-only rendering, render to the backbuffer
         // Special case: if rendertarget 0 is null and depth stencil has same size as backbuffer, assume the intention is to do
         // backbuffer rendering with a custom depth stencil

+ 2 - 0
Source/Urho3D/Graphics/GraphicsDefs.cpp

@@ -82,6 +82,8 @@ extern URHO3D_API const StringHash PSP_SHADOWMAPINVSIZE("ShadowMapInvSize");
 extern URHO3D_API const StringHash PSP_SHADOWSPLITS("ShadowSplits");
 extern URHO3D_API const StringHash PSP_LIGHTMATRICES("LightMatricesPS");
 extern URHO3D_API const StringHash PSP_VSMSHADOWPARAMS("VSMShadowParams");
+extern URHO3D_API const StringHash PSP_ROUGHNESS("RoughnessPS");
+extern URHO3D_API const StringHash PSP_METALLIC("MetallicPS");
 
 extern URHO3D_API const Vector3 DOT_SCALE(1 / 3.0f, 1 / 3.0f, 1 / 3.0f);
 

+ 2 - 0
Source/Urho3D/Graphics/GraphicsDefs.h

@@ -340,6 +340,8 @@ extern URHO3D_API const StringHash PSP_SHADOWMAPINVSIZE;
 extern URHO3D_API const StringHash PSP_SHADOWSPLITS;
 extern URHO3D_API const StringHash PSP_LIGHTMATRICES;
 extern URHO3D_API const StringHash PSP_VSMSHADOWPARAMS;
+extern URHO3D_API const StringHash PSP_ROUGHNESS;
+extern URHO3D_API const StringHash PSP_METALLIC;
 
 // Scale calculation from bounding box diagonal.
 extern URHO3D_API const Vector3 DOT_SCALE;

+ 6 - 1
Source/Urho3D/Graphics/Material.cpp

@@ -27,6 +27,7 @@
 #include "../Core/Profiler.h"
 #include "../Graphics/Graphics.h"
 #include "../Graphics/Material.h"
+#include "../Graphics/Renderer.h"
 #include "../Graphics/Technique.h"
 #include "../Graphics/Texture2D.h"
 #include "../Graphics/Texture2DArray.h"
@@ -1164,7 +1165,9 @@ void Material::ResetToDefaults()
         return;
 
     SetNumTechniques(1);
-    SetTechnique(0, GetSubsystem<ResourceCache>()->GetResource<Technique>("Techniques/NoTexture.xml"));
+    Renderer* renderer = GetSubsystem<Renderer>();
+    SetTechnique(0, renderer ? renderer->GetDefaultTechnique() :
+        GetSubsystem<ResourceCache>()->GetResource<Technique>("Techniques/NoTexture.xml"));
 
     textures_.Clear();
 
@@ -1176,6 +1179,8 @@ void Material::ResetToDefaults()
     SetShaderParameter("MatEmissiveColor", Vector3::ZERO);
     SetShaderParameter("MatEnvMapColor", Vector3::ONE);
     SetShaderParameter("MatSpecColor", Vector4(0.0f, 0.0f, 0.0f, 1.0f));
+    SetShaderParameter("RoughnessPS", 0.5f);
+    SetShaderParameter("MetallicPS", 0.0f);
     batchedParameterUpdate_ = false;
 
     cullMode_ = CULL_CCW;

+ 14 - 0
Source/Urho3D/Graphics/Renderer.cpp

@@ -310,6 +310,11 @@ void Renderer::SetDefaultRenderPath(XMLFile* xmlFile)
         defaultRenderPath_ = newRenderPath;
 }
 
+void Renderer::SetDefaultTechnique(Technique* technique)
+{
+    defaultTechnique_ = technique;
+}
+
 void Renderer::SetHDRRendering(bool enable)
 {
     hdrRendering_ = enable;
@@ -522,6 +527,15 @@ RenderPath* Renderer::GetDefaultRenderPath() const
     return defaultRenderPath_;
 }
 
+Technique* Renderer::GetDefaultTechnique() const
+{
+    // Assign default when first asked if not assigned yet
+    if (!defaultTechnique_)
+        const_cast<SharedPtr<Technique>& >(defaultTechnique_) = GetSubsystem<ResourceCache>()->GetResource<Technique>("Techniques/NoTexture.xml");
+
+    return defaultTechnique_;
+}
+
 unsigned Renderer::GetNumGeometries(bool allViews) const
 {
     unsigned numGeometries = 0;

+ 7 - 0
Source/Urho3D/Graphics/Renderer.h

@@ -45,6 +45,7 @@ class RenderSurface;
 class ResourceCache;
 class Skeleton;
 class OcclusionBuffer;
+class Technique;
 class Texture;
 class Texture2D;
 class TextureCube;
@@ -168,6 +169,8 @@ public:
     void SetDefaultRenderPath(RenderPath* renderPath);
     /// Set default renderpath from an XML file.
     void SetDefaultRenderPath(XMLFile* file);
+    /// Set default non-textured material technique.
+    void SetDefaultTechnique(Technique* tech);
     /// Set HDR rendering on/off.
     void SetHDRRendering(bool enable);
     /// Set specular lighting on/off.
@@ -227,6 +230,8 @@ public:
     Viewport* GetViewport(unsigned index) const;
     /// Return default renderpath.
     RenderPath* GetDefaultRenderPath() const;
+    /// Return default non-textured material technique.
+    Technique* GetDefaultTechnique() const;
 
     /// Return whether HDR rendering is enabled.
     bool GetHDRRendering() const { return hdrRendering_; }
@@ -431,6 +436,8 @@ private:
     WeakPtr<Graphics> graphics_;
     /// Default renderpath.
     SharedPtr<RenderPath> defaultRenderPath_;
+    /// Default non-textured material technique.
+    SharedPtr<Technique> defaultTechnique_;
     /// Default zone.
     SharedPtr<Zone> defaultZone_;
     /// Directional light quad geometry.

+ 3 - 0
Source/Urho3D/LuaScript/pkgs/Graphics/Renderer.pkg

@@ -6,6 +6,7 @@ class Renderer
     void SetViewport(unsigned index, Viewport* viewport);
     void SetDefaultRenderPath(RenderPath* renderPath);
     void SetDefaultRenderPath(XMLFile* file);
+    void SetDefaultTechnique(Technique* technique);
     void SetHDRRendering(bool enable);
     void SetSpecularLighting(bool enable);
     void SetTextureAnisotropy(int level);
@@ -33,6 +34,7 @@ class Renderer
     unsigned GetNumViewports() const;
     Viewport* GetViewport(unsigned index) const;
     RenderPath* GetDefaultRenderPath() const;
+    Technique* GetDefaultTechnique() const;
     bool GetHDRRendering() const;
     bool GetSpecularLighting() const;
     bool GetDrawShadows() const;
@@ -71,6 +73,7 @@ class Renderer
 
     tolua_property__get_set unsigned numViewports;
     tolua_property__get_set RenderPath* defaultRenderPath;
+    tolua_property__get_set Technique* defaultTechnique;
     tolua_property__get_set bool HDRRendering;
     tolua_property__get_set bool specularLighting;
     tolua_property__get_set bool drawShadows;

+ 18 - 0
bin/Autoload/LargeData/Materials/PBR/ColorGrid.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRDiff.xml" quality="0" loddistance="0" />
+	<texture unit="diffuse" name="Textures/T_ColorGrid.png" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 1 1 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="0 0 0 1" />
+	<parameter name="RoughnessPS" value="0.5" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 20 - 0
bin/Autoload/LargeData/Materials/PBR/Concrete.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRMetallicRoughDiffNormalSpec.xml" quality="0" loddistance="0" />
+	<texture unit="diffuse" name="Textures/PBR/Concrete/Albedo.jpg" />
+	<texture unit="normal" name="Textures/PBR/Concrete/Normal.jpg" />
+	<texture unit="specular" name="Textures/PBR/Concrete/PBR.jpg" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 1 1 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 21 - 0
bin/Autoload/LargeData/Materials/PBR/EmissivePannel.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissive.xml" quality="0" loddistance="0" />
+	<texture unit="diffuse" name="Textures/PBR/Emissive Pannel/Albedo.jpg" />
+	<texture unit="normal" name="Textures/PBR/Emissive Pannel/Normal.jpg" />
+	<texture unit="specular" name="Textures/PBR/Emissive Pannel/PBR.jpg" />
+	<texture unit="emissive" name="Textures/PBR/Emissive Pannel/Emissive.jpg" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 1 1 1" />
+	<parameter name="MatEmissiveColor" value="1 1 1" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="-0.95" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Metallic0.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.5 0.5 0.5 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Metallic10.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.5 0.5 0.5 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="1" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Metallic3.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.5 0.5 0.5 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0.3" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Metallic5.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.5 0.5 0.5 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0.5" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Metallic7.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.5 0.5 0.5 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0.7" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Metallic9.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="0.5 0.5 0.5 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0.9" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Roughness0.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 0 0 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Roughness10.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 0 0 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="1" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Roughness3.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 0 0 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0.3" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Roughness5.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 0 0 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0.5" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 17 - 0
bin/Autoload/LargeData/Materials/PBR/Roughness7.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRNoTexture.xml" quality="0" loddistance="0" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 0 0 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0.7" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 20 - 0
bin/Autoload/LargeData/Materials/PBR/Tile.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<material>
+	<technique name="Techniques/PBR/PBRMetallicRoughDiffNormalSpec.xml" quality="0" loddistance="0" />
+	<texture unit="diffuse" name="Textures/PBR/Pannel/Albedo.jpg" />
+	<texture unit="normal" name="Textures/PBR/Pannel/Normal.jpg" />
+	<texture unit="specular" name="Textures/PBR/Pannel/PBR.jpg" />
+	<parameter name="UOffset" value="1 0 0 0" />
+	<parameter name="VOffset" value="0 1 0 0" />
+	<parameter name="MatDiffColor" value="1 1 1 1" />
+	<parameter name="MatEmissiveColor" value="0 0 0" />
+	<parameter name="MatEnvMapColor" value="1 1 1" />
+	<parameter name="MatSpecColor" value="1 1 1 1" />
+	<parameter name="RoughnessPS" value="0.1" />
+	<parameter name="MetallicPS" value="0" />
+	<cull value="ccw" />
+	<shadowcull value="ccw" />
+	<fill value="solid" />
+	<depthbias constant="0" slopescaled="0" />
+	<renderorder value="128" />
+</material>

+ 5 - 0
bin/Autoload/LargeData/Materials/Skybox2.xml

@@ -0,0 +1,5 @@
+<material>
+    <technique name="Techniques/DiffSkybox.xml" />
+    <texture unit="diffuse" name="Textures/Skybox2.xml" />
+    <cull value="none" />
+</material>

BIN
bin/Autoload/LargeData/Textures/PBR/Concrete/Albedo.jpg


+ 3 - 0
bin/Autoload/LargeData/Textures/PBR/Concrete/Albedo.xml

@@ -0,0 +1,3 @@
+<texture>
+    <srgb enable="true" />
+</texture>

BIN
bin/Autoload/LargeData/Textures/PBR/Concrete/Normal.jpg


BIN
bin/Autoload/LargeData/Textures/PBR/Concrete/PBR.jpg


BIN
bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Albedo.jpg


+ 3 - 0
bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Albedo.xml

@@ -0,0 +1,3 @@
+<texture>
+    <srgb enable="true" />
+</texture>

BIN
bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Emissive.jpg


BIN
bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/Normal.jpg


BIN
bin/Autoload/LargeData/Textures/PBR/Emissive Pannel/PBR.jpg


+ 8 - 0
bin/Autoload/LargeData/Textures/PBR/PBRTextureLicence.txt

@@ -0,0 +1,8 @@
+All PBR textures gathered from https://share.allegorithmic.com/ 
+
+Concrete Tiles by Allegorithmic (https://share.allegorithmic.com/libraries/729)
+Fallen Painted Metal(Pannel) by Käy Vriend (https://share.allegorithmic.com/libraries/499)
+Door Panel by isaacpapismado (https://share.allegorithmic.com/libraries/979)
+
+
+IBL texture gathered from HDRLab's sIBL Archive (http://www.hdrlabs.com/sibl/archive.html)

BIN
bin/Autoload/LargeData/Textures/PBR/Pannel/Albedo.jpg


+ 3 - 0
bin/Autoload/LargeData/Textures/PBR/Pannel/Albedo.xml

@@ -0,0 +1,3 @@
+<texture>
+    <srgb enable="true" />
+</texture>

BIN
bin/Autoload/LargeData/Textures/PBR/Pannel/Normal.jpg


BIN
bin/Autoload/LargeData/Textures/PBR/Pannel/PBR.jpg


+ 10 - 0
bin/Autoload/LargeData/Textures/Skybox2.xml

@@ -0,0 +1,10 @@
+<cubemap>
+    <srgb enable="true" />
+    <face name="output_skybox_posx.dds" />
+    <face name="output_skybox_negx.dds" />
+    <face name="output_skybox_posy.dds" />
+    <face name="output_skybox_negy.dds" />
+    <face name="output_skybox_posz.dds" />
+    <face name="output_skybox_negz.dds" />
+    <quality low="0" />
+</cubemap>

BIN
bin/Autoload/LargeData/Textures/T_ColorGrid.png


+ 3 - 0
bin/Autoload/LargeData/Textures/T_ColorGrid.xml

@@ -0,0 +1,3 @@
+<texture>
+    <srgb enable="true" />
+</texture>

BIN
bin/Autoload/LargeData/Textures/output_skybox_negx.dds


BIN
bin/Autoload/LargeData/Textures/output_skybox_negy.dds


BIN
bin/Autoload/LargeData/Textures/output_skybox_negz.dds


BIN
bin/Autoload/LargeData/Textures/output_skybox_posx.dds


BIN
bin/Autoload/LargeData/Textures/output_skybox_posy.dds


BIN
bin/Autoload/LargeData/Textures/output_skybox_posz.dds


+ 30 - 0
bin/CoreData/RenderPaths/PBRDeferred.xml

@@ -0,0 +1,30 @@
+<renderpath>
+    <rendertarget name="specular" sizedivisor="1 1" format="rgba16f" />
+    <rendertarget name="albedo" sizedivisor="1 1" format="rgba16f" />
+    <rendertarget name="normal" sizedivisor="1 1" format="rgba16f" />
+    <rendertarget name="depth" sizedivisor="1 1" format="lineardepth" />
+    <command type="clear" color="0 0 0 0" depth="1.0" stencil="0" />
+    <command type="clear" color="0 0 0 0" output="albedo" />
+    <command type="clear" color="0 0 0 0" output="specular" />
+    <command type="clear" color="0 0 0 0" output="normal" />
+    <command type="clear" color="0 0 0 0" depth="1.0" output="depth" />
+    <command type="scenepass" pass="base" vertexlights="true" metadata="base" />
+    <command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer">
+        <output index="0" name="specular" />
+        <output index="1" name="albedo" />
+        <output index="2" name="normal" />
+        <output index="3" name="depth" />
+    </command>
+    <command type="lightvolumes" vs="PBRDeferred" ps="PBRDeferred" psdefines="PBRDEFERRED PBR" vsdefines="PBR" output="viewport">
+        <texture unit="specular" name="specular" />
+        <texture unit="albedo" name="albedo" />
+        <texture unit="normal" name="normal" />
+        <texture unit="depth" name="depth" />
+    </command>
+    <command type="scenepass" pass="postopaque" />
+    <command type="scenepass" pass="refract">
+        <texture unit="environment" name="viewport" />
+    </command>
+    <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" />
+    <command type="scenepass" pass="postalpha" sort="backtofront" />
+</renderpath>

+ 29 - 0
bin/CoreData/RenderPaths/PBRDeferredHWDepth.xml

@@ -0,0 +1,29 @@
+<renderpath>
+    <rendertarget name="specular" sizedivisor="1 1" format="rgba16f" />
+    <rendertarget name="albedo" sizedivisor="1 1" format="rgba16f" />
+    <rendertarget name="normal" sizedivisor="1 1" format="rgba16f" />
+    <rendertarget name="depth" sizedivisor="1 1" format="readabledepth" />
+    <command type="clear" color="0 0 0 0" depth="1.0" stencil="0" depthstencil="depth" />
+    <command type="clear" color="0 0 0 0" output="albedo" depthstencil="depth"/>
+    <command type="clear" color="0 0 0 0" output="specular" depthstencil="depth" />
+    <command type="clear" color="0 0 0 0" output="normal" depthstencil="depth" />
+    <command type="clear" color="0 0 0 0" depth="1.0" output="depth" depthstencil="depth" />
+    <command type="scenepass" pass="base" vertexlights="true" metadata="base" depthstencil="depth" />
+    <command type="scenepass" pass="deferred" marktostencil="true" vertexlights="true" metadata="gbuffer" depthstencil="depth">
+        <output index="0" name="specular" />
+        <output index="1" name="albedo" />
+        <output index="2" name="normal" />
+    </command>
+    <command type="lightvolumes" vs="PBRDeferred" ps="PBRDeferred" psdefines="PBRDEFERRED PBR HWDEPTH" vsdefines="PBR" output="viewport" depthstencil="depth">
+        <texture unit="specular" name="specular" />
+        <texture unit="albedo" name="albedo" />
+        <texture unit="normal" name="normal" />
+        <texture unit="depth" name="depth" />
+    </command>
+    <command type="scenepass" pass="postopaque" depthstencil="depth"/>
+    <command type="scenepass" pass="refract" depthstencil="depth">
+        <texture unit="environment" name="viewport" />
+    </command>
+    <command type="scenepass" pass="alpha" vertexlights="true" sort="backtofront" metadata="alpha" depthstencil="depth" />
+    <command type="scenepass" pass="postalpha" sort="backtofront" depthstencil="depth" />
+</renderpath>

+ 193 - 0
bin/CoreData/Shaders/GLSL/BRDF.glsl

@@ -0,0 +1,193 @@
+#line 20001
+#ifdef COMPILEPS
+  #ifdef PBR
+    /// Diffuse factors
+
+    /// Oren-Nayar diffuse factor
+    ///     diffuseColor: input rgb
+    ///     roughness: roughness of the surface
+    ///     NdotV: dot prod of surface normal and view direction
+    ///     NdotL: dot prod of surface normal and light direction
+    ///     VdotH: dot prod of view direction and half-angle
+    vec3 OrenNayarDiffuse(in vec3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        float rough2 = roughness * roughness;
+
+        float VdotL = 2.0 * VdotH - 1.0;
+        float majorCtrl = 1.0 - 0.5 * rough2 / (rough2 + 0.33);
+        float cosRi = VdotL - NdotV * NdotL;
+        float minorCtrl = 0.4545 * rough2 / (rough2 + 0.09) * cosRi * (cosRi >= 0.0 ? min(1.0, NdotL / NdotV) : NdotL);
+        return diffuseColor / M_PI * (NdotL * majorCtrl + minorCtrl);
+    }
+
+    /// Lambertian diffuse factor
+    ///     diffuseColor: input rgb
+    ///     roughness: roughness of the surface
+    ///     NdotV: dot prod of surface normal and view direction
+    ///     NdotL: dot prod of surface normal and light direction
+    ///     VdotH: dot prod of view direction and half-angle
+    vec3 LambertianDiffuse(in vec3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        return diffuseColor * NdotL;
+    }
+
+    vec3 BurleyDiffuse(in vec3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        float energyBias = mix(0.0, 0.5, roughness);
+        float energyFactor = mix(1.0, 1.0 / 1.51, roughness);
+        float fd90 = energyBias + 2.0 * VdotH * VdotH * roughness;
+        const float f0 = 1.0;
+        float lightScatter = f0 + (fd90 - f0) * pow(1.0 - NdotL, 5.0);
+        float viewScatter = f0 + (fd90 - f0) * pow(1.0f - NdotV, 5.0);
+
+        return diffuseColor * lightScatter * viewScatter * energyFactor;
+    }
+
+    vec3 Diffuse(in vec3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        return BurleyDiffuse(diffuseColor, roughness, NdotV, NdotL, VdotH);
+    }
+
+    /// Specular BRDF
+    vec3 CookTorranceBRDF(in float D, in vec3 F, in float G, in float NdotL, in float NdotV)
+    {
+        return D * F * G / (4.0 *  max(NdotL * NdotV, M_EPSILON));
+    }
+
+    vec3 SpecularBRDF(in float D, in vec3 F, in float G, in float NdotL, in float NdotV)
+    {
+        return CookTorranceBRDF(D, F, G, NdotL, NdotV);
+    }
+
+    /// Specular probability density function (for importance sampling)
+    float CookTorrancePDF(in float D, in float NdotH, in float VdotH)
+    {
+        return D * NdotH / (4.0 * VdotH);
+    }
+
+    float ImportanceSamplePDF(in float D, in float NdotH, in float VdotH)
+    {
+        return CookTorrancePDF(D, NdotH, VdotH);
+    }
+
+    /// Fresnel Terms
+
+    /// Fresnel factor
+    ///     specular: Specular color input
+    ///     VdotH: dot product of view direction and half-angle
+    vec3 SchlickFresnel(in vec3 specular, in float VdotH)
+    {
+        return specular + (vec3(1.0, 1.0, 1.0) - specular) * pow(1.0 - VdotH, 5.0);
+    }
+
+    /// Fresnel factor, spherical gaussian in Schlick approximation; https://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/
+    ///     specular: specular color of the surface
+    ///     VdotH: dot product of view direction and half-angle
+    vec3 SchlickGaussianFresnel(in vec3 specular, in float VdotH)
+    {
+        float sphericalGaussian = pow(2.0, (-5.55473 * VdotH - 6.98316) * VdotH);
+        return specular + (vec3(1.0, 1.0, 1.0) - specular) * sphericalGaussian;
+    }
+
+    vec3 Fresnel(in vec3 specular, in float VdotH)
+    {
+        return SchlickFresnel(specular, VdotH);
+    }
+
+    /// Visibility terms
+
+    /// Smith GGX Visibility
+    ///     NdotL: dot-prod of surface normal and light direction
+    ///     NdotV: dot-prod of surface normal and view direction
+    ///     roughness: surface roughness
+    float SmithGGXVisibility(in float NdotL, in float NdotV, in float roughness)
+    {
+        // BUG ?
+        float rough2 = roughness * roughness;
+        float gSmithV = NdotV + sqrt(NdotV * (NdotV - NdotV * rough2) + rough2);
+        float gSmithL = NdotL + sqrt(NdotL * (NdotL - NdotL * rough2) + rough2);
+        return 1.0 / ( gSmithV * gSmithL );
+    }
+
+    float SmithGGXG(in float factor, in float k)
+    {
+        return 2.0 * factor / (factor + sqrt(k + (1.0 - k) * (factor * factor))) ;
+    }
+
+    float SchlickG(in float factor, in float k)
+    {
+        return factor / (factor * (1.0 - k) + k);
+    }
+
+    float SmithGGXVisibility2(in float NdotL, in float NdotV, in float roughness)
+    {
+        float k = roughness * roughness;
+        return (SmithGGXG(NdotL, k) * SmithGGXG(NdotV, k));
+    }
+
+    /// Schlick approximation of Smith GGX
+    ///     NdotL: dot product of surface normal and light direction
+    ///     NdotV: dot product of surface normal and view direction
+    ///     roughness: surface roughness
+    float SmithGGXSchlickVisibility(float NdotL, float NdotV, float roughness)
+    {
+        float rough2 = roughness * roughness;
+        return (SchlickG(NdotL, rough2) * SchlickG(NdotV, rough2)) * 0.25; // divided by four
+    }
+
+    float SmithGGXSchlickVisibility2(float NdotL, float NdotV, float roughness)
+    {
+        float rough = roughness + 1.0;
+        float a = rough * rough;
+        float k =  a / 8.0;
+        return (SchlickG(NdotL, k) * SchlickG(NdotV, k));
+    }
+
+    float SchlickBeckmannVisibility(in float NdotL, in float NdotV, in float roughness)
+    {
+        float a = roughness * roughness;
+        float k =  a * sqrt(2.0 / M_PI);
+        return (SchlickG(NdotL, k) * SchlickG(NdotV, k));
+    }
+
+    float Visibility(in float NdotL, in float NdotV, in float roughness)
+    {
+        return SmithGGXVisibility2(NdotL, NdotV, roughness);
+    }
+
+    /// Normal Distributions
+
+    float BlinnPhongDistribution(in float NdotH, in float roughness)
+    {
+        float specPower = max((2.0 / (roughness * roughness)) - 2.0, 1e-4); // Calculate specular power from roughness
+        return pow(clamp(NdotH, 0.0, 1.0), specPower);
+    }
+
+    /// Beckmann normal distribution
+    ///     NdotH: dot-prod of surface normal and half-angle
+    ///     roughness: surface roughness
+    float BeckmannDistribution(in float NdotH, in float roughness)
+    {
+        float rough2 = roughness * roughness;
+        float roughnessA = 1.0 / (4.0 * rough2 * pow(NdotH, 4.0));
+        float roughnessB = NdotH * NdotH - 1.0;
+        float roughnessC = rough2 * NdotH * NdotH;
+        return roughnessA * exp(roughnessB / roughnessC);
+    }
+
+    /// Trowbridge-Reitz GGX normal distribution
+    ///     NdotH: dot-prod of surface normal and half-angle
+    ///     roughness: surface roughness
+    float GGXDistribution(in float NdotH, in float roughness)
+    {
+        float rough2 = roughness * roughness;
+        float tmp = roughness / max(M_EPSILON, NdotH * NdotH * (rough2 - 1.0) + 1.0);
+        return tmp * tmp / M_PI;
+    }
+
+    float Distribution(in float NdotH, in float roughness)
+    {
+        return GGXDistribution(NdotH, roughness);
+    }
+  #endif
+#endif

+ 7 - 0
bin/CoreData/Shaders/GLSL/Constants.glsl

@@ -0,0 +1,7 @@
+#define M_PI 3.14159265358979323846
+#define M_EPSILON 0.0001
+
+#ifdef PBR
+#define ROUGHNESS_FLOOR 0.04
+#define METALNESS_FLOOR 0.05
+#endif

+ 256 - 0
bin/CoreData/Shaders/GLSL/IBL.glsl

@@ -0,0 +1,256 @@
+#line 10001
+#ifdef COMPILEPS
+    #define PBRFAST
+
+    vec3 ImportanceSampleSimple(in vec2 Xi, in float roughness, in vec3 T, in vec3 B, in vec3 N)
+    {
+      float a = roughness * roughness;
+      mat3 tbn = mat3(T, B, N);
+      #ifdef PBRFAST
+          const float blurFactor = 0.0;
+      #else
+          const float blurFactor = 5.0;
+      #endif
+      vec3 Xi3 = mix(vec3(0,0,1), normalize(vec3(Xi.xy * blurFactor , 1)), a);
+      vec3 XiWS = tbn * Xi3;
+      return normalize(N + XiWS);
+    }
+
+    // Karis '13
+    vec3 ImportanceSampleGGX(in vec2 Xi, in float roughness, in vec3 N)
+    {
+       float a = roughness * roughness;
+       float Phi = 2.0 * M_PI * Xi.x;
+       float CosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a*a - 1.0) * Xi.y));
+       float SinTheta = sqrt(1.0 - CosTheta * CosTheta);
+       vec3 H = vec3(0,0,0);
+       H.x = SinTheta * cos(Phi);
+       H.y = SinTheta * sin(Phi);
+       H.z = CosTheta;
+
+       vec3 UpVector = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
+       vec3 TangentX = normalize(cross(UpVector, N));
+       vec3 TangentY = cross(N, TangentX);
+       // Tangent to world space
+       return TangentX * H.x + TangentY * H.y + N * H.z;
+    }
+    /// Determine reflection vector based on surface roughness, rougher uses closer to the normal and smoother uses closer to the reflection vector
+    ///     normal: surface normal
+    ///     reflection: vector of reflection off of the surface
+    ///     roughness: surface roughness
+    vec3 GetSpecularDominantDir(vec3 normal, vec3 reflection, float roughness)
+    {
+        float smoothness = 1.0 - roughness;
+        float lerpFactor = smoothness * (sqrt(smoothness) + roughness);
+        return mix(normal, reflection, lerpFactor);
+    }
+
+    #define IMPORTANCE_SAMPLES 16
+    vec2 IMPORTANCE_KERNEL[IMPORTANCE_SAMPLES] = vec2[] (
+        vec2(-0.0780436, 0.0558389),
+        vec2(0.034318, -0.0635879),
+        vec2(0.00230821, 0.0807279),
+        vec2(0.0124638, 0.117585),
+        vec2(0.093943, -0.0944602),
+        vec2(0.139348, -0.109816),
+        vec2(-0.181872, -0.129649),
+        vec2(0.240066, -0.0494057),
+        vec2(0.115965, -0.0374714),
+        vec2(-0.294819, -0.100726),
+        vec2(-0.149652, 0.37459),
+        vec2(0.261695, -0.292813),
+        vec2(-0.37944, -0.425145),
+        vec2(0.628994, -0.189387),
+        vec2(-0.331257, -0.646864),
+        vec2(-0.467004, 0.439687)
+      );
+
+      float GetMipFromRougness(float roughness)
+      {
+          float smoothness = 1.0 - roughness;
+          return (1.0 - smoothness * smoothness) * 10.0;
+      }
+
+    /// Perform importance sampling
+    ///     reflectVec: calculated vector of reflection
+    ///     wsNormal: world-space normal of the surface
+    ///     toCamera: direction from the pixel to the camera
+    ///     specular: specular color
+    ///     roughness: surface roughness
+    ///     reflectionCubeColor: output color for diffuse
+    // Implementation based on Epics 2013 course notes
+    vec3 ImportanceSampling(in vec3 reflectVec, in vec3 tangent, in vec3 bitangent, in vec3 wsNormal, in vec3 toCamera,  in vec3 diffColor, in vec3 specColor, in float roughness, inout vec3 reflectionCubeColor)
+    {
+        reflectionCubeColor = vec3(1,1,1);
+
+        vec3 reflectSpec = normalize(GetSpecularDominantDir(wsNormal, reflectVec, roughness));
+
+        vec3 V = normalize(-toCamera);
+        vec3 N = normalize(wsNormal);
+        float ndv = clamp(abs(dot(N, V)), 0.0, 1.0);
+
+        float specMipLevel = GetMipFromRougness(roughness);
+
+        vec3 accumulatedColor = vec3(0,0,0);
+        for (int i = 0; i < IMPORTANCE_SAMPLES; ++i)
+        {
+            vec3 kd = vec3(1,1,1);
+            vec3 diffuseFactor = vec3(0,0,0);
+            vec3 specularFactor = vec3(0,0,0);
+
+            {
+                // Diffuse IBL
+                const float rough = 1.0;
+                const float mipLevel = 9.0;
+
+                vec3 H = ImportanceSampleSimple(IMPORTANCE_KERNEL[i], rough, tangent, bitangent, N);
+                vec3 L = 2.0 * dot( V, H ) * H - V;
+
+                float vdh = clamp(abs(dot(V, H)), 0.0, 1.0);
+                float ndh = clamp(abs(dot(N, H)), 0.0, 1.0);
+                float ndl = clamp(abs(dot(N, L)), 0.0, 1.0);
+
+                //if (ndl > 0.0)
+                {
+                    vec3 sampledColor = textureLod(sZoneCubeMap, L, mipLevel).rgb;
+
+                    vec3 diffuseTerm = Diffuse(diffColor, rough, ndv, ndl, vdh);
+                    vec3 lightTerm = sampledColor;
+
+                    diffuseFactor = lightTerm * diffuseTerm;
+                }
+            }
+
+            {
+                // Specular IBL
+                float rough = roughness;
+                float mipLevel = specMipLevel;
+
+                vec3 H = ImportanceSampleSimple(IMPORTANCE_KERNEL[i], rough, tangent, bitangent, N);
+                vec3 L = 2.0 * dot( V, H ) * H - V;
+                vec3 sampledColor = textureLod(sZoneCubeMap, L, mipLevel).rgb;
+
+                float vdh = clamp(abs(dot(V, H)), 0.0, 1.0);
+                float ndh = clamp(abs(dot(N, H)), 0.0, 1.0);
+                float ndl = clamp(abs(dot(N, L)), 0.0, 1.0);
+
+                vec3 specularTerm = vec3(0,0,0);
+                float pdf = 1.0;
+                vec3 lightTerm = vec3(0,0,0);
+
+                if (ndl > 0.05)
+                {
+                    vec3 fresnelTerm = Fresnel(specColor, vdh);
+                    float distTerm = 1.0; // Optimization, this term is mathematically cancelled out  -- Distribution(ndh, roughness);
+                    float visTerm = Visibility(ndl, ndv, rough);
+
+                    lightTerm = sampledColor * ndl;
+                    specularTerm = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv);
+                    pdf = ImportanceSamplePDF(distTerm, ndh, vdh);
+                }
+                else // reduce artifacts at extreme grazing angles
+                {
+                    vec3 fresnelTerm = Fresnel(specColor, vdh);
+                    float distTerm = 1.0;//Distribution(ndh_, roughness);
+                    float visTerm = Visibility(ndl, ndv, rough);
+
+                    lightTerm = sampledColor * ndl;
+                    specularTerm = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndl);
+                    pdf = 4.0;//ImportanceSamplePDF(distTerm, ndh, vdh);
+                }
+
+                // energy conservation:
+                // Specular conservation:
+                specularFactor = lightTerm * specularTerm / pdf;
+                specularFactor = max(
+                  clamp(normalize(specularFactor) * (length(sampledColor * specColor)), 0.0, 1.0),
+                  specularFactor
+                );
+
+                // Diffuse conservation:
+                //kd = (sampledColor * specColor)/specularFactor; //energy conservation
+                kd = 1.0 - specularFactor;
+            }
+
+            accumulatedColor += specularFactor + diffuseFactor * kd;
+        }
+
+        return (accumulatedColor / IMPORTANCE_SAMPLES);
+    }
+
+    vec3 ImportanceSamplingSimple(in vec3 reflectVec, in vec3 tangent, in vec3 bitangent, in vec3 wsNormal, in vec3 toCamera,  in vec3 diffColor, in vec3 specColor, in float roughness, inout vec3 reflectionCubeColor)
+    {
+        reflectionCubeColor = vec3(1,1,1);
+
+        reflectVec = normalize(GetSpecularDominantDir(wsNormal, reflectVec, roughness));
+
+        vec3 Hn = normalize(-toCamera + wsNormal);
+        float ndv = clamp(dot(-toCamera, wsNormal), 0.0, 1.0);
+        float vdh = clamp(dot(-toCamera, Hn), 0.0, 1.0);
+        float ndh = clamp(dot(wsNormal, Hn), 0.0, 1.0);
+
+        vec3 accumulatedColor = vec3(0,0,0);
+        for (int i = 0; i < IMPORTANCE_SAMPLES; ++i)
+        {
+            vec3 kd = vec3(1,1,1);
+            vec3 diffuseFactor = vec3(0,0,0);
+            vec3 specularFactor = vec3(0,0,0);
+
+            {
+                // Diffuse IBL
+                const float rough = 1.0;
+                const float mipLevel = 9.0;
+
+                vec3 perturb = ImportanceSampleGGX(IMPORTANCE_KERNEL[i].xy, rough, wsNormal);
+                vec3 sampleVec = wsNormal + perturb; //perturb by the sample vector
+
+                vec3 sampledColor = textureLod(sZoneCubeMap, sampleVec, mipLevel).rgb;
+                float ndl = clamp(dot(sampleVec, wsNormal), 0.0, 1.0);
+
+                vec3 diffuseTerm = Diffuse(diffColor, rough, ndv, ndl, vdh);
+                vec3 lightTerm = sampledColor;
+
+                diffuseFactor = lightTerm * diffuseTerm;
+            }
+
+            {
+                // Specular IBL
+                float rough = roughness;
+                float mipLevel =  GetMipFromRougness(rough);
+
+                vec3 perturb = ImportanceSampleGGX(IMPORTANCE_KERNEL[i].xy, rough, reflectVec);
+                vec3 sampleVec = reflectVec + perturb; //perturb by the sample vector
+
+                vec3 sampledColor = textureCube(sZoneCubeMap, sampleVec, mipLevel).rgb;
+                float ndl = clamp(dot(sampleVec, wsNormal), 0.0, 1.0);
+
+                vec3 fresnelTerm = SchlickFresnel(specColor, ndh) ;
+                float distTerm = 1.0; //Optimization, this term is mathematically cancelled out  //Distribution(ndh, roughness);
+                float visTerm = SmithGGXVisibility(ndl, ndv, rough);
+                vec3 lightTerm = sampledColor * ndl;
+
+                float pdf = 1.0; //ImportanceSamplePDF(distTerm, ndh, vdh);
+
+                specularFactor = lightTerm * SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv) / pdf;
+                specularFactor *= pdf * ndv * (4.0 * ndl * ndv); // hacks
+                kd = (1.0 - clamp(specularFactor, 0.0, 1.0)); //energy conservation
+            }
+
+            accumulatedColor += specularFactor + diffuseFactor * kd;
+        }
+
+        return accumulatedColor / IMPORTANCE_SAMPLES;
+    }
+
+
+    /// Calculate IBL contributation
+    ///     reflectVec: reflection vector for cube sampling
+    ///     wsNormal: surface normal in word space
+    ///     toCamera: normalized direction from surface point to camera
+    ///     roughness: surface roughness
+    ///     ambientOcclusion: ambient occlusion
+    vec3 ImageBasedLighting(in vec3 reflectVec, in vec3 tangent, in vec3 bitangent, in vec3 wsNormal, in vec3 toCamera, in vec3 diffColor, in vec3 specColor, in float roughness, inout vec3 reflectionCubeColor)
+    {
+        return ImportanceSampling(reflectVec, tangent, bitangent, wsNormal, toCamera, diffColor, specColor, roughness, reflectionCubeColor);
+    }
+#endif

+ 124 - 0
bin/CoreData/Shaders/GLSL/PBRDeferred.glsl

@@ -0,0 +1,124 @@
+#include "Uniforms.glsl"
+#include "Samplers.glsl"
+#include "Transform.glsl"
+#include "ScreenPos.glsl"
+#include "Lighting.glsl"
+#include "Constants.glsl"
+#include "BRDF.glsl"
+#line 40007
+
+#ifdef DIRLIGHT
+    varying vec2 vScreenPos;
+#else
+    varying vec4 vScreenPos;
+#endif
+varying vec3 vFarRay;
+#ifdef ORTHO
+    varying vec3 vNearRay;
+#endif
+
+void VS()
+{
+    mat4 modelMatrix = iModelMatrix;
+    vec3 worldPos = GetWorldPos(modelMatrix);
+    gl_Position = GetClipPos(worldPos);
+    #ifdef DIRLIGHT
+        vScreenPos = GetScreenPosPreDiv(gl_Position);
+        vFarRay = GetFarRay(gl_Position);
+        #ifdef ORTHO
+            vNearRay = GetNearRay(gl_Position);
+        #endif
+    #else
+        vScreenPos = GetScreenPos(gl_Position);
+        vFarRay = GetFarRay(gl_Position) * gl_Position.w;
+        #ifdef ORTHO
+            vNearRay = GetNearRay(gl_Position) * gl_Position.w;
+        #endif
+    #endif
+}
+
+
+void PS()
+{
+    // If rendering a directional light quad, optimize out the w divide
+    #ifdef DIRLIGHT
+        vec4 depthInput = texture2D(sDepthBuffer, vScreenPos);
+        #ifdef HWDEPTH
+            float depth = ReconstructDepth(depthInput.r);
+        #else
+            float depth = DecodeDepth(depthInput.rgb);
+        #endif
+        #ifdef ORTHO
+            vec3 worldPos = mix(vNearRay, vFarRay, depth);
+        #else
+            vec3 worldPos = vFarRay * depth;
+        #endif
+        vec4 albedoInput = texture2D(sAlbedoBuffer, vScreenPos);
+        vec4 normalInput = texture2D(sNormalBuffer, vScreenPos);
+        vec4 specularInput = texture2D(sSpecMap, vScreenPos);
+    #else
+        vec4 depthInput = texture2DProj(sDepthBuffer, vScreenPos);
+        #ifdef HWDEPTH
+            float depth = ReconstructDepth(depthInput.r);
+        #else
+            float depth = DecodeDepth(depthInput.rgb);
+        #endif
+        #ifdef ORTHO
+            vec3 worldPos = mix(vNearRay, vFarRay, depth) / vScreenPos.w;
+        #else
+            vec3 worldPos = vFarRay * depth / vScreenPos.w;
+        #endif
+        vec4 albedoInput = texture2DProj(sAlbedoBuffer, vScreenPos);
+        vec4 normalInput = texture2DProj(sNormalBuffer, vScreenPos);
+        vec4 specularInput = texture2DProj(sSpecMap, vScreenPos);
+    #endif
+
+    vec3 normal = normalize(normalInput.rgb);
+    float roughness = depthInput.a;//length(normal);
+    //normal = normalize(normal);
+
+    vec3 specColor = vec3(specularInput.a, albedoInput.a, normalInput.a);
+
+    vec4 projWorldPos = vec4(worldPos, 1.0);
+
+    vec3 lightDir;
+    float diff = GetDiffuse(normal, worldPos, lightDir);
+
+    #ifdef SHADOW
+        diff *= GetShadowDeferred(projWorldPos, depth);
+    #endif
+
+    #if defined(SPOTLIGHT)
+        vec4 spotPos = projWorldPos * cLightMatricesPS[0];
+        vec3 lightColor = spotPos.w > 0.0 ? texture2DProj(sLightSpotMap, spotPos).rgb * cLightColor.rgb : vec3(0.0);
+    #elif defined(CUBEMASK)
+        mat3 lightVecRot = mat3(cLightMatricesPS[0][0].xyz, cLightMatricesPS[0][1].xyz, cLightMatricesPS[0][2].xyz);
+        vec3 lightColor = textureCube(sLightCubeMap, (worldPos - cLightPosPS.xyz) * lightVecRot).rgb * cLightColor.rgb;
+    #else
+        vec3 lightColor = cLightColor.rgb;
+    #endif
+
+    vec3 toCamera = normalize(-worldPos);
+    vec3 lightVec = lightDir;
+
+    vec3 Hn = normalize(toCamera + lightVec);
+    float vdh = max(M_EPSILON, dot(toCamera, Hn));
+    float ndh = max(M_EPSILON, dot(normal, Hn));
+    float ndl = max(M_EPSILON, dot(normal, lightVec));
+    float ndv = max(M_EPSILON, dot(normal, toCamera));
+
+    vec3 diffuseFactor = BurleyDiffuse(albedoInput.rgb, roughness, ndv, ndl, vdh);
+    vec3 specularFactor = vec3(0,0,0);
+
+     #ifdef SPECULAR
+        vec3 fresnelTerm = Fresnel(specColor, vdh) ;
+        float distTerm = Distribution(ndh, roughness);
+        float visTerm = Visibility(ndl, ndv, roughness);
+
+        specularFactor = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv);
+    #endif
+
+    gl_FragColor.a = 1.0;
+    gl_FragColor.rgb = (diffuseFactor + specularFactor) * lightColor * diff;
+
+}

+ 257 - 0
bin/CoreData/Shaders/GLSL/PBRLitSolid.glsl

@@ -0,0 +1,257 @@
+#include "Uniforms.glsl"
+#include "Samplers.glsl"
+#include "Transform.glsl"
+#include "ScreenPos.glsl"
+#include "Lighting.glsl"
+#include "Constants.glsl"
+#include "Fog.glsl"
+#include "BRDF.glsl"
+#include "IBL.glsl"
+#line 30010
+
+#if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+    varying vec4 vTexCoord;
+    varying vec4 vTangent;
+#else
+    varying vec2 vTexCoord;
+#endif
+varying vec3 vNormal;
+varying vec4 vWorldPos;
+#ifdef VERTEXCOLOR
+    varying vec4 vColor;
+#endif
+#ifdef PERPIXEL
+    #ifdef SHADOW
+        varying vec4 vShadowPos[NUMCASCADES];
+    #endif
+    #ifdef SPOTLIGHT
+        varying vec4 vSpotPos;
+    #endif
+    #ifdef POINTLIGHT
+        varying vec3 vCubeMaskVec;
+    #endif
+#else
+    varying vec3 vVertexLight;
+    varying vec4 vScreenPos;
+    #ifdef ENVCUBEMAP
+        varying vec3 vReflectionVec;
+    #endif
+    #if defined(LIGHTMAP) || defined(AO)
+        varying vec2 vTexCoord2;
+    #endif
+#endif
+
+void VS()
+{
+    mat4 modelMatrix = iModelMatrix;
+    vec3 worldPos = GetWorldPos(modelMatrix);
+    gl_Position = GetClipPos(worldPos);
+    vNormal = GetWorldNormal(modelMatrix);
+    vWorldPos = vec4(worldPos, GetDepth(gl_Position));
+
+    #ifdef VERTEXCOLOR
+        vColor = iColor;
+    #endif
+
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        vec3 tangent = GetWorldTangent(modelMatrix);
+        vec3 bitangent = cross(tangent, vNormal) * iTangent.w;
+        vTexCoord = vec4(GetTexCoord(iTexCoord), bitangent.xy);
+        vTangent = vec4(tangent, bitangent.z);
+    #else
+        vTexCoord = GetTexCoord(iTexCoord);
+    #endif
+
+    #ifdef PERPIXEL
+        // Per-pixel forward lighting
+        vec4 projWorldPos = vec4(worldPos, 1.0);
+
+        #ifdef SHADOW
+            // Shadow projection: transform from world space to shadow space
+            for (int i = 0; i < NUMCASCADES; i++)
+                vShadowPos[i] = GetShadowPos(i, projWorldPos);
+        #endif
+
+        #ifdef SPOTLIGHT
+            // Spotlight projection: transform from world space to projector texture coordinates
+            vSpotPos = projWorldPos * cLightMatrices[0];
+        #endif
+
+        #ifdef POINTLIGHT
+            vCubeMaskVec = (worldPos - cLightPos.xyz) * mat3(cLightMatrices[0][0].xyz, cLightMatrices[0][1].xyz, cLightMatrices[0][2].xyz);
+        #endif
+    #else
+        // Ambient & per-vertex lighting
+        #if defined(LIGHTMAP) || defined(AO)
+            // If using lightmap, disregard zone ambient light
+            // If using AO, calculate ambient in the PS
+            vVertexLight = vec3(0.0, 0.0, 0.0);
+            vTexCoord2 = iTexCoord2;
+        #else
+            vVertexLight = GetAmbient(GetZonePos(worldPos));
+        #endif
+
+        #ifdef NUMVERTEXLIGHTS
+            for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
+                vVertexLight += GetVertexLight(i, worldPos, vNormal) * cVertexLights[i * 3].rgb;
+        #endif
+
+        vScreenPos = GetScreenPos(gl_Position);
+
+        #ifdef ENVCUBEMAP
+            vReflectionVec = worldPos - cCameraPos;
+        #endif
+    #endif
+}
+
+void PS()
+{
+    // Get material diffuse albedo
+    #ifdef DIFFMAP
+        vec4 diffInput = texture2D(sDiffMap, vTexCoord.xy);
+        #ifdef ALPHAMASK
+            if (diffInput.a < 0.5)
+                discard;
+        #endif
+        vec4 diffColor = cMatDiffColor * diffInput;
+    #else
+        vec4 diffColor = cMatDiffColor;
+    #endif
+
+    #ifdef VERTEXCOLOR
+        diffColor *= vColor;
+    #endif
+
+    #ifdef METALLIC
+        vec4 roughMetalSrc = texture2D(sSpecMap, vTexCoord.xy);
+
+        float roughness = clamp(pow(roughMetalSrc.r + cRoughnessPS, 2.0), ROUGHNESS_FLOOR, 1.0);
+        float metalness = clamp(roughMetalSrc.g + cMetallicPS, METALNESS_FLOOR, 1.0);
+    #else
+        float roughness = clamp(pow(cRoughnessPS, 2.0), ROUGHNESS_FLOOR, 1.0);
+        float metalness = clamp(cMetallicPS, METALNESS_FLOOR, 1.0);
+    #endif
+
+    vec3 specColor = mix(0.08 * cMatSpecColor.rgb, diffColor.rgb, metalness);
+    diffColor.rgb = diffColor.rgb - diffColor.rgb * metalness;
+
+    // Get normal
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        vec3 tangent = vTangent.xyz;
+        vec3 bitangent = vec3(vTexCoord.zw, vTangent.w);
+        mat3 tbn = mat3(tangent, bitangent, vNormal);
+    #endif
+
+    #ifdef NORMALMAP
+        vec3 nn = DecodeNormal(texture2D(sNormalMap, vTexCoord.xy));
+        //nn.rg *= 2.0;
+        vec3 normal = normalize(tbn * nn);
+    #else
+        vec3 normal = normalize(vNormal);
+    #endif
+
+    // Get fog factor
+    #ifdef HEIGHTFOG
+        float fogFactor = GetHeightFogFactor(vWorldPos.w, vWorldPos.y);
+    #else
+        float fogFactor = GetFogFactor(vWorldPos.w);
+    #endif
+
+    #if defined(PERPIXEL)
+        // Per-pixel forward lighting
+        vec3 lightColor;
+        vec3 lightDir;
+        vec3 finalColor;
+
+        float diff = GetDiffuse(normal, vWorldPos.xyz, lightDir);
+
+        #ifdef SHADOW
+            diff *= GetShadow(vShadowPos, vWorldPos.w);
+        #endif
+
+        #if defined(SPOTLIGHT)
+            lightColor = vSpotPos.w > 0.0 ? texture2DProj(sLightSpotMap, vSpotPos).rgb * cLightColor.rgb : vec3(0.0, 0.0, 0.0);
+        #elif defined(CUBEMASK)
+            lightColor = textureCube(sLightCubeMap, vCubeMaskVec).rgb * cLightColor.rgb;
+        #else
+            lightColor = cLightColor.rgb;
+        #endif
+
+        vec3 toCamera = normalize(cCameraPosPS - vWorldPos.xyz);
+
+        vec3 Hn = normalize(toCamera + lightDir);
+        float vdh = max(M_EPSILON, dot(toCamera, Hn));
+        float ndh = max(M_EPSILON, dot(normal, Hn));
+        float ndl = max(M_EPSILON, dot(normal, lightDir));
+        float ndv = max(M_EPSILON, dot(normal, toCamera));
+
+        vec3 diffuseFactor = BurleyDiffuse(diffColor.rgb, roughness, ndv, ndl, vdh);
+        vec3 specularFactor = vec3(0,0,0);
+
+        #ifdef SPECULAR
+            vec3 fresnelTerm = Fresnel(specColor, vdh) ;
+            float distTerm = Distribution(ndh, roughness);
+            float visTerm = Visibility(ndl, ndv, roughness);
+
+            specularFactor = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv);
+        #endif
+
+        finalColor.rgb = (diffuseFactor + specularFactor) * lightColor * diff;
+
+        #ifdef AMBIENT
+            finalColor += cAmbientColor * diffColor.rgb;
+            finalColor += cMatEmissiveColor;
+            gl_FragColor = vec4(GetFog(finalColor, fogFactor), diffColor.a);
+        #else
+            gl_FragColor = vec4(GetLitFog(finalColor, fogFactor), diffColor.a);
+        #endif
+    #elif defined(DEFERRED)
+        // Fill deferred G-buffer'
+        const vec3 spareData = vec3(0,0,0); // Can be used to pass more data to deferred renderer
+        gl_FragData[0] = vec4(spareData, specColor.r);
+        gl_FragData[1] = vec4(diffColor.rgb, specColor.g);
+        gl_FragData[2] = vec4(normal, specColor.b);
+        gl_FragData[3] = vec4(EncodeDepth(vWorldPos.w), roughness);
+    #else
+        // Ambient & per-vertex lighting
+        vec3 finalColor = vVertexLight * diffColor.rgb;
+        #ifdef AO
+            // If using AO, the vertex light ambient is black, calculate occluded ambient here
+            finalColor += texture2D(sEmissiveMap, vTexCoord2).rgb * cAmbientColor * diffColor.rgb;
+        #endif
+
+        #ifdef MATERIAL
+            // Add light pre-pass accumulation result
+            // Lights are accumulated at half intensity. Bring back to full intensity now
+            vec4 lightInput = 2.0 * texture2DProj(sLightBuffer, vScreenPos);
+            vec3 lightSpecColor = lightInput.a * lightInput.rgb / max(GetIntensity(lightInput.rgb), 0.001);
+
+            finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
+        #endif
+
+        vec3 toCamera = normalize(vWorldPos.xyz - cCameraPosPS);
+        vec3 reflection = normalize(reflect(toCamera, normal));
+
+        vec3 cubeColor = vVertexLight.rgb;
+
+        #ifdef IBL
+          vec3 iblColor = ImageBasedLighting(reflection, tangent, bitangent, normal, toCamera, diffColor.rgb, specColor.rgb, roughness, cubeColor);
+          float gamma = 0.0;
+          finalColor.rgb += iblColor * (cubeColor + gamma);
+        #endif
+
+        #ifdef ENVCUBEMAP
+            finalColor += cMatEnvMapColor * textureCube(sEnvCubeMap, reflect(vReflectionVec, normal)).rgb;
+        #endif
+        #ifdef LIGHTMAP
+            finalColor += texture2D(sEmissiveMap, vTexCoord2).rgb * diffColor.rgb;
+        #endif
+        #ifdef EMISSIVEMAP
+            finalColor += cMatEmissiveColor * texture2D(sEmissiveMap, vTexCoord.xy).rgb;
+        #else
+            finalColor += cMatEmissiveColor;
+        #endif
+
+        gl_FragColor = vec4(GetFog(finalColor, fogFactor), diffColor.a);
+    #endif
+}

+ 8 - 0
bin/CoreData/Shaders/GLSL/Uniforms.glsl

@@ -67,6 +67,10 @@ uniform vec4 cMatDiffColor;
 uniform vec3 cMatEmissiveColor;
 uniform vec3 cMatEnvMapColor;
 uniform vec4 cMatSpecColor;
+#ifdef PBR
+    uniform float cRoughnessPS;
+    uniform float cMetallicPS;
+#endif
 uniform float cNearClipPS;
 uniform float cFarClipPS;
 uniform vec4 cShadowCubeAdjust;
@@ -194,6 +198,10 @@ uniform MaterialPS
     vec3 cMatEmissiveColor;
     vec3 cMatEnvMapColor;
     vec4 cMatSpecColor;
+    #ifdef PBR
+        float cRoughnessPS;
+        float cMetallicPS;
+    #endif
 };
 #endif
 

+ 191 - 0
bin/CoreData/Shaders/HLSL/BDRF.hlsl

@@ -0,0 +1,191 @@
+#ifdef COMPILEPS
+  #ifdef PBR
+    /// Diffuse factors
+
+    /// Oren-Nayar diffuse factor
+    ///     diffuseColor: input rgb
+    ///     roughness: roughness of the surface
+    ///     NdotV: dot prod of surface normal and view direction
+    ///     NdotL: dot prod of surface normal and light direction
+    ///     VdotH: dot prod of view direction and half-angle
+    float3 OrenNayarDiffuse(in float3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        const float rough2 = roughness * roughness;
+
+        const float VdotL = 2.0 * VdotH - 1.0;
+        const float majorCtrl = 1.0 - 0.5 * rough2 / (rough2 + 0.33);
+        const float cosRi = VdotL - NdotV * NdotL;
+        const float minorCtrl = 0.4545 * rough2 / (rough2 + 0.09) * cosRi * (cosRi >= 0.0 ? min(1., NdotL / NdotV) : NdotL);
+        return diffuseColor / M_PI * ( NdotL * majorCtrl + minorCtrl);
+    }
+
+    /// Lambertian diffuse factor
+    ///     diffuseColor: input rgb
+    ///     roughness: roughness of the surface
+    ///     NdotV: dot prod of surface normal and view direction
+    ///     NdotL: dot prod of surface normal and light direction
+    ///     VdotH: dot prod of view direction and half-angle
+    float3 LambertianDiffuse(in float3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        return diffuseColor * NdotL;
+    }
+
+    float3 BurleyDiffuse(in float3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        const float energyBias = lerp(0, 0.5, roughness);
+        const float energyFactor = lerp(1.0, 1.0 / 1.51, roughness);
+        const float fd90 = energyBias + 2.0 * VdotH * VdotH * roughness;
+        const float f0 = 1.0;
+        const float lightScatter = f0 + (fd90 - f0) * pow(1.0f - NdotL, 5.0f);
+        const float viewScatter = f0 + (fd90 - f0) * pow(1.0f - NdotV, 5.0f);
+
+        return diffuseColor * lightScatter * viewScatter * energyFactor;
+    }
+
+    float3 Diffuse(in float3 diffuseColor, in float roughness, in float NdotV, in float NdotL, in float VdotH)
+    {
+        return BurleyDiffuse(diffuseColor, roughness, NdotV, NdotL, VdotH);
+    }
+
+    /// Specular BRDF
+    float3 CookTorranceBRDF(in float D, in float3 F, in float G, in float NdotL, in float NdotV)
+    {
+        return D * F * G / (4.0 *  max(NdotL * NdotV, M_EPSILON));
+    }
+
+    float3 SpecularBRDF(in float D, in float3 F, in float G, in float NdotL, in float NdotV)
+    {
+        return CookTorranceBRDF(D, F, G, NdotL, NdotV);
+    }
+
+    /// Specular probability density function (for importance sampling)
+    float CookTorrancePDF(in float D, in float NdotH, in float VdotH)
+    {
+        return D * NdotH / (4.0 * VdotH);
+    }
+
+    float ImportanceSamplePDF(in float D, in float NdotH, in float VdotH)
+    {
+        return CookTorrancePDF(D, NdotH, VdotH);
+    }
+
+    /// Fresnel Terms
+
+    /// Fresnel factor
+    ///     specular: Specular color input
+    ///     VdotH: dot product of view direction and half-angle
+    float3 SchlickFresnel(in float3 specular, in float VdotH)
+    {
+        return specular + (float3(1.0, 1.0, 1.0) - specular) * pow(1.0 - VdotH, 5.0);
+    }
+
+    /// Fresnel factor, spherical gaussian in Schlick approximation; https://seblagarde.wordpress.com/2012/06/03/spherical-gaussien-approximation-for-blinn-phong-phong-and-fresnel/
+    float3 SchlickGaussianFresnel(in float3 specular, in float VdotH)
+    {
+        float sphericalGaussian = pow(2.0, (-5.55473 * VdotH - 6.98316) * VdotH);
+        return specular + (float3(1.0, 1.0, 1.0) - specular) * sphericalGaussian;
+    }
+
+    float3 Fresnel(in float3 specular, in float VdotH)
+    {
+        return SchlickFresnel(specular, VdotH);
+    }
+
+    /// Visibility terms
+
+    /// Smith GGX Visibility
+    ///     NdotL: dot-prod of surface normal and light direction
+    ///     NdotV: dot-prod of surface normal and view direction
+    ///     roughness: surface roughness
+    float SmithGGXVisibility(in float NdotL, in float NdotV, in float roughness)
+    {
+        float a = roughness * roughness;
+        float a2 = a*a;
+
+        float Vis_SmithV = NdotV + sqrt(NdotV * (NdotV - NdotV * a2) + a2);
+        float Vis_SmithL = NdotL + sqrt(NdotL * (NdotL - NdotL * a2) + a2);
+        return rcp(Vis_SmithV * Vis_SmithL);
+    }
+
+    float SmithGGXG(in float factor, in float k)
+    {
+        return 2.0 * factor / (factor + sqrt(k + (1.0 - k) * (factor * factor))) ;
+    }
+
+    float SchlickG(in float factor, in float k)
+    {
+        return factor / (factor * (1.0 - k) + k);
+    }
+
+    float SmithGGXVisibility2(in float NdotL, in float NdotV, in float roughness)
+    {
+        const float k = roughness * roughness;
+        return (SmithGGXG(NdotL, k) * SmithGGXG(NdotV, k));
+    }
+
+    /// Schlick approximation of Smith GGX
+    ///     NdotL: dot product of surface normal and light direction
+    ///     NdotV: dot product of surface normal and view direction
+    ///     roughness: surface roughness
+    float SmithGGXSchlickVisibility(float NdotL, float NdotV, float roughness)
+    {
+        float rough2 = roughness * roughness;
+        return (SchlickG(NdotL, rough2) * SchlickG(NdotV, rough2)) * 0.25; // divided by four
+    }
+
+    float SmithGGXSchlickVisibility2(in float NdotL, in float NdotV, in float roughness)
+    {
+        const float rough = roughness + 1.0;
+        const float a = rough * rough;
+        const float k =  a / 8.0;
+        return (SchlickG(NdotL, k) * SchlickG(NdotV, k));
+    }
+
+    float SchlickBeckmannVisibility(in float NdotL, in float NdotV, in float roughness)
+    {
+        const float a = roughness * roughness;
+        const float k =  a * sqrt(2.0 / M_PI);
+        return (SchlickG(NdotL, k) * SchlickG(NdotV, k));
+    }
+
+    float Visibility(in float NdotL, in float NdotV, in float roughness)
+    {
+        return SmithGGXVisibility2(NdotL, NdotV, roughness);
+    }
+
+    /// Normal Distributions
+
+    float BlinnPhongDistribution(in float NdotH, in float roughness)
+    {
+        const float specPower = max((2.0 / (roughness * roughness)) - 2.0, 1e-4f); // Calculate specular power from roughness
+        return pow(saturate(NdotH), specPower);
+    }
+
+    /// Beckmann normal distribution
+    ///     NdotH: dot-prod of surface normal and half-angle
+    ///     roughness: surface roughness
+    float BeckmannDistribution(in float NdotH, in float roughness)
+    {
+        const float rough2 = roughness * roughness;
+        const float roughnessA = 1.0 / (4.0 * rough2 * pow(NdotH, 4.0));
+        const float roughnessB = NdotH * NdotH - 1.0;
+        const float roughnessC = rough2 * NdotH * NdotH;
+        return roughnessA * exp(roughnessB / roughnessC);
+    }
+
+    /// Trowbridge-Reitz GGX normal distribution
+    ///     NdotH: dot-prod of surface normal and half-angle
+    ///     roughness: surface roughness
+    float GGXDistribution(in float NdotH, in float roughness)
+    {
+        float rough2 = roughness * roughness;
+        float tmp = roughness / max(M_EPSILON, NdotH * NdotH * (rough2 - 1.0) + 1.0);
+        return tmp * tmp / M_PI;
+    }
+
+    float Distribution(in float NdotH, in float roughness)
+    {
+        return GGXDistribution(NdotH, roughness);
+    }
+  #endif
+#endif

+ 7 - 0
bin/CoreData/Shaders/HLSL/Constants.hlsl

@@ -0,0 +1,7 @@
+#define M_PI 3.14159265358979323846
+#define M_EPSILON 0.0001
+
+#ifdef PBR
+#define ROUGHNESS_FLOOR 0.04
+#define METALNESS_FLOOR 0.05
+#endif

+ 272 - 0
bin/CoreData/Shaders/HLSL/IBL.hlsl

@@ -0,0 +1,272 @@
+#ifdef COMPILEPS
+    float3 ImportanceSampleSimple(in float2 Xi, in float roughness, in float3 T, in float3 B, in float3 N)
+    {
+        const float a = roughness * roughness;
+        const float3x3 tbn = float3x3(T, B, N);
+        #if defined(PBRFAST)
+            const float blurFactor = 0.0;
+        #else
+            const float blurFactor = 5.0;
+        #endif
+        const float3 Xi3 = lerp(float3(0,0,1), normalize(float3(Xi.xy * blurFactor , 1)), a);
+        const float3 XiWS = mul(Xi3, tbn);
+        return normalize(N + XiWS);
+    }
+
+    // Karis '13
+    float3 ImportanceSampleGGX(in float2 Xi, in float roughness, in float3 N)
+    {
+        float a = roughness * roughness;
+        float Phi = 2.0 * M_PI * Xi.x;
+        float CosTheta = (sqrt((1.0 - Xi.y) / (1.0 + (a*a - 1.0) * Xi.y)));
+        float SinTheta = sqrt(1.0 - CosTheta * CosTheta);
+        float3 H = 0;
+        H.x = SinTheta * cos(Phi);
+        H.y = SinTheta * sin(Phi);
+        H.z = CosTheta;
+
+        float3 UpVector = abs(N.z) < 0.999 ? float3(0, 0, 1) : float3(1, 0, 0);
+        float3 TangentX = normalize(cross(UpVector, N));
+        float3 TangentY = cross(N, TangentX);
+        // Tangent to world space
+        return TangentX * H.x + TangentY * H.y + N * H.z;
+    }
+
+    /// Determine reflection vector based on surface roughness, rougher uses closer to the normal and smoother uses closer to the reflection vector
+    ///     normal: surface normal
+    ///     reflection: vector of reflection off of the surface
+    ///     roughness: surface roughness
+    float3 GetSpecularDominantDir(float3 normal, float3 reflection, float roughness)
+    {
+        const float smoothness = 1.0 - roughness;
+        const float lerpFactor = smoothness * (sqrt(smoothness) + roughness);
+        return lerp(normal, reflection, lerpFactor);
+    }
+
+    #define IMPORTANCE_SAMPLES 16
+    static const float2 IMPORTANCE_KERNEL[IMPORTANCE_SAMPLES] =
+    {
+        float2(-0.0780436, 0.0558389),
+        float2(0.034318, -0.0635879),
+        float2(0.00230821, 0.0807279),
+        float2(0.0124638, 0.117585),
+        float2(0.093943, -0.0944602),
+        float2(0.139348, -0.109816),
+        float2(-0.181872, -0.129649),
+        float2(0.240066, -0.0494057),
+        float2(0.115965, -0.0374714),
+        float2(-0.294819, -0.100726),
+        float2(-0.149652, 0.37459),
+        float2(0.261695, -0.292813),
+        float2(-0.37944, -0.425145),
+        float2(0.628994, -0.189387),
+        float2(-0.331257, -0.646864),
+        float2(-0.467004, 0.439687),
+    };
+
+    float GetMipFromRougness(float roughness)
+    {
+        const float smoothness = 1.0 - roughness;
+        return (1.0 - smoothness * smoothness) * 10.0;
+    }
+
+    /// Perform importance sampling
+    ///     reflectVec: calculated vector of reflection
+    ///     wsNormal: world-space normal of the surface
+    ///     toCamera: direction from the pixel to the camera
+    ///     specular: specular color
+    ///     roughness: surface roughness
+    ///     reflectionCubeColor: output color for diffuse
+
+    // Implementation based on Epics 2013 course notes
+    float3 ImportanceSampling(in float3 reflectVec, in float3 tangent, in float3 bitangent, in float3 wsNormal, in float3 toCamera,  in float3 diffColor, in float3 specColor, in float roughness, inout float3 reflectionCubeColor)
+    {
+        reflectionCubeColor = 1.0;
+
+        const float3 reflectSpec = normalize(GetSpecularDominantDir(wsNormal, reflectVec, roughness));
+
+        const float3 V = normalize(-toCamera);
+        const float3 N = normalize(wsNormal);
+        const float ndv = saturate(abs(dot(N, V)));
+
+        const float specMipLevel = GetMipFromRougness(roughness);
+
+        float3 accumulatedColor = float3(0,0,0);
+        for (int i = 0; i < IMPORTANCE_SAMPLES; ++i)
+        {
+            float3 kd = 1.0;
+            float3 diffuseFactor = 0.0;
+            float3 specularFactor = 0.0;
+
+            {
+                // Diffuse IBL
+                const float rough = 1.0;
+                const float mipLevel = 9.0;
+
+                const float3 H = ImportanceSampleSimple(IMPORTANCE_KERNEL[i], rough, tangent, bitangent, N);
+                const float3 L = 2.0 * dot( V, H ) * H - V;
+
+                const float vdh = saturate(abs(dot(V, H)));
+                const float ndh = saturate(abs(dot(N, H)));
+                const float ndl = saturate(abs(dot(N, L)));
+
+                //if (ndl > 0.0)
+                {
+                    const float3 sampledColor = SampleCubeLOD(ZoneCubeMap, float4(L, mipLevel));
+
+                    const float3 diffuseTerm = Diffuse(diffColor, rough, ndv, ndl, vdh);
+                    const float3 lightTerm = sampledColor;
+
+                    diffuseFactor = lightTerm * diffuseTerm;
+                }
+            }
+
+            {
+                // Specular IBL
+                const float rough = roughness;
+                const float mipLevel = specMipLevel;
+
+                const float3 H = ImportanceSampleSimple(IMPORTANCE_KERNEL[i], rough, tangent, bitangent, N);
+                const float3 L = 2.0 * dot( V, H ) * H - V;
+                const float3 sampledColor = SampleCubeLOD(ZoneCubeMap, float4(L, mipLevel));
+
+                const float vdh = saturate(abs(dot(V, H)));
+                const float ndh = saturate(abs(dot(N, H)));
+                const float ndl = saturate(abs(dot(N, L)));
+
+                float3 specularTerm = 0.0;
+                float pdf = 1.0;
+                float3 lightTerm = 0.0;
+
+                if (ndl > 0.05)
+                {
+                    const float3 fresnelTerm = Fresnel(specColor, vdh);
+                    const float distTerm = 1.0; // Optimization, this term is mathematically cancelled out  -- Distribution(ndh, roughness);
+                    const float visTerm = Visibility(ndl, ndv, rough);
+
+                    lightTerm = sampledColor * ndl;
+                    specularTerm = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv);
+                    pdf = ImportanceSamplePDF(distTerm, ndh, vdh);
+                }
+                else // reduce artifacts at extreme grazing angles
+                {
+                    const float3 fresnelTerm = Fresnel(specColor, vdh);
+                    const float distTerm = 1.0;//Distribution(ndh_, roughness);
+                    const float visTerm = Visibility(ndl, ndv, rough);
+
+                    lightTerm = sampledColor * ndl;
+                    specularTerm = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndl);
+                    pdf = 4.0;//ImportanceSamplePDF(distTerm, ndh, vdh);
+                }
+
+                // energy conservation:
+                // Specular conservation:
+                specularFactor = lightTerm * specularTerm / pdf;
+                specularFactor = max(saturate(normalize(specularFactor) * (length(sampledColor * specColor))), specularFactor);
+
+                // Diffuse conservation:
+                //kd = (sampledColor * specColor)/specularFactor; //energy conservation
+                kd = 1.0 - specularFactor;
+            }
+
+            accumulatedColor += specularFactor + diffuseFactor * kd;
+        }
+
+        return (accumulatedColor / IMPORTANCE_SAMPLES);
+    }
+
+
+    float3 ImportanceSamplingSimple(in float3 reflectVec, in float3 tangent, in float3 bitangent, in float3 wsNormal, in float3 toCamera,  in float3 diffColor, in float3 specColor, in float roughness, inout float3 reflectionCubeColor)
+    {
+        reflectionCubeColor = 1.0;
+
+        reflectVec = normalize(GetSpecularDominantDir(wsNormal, reflectVec, roughness));
+
+        const float3 Hn = normalize(-toCamera + wsNormal);
+        const float ndv = saturate(dot(-toCamera, wsNormal));
+        const float vdh = saturate(dot(-toCamera, Hn));
+        const float ndh = saturate(dot(wsNormal, Hn));
+
+        float3 accumulatedColor = float3(0,0,0);
+        for (int i = 0; i < IMPORTANCE_SAMPLES; ++i)
+        {
+            float3 kd = 1.0;
+            float3 diffuseFactor = 0.0;
+            float3 specularFactor = 0.0;
+
+            {
+                // Diffuse IBL
+                const float rough = 1.0;
+                const float mipLevel = 9.0;
+
+                const float3 perturb = ImportanceSampleGGX(IMPORTANCE_KERNEL[i].xy, rough, wsNormal);
+                const float3 sampleVec = wsNormal + perturb; //perturb by the sample vector
+
+                const float3 sampledColor = SampleCubeLOD(ZoneCubeMap, float4(sampleVec, mipLevel));
+                const float ndl = saturate(dot(sampleVec, wsNormal));
+
+                const float3 diffuseTerm = Diffuse(diffColor, rough, ndv, ndl, vdh);
+                const float3 lightTerm = sampledColor;
+
+                diffuseFactor = lightTerm * diffuseTerm;
+            }
+
+            {
+                // Specular IBL
+                const float rough = roughness;
+                const float mipLevel =  GetMipFromRougness(rough);
+
+                const float3 perturb = ImportanceSampleGGX(IMPORTANCE_KERNEL[i].xy, rough, reflectVec);
+                const float3 sampleVec = reflectVec + perturb; //perturb by the sample vector
+
+                const float3 sampledColor = SampleCubeLOD(ZoneCubeMap, float4(sampleVec, mipLevel));
+                const float ndl = saturate(dot(sampleVec, wsNormal));
+
+                const float3 fresnelTerm = SchlickFresnel(specColor, ndh) ;
+                const float distTerm = 1.0; //Optimization, this term is mathematically cancelled out  //Distribution(ndh, roughness);
+                const float visTerm = SmithGGXVisibility(ndl, ndv, rough);
+                const float3 lightTerm = sampledColor * ndl;
+
+                const float pdf = 1.0;//ImportanceSamplePDF(distTerm, ndh, vdh);
+
+                specularFactor = lightTerm * SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv) / pdf;
+                specularFactor *= pdf * ndv * (4.0 * ndl * ndv); // hacks
+                kd = (1.0 - saturate(specularFactor)); //energy conservation
+            }
+
+            accumulatedColor += specularFactor + diffuseFactor * kd;
+        }
+
+        return accumulatedColor / IMPORTANCE_SAMPLES;
+    }
+
+    float3 EnvBRDFApprox (float3 SpecularColor, float Roughness, float NoV)
+    {
+        const float4 c0 = float4(-1, -0.0275, -0.572, 0.022 );
+        const float4 c1 = float4(1, 0.0425, 1.0, -0.04 );
+        float4 r = Roughness * c0 + c1;
+        float a004 = min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;
+        float2 AB = float2( -1.04, 1.04 ) * a004 + r.zw;
+        return SpecularColor * AB.x + AB.y;
+    }
+
+    float EnvBRDFApproxNonmetal( float Roughness, float NoV )
+    {
+        // Same as EnvBRDFApprox( 0.04, Roughness, NoV )
+        const float2 c0 = { -1, -0.0275 };
+        const float2 c1 = { 1, 0.0425 };
+        float2 r = Roughness * c0 + c1;
+        return min( r.x * r.x, exp2( -9.28 * NoV ) ) * r.x + r.y;
+    }
+
+    /// Calculate IBL contributation
+    ///     reflectVec: reflection vector for cube sampling
+    ///     wsNormal: surface normal in word space
+    ///     toCamera: normalized direction from surface point to camera
+    ///     roughness: surface roughness
+    ///     ambientOcclusion: ambient occlusion
+    float3 ImageBasedLighting(in float3 reflectVec, in float3 tangent, in float3 bitangent, in float3 wsNormal, in float3 toCamera, in float3 diffColor, in float3 specColor, in float roughness, inout float3 reflectionCubeColor)
+    {
+        return ImportanceSampling(reflectVec, tangent, bitangent, wsNormal, toCamera, diffColor, specColor, roughness, reflectionCubeColor);
+    }
+#endif

+ 129 - 0
bin/CoreData/Shaders/HLSL/PBRDeferred.hlsl

@@ -0,0 +1,129 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+#include "ScreenPos.hlsl"
+#include "Lighting.hlsl"
+#include "Constants.hlsl"
+#include "BDRF.hlsl"
+#line 9
+
+void VS(float4 iPos : POSITION,
+    #ifdef DIRLIGHT
+        out float2 oScreenPos : TEXCOORD0,
+    #else
+        out float4 oScreenPos : TEXCOORD0,
+    #endif
+    out float3 oFarRay : TEXCOORD1,
+    #ifdef ORTHO
+        out float3 oNearRay : TEXCOORD2,
+    #endif
+    out float4 oPos : OUTPOSITION)
+{
+    float4x3 modelMatrix = iModelMatrix;
+    float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    #ifdef DIRLIGHT
+        oScreenPos = GetScreenPosPreDiv(oPos);
+        oFarRay = GetFarRay(oPos);
+        #ifdef ORTHO
+            oNearRay = GetNearRay(oPos);
+        #endif
+    #else
+        oScreenPos = GetScreenPos(oPos);
+        oFarRay = GetFarRay(oPos) * oPos.w;
+        #ifdef ORTHO
+            oNearRay = GetNearRay(oPos) * oPos.w;
+        #endif
+    #endif
+}
+
+void PS(
+    #ifdef DIRLIGHT
+        float2 iScreenPos : TEXCOORD0,
+    #else
+        float4 iScreenPos : TEXCOORD0,
+    #endif
+    float3 iFarRay : TEXCOORD1,
+    #ifdef ORTHO
+        float3 iNearRay : TEXCOORD2,
+    #endif
+
+    float2 iFragPos : VPOS,
+    out float4 oColor : OUTCOLOR0)
+{
+    // If rendering a directional light quad, optimize out the w divide
+    #ifdef DIRLIGHT
+        float3 depth = Sample2DLod0(DepthBuffer, iScreenPos).r;
+        #ifdef HWDEPTH
+            depth = ReconstructDepth(depth);
+        #endif
+        #ifdef ORTHO
+            const float3 worldPos = lerp(iNearRay, iFarRay, depth);
+        #else
+            const float3 worldPos = iFarRay * depth;
+        #endif
+        const float4 albedoInput = Sample2DLod0(AlbedoBuffer, iScreenPos);
+        const float4 normalInput = Sample2DLod0(NormalBuffer, iScreenPos);
+        const float4 specularInput = Sample2DLod0(SpecMap, iScreenPos);
+    #else
+        float depth = Sample2DProj(DepthBuffer, iScreenPos).r;
+        #ifdef HWDEPTH
+            depth = ReconstructDepth(depth);
+        #endif
+        #ifdef ORTHO
+            const float3 worldPos = lerp(iNearRay, iFarRay, depth) / iScreenPos.w;
+        #else
+            const float3 worldPos = iFarRay * depth / iScreenPos.w;
+        #endif
+        const float4 albedoInput = Sample2DProj(AlbedoBuffer, iScreenPos);
+        const float4 normalInput = Sample2DProj(NormalBuffer, iScreenPos);
+        const float4 specularInput = Sample2DProj(SpecMap, iScreenPos);
+    #endif
+
+    float3 normal = normalInput.rgb;
+    const float roughness = length(normal);
+    normal = normalize(normal);
+
+    const float3 specColor = float3(specularInput.a, albedoInput.a, normalInput.a);
+
+    const float4 projWorldPos = float4(worldPos, 1.0);
+
+    float3 lightDir;
+    float diff = GetDiffuse(normal, worldPos, lightDir);
+
+    #ifdef SHADOW
+        diff *= GetShadowDeferred(projWorldPos, depth);
+    #endif
+
+    #if defined(SPOTLIGHT)
+        const float4 spotPos = mul(projWorldPos, cLightMatricesPS[0]);
+        const float3 lightColor = spotPos.w > 0.0 ? Sample2DProj(LightSpotMap, spotPos).rgb * cLightColor.rgb : 0.0;
+    #elif defined(CUBEMASK)
+        const float3 lightColor = texCUBE(sLightCubeMap, mul(worldPos - cLightPosPS.xyz, (float3x3)cLightMatricesPS[0])).rgb * cLightColor.rgb;
+    #else
+        const float3 lightColor = cLightColor.rgb;
+    #endif
+
+    const float3 toCamera = normalize(-worldPos);
+    const float3 lightVec = normalize(lightDir);
+
+    const float3 Hn = normalize(toCamera + lightVec);
+    const float vdh = max(M_EPSILON, dot(toCamera, Hn));
+    const float ndh = max(M_EPSILON, dot(normal, Hn));
+    const float ndl = max(M_EPSILON, dot(normal, lightVec));
+    const float ndv = max(M_EPSILON, dot(normal, toCamera));
+
+    const float3 diffuseFactor = BurleyDiffuse(albedoInput.rgb, roughness, ndv, ndl, vdh);
+    float3 specularFactor = 0;
+
+    #ifdef SPECULAR
+        const float3 fresnelTerm = Fresnel(specColor, vdh);
+        const float distTerm = Distribution(ndh, roughness);
+        const float visTerm = Visibility(ndl, ndv, roughness);
+
+        specularFactor = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv);
+    #endif
+
+    oColor.a = 1;
+    oColor.rgb  = (diffuseFactor + specularFactor) * lightColor * diff;
+}

+ 342 - 0
bin/CoreData/Shaders/HLSL/PBRLitSolid.hlsl

@@ -0,0 +1,342 @@
+#include "Uniforms.hlsl"
+#include "Samplers.hlsl"
+#include "Transform.hlsl"
+#include "ScreenPos.hlsl"
+#include "Lighting.hlsl"
+#include "Constants.hlsl"
+#include "Fog.hlsl"
+#include "BDRF.hlsl"
+#include "IBL.hlsl"
+
+void VS(float4 iPos : POSITION,
+    #ifndef BILLBOARD
+        float3 iNormal : NORMAL,
+    #endif
+    #ifndef NOUV
+        float2 iTexCoord : TEXCOORD0,
+    #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    #if defined(LIGHTMAP) || defined(AO)
+        float2 iTexCoord2 : TEXCOORD1,
+    #endif
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        float4 iTangent : TANGENT,
+    #endif
+    #ifdef SKINNED
+        float4 iBlendWeights : BLENDWEIGHT,
+        int4 iBlendIndices : BLENDINDICES,
+    #endif
+    #ifdef INSTANCED
+        float4x3 iModelInstance : TEXCOORD2,
+    #endif
+    #if defined(BILLBOARD) || defined(DIRBILLBOARD)
+        float2 iSize : TEXCOORD1,
+    #endif
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        out float4 oTexCoord : TEXCOORD0,
+        out float4 oTangent : TEXCOORD3,
+    #else
+        out float2 oTexCoord : TEXCOORD0,
+    #endif
+    out float3 oNormal : TEXCOORD1,
+    out float4 oWorldPos : TEXCOORD2,
+    #ifdef PERPIXEL
+        #ifdef SHADOW
+            out float4 oShadowPos[NUMCASCADES] : TEXCOORD4,
+        #endif
+        #ifdef SPOTLIGHT
+            out float4 oSpotPos : TEXCOORD5,
+        #endif
+        #ifdef POINTLIGHT
+            out float3 oCubeMaskVec : TEXCOORD5,
+        #endif
+    #else
+        out float3 oVertexLight : TEXCOORD4,
+        out float4 oScreenPos : TEXCOORD5,
+        #ifdef ENVCUBEMAP
+            out float3 oReflectionVec : TEXCOORD6,
+        #endif
+        #if defined(LIGHTMAP) || defined(AO)
+            out float2 oTexCoord2 : TEXCOORD7,
+        #endif
+    #endif
+    #ifdef VERTEXCOLOR
+        out float4 oColor : COLOR0,
+    #endif
+    #if defined(D3D11) && defined(CLIPPLANE)
+        out float oClip : SV_CLIPDISTANCE0,
+    #endif
+    out float4 oPos : OUTPOSITION)
+{
+    // Define a 0,0 UV coord if not expected from the vertex data
+    #ifdef NOUV
+        const float2 iTexCoord = float2(0.0, 0.0);
+    #endif
+
+    const float4x3 modelMatrix = iModelMatrix;
+    const float3 worldPos = GetWorldPos(modelMatrix);
+    oPos = GetClipPos(worldPos);
+    oNormal = GetWorldNormal(modelMatrix);
+    oWorldPos = float4(worldPos, GetDepth(oPos));
+
+    #if defined(D3D11) && defined(CLIPPLANE)
+        oClip = dot(oPos, cClipPlane);
+    #endif
+
+    #ifdef VERTEXCOLOR
+        oColor = iColor;
+    #endif
+
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        const float3 tangent = GetWorldTangent(modelMatrix);
+        const float3 bitangent = cross(tangent, oNormal) * iTangent.w;
+        oTexCoord = float4(GetTexCoord(iTexCoord), bitangent.xy);
+        oTangent = float4(tangent, bitangent.z);
+    #else
+        oTexCoord = GetTexCoord(iTexCoord);
+    #endif
+
+    #ifdef PERPIXEL
+        // Per-pixel forward lighting
+        const float4 projWorldPos = float4(worldPos.xyz, 1.0);
+
+        #ifdef SHADOW
+            // Shadow projection: transform from world space to shadow space
+            GetShadowPos(projWorldPos, oShadowPos);
+        #endif
+
+        #ifdef SPOTLIGHT
+            // Spotlight projection: transform from world space to projector texture coordinates
+            oSpotPos = mul(projWorldPos, cLightMatrices[0]);
+        #endif
+
+        #ifdef POINTLIGHT
+            oCubeMaskVec = mul(worldPos - cLightPos.xyz, (float3x3)cLightMatrices[0]);
+        #endif
+    #else
+        // Ambient & per-vertex lighting
+        #if defined(LIGHTMAP) || defined(AO)
+            // If using lightmap, disregard zone ambient light
+            // If using AO, calculate ambient in the PS
+            oVertexLight = float3(0.0, 0.0, 0.0);
+            oTexCoord2 = iTexCoord2;
+        #else
+            oVertexLight = GetAmbient(GetZonePos(worldPos));
+        #endif
+
+        #ifdef NUMVERTEXLIGHTS
+            for (int i = 0; i < NUMVERTEXLIGHTS; ++i)
+                oVertexLight += GetVertexLight(i, worldPos, oNormal) * cVertexLights[i * 3].rgb;
+        #endif
+
+        oScreenPos = GetScreenPos(oPos);
+
+        #ifdef ENVCUBEMAP
+            oReflectionVec = worldPos - cCameraPos;
+        #endif
+    #endif
+}
+
+void PS(
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        float4 iTexCoord : TEXCOORD0,
+        float4 iTangent : TEXCOORD3,
+    #else
+        float2 iTexCoord : TEXCOORD0,
+    #endif
+    float3 iNormal : TEXCOORD1,
+    float4 iWorldPos : TEXCOORD2,
+    #ifdef PERPIXEL
+        #ifdef SHADOW
+            float4 iShadowPos[NUMCASCADES] : TEXCOORD4,
+        #endif
+        #ifdef SPOTLIGHT
+            float4 iSpotPos : TEXCOORD5,
+        #endif
+        #ifdef POINTLIGHT
+            float3 iCubeMaskVec : TEXCOORD5,
+        #endif
+    #else
+        float3 iVertexLight : TEXCOORD4,
+        float4 iScreenPos : TEXCOORD5,
+        #ifdef ENVCUBEMAP
+            float3 iReflectionVec : TEXCOORD6,
+        #endif
+        #if defined(LIGHTMAP) || defined(AO)
+            float2 iTexCoord2 : TEXCOORD7,
+        #endif
+    #endif
+    #ifdef VERTEXCOLOR
+        float4 iColor : COLOR0,
+    #endif
+    #if defined(D3D11) && defined(CLIPPLANE)
+        float iClip : SV_CLIPDISTANCE0,
+    #endif
+    #ifdef PREPASS
+        out float4 oDepth : OUTCOLOR1,
+    #endif
+    #ifdef DEFERRED
+        out float4 oAlbedo : OUTCOLOR1,
+        out float4 oNormal : OUTCOLOR2,
+        out float4 oDepth : OUTCOLOR3,
+        #ifndef D3D11
+            float2 iFragPos : VPOS,
+        #else
+            float4 iFragPos : SV_Position,
+        #endif
+    #endif
+    out float4 oColor : OUTCOLOR0)
+{
+    // Get material diffuse albedo
+    #ifdef DIFFMAP
+        const float4 diffInput = Sample2D(DiffMap, iTexCoord.xy);
+        #ifdef ALPHAMASK
+            if (diffInput.a < 0.5)
+                discard;
+        #endif
+        float4 diffColor = cMatDiffColor * diffInput;
+    #else
+        float4 diffColor = cMatDiffColor;
+    #endif
+
+    #ifdef VERTEXCOLOR
+        diffColor *= iColor;
+    #endif
+
+    // Get material specular albedo
+    #ifdef METALLIC // METALNESS
+        const float4 roughMetalSrc = Sample2D(RoughMetalFresnel, iTexCoord.xy);
+
+        const float roughness = clamp(pow(roughMetalSrc.r + cRoughnessPS, 2.0), ROUGHNESS_FLOOR, 1.0);
+        const float metalness = clamp(roughMetalSrc.g + cMetallicPS, METALNESS_FLOOR, 1.0);
+    #else
+        const float roughness = clamp(pow(cRoughnessPS, 2.0), ROUGHNESS_FLOOR, 1.0);
+        const float metalness = clamp(cMetallicPS, METALNESS_FLOOR, 1.0);
+    #endif
+
+    float3 specColor = lerp(0.08 * cMatSpecColor.rgb, diffColor.rgb, metalness);
+    specColor *= cMatSpecColor.rgb;
+    diffColor.rgb = diffColor.rgb - diffColor.rgb * metalness; // Modulate down the diffuse
+
+    // Get normal
+    #if defined(NORMALMAP) || defined(DIRBILLBOARD) || defined(IBL)
+        const float3 tangent = normalize(iTangent.xyz);
+        const float3 bitangent = normalize(float3(iTexCoord.zw, iTangent.w));
+        const float3x3 tbn = float3x3(tangent, bitangent, iNormal);
+    #endif
+
+    #ifdef NORMALMAP
+        const float3 nn = DecodeNormal(Sample2D(NormalMap, iTexCoord.xy));
+        //nn.rg *= 2.0;
+        const float3 normal = normalize(mul(nn, tbn));
+    #else
+        const float3 normal = normalize(iNormal);
+    #endif
+
+    // Get fog factor
+    #ifdef HEIGHTFOG
+        const float fogFactor = GetHeightFogFactor(iWorldPos.w, iWorldPos.y);
+    #else
+        const float fogFactor = GetFogFactor(iWorldPos.w);
+    #endif
+
+    #if defined(PERPIXEL)
+        // Per-pixel forward lighting
+        float3 lightDir;
+        float3 lightColor;
+        float3 finalColor;
+
+        float diff = GetDiffuse(normal, iWorldPos.xyz, lightDir);
+
+        #ifdef SHADOW
+            diff *= GetShadow(iShadowPos, iWorldPos.w);
+        #endif
+
+        #if defined(SPOTLIGHT)
+            lightColor = iSpotPos.w > 0.0 ? Sample2DProj(LightSpotMap, iSpotPos).rgb * cLightColor.rgb : 0.0;
+        #elif defined(CUBEMASK)
+            lightColor = SampleCube(LightCubeMap, iCubeMaskVec).rgb * cLightColor.rgb;
+        #else
+            lightColor = cLightColor.rgb;
+        #endif
+
+        const float3 toCamera = normalize(cCameraPosPS - iWorldPos.xyz);
+
+        const float3 Hn = normalize(toCamera + lightDir);
+        const float vdh = max(M_EPSILON, dot(toCamera, Hn));
+        const float ndh = max(M_EPSILON, dot(normal, Hn));
+        const float ndl = max(M_EPSILON, dot(normal, lightDir));
+        const float ndv = max(M_EPSILON, dot(normal, toCamera));
+
+        const float3 diffuseFactor = BurleyDiffuse(diffColor.rgb, roughness, ndv, ndl, vdh);
+        float3 specularFactor = 0;
+
+        #ifdef SPECULAR
+            const float3 fresnelTerm = Fresnel(specColor, vdh) ;
+            const float distTerm = Distribution(ndh, roughness);
+            const float visTerm = Visibility(ndl, ndv, roughness);
+
+            specularFactor = SpecularBRDF(distTerm, fresnelTerm, visTerm, ndl, ndv);
+        #endif
+
+        finalColor.rgb = (diffuseFactor + specularFactor) * lightColor * diff;
+
+        #ifdef AMBIENT
+            finalColor += cAmbientColor * diffColor.rgb;
+            finalColor += cMatEmissiveColor;
+            oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
+        #else
+            oColor = float4(GetLitFog(finalColor, fogFactor), diffColor.a);
+        #endif
+    #elif defined(DEFERRED)
+        // Fill deferred G-buffer
+        const float3 spareData = 0; // Can be used to pass more data to deferred renderer
+        oColor = float4(spareData, specColor.r);
+        oAlbedo = float4(diffColor.rgb, specColor.g);
+        oNormal = float4(normalize(normal) * roughness, specColor.b);
+        oDepth = iWorldPos.w;
+    #else
+        // Ambient & per-vertex lighting
+        float3 finalColor = iVertexLight * diffColor.rgb;
+        #ifdef AO
+            // If using AO, the vertex light ambient is black, calculate occluded ambient here
+            finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * cAmbientColor * diffColor.rgb;
+        #endif
+
+        #ifdef MATERIAL
+            // Add light pre-pass accumulation result
+            // Lights are accumulated at half intensity. Bring back to full intensity now
+            float4 lightInput = 2.0 * Sample2DProj(LightBuffer, iScreenPos);
+            float3 lightSpecColor = lightInput.a * lightInput.rgb / max(GetIntensity(lightInput.rgb), 0.001);
+
+            finalColor += lightInput.rgb * diffColor.rgb + lightSpecColor * specColor;
+        #endif
+
+        const float3 toCamera = normalize(iWorldPos.xyz - cCameraPosPS);
+
+        const float3 reflection = normalize(reflect(toCamera, normal));
+        float3 cubeColor = iVertexLight.rgb;
+
+        #ifdef IBL
+            const float3 iblColor = ImageBasedLighting(reflection, tangent, bitangent, normal, toCamera, diffColor, specColor, roughness, cubeColor);
+            const float gamma = 0;
+            finalColor += iblColor * (cubeColor + gamma);
+        #endif
+
+        #ifdef ENVCUBEMAP
+            finalColor += cMatEnvMapColor * SampleCube(EnvCubeMap, reflect(iReflectionVec, normal)).rgb;
+        #endif
+        #ifdef LIGHTMAP
+            finalColor += Sample2D(EmissiveMap, iTexCoord2).rgb * diffColor.rgb;
+        #endif
+        #ifdef EMISSIVEMAP
+            finalColor += cMatEmissiveColor * Sample2D(EmissiveMap, iTexCoord.xy).rgb;
+        #else
+            finalColor += cMatEmissiveColor;
+        #endif
+
+        oColor = float4(GetFog(finalColor, fogFactor), diffColor.a);
+    #endif
+}

+ 5 - 0
bin/CoreData/Shaders/HLSL/Samplers.hlsl

@@ -4,6 +4,7 @@
 #define Sample2DProj(tex, uv) t##tex.Sample(s##tex, uv.xy / uv.w)
 #define Sample2DLod0(tex, uv) t##tex.SampleLevel(s##tex, uv, 0.0)
 #define SampleCube(tex, uv) t##tex.Sample(s##tex, uv)
+#define SampleCubeLOD(tex, uv) t##tex.SampleLevel(s##tex, uv.xyz, uv.w)
 #define SampleShadow(tex, uv) t##tex.SampleCmpLevelZero(s##tex, uv.xy, uv.z)
 #endif
 
@@ -18,6 +19,7 @@ sampler2D sAlbedoBuffer : register(s0);
 sampler2D sNormalMap : register(s1);
 sampler2D sNormalBuffer : register(s1);
 sampler2D sSpecMap : register(s2);
+sampler2D sRoughMetalFresnel : register(s2); //R: Roughness, G: Metal
 sampler2D sEmissiveMap : register(s3);
 sampler2D sEnvMap : register(s4);
 sampler3D sVolumeMap : register(s5);
@@ -37,6 +39,7 @@ sampler3D sZoneVolumeMap : register(s15);
 #define Sample2DProj(tex, uv) tex2Dproj(s##tex, uv)
 #define Sample2DLod0(tex, uv) tex2Dlod(s##tex, float4(uv, 0.0, 0.0))
 #define SampleCube(tex, uv) texCUBE(s##tex, uv)
+#define SampleCubeLOD(tex, uv) texCUBElod(s##tex, uv)
 #define SampleShadow(tex, uv) tex2Dproj(s##tex, uv)
 
 #else
@@ -49,6 +52,7 @@ Texture2D tAlbedoBuffer : register(t0);
 Texture2D tNormalMap : register(t1);
 Texture2D tNormalBuffer : register(t1);
 Texture2D tSpecMap : register(t2);
+Texture2D tRoughMetalFresnel : register(t2); //R: Roughness, G: Metal
 Texture2D tEmissiveMap : register(t3);
 Texture2D tEnvMap : register(t4);
 Texture3D tVolumeMap : register(t5);
@@ -70,6 +74,7 @@ SamplerState sAlbedoBuffer : register(s0);
 SamplerState sNormalMap : register(s1);
 SamplerState sNormalBuffer : register(s1);
 SamplerState sSpecMap : register(s2);
+SamplerState sRoughMetalFresnel : register(s2); //R: Roughness, G: Metal 
 SamplerState sEmissiveMap : register(s3);
 SamplerState sEnvMap : register(s4);
 SamplerState sVolumeMap : register(s5);

+ 8 - 0
bin/CoreData/Shaders/HLSL/Uniforms.hlsl

@@ -56,6 +56,10 @@ uniform float4 cMatDiffColor;
 uniform float3 cMatEmissiveColor;
 uniform float3 cMatEnvMapColor;
 uniform float4 cMatSpecColor;
+#ifdef PBR
+    uniform float cRoughnessPS; 
+    uniform float cMetallicPS;
+#endif
 uniform float cNearClipPS;
 uniform float cFarClipPS;
 uniform float4 cShadowCubeAdjust;
@@ -181,6 +185,10 @@ cbuffer MaterialPS : register(b4)
     float3 cMatEmissiveColor;
     float3 cMatEnvMapColor;
     float4 cMatSpecColor;
+    #ifdef PBR
+        float cRoughnessPS; 
+        float cMetallicPS;
+    #endif
 }
 #endif
 

+ 9 - 0
bin/CoreData/Techniques/PBR/DiffNormalSpecEmissive.xml

@@ -0,0 +1,9 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" psdefines="DIFFMAP">
+    <pass name="base" psdefines="EMISSIVEMAP" />
+    <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP SPECMAP" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="prepass" vsdefines="NORMALMAP" psdefines="PREPASS NORMALMAP SPECMAP" />
+    <pass name="material" psdefines="MATERIAL SPECMAP EMISSIVEMAP" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" vsdefines="NORMALMAP" psdefines="DEFERRED NORMALMAP SPECMAP EMISSIVEMAP" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/DiffNormalSpecEmissiveAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" psdefines="DIFFMAP">
+    <pass name="alpha" psdefines="EMISSIVEMAP" depthwrite="false" blend="alpha" />
+    <pass name="litalpha" vsdefines="NORMALMAP" psdefines="NORMALMAP SPECMAP" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 8 - 0
bin/CoreData/Techniques/PBR/PBRDiff.xml

@@ -0,0 +1,8 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="IBL" psdefines="DIFFMAP PBR IBL">
+    <pass name="base" />
+    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" blend="add" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/PBRDiffAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="IBL" psdefines="DIFFMAP PBR IBL">
+    <pass name="alpha" depthwrite="false" blend="alpha" />
+    <pass name="litalpha" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 8 - 0
bin/CoreData/Techniques/PBR/PBRDiffNormal.xml

@@ -0,0 +1,8 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="IBL" psdefines="DIFFMAP PBR IBL">
+    <pass name="base" />
+    <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" blend="add" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/PBRDiffNormalAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="IBL" psdefines="DIFFMAP PBR IBL">
+    <pass name="alpha" depthwrite="false" blend="alpha" />
+    <pass name="litalpha" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 7 - 0
bin/CoreData/Techniques/PBR/PBRDiffNormalEmissive.xml

@@ -0,0 +1,7 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid"  vsdefines="IBL" psdefines="DIFFMAP PBR IBL">
+    <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="material" psdefines="MATERIAL EMISSIVEMAP" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED EMISSIVEMAP" blend="add" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/PBRDiffNormalEmissiveAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid"  vsdefines="IBL" psdefines="DIFFMAP PBR IBL">
+    <pass name="alpha" psdefines="EMISSIVEMAP" depthwrite="false" blend="alpha" />
+    <pass name="litalpha" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 8 - 0
bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffNormalSpec.xml

@@ -0,0 +1,8 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="NORMALMAP IBL" psdefines="NORMALMAP DIFFMAP METALLIC ROUGHNESS PBR IBL">
+    <pass name="base" />
+    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="material" psdefines="MATERIAL NORMALMAP" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" blend="add"/>
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 8 - 0
bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissive.xml

@@ -0,0 +1,8 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="NORMALMAP IBL" psdefines="NORMALMAP DIFFMAP METALLIC ROUGHNESS PBR IBL">
+    <pass name="base" psdefines="EMISSIVEMAP"/>
+    <pass name="light" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="material" psdefines="MATERIAL EMISSIVEMAP NORMALMAP" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED EMISSIVEMAP NORMALMAP" blend="add"/>
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffNormalSpecEmissiveAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" psdefines="DIFFMAP PBR IBL METALLIC ROUGHNESS">
+    <pass name="alpha" psdefines="EMISSIVEMAP" depthwrite="false" blend="alpha" />
+    <pass name="litalpha" vsdefines="NORMALMAP" psdefines="NORMALMAP" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 8 - 0
bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffSpec.xml

@@ -0,0 +1,8 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" psdefines="DIFFMAP PBR IBL METALLIC ROUGHNESS">
+    <pass name="base"/>
+    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" blend="add" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/PBRMetallicRoughDiffSpecAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" psdefines="DIFFMAP PBR IBL METALLIC ROUGHNESS">
+    <pass name="alpha" depthwrite="false" blend="alpha" />
+    <pass name="litalpha" psdefines="METALLIC ROUGHNESS" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 9 - 0
bin/CoreData/Techniques/PBR/PBRNoTexture.xml

@@ -0,0 +1,9 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="NOUV PBR IBL" psdefines="PBR IBL">
+    <pass name="base" />
+    <pass name="light" depthtest="equal" depthwrite="false" blend="add" />
+    <pass name="prepass" psdefines="PREPASS" />
+    <pass name="material" psdefines="MATERIAL" depthtest="equal" depthwrite="false" />
+    <pass name="deferred" psdefines="DEFERRED" />
+    <pass name="depth" vs="Depth" ps="Depth" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 5 - 0
bin/CoreData/Techniques/PBR/PBRNoTextureAlpha.xml

@@ -0,0 +1,5 @@
+<technique vs="PBRLitSolid" ps="PBRLitSolid" vsdefines="NOUV" psdefines="PBR IBL">
+    <pass name="alpha"  depthwrite="false" blend="alpha" />
+    <pass name="litalpha" depthwrite="false" blend="addalpha" />
+    <pass name="shadow" vs="Shadow" ps="Shadow" />
+</technique>

+ 1528 - 0
bin/Data/Scenes/PBRExample.xml

@@ -0,0 +1,1528 @@
+<?xml version="1.0"?>
+<scene id="1">
+	<attribute name="Name" value="" />
+	<attribute name="Time Scale" value="1" />
+	<attribute name="Smoothing Constant" value="50" />
+	<attribute name="Snap Threshold" value="5" />
+	<attribute name="Elapsed Time" value="36.5494" />
+	<attribute name="Next Replicated Node ID" value="155" />
+	<attribute name="Next Replicated Component ID" value="174" />
+	<attribute name="Next Local Node ID" value="16777242" />
+	<attribute name="Next Local Component ID" value="16777505" />
+	<attribute name="Variables" />
+	<attribute name="Variable Names" value="" />
+	<component type="Octree" id="1" />
+	<component type="DebugRenderer" id="2" />
+	<component type="PhysicsWorld" id="64" />
+	<node id="2">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Room" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<node id="3">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-5.33303 2.35842 4.88357" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="3">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="7">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.666969 2.35842 -10.1164" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="6">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="8">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.666969 2.35842 -13.1164" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="7">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="9">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 -13.1164" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="8">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="10">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 -10.1164" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="9">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="15">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.666969 2.35842 -7.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="17">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="30">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 -7.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="32">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="31">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 4.88357" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="33">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="32">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.66697 2.35842 4.88357" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="34">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="22">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.16697 1.83612 3.88357" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="24">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="23">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 3.85842 -15.1164" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="25">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness5.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="24">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-5.33303 3.85842 -6.11643" />
+			<attribute name="Rotation" value="-2.98023e-08 0 1 0" />
+			<attribute name="Scale" value="3.00001 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="26">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="25">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-6.33303 1.35842 4.88357" />
+			<attribute name="Rotation" value="-0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="27">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="26">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 3.85842 -14.1164" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="28">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="27">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 3.85842 -11.1164" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="29">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="28">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.666969 3.85842 -6.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="30">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="29">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.666969 3.85842 -15.1164" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="31">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness5.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="33">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 3.85842 -8.11643" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="35">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="34">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 3.85842 -14.1164" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="36">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="35">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.16697 1.83612 -14.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="37">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="36">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 0.88357" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="38">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="37">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 -14.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="39">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="38">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.16697 1.83612 0.88357" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="40">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="39">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 -14.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="41">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="43">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 -11.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="45">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="44">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 -11.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="46">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="45">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.16697 1.83612 -11.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="47">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="46">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 -8.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="48">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="47">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 5.85842 -8.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="49">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="48">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.66697 1.83612 -8.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="50">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="51">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 3.85842 -11.1164" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="54">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="52">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 1.35842 -8.11643" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="55">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="53">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.514838 2.08884 -0.61643" />
+			<attribute name="Rotation" value="-0.651315 0.275298 0.651315 0.275298" />
+			<attribute name="Scale" value="3 0.3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="56">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="84">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 1.35842 3.88357" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="94">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="85">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.66697 1.35842 5.88357" />
+			<attribute name="Rotation" value="-2.98023e-08 0 1 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="95">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="86">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.35842 5.88357" />
+			<attribute name="Rotation" value="-2.98023e-08 0 1 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="96">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="69">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-5.33303 2.35842 -4.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="79">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="70">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 -4.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="80">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="71">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.66697 2.35842 -4.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="81">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="72">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-5.33303 2.35842 -1.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="82">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="73">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 -1.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="83">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="74">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.66697 2.35842 -1.11643" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="84">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="75">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-5.33303 2.35842 1.88357" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="85">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="76">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.33303 2.35842 1.88357" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="86">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="77">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Plane" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.66697 2.35842 1.88357" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="3 1 3" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="87">
+				<attribute name="Model" value="Model;Models/Plane.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Concrete.xml" />
+			</component>
+		</node>
+		<node id="78">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-6.33303 1.35842 -4.11643" />
+			<attribute name="Rotation" value="0.707107 0 -0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="88">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="79">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 1.35842 -5.11643" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="89">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="80">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-6.33303 1.35842 -1.11643" />
+			<attribute name="Rotation" value="0.707107 0 -0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="90">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="81">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 1.35842 -2.11643" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="91">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="82">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-6.33303 1.35842 1.88357" />
+			<attribute name="Rotation" value="0.707107 0 -0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="92">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="83">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="2.66697 1.35842 0.88357" />
+			<attribute name="Rotation" value="0.707107 0 0.707107 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="93">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="115">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 -8.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="123">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="123">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 0.88357" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="131">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="124">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 3.88357" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="132">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="125">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 3.88357" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="133">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="104">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 5.85842 -6.05065" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 1.18952 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="112">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="105">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.66697 5.85842 -14.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="113">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="106">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 5.85842 -6.05065" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 1.18952 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="114">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="107">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 5.85842 -14.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="115">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="108">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.66697 5.85842 -6.05065" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 1.18952 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="116">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="109">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 5.85842 -14.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="117">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="110">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 5.85842 -11.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="118">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="111">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 5.85842 -11.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="119">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="112">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.66697 5.85842 -11.1164" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="120">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="113">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 5.85842 -8.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="121">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="114">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.66697 5.85842 -8.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="122">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="117">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 -5.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="125">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="118">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 -5.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="126">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="119">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.16697 1.83612 -5.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="127">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="120">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.83612 -2.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="128">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="121">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.33303 1.83612 -2.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="129">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="122">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.16697 1.83612 -2.11643" />
+			<attribute name="Rotation" value="2.68221e-07 -2.68221e-07 0.707107 0.707107" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="130">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="134">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.33303 1.35842 5.88357" />
+			<attribute name="Rotation" value="-2.98023e-08 0 1 0" />
+			<attribute name="Scale" value="3 3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="152">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="135">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Box" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-3.95347 2.08884 -0.61643" />
+			<attribute name="Rotation" value="-0.651315 0.275298 0.651315 0.275298" />
+			<attribute name="Scale" value="3 0.3 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="153">
+				<attribute name="Model" value="Model;Models/Box.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+	</node>
+	<node id="4">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Light" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="4.04012 -4.45908 11.8185" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<node id="103">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sun" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0 0 0" />
+			<attribute name="Rotation" value="1 0 2.77556e-17 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="ScriptInstance" id="134">
+				<attribute name="Delayed Method Calls" value="0" />
+				<attribute name="Script File" value="ScriptFile;Scripts/Utilities/Rotator.as" />
+				<attribute name="Class Name" value="Rotator" />
+				<attribute name="rotationSpeed" value="0 0 10" />
+			</component>
+			<node id="5">
+				<attribute name="Is Enabled" value="true" />
+				<attribute name="Name" value="Directional" />
+				<attribute name="Tags" />
+				<attribute name="Position" value="0 0 0" />
+				<attribute name="Rotation" value="0.707107 0.707107 0 0" />
+				<attribute name="Scale" value="1 1 1" />
+				<attribute name="Variables" />
+				<component type="Light" id="4">
+					<attribute name="Light Type" value="Directional" />
+					<attribute name="Brightness Multiplier" value="2" />
+					<attribute name="Cast Shadows" value="true" />
+					<attribute name="CSM Splits" value="10 20 30 40" />
+				</component>
+			</node>
+		</node>
+		<node id="131">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.84718 8.26835 -24.4161" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="Light" id="145">
+				<attribute name="Range" value="4.34" />
+				<attribute name="Light Shape Texture" value="TextureCube;" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+	</node>
+	<node id="11">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-1.58774 3.71769 -0.0921001" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="11">
+			<attribute name="Bounding Box Min" value="-1000 -1000 -1000" />
+			<attribute name="Bounding Box Max" value="1000 1000 1000" />
+			<attribute name="Ambient Color" value="0 0 0 1" />
+			<attribute name="Zone Texture" value="TextureCube;Textures/Skybox2.xml" />
+		</component>
+	</node>
+	<node id="12">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Sky" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Skybox" id="12">
+			<attribute name="Model" value="Model;Models/Sphere.mdl" />
+			<attribute name="Material" value="Material;Materials/Skybox2.xml" />
+		</component>
+	</node>
+	<node id="58">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="DemoSphere" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<node id="89">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.90273 2.84736 -3.50626" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="98">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness10.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="95">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.90273 2.84736 0.993734" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="104">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness3.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="96">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.90273 2.84736 -0.506262" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="105">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness5.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="97">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.90273 2.84736 -2.00626" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="106">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness7.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="98">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.13148 2.84736 -3.50626" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="107">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Metallic10.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="99">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.13147 2.84736 2.49373" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="108">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Metallic0.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="100">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.13147 2.84736 0.993734" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="109">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Metallic3.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="101">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.13147 2.84736 -0.506262" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="110">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Metallic5.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="102">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="1.13147 2.84736 -2.00626" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="111">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Metallic7.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="139">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.90273 2.84736 2.49373" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="156">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Roughness0.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+		<node id="140">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-2.34362 2.84736 4.61852" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="157">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/EmissivePannel.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+			<node id="16777236">
+				<attribute name="Is Enabled" value="true" />
+				<attribute name="Name" value="" />
+				<attribute name="Tags" />
+				<attribute name="Position" value="0 0 -0.63" />
+				<attribute name="Rotation" value="1 0 0 0" />
+				<attribute name="Scale" value="1 1 1" />
+				<attribute name="Variables" />
+				<component type="Light" id="16777444">
+					<attribute name="Color" value="0.77 0.47 0.08 1" />
+					<attribute name="Brightness Multiplier" value="3.69" />
+					<attribute name="Range" value="1.65" />
+					<attribute name="Light Shape Texture" value="TextureCube;" />
+					<attribute name="Cast Shadows" value="true" />
+				</component>
+			</node>
+		</node>
+		<node id="141">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="Sphere" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-1.07697 2.84736 4.61852" />
+			<attribute name="Rotation" value="1 0 0 0" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="StaticModel" id="158">
+				<attribute name="Model" value="Model;Models/Sphere.mdl" />
+				<attribute name="Material" value="Material;Materials/PBR/Tile.xml" />
+				<attribute name="Cast Shadows" value="true" />
+			</component>
+		</node>
+	</node>
+	<node id="127">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Zone" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-1.58774 3.71769 -11.0921" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="Zone" id="137">
+			<attribute name="Bounding Box Min" value="-2.9 -1.52 -3.88" />
+			<attribute name="Bounding Box Max" value="3.9 1.52 4.87" />
+			<attribute name="Ambient Color" value="0 0 0 1" />
+			<attribute name="Priority" value="1" />
+			<attribute name="Zone Texture" value="TextureCube;Textures/Skybox2.xml" />
+		</component>
+	</node>
+	<node id="136">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="Text" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="0 0 0" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<node id="137">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="-4.18535 2.542 -1.53532" />
+			<attribute name="Rotation" value="0.653282 0.270598 -0.653282 0.270598" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="Text3D" id="154">
+				<attribute name="Font" value="Font;Fonts/BlueHighway.ttf" />
+				<attribute name="Font Size" value="15" />
+				<attribute name="Text" value="Roughness Value    &lt;-1.0  -&gt;0.0" />
+				<attribute name="Width" value="262" />
+			</component>
+		</node>
+		<node id="138">
+			<attribute name="Is Enabled" value="true" />
+			<attribute name="Name" value="" />
+			<attribute name="Tags" />
+			<attribute name="Position" value="0.24637 2.542 0.314509" />
+			<attribute name="Rotation" value="0.653282 0.270598 0.653282 -0.270598" />
+			<attribute name="Scale" value="1 1 1" />
+			<attribute name="Variables" />
+			<component type="Text3D" id="155">
+				<attribute name="Font" value="Font;Fonts/BlueHighway.ttf" />
+				<attribute name="Font Size" value="15" />
+				<attribute name="Text" value="Metallic Value    &lt;-0.0  -&gt;1.0" />
+				<attribute name="Width" value="236" />
+			</component>
+		</node>
+	</node>
+	<node id="144">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="2.66 3.36 5.89" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="163">
+			<attribute name="Model" value="Model;Models/Box.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/ColorGrid.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="145">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="2.69 2.84 -3.5" />
+		<attribute name="Rotation" value="-4.37114e-08 0 1 -0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="164">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Metallic10.xml;Materials/PBR/Metallic10.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="146">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-6.31 2.84 -3.5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="165">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Roughness10.xml;Materials/PBR/Roughness10.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="147">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-6.31 2.84 1" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="166">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Roughness3.xml;Materials/PBR/Roughness3.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="148">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-6.31 2.84 -0.5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="167">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Roughness5.xml;Materials/PBR/Roughness5.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="149">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-6.31 2.84 -2" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="168">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Roughness7.xml;Materials/PBR/Roughness7.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="150">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="-6.31 2.84 2.5" />
+		<attribute name="Rotation" value="1 0 0 0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="169">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Roughness0.xml;Materials/PBR/Roughness0.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="151">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="2.69 2.84 2.5" />
+		<attribute name="Rotation" value="-4.37114e-08 0 1 -0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="170">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Metallic0.xml;Materials/PBR/Metallic0.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="152">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="2.69 2.84 1" />
+		<attribute name="Rotation" value="-4.37114e-08 0 1 -0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="171">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Metallic3.xml;Materials/PBR/Metallic3.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="153">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="2.69 2.84 -0.5" />
+		<attribute name="Rotation" value="-4.37114e-08 0 1 -0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="172">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Metallic5.xml;Materials/PBR/Metallic5.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+	<node id="154">
+		<attribute name="Is Enabled" value="true" />
+		<attribute name="Name" value="" />
+		<attribute name="Tags" />
+		<attribute name="Position" value="2.69 2.84 -2" />
+		<attribute name="Rotation" value="-4.37114e-08 0 1 -0" />
+		<attribute name="Scale" value="1 1 1" />
+		<attribute name="Variables" />
+		<component type="StaticModel" id="173">
+			<attribute name="Model" value="Model;Models/TeaPot.mdl" />
+			<attribute name="Material" value="Material;Materials/PBR/Metallic7.xml;Materials/PBR/Metallic7.xml" />
+			<attribute name="Cast Shadows" value="true" />
+		</component>
+	</node>
+</scene>

+ 128 - 0
bin/Data/Scripts/42_PBRMaterials.as

@@ -0,0 +1,128 @@
+// Scene & UI load example.
+// This sample demonstrates:
+//      - Loading a scene from a file and showing it
+//      - Loading a UI layout from a file and showing it
+//      - Subscribing to the UI layout's events
+
+#include "Scripts/Utilities/Sample.as"
+
+void Start()
+{
+    // Execute the common startup for samples
+    SampleStart();
+
+    // Create the scene content
+    CreateScene();
+
+    // Create the UI content and subscribe to UI events
+    CreateUI();
+
+    // Setup the viewport for displaying the scene
+    SetupViewport();
+
+    // Subscribe to global events for camera movement
+    SubscribeToEvents();
+}
+
+void CreateScene()
+{
+    scene_ = Scene();
+
+    // Load scene content prepared in the editor (XML format). GetFile() returns an open file from the resource system
+    // which scene.LoadXML() will read
+    scene_.LoadXML(cache.GetFile("Scenes/PBRExample.xml"));
+
+    // Create the camera (not included in the scene file)
+    cameraNode = scene_.CreateChild("Camera");
+    cameraNode.CreateComponent("Camera");
+
+    // Set an initial position for the camera scene node above the plane
+    cameraNode.position = Vector3(0.0f, 4.0f, 0.0f);
+}
+
+void CreateUI()
+{
+    // Set up global UI style into the root UI element
+    XMLFile@ style = cache.GetResource("XMLFile", "UI/DefaultStyle.xml");
+    ui.root.defaultStyle = style;
+
+    // Create a Cursor UI element because we want to be able to hide and show it at will. When hidden, the mouse cursor will
+    // control the camera, and when visible, it will interact with the UI
+    Cursor@ cursor = Cursor();
+    cursor.SetStyleAuto();
+    ui.cursor = cursor;
+    // Set starting position of the cursor at the rendering window center
+    cursor.SetPosition(graphics.width / 2, graphics.height / 2);
+}
+
+void SetupViewport()
+{
+    renderer.hdrRendering = true;
+
+    // Set up a viewport to the Renderer subsystem so that the 3D scene can be seen
+    Viewport@ viewport = Viewport(scene_, cameraNode.GetComponent("Camera"));
+    renderer.viewports[0] = viewport;
+
+    RenderPath@ effectRenderPath = viewport.renderPath.Clone();
+    effectRenderPath.Append(cache.GetResource("XMLFile", "PostProcess/BloomHDR.xml"));
+    effectRenderPath.Append(cache.GetResource("XMLFile", "PostProcess/FXAA2.xml"));
+    effectRenderPath.Append(cache.GetResource("XMLFile", "PostProcess/GammaCorrection.xml"));
+
+    viewport.renderPath = effectRenderPath;
+}
+
+void SubscribeToEvents()
+{
+    // Subscribe HandleUpdate() function for camera motion
+    SubscribeToEvent("Update", "HandleUpdate");
+}
+
+void HandleUpdate(StringHash eventType, VariantMap& eventData)
+{
+    // Take the frame time step, which is stored as a float
+    float timeStep = eventData["TimeStep"].GetFloat();
+
+    // Move the camera, scale movement with time step
+    MoveCamera(timeStep);
+}
+
+void MoveCamera(float timeStep)
+{
+    // Right mouse button controls mouse cursor visibility: hide when pressed
+    ui.cursor.visible = !input.mouseButtonDown[MOUSEB_RIGHT];
+
+    // Do not move if the UI has a focused element
+    if (ui.focusElement !is null)
+        return;
+
+    // Movement speed as world units per second
+    const float MOVE_SPEED = 10.0f;
+    // Mouse sensitivity as degrees per pixel
+    const float MOUSE_SENSITIVITY = 0.1f;
+
+    // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
+    // Only move the camera when the cursor is hidden
+    if (!ui.cursor.visible)
+    {
+        IntVector2 mouseMove = input.mouseMove;
+        yaw += MOUSE_SENSITIVITY * mouseMove.x;
+        pitch += MOUSE_SENSITIVITY * mouseMove.y;
+        pitch = Clamp(pitch, -90.0f, 90.0f);
+
+        // Construct new orientation for the camera scene node from yaw and pitch. Roll is fixed to zero
+        cameraNode.rotation = Quaternion(pitch, yaw, 0.0f);
+    }
+
+    // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
+    if (input.keyDown['W'])
+        cameraNode.Translate(Vector3(0.0f, 0.0f, 1.0f) * MOVE_SPEED * timeStep);
+    if (input.keyDown['S'])
+        cameraNode.Translate(Vector3(0.0f, 0.0f, -1.0f) * MOVE_SPEED * timeStep);
+    if (input.keyDown['A'])
+        cameraNode.Translate(Vector3(-1.0f, 0.0f, 0.0f) * MOVE_SPEED * timeStep);
+    if (input.keyDown['D'])
+        cameraNode.Translate(Vector3(1.0f, 0.0f, 0.0f) * MOVE_SPEED * timeStep);
+}
+
+// Create XML patch instructions for screen joystick layout specific to this sample app
+String patchInstructions = "";

+ 3 - 0
bin/PBRDemo.bat

@@ -0,0 +1,3 @@
+@echo off
+if exist "%~dp0Urho3DPlayer.exe" (set "DEBUG=") else (set "DEBUG=_d")
+"%~dp0Urho3DPlayer%DEBUG%" Scripts/42_PBRMaterials.as %*

+ 1 - 0
bin/PBRDemo.sh

@@ -0,0 +1 @@
+$(dirname $0)/Urho3DPlayer 42_PBRMaterials.as $@

+ 3 - 0
bin/PBRDemoDeferred.bat

@@ -0,0 +1,3 @@
+@echo off
+if exist "%~dp0Urho3DPlayer.exe" (set "DEBUG=") else (set "DEBUG=_d")
+"%~dp0Urho3DPlayer%DEBUG%" Scripts/42_PBRMaterials.as -renderpath CoreData/RenderPaths/PBRDeferred.xml %*

+ 3 - 0
bin/PBRDemoDeferredHWDepth.bat

@@ -0,0 +1,3 @@
+@echo off
+if exist "%~dp0Urho3DPlayer.exe" (set "DEBUG=") else (set "DEBUG=_d")
+"%~dp0Urho3DPlayer%DEBUG%" Scripts/42_PBRMaterials.as -renderpath CoreData/RenderPaths/PBRDeferredHWDepth.xml %*