Skip to content

Commit

Permalink
Merge pull request #423 from aws-lumberyard-dev/Atom/santorac/FixingP…
Browse files Browse the repository at this point in the history
…arallaxIssues

Added New "ParallaxDepthArtifacts" Screenshot Tests
  • Loading branch information
santorac authored Apr 26, 2022
2 parents c1ce96f + 1c8e8da commit 4b8bb33
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 16 deletions.
3 changes: 3 additions & 0 deletions Gem/Code/Source/CommonSampleComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ namespace AtomSampleViewer
{
AZ::Render::SkyBoxFeatureProcessorInterface* skyboxFeatureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntityContextId<AZ::Render::SkyBoxFeatureProcessorInterface>(m_entityContextId);
AZ::Render::DirectionalLightFeatureProcessorInterface* directionalLightFeatureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntityContextId<AZ::Render::DirectionalLightFeatureProcessorInterface>(m_entityContextId);
AZ::Render::ImageBasedLightFeatureProcessorInterface* iblFeatureProcessor = AZ::RPI::Scene::GetFeatureProcessorForEntityContextId<AZ::Render::ImageBasedLightFeatureProcessorInterface>(m_entityContextId);

for (AZ::Render::DirectionalLightFeatureProcessorInterface::LightHandle& handle : m_lightHandles)
{
Expand All @@ -137,6 +138,8 @@ namespace AtomSampleViewer

skyboxFeatureProcessor->Enable(false);

iblFeatureProcessor->Reset();

AZ::TransformNotificationBus::MultiHandler::BusDisconnect();
AZ::EntityBus::MultiHandler::BusDisconnect();
}
Expand Down
41 changes: 26 additions & 15 deletions Gem/Code/Source/ParallaxMappingExampleComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,34 @@ namespace AtomSampleViewer
auto transform = AZ::Transform::CreateLookAt(
location,
AZ::Vector3::CreateZero());

using Lux = AZ::Render::PhotometricColor<AZ::Render::PhotometricUnit::Lux>;
using Candela = AZ::Render::PhotometricColor<AZ::Render::PhotometricUnit::Candela>;

if (m_lightType)
{
AZ::Render::PhotometricColor<AZ::Render::PhotometricUnit::Lux> directionalLightColor(AZ::Color::CreateZero());
AZ::Render::PhotometricColor<AZ::Render::PhotometricUnit::Candela> diskLightColor(AZ::Color::CreateOne() * 500.f);
m_directionalLightFeatureProcessor->SetRgbIntensity(m_directionalLightHandle, directionalLightColor);
m_diskLightFeatureProcessor->SetRgbIntensity(m_diskLightHandle, diskLightColor);
}
else
Lux directionalLightColor{AZ::Color::CreateZero()};
Candela diskLightColor{AZ::Color::CreateZero()};

switch (static_cast<LightSelection>(m_lightType))
{
AZ::Render::PhotometricColor<AZ::Render::PhotometricUnit::Lux> directionalLightColor(AZ::Color::CreateOne() * 5.f);
AZ::Render::PhotometricColor<AZ::Render::PhotometricUnit::Candela> diskLightColor(AZ::Color::CreateZero());
m_directionalLightFeatureProcessor->SetRgbIntensity(m_directionalLightHandle, directionalLightColor);
m_diskLightFeatureProcessor->SetRgbIntensity(m_diskLightHandle, diskLightColor);
case LightSelection::Directional:
directionalLightColor = Lux{AZ::Color::CreateOne() * 5.f};
break;
case LightSelection::Spot:
diskLightColor = Candela{AZ::Color::CreateOne() * 500.f};
break;
case LightSelection::None:
// Keep initial 0 values
break;
default:
AZ_Assert(false, "Unhandled case");
break;
}


m_diskLightFeatureProcessor->SetRgbIntensity(m_diskLightHandle, diskLightColor);
m_diskLightFeatureProcessor->SetPosition(m_diskLightHandle, location);
m_diskLightFeatureProcessor->SetDirection(m_diskLightHandle, transform.GetBasis(1));

m_directionalLightFeatureProcessor->SetRgbIntensity(m_directionalLightHandle, directionalLightColor);
m_directionalLightFeatureProcessor->SetDirection(m_directionalLightHandle, transform.GetBasis(1));

// Camera Configuration
Expand Down Expand Up @@ -305,8 +315,9 @@ namespace AtomSampleViewer
ImGui::Text("Lighting");
ImGui::Indent();
{
ScriptableImGui::RadioButton("Directional Light", &m_lightType, 0);
ScriptableImGui::RadioButton("Spot Light", &m_lightType, 1);
ScriptableImGui::RadioButton("No Light", &m_lightType, 0);
ScriptableImGui::RadioButton("Directional Light", &m_lightType, 1);
ScriptableImGui::RadioButton("Spot Light", &m_lightType, 2);
ScriptableImGui::Checkbox("Auto Rotation", &m_lightAutoRotate);
ScriptableImGui::SliderAngle("Direction", &m_lightRotationAngle, 0, 360);
}
Expand Down
9 changes: 8 additions & 1 deletion Gem/Code/Source/ParallaxMappingExampleComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ namespace AtomSampleViewer

float m_lightRotationAngle = 0.f; // in radian
bool m_lightAutoRotate = true;
int m_lightType = 0; // 0: diectionalLight, 1: diskLight

enum class LightSelection : int
{
None,
Directional,
Spot
};
int m_lightType = static_cast<int>(LightSelection::Directional);

//Assets
AZ::Data::Asset<AZ::RPI::ModelAsset> m_planeAsset;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions Scripts/ParallaxDepthArtifacts.bv.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
----------------------------------------------------------------------------------------------------
--
-- Copyright (c) Contributors to the Open 3D Engine Project.
-- For complete copyright and license terms please see the LICENSE at the root of this distribution.
--
-- SPDX-License-Identifier: Apache-2.0 OR MIT
--
--
--
----------------------------------------------------------------------------------------------------

g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/ParallaxDepthArtifacts/')
Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))

OpenSample('Features/Parallax')
ResizeViewport(512, 512)

-- There have been several bugs related to inconsistent depth calculations causing unwanted clipping of pixels on parallax surfaces.
-- We attempt to detect this by putting the camera at several angles that have been observed to reveal these artifacts in the past.
-- All lights are turned off to avoid the sensitive platform differences we are used to seeing on parallax materials, which allows us to use a much
-- tighter tolerance level than other parallax test cases, so that even small amounts of artifacts will be detected and fail the test. These
-- artifacts were showing up as gray firefly pixels on the otherwise black parallax surface.
-- Many camera angles are used because the noise seems to be platform- and/or driver-dependent, so having more angles increases the chances of detecting failures.

SelectImageComparisonToleranceLevel("Level B")

SetImguiValue('Lighting/Auto Rotation', false)
SetImguiValue('Lighting/Direction', DegToRad(110))
SetImguiValue('Parallax Setting/Heightmap Scale', 0.1)
SetImguiValue('Parallax Setting/Enable Pdo', true)
SetImguiValue('Lighting/No Light', true)

ArcBallCameraController_SetDistance(3.000000)

ArcBallCameraController_SetHeading(DegToRad(-38.356312))
ArcBallCameraController_SetPitch(DegToRad(-2.705635))
IdleFrames(1)
CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_1.png')

ArcBallCameraController_SetHeading(DegToRad(-66.861877))
ArcBallCameraController_SetPitch(DegToRad(-4.933800))
IdleFrames(1)
CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_2.png')

ArcBallCameraController_SetHeading(DegToRad(30.230936))
ArcBallCameraController_SetPitch(DegToRad(-3.819724))
IdleFrames(1)
CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_3.png')

ArcBallCameraController_SetHeading(DegToRad(-140.709763))
ArcBallCameraController_SetPitch(DegToRad(-3.501410))
IdleFrames(1)
CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_4.png')

ArcBallCameraController_SetHeading(DegToRad(135.264740))
ArcBallCameraController_SetPitch(DegToRad(-2.387333))
IdleFrames(1)
CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_5.png')

ArcBallCameraController_SetHeading(DegToRad(20.355005))
ArcBallCameraController_SetPitch(DegToRad(-4.456343))
IdleFrames(1)
CaptureScreenshot(g_screenshotOutputFolder .. '/screenshot_6.png')

OpenSample(nil)
1 change: 1 addition & 0 deletions Scripts/_FullTestSuite_.bv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ tests= {
RunScriptWrapper('scripts/transparenttest.bv.luac'),
RunScriptWrapper('scripts/streamingimagetest.bv.luac'),
RunScriptWrapper('scripts/parallaxtest.bv.luac'),
RunScriptWrapper('scripts/parallaxdepthartifacts.bv.luac'),
RunScriptWrapper('scripts/checkerboardtest.bv.luac'),
RunScriptWrapper('scripts/scenereloadsoaktest.bv.luac'),
RunScriptWrapper('scripts/diffusegitest.bv.luac'),
Expand Down

0 comments on commit 4b8bb33

Please sign in to comment.