瀏覽代碼

Adding directional light, normal maps and updating the xshot

Signed-off-by: mrieggeramzn <[email protected]>
mrieggeramzn 3 年之前
父節點
當前提交
504153f591

+ 34 - 0
Gem/Code/Source/DecalExampleComponent.cpp

@@ -68,6 +68,8 @@ namespace AtomSampleViewer
         EnableArcBallCameraController();
         ConfigureCameraToLookDownAtObject();
         AddImageBasedLight();
+        AcquireDirectionalLightFeatureProcessor();
+        CreateDirectionalLight();
 
         ScriptRunnerRequestBus::Broadcast(&ScriptRunnerRequests::ResumeScript);
         AZ::TickBus::Handler::BusConnect();
@@ -94,6 +96,7 @@ namespace AtomSampleViewer
         m_imguiSidebar.Deactivate();
         m_defaultIbl.Reset();
         GetMeshFeatureProcessor()->ReleaseMesh(m_meshHandle);
+        m_directionalLightFeatureProcessor->ReleaseLight(m_directionalLightHandle);
     }
 
     void DecalExampleComponent::AddImageBasedLight()
@@ -101,6 +104,24 @@ namespace AtomSampleViewer
         m_defaultIbl.Init(AZ::RPI::RPISystemInterface::Get()->GetDefaultScene().get());
     }
 
+    void DecalExampleComponent::AcquireDirectionalLightFeatureProcessor()
+    {
+        using namespace AZ;
+		
+        RPI::Scene* scene = RPI::RPISystemInterface::Get()->GetDefaultScene().get();
+        m_directionalLightFeatureProcessor = scene->GetFeatureProcessor<Render::DirectionalLightFeatureProcessorInterface>();
+    }
+
+    void DecalExampleComponent::CreateDirectionalLight()
+    {
+        using namespace AZ;
+
+        const auto directionalLightHandle = m_directionalLightFeatureProcessor->AcquireLight();
+        const Render::PhotometricColor<Render::PhotometricUnit::Lux> lightColor(AZ::Color::CreateOne());
+        m_directionalLightFeatureProcessor->SetRgbIntensity(directionalLightHandle, lightColor);
+        m_directionalLightHandle = directionalLightHandle;
+    }
+
     void DecalExampleComponent::EnableArcBallCameraController()
     {
         AZ::Debug::CameraControllerRequestBus::Event(GetCameraEntityId(), &AZ::Debug::CameraControllerRequestBus::Events::Enable,
@@ -121,6 +142,7 @@ namespace AtomSampleViewer
     void DecalExampleComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint timePoint)
     {
         DrawSidebar();
+        UpdateDirectionalLight();
     }
 
     void DecalExampleComponent::DrawSidebar()
@@ -147,6 +169,8 @@ namespace AtomSampleViewer
             }
         }
 
+        ScriptableImGui::SliderAngle("Direction##Directional", &m_directionalLightRotationAngle, 0, 360);
+
         m_imguiSidebar.End();
     }
 
@@ -158,4 +182,14 @@ namespace AtomSampleViewer
         m_decalContainerClone = AZStd::make_unique<DecalContainer>(decalFeatureProcessor, AZ::Vector3(-1,0,0));
     }
 
+    void DecalExampleComponent::UpdateDirectionalLight()
+    {
+        using namespace AZ;
+
+        constexpr float directionalLightDist = 10.0f;
+
+        const auto lightLocation = Vector3(directionalLightDist * sinf(m_directionalLightRotationAngle), directionalLightDist * cosf(m_directionalLightRotationAngle), 10.0f);
+        const auto lightTransform = Transform::CreateLookAt(lightLocation, Vector3::CreateZero());
+        m_directionalLightFeatureProcessor->SetDirection(m_directionalLightHandle, lightTransform.GetBasis(1));
+    }
 }

+ 7 - 0
Gem/Code/Source/DecalExampleComponent.h

@@ -14,6 +14,7 @@
 #include <AzCore/Component/TickBus.h>
 
 #include <AzFramework/Input/Events/InputChannelEventListener.h>
+#include <Atom/Feature/CoreLights/DirectionalLightFeatureProcessorInterface.h>
 #include <Atom/Feature/Decals/DecalFeatureProcessorInterface.h>
 #include <Utils/Utils.h>
 #include <Utils/ImGuiSidebar.h>
@@ -50,6 +51,9 @@ namespace AtomSampleViewer
         void EnableArcBallCameraController();
         void ConfigureCameraToLookDownAtObject();
         void AddImageBasedLight();
+        void AcquireDirectionalLightFeatureProcessor();
+        void CreateDirectionalLight();
+        void UpdateDirectionalLight();
         void DrawSidebar();
         AZ::Render::MeshFeatureProcessorInterface::MeshHandle m_meshHandle;
         Utils::DefaultIBL m_defaultIbl;
@@ -58,6 +62,9 @@ namespace AtomSampleViewer
         AZStd::unique_ptr<DecalContainer> m_decalContainerClone;
         ImGuiSidebar m_imguiSidebar;
         bool m_cloneDecalsEnabled = false;
+        float m_directionalLightRotationAngle = 0.f; // in radians
+        AZ::Render::DirectionalLightFeatureProcessorInterface* m_directionalLightFeatureProcessor = nullptr;
+        AZ::Render::DirectionalLightFeatureProcessorInterface::LightHandle m_directionalLightHandle;
 
         // CommonSampleComponentBase overrides...
         void OnAllAssetsReadyActivate() override;

+ 2 - 2
Materials/Decal/airship_nose_number_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:27cec8b8c32cd704f74d10d8084cb28f9f136cbe9f254d2ba62b563292e9de87
-size 7046
+oid sha256:e7da24b0f51193ff9093acab3e77ff43e11bd5503045368b1d51588a8ac6eb7b
+size 401090

+ 2 - 2
Materials/Decal/airship_symbol_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:43c6374a655d7b8b2d120f68425ba3734a93c76e4857857476ec6433b33f2c79
-size 24504
+oid sha256:dd8465bfbc92365faa5b70ff1c303793d5e289ba0a522310d4bca187e7d8d88b
+size 3209850

+ 2 - 2
Materials/Decal/airship_tail_01_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:918ba5f4bfdec90871e8120309010a38c24b8cc8587e3ca33088a76d76db12d0
-size 14502
+oid sha256:3a75336080398ebed7af7736c2aeca5787a7830c90ee316510ba5e47bc1dcc8a
+size 705164

+ 2 - 2
Materials/Decal/airship_tail_02_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:743ca3df4e99afd14298e88b8b417cc191e9ef2b9157544575084bc620755270
-size 14502
+oid sha256:59b6f804779c74fdb4c3a772206c6fd25861508ffd92a2e4fd146bbe59f89fd8
+size 661776

+ 2 - 2
Materials/Decal/am_mud_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:e66f8fd4aed0c4e098ed941f23bbafd9c57256f2e3a0e9928cca23f88adb05c6
-size 78240
+oid sha256:f9e538ff32a7ca71c46af4333d27f1cebf6dafac3694984d6a09bed503ca3d26
+size 3005816

+ 2 - 2
Materials/Decal/am_road_dust_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:cf1c0c0d63f0e574ef58467bf1b1c959dc6c6e5d93d4076128025f10c0c25e7e
-size 98792
+oid sha256:986f86f787bd93b1f59b59fcc7e182ee2ba4e6edd748e86ac9cb346e11a77b75
+size 13072606

+ 2 - 2
Materials/Decal/brushstoke_01_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:38c486a0941c13f7b1c466e8253baa98b1682797507d2f9ad38f9f0c7bd6c043
-size 23940
+oid sha256:0ecabd28609687f23e624317292fc2e369183d59b8fea37a6cb0279edd38989a
+size 63464

+ 39 - 0
Materials/Decal/normalmapdebug.material

@@ -0,0 +1,39 @@
+{
+    "description": "",
+    "materialType": "Materials\\Types\\StandardPBR.materialtype",
+    "parentMaterial": "",
+    "propertyLayoutVersion": 3,
+    "properties": {
+        "baseColor": {
+            "textureMap": "Materials/Decal/normalmapdebug.tif"
+        },
+        "general": {
+            "applySpecularAA": false
+        },
+        "metallic": {
+            "useTexture": false
+        },
+        "normal": {
+            "textureMap": "Materials/Decal/normalmapdebug_nrm.tif"
+        },  
+        "opacity": {
+            "alphaSource": "Split",
+            "doubleSided": true,
+            "factor": 0.6899999976158142,
+            "mode": "Cutout",
+            "textureMap": "Materials/Decal/normalmapdebug.tif"
+        },
+        "roughness": {
+            "useTexture": false
+        },
+        "specularF0": {
+            "useTexture": false
+        },
+        "uv": {
+            "center": [
+                0.0,
+                1.0
+            ]
+        }
+    }
+}

+ 3 - 0
Materials/Decal/normalmapdebug.tif

@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:536db4d93df53dfb16ae7a010598054b805d5c42eca444e9e91efba9d66907fc
+size 25988

+ 2 - 2
Materials/Decal/scorch_01_decal_nrm.tif

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:ecee5e5c5cad9bc15d32010aa38d8a8a65c924b18a586284e04269aea1713b94
-size 98552
+oid sha256:699f8d47ff86b2b3f9d48ed05ac6d7942fb7fbe56a4c445a0e74f98479a4fbb1
+size 2734930

+ 2 - 2
Scripts/ExpectedScreenshots/Decals/screenshot_decals.png

@@ -1,3 +1,3 @@
 version https://git-lfs.github.com/spec/v1
-oid sha256:1a44e936b61fd9181b72d2e4e4decf73a68cd6e0f9b88646f4ad5de5ce819d94
-size 379981
+oid sha256:7a76d014f020507e884f5a28dbd5646691f73fd9846e2c705e9242f9920c2d97
+size 433806