diff --git a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt index d987833862..260d5ea1b1 100644 --- a/AutomatedTesting/Gem/PythonTests/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonTests/CMakeLists.txt @@ -19,37 +19,50 @@ add_subdirectory(assetpipeline) add_subdirectory(atom_renderer) ## Physics ## -# DISABLED - see LYN-2536 -#if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) -# ly_add_pytest( -# NAME AutomatedTesting::PhysicsTests -# TEST_SUITE main -# TEST_SERIAL -# PATH ${CMAKE_CURRENT_LIST_DIR}/physics/TestSuite_Active.py -# TIMEOUT 3600 -# RUNTIME_DEPENDENCIES -# Legacy::Editor -# Legacy::CryRenderNULL -# AZ::AssetProcessor -# AutomatedTesting.Assets -# COMPONENT -# Physics -# ) -# ly_add_pytest( -# NAME AutomatedTesting::PhysicsTests_Sandbox -# TEST_SUITE sandbox -# TEST_SERIAL -# PATH ${CMAKE_CURRENT_LIST_DIR}/physics/TestSuite_Sandbox.py -# TIMEOUT 3600 -# RUNTIME_DEPENDENCIES -# Legacy::Editor -# Legacy::CryRenderNULL -# AZ::AssetProcessor -# AutomatedTesting.Assets -# COMPONENT -# Physics -# ) -#endif() +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) + ly_add_pytest( + NAME AutomatedTesting::PhysicsTests_Main + TEST_SUITE main + TEST_SERIAL + PATH ${CMAKE_CURRENT_LIST_DIR}/physics/TestSuite_Main.py + TIMEOUT 3600 + RUNTIME_DEPENDENCIES + Legacy::Editor + Legacy::CryRenderNULL + AZ::AssetProcessor + AutomatedTesting.Assets + COMPONENT + Physics + ) + ly_add_pytest( + NAME AutomatedTesting::PhysicsTests_Periodic + TEST_SUITE periodic + TEST_SERIAL + PATH ${CMAKE_CURRENT_LIST_DIR}/physics/TestSuite_Periodic.py + TIMEOUT 3600 + RUNTIME_DEPENDENCIES + Legacy::Editor + Legacy::CryRenderNULL + AZ::AssetProcessor + AutomatedTesting.Assets + COMPONENT + Physics + ) + ly_add_pytest( + NAME AutomatedTesting::PhysicsTests_Sandbox + TEST_SUITE sandbox + TEST_SERIAL + PATH ${CMAKE_CURRENT_LIST_DIR}/physics/TestSuite_Sandbox.py + TIMEOUT 3600 + RUNTIME_DEPENDENCIES + Legacy::Editor + Legacy::CryRenderNULL + AZ::AssetProcessor + AutomatedTesting.Assets + COMPONENT + Physics + ) +endif() ## ScriptCanvas ## if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) @@ -82,23 +95,22 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) endif() ## White Box ## -# DISABLED - See LYN-2663 -#if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) -# ly_add_pytest( -# NAME AutomatedTesting::WhiteBoxTests -# TEST_SUITE main -# TEST_SERIAL -# PATH ${CMAKE_CURRENT_LIST_DIR}/WhiteBox/TestSuite_Active.py -# TIMEOUT 3600 -# RUNTIME_DEPENDENCIES -# Legacy::Editor -# Legacy::CryRenderNULL -# AZ::AssetProcessor -# AutomatedTesting.Assets -# COMPONENT -# WhiteBox -# ) -#endif() +if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) + ly_add_pytest( + NAME AutomatedTesting::WhiteBoxTests + TEST_SUITE main + TEST_SERIAL + PATH ${CMAKE_CURRENT_LIST_DIR}/WhiteBox/TestSuite_Active.py + TIMEOUT 3600 + RUNTIME_DEPENDENCIES + Legacy::Editor + Legacy::CryRenderNULL + AZ::AssetProcessor + AutomatedTesting.Assets + COMPONENT + WhiteBox + ) +endif() ## NvCloth ## # [TODO LYN-1928] Enable when AutomatedTesting runs with Atom @@ -178,8 +190,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ## DynVeg ## ly_add_pytest( - NAME DynamicVegetationTests_Main_GPU - TEST_REQUIRES gpu + NAME AutomatedTesting::DynamicVegetationTests_Main TEST_SERIAL TEST_SUITE main PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg @@ -195,8 +206,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ) ly_add_pytest( - NAME DynamicVegetationTests_Sandbox_GPU - TEST_REQUIRES gpu + NAME AutomatedTesting::DynamicVegetationTests_Sandbox TEST_SERIAL TEST_SUITE sandbox PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg @@ -212,8 +222,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ) ly_add_pytest( - NAME DynamicVegetationTests_Periodic_GPU - TEST_REQUIRES gpu + NAME AutomatedTesting::DynamicVegetationTests_Periodic TEST_SERIAL TEST_SUITE periodic PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/dyn_veg @@ -229,8 +238,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ## LandscapeCanvas ## ly_add_pytest( - NAME LandscapeCanvasTests_Main - TEST_REQUIRES gpu + NAME AutomatedTesting::LandscapeCanvasTests_Main TEST_SERIAL TEST_SUITE main PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/landscape_canvas @@ -245,8 +253,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ) ly_add_pytest( - NAME LandscapeCanvasTests_Periodic - TEST_REQUIRES gpu + NAME AutomatedTesting::LandscapeCanvasTests_Periodic TEST_SERIAL TEST_SUITE periodic PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/landscape_canvas @@ -262,8 +269,7 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_ ## GradientSignal ## ly_add_pytest( - NAME GradientSignalTests_Periodic - TEST_REQUIRES gpu + NAME AutomatedTesting::GradientSignalTests_Periodic TEST_SERIAL TEST_SUITE periodic PATH ${CMAKE_CURRENT_LIST_DIR}/largeworlds/gradient_signal @@ -281,7 +287,7 @@ endif() ## Editor ## if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_FOUNDATION_TEST_SUPPORTED) ly_add_pytest( - NAME EditorTests_Periodic + NAME AutomatedTesting::EditorTests_Periodic TEST_SUITE periodic TEST_SERIAL PATH ${CMAKE_CURRENT_LIST_DIR}/editor @@ -299,7 +305,7 @@ endif() if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) # Unstable, SPEC-3838 will restore #ly_add_pytest( - # NAME asset_load_benchmark_test + # NAME AutomatedTesting::asset_load_benchmark_test # TEST_SERIAL # TEST_SUITE benchmark # PATH ${CMAKE_CURRENT_LIST_DIR}/streaming/benchmark/asset_load_benchmark_test.py diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py index ba5bb8ffa4..9f498bbf50 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py @@ -32,7 +32,7 @@ def teardown_editor(editor): def launch_and_validate_results(request, test_directory, editor, editor_script, expected_lines, unexpected_lines=[], - halt_on_unexpected=False, run_python="--runpythontest", auto_test_mode=True, null_renderer=False, cfg_args=[], + halt_on_unexpected=False, run_python="--runpythontest", auto_test_mode=True, null_renderer=True, cfg_args=[], timeout=300): """ Runs the Editor with the specified script, and monitors for expected log lines. @@ -58,7 +58,7 @@ def launch_and_validate_results(request, test_directory, editor, editor_script, if auto_test_mode: editor.args.extend(["--autotest_mode"]) if null_renderer: - editor.args.extend(["-rhi=null"]) + editor.args.extend(["-rhi=Null"]) with editor.start(): diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py index 6ca0ec16a7..a9f6d0aa02 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py @@ -278,6 +278,12 @@ class Tracer: self.function = args[3] self.message = args[4] + def __str__(self): + return f"Warning: [{self.filename}:{self.function}:{self.line}]: [{self.window}] {self.message}" + + def __repr__(self): + return f"[Warning: {self.message}]" + class ErrorInfo: def __init__(self, args): self.window = args[0] @@ -285,6 +291,12 @@ class Tracer: self.line = args[2] self.function = args[3] self.message = args[4] + + def __str__(self): + return f"Error: [{self.filename}:{self.function}:{self.line}]: [{self.window}] {self.message}" + + def __repr__(self): + return f"[Error: {self.message}]" class AssertInfo: def __init__(self, args): @@ -292,6 +304,12 @@ class Tracer: self.line = args[1] self.function = args[2] self.message = args[3] + + def __str__(self): + return f"Assert: [{self.filename}:{self.function}:{self.line}]: {self.message}" + + def __repr__(self): + return f"[Assert: {self.message}]" def _on_warning(self, args): warningInfo = Tracer.WarningInfo(args) diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py index 252126674c..dabc04575f 100755 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798177_WhiteBox_AddComponentToEntity.py @@ -22,10 +22,10 @@ class Tests(): # fmt:on -def run(): +def C28798177_WhiteBox_AddComponentToEntity(): import os import sys - import WhiteBoxInit as init + from Gems.WhiteBox.Editor.Scripts import WhiteBoxInit as init import ImportPathHelper as imports imports.init() @@ -58,4 +58,8 @@ def run(): if __name__ == "__main__": - run() + import ImportPathHelper as imports + imports.init() + + from editor_python_test_tools.utils import Report + Report.start_test(C28798177_WhiteBox_AddComponentToEntity) diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py index b7c6719721..18a5c3164e 100755 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/C28798205_WhiteBox_SetInvisible.py @@ -22,13 +22,13 @@ class Tests(): # fmt:on -def run(): +def C28798205_WhiteBox_SetInvisible(): # note: This automated test does not fully replicate the test case in Test Rail as it's # not currently possible using the Hydra API to get an EntityComponentIdPair at runtime, # in future game_mode will be activated and a runtime White Box Component queried import os import sys - import WhiteBoxInit as init + from Gems.WhiteBox.Editor.Scripts import WhiteBoxInit as init import ImportPathHelper as imports import editor_python_test_tools.hydra_editor_utils as hydra imports.init() @@ -68,4 +68,8 @@ def run(): if __name__ == "__main__": - run() + import ImportPathHelper as imports + imports.init() + + from editor_python_test_tools.utils import Report + Report.start_test(C28798205_WhiteBox_SetInvisible) diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py index 0b0a081186..e892285dde 100755 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/C29279329_WhiteBox_SetDefaultShape.py @@ -26,10 +26,10 @@ class Tests(): critical_shape_check = ("Default shape has more than 0 sides", "default shape has 0 sides") -def run(): +def C29279329_WhiteBox_SetDefaultShape(): import os import sys - import WhiteBoxInit as init + from Gems.WhiteBox.Editor.Scripts import WhiteBoxInit as init import ImportPathHelper as imports imports.init() @@ -107,4 +107,8 @@ def run(): if __name__ == "__main__": - run() + import ImportPathHelper as imports + imports.init() + + from editor_python_test_tools.utils import Report + Report.start_test(C29279329_WhiteBox_SetDefaultShape) diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt index 34b504b2d3..7ffc2072f1 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/CMakeLists.txt @@ -16,7 +16,7 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedTesting IN_LIST LY_PROJECTS) ly_add_pytest( - NAME AtomRenderer::HydraTestsMain + NAME AutomatedTesting::AtomRenderer_HydraTests_Main TEST_SUITE main PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_MainSuite.py TEST_SERIAL @@ -26,4 +26,15 @@ if(PAL_TRAIT_BUILD_HOST_TOOLS AND PAL_TRAIT_BUILD_TESTS_SUPPORTED AND AutomatedT AutomatedTesting.Assets Editor ) + ly_add_pytest( + NAME AutomatedTesting::AtomRenderer_HydraTests_Sandbox + TEST_SUITE sandbox + PATH ${CMAKE_CURRENT_LIST_DIR}/test_Atom_SandboxSuite.py + TEST_SERIAL + TIMEOUT 300 + RUNTIME_DEPENDENCIES + AssetProcessor + AutomatedTesting.Assets + Editor + ) endif() diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py index a82d5c5fd4..8031d7e65d 100644 --- a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_MainSuite.py @@ -39,181 +39,6 @@ class TestAtomEditorComponents(object): request.addfinalizer(teardown) - @pytest.mark.test_case_id( - "C32078130", # Tone Mapper - "C32078129", # Light - "C32078131", # Radius Weight Modifier - "C32078127", # PostFX Layer - "C32078126", # Point Light - "C32078125", # Physical Sky - "C32078115", # Global Skylight (IBL) - "C32078121", # Exposure Control - "C32078120", # Directional Light - "C32078119", # DepthOfField - "C32078118") # Decal - def test_AtomEditorComponents_AddedToEntity(self, request, editor, level, workspace, project, launcher_platform): - cfg_args = [level] - - expected_lines = [ - # Area Light Component - "Area Light Entity successfully created", - "Area Light_test: Component added to the entity: True", - "Area Light_test: Component removed after UNDO: True", - "Area Light_test: Component added after REDO: True", - "Area Light_test: Entered game mode: True", - "Area Light_test: Entity enabled after adding required components: True", - "Area Light_test: Entity is hidden: True", - "Area Light_test: Entity is shown: True", - "Area Light_test: Entity deleted: True", - "Area Light_test: UNDO entity deletion works: True", - "Area Light_test: REDO entity deletion works: True", - # Decal Component - "Decal Entity successfully created", - "Decal_test: Component added to the entity: True", - "Decal_test: Component removed after UNDO: True", - "Decal_test: Component added after REDO: True", - "Decal_test: Entered game mode: True", - "Decal_test: Exit game mode: True", - "Decal Settings|Decal Settings|Material: SUCCESS", - "Decal_test: Entity is hidden: True", - "Decal_test: Entity is shown: True", - "Decal_test: Entity deleted: True", - "Decal_test: UNDO entity deletion works: True", - "Decal_test: REDO entity deletion works: True", - # DepthOfField Component - "DepthOfField Entity successfully created", - "DepthOfField_test: Component added to the entity: True", - "DepthOfField_test: Component removed after UNDO: True", - "DepthOfField_test: Component added after REDO: True", - "DepthOfField_test: Entered game mode: True", - "DepthOfField_test: Exit game mode: True", - "DepthOfField_test: Entity disabled initially: True", - "DepthOfField_test: Entity enabled after adding required components: True", - "DepthOfField Controller|Configuration|Camera Entity: SUCCESS", - "DepthOfField_test: Entity is hidden: True", - "DepthOfField_test: Entity is shown: True", - "DepthOfField_test: Entity deleted: True", - "DepthOfField_test: UNDO entity deletion works: True", - "DepthOfField_test: REDO entity deletion works: True", - # Directional Light Component - "Directional Light Entity successfully created", - "Directional Light_test: Component added to the entity: True", - "Directional Light_test: Component removed after UNDO: True", - "Directional Light_test: Component added after REDO: True", - "Directional Light_test: Entered game mode: True", - "Directional Light_test: Exit game mode: True", - "Directional Light Controller|Configuration|Shadow|Camera: SUCCESS", - "Directional Light_test: Entity is hidden: True", - "Directional Light_test: Entity is shown: True", - "Directional Light_test: Entity deleted: True", - "Directional Light_test: UNDO entity deletion works: True", - "Directional Light_test: REDO entity deletion works: True", - # Exposure Control Component - "Exposure Control Entity successfully created", - "Exposure Control_test: Component added to the entity: True", - "Exposure Control_test: Component removed after UNDO: True", - "Exposure Control_test: Component added after REDO: True", - "Exposure Control_test: Entered game mode: True", - "Exposure Control_test: Exit game mode: True", - "Exposure Control_test: Entity disabled initially: True", - "Exposure Control_test: Entity enabled after adding required components: True", - "Exposure Control_test: Entity is hidden: True", - "Exposure Control_test: Entity is shown: True", - "Exposure Control_test: Entity deleted: True", - "Exposure Control_test: UNDO entity deletion works: True", - "Exposure Control_test: REDO entity deletion works: True", - # Global Skylight (IBL) Component - "Global Skylight (IBL) Entity successfully created", - "Global Skylight (IBL)_test: Component added to the entity: True", - "Global Skylight (IBL)_test: Component removed after UNDO: True", - "Global Skylight (IBL)_test: Component added after REDO: True", - "Global Skylight (IBL)_test: Entered game mode: True", - "Global Skylight (IBL)_test: Exit game mode: True", - "Global Skylight (IBL) Controller|Configuration|Diffuse Image: SUCCESS", - "Global Skylight (IBL) Controller|Configuration|Specular Image: SUCCESS", - "Global Skylight (IBL)_test: Entity is hidden: True", - "Global Skylight (IBL)_test: Entity is shown: True", - "Global Skylight (IBL)_test: Entity deleted: True", - "Global Skylight (IBL)_test: UNDO entity deletion works: True", - "Global Skylight (IBL)_test: REDO entity deletion works: True", - # Physical Sky Component - "Physical Sky Entity successfully created", - "Physical Sky component was added to entity", - "Entity has a Physical Sky component", - "Physical Sky_test: Component added to the entity: True", - "Physical Sky_test: Component removed after UNDO: True", - "Physical Sky_test: Component added after REDO: True", - "Physical Sky_test: Entered game mode: True", - "Physical Sky_test: Exit game mode: True", - "Physical Sky_test: Entity is hidden: True", - "Physical Sky_test: Entity is shown: True", - "Physical Sky_test: Entity deleted: True", - "Physical Sky_test: UNDO entity deletion works: True", - "Physical Sky_test: REDO entity deletion works: True", - # Point Light Component - "Point Light Entity successfully created", - "Point Light_test: Component added to the entity: True", - "Point Light_test: Component removed after UNDO: True", - "Point Light_test: Component added after REDO: True", - "Point Light_test: Entered game mode: True", - "Point Light_test: Exit game mode: True", - "Point Light_test: Entity is hidden: True", - "Point Light_test: Entity is shown: True", - "Point Light_test: Entity deleted: True", - "Point Light_test: UNDO entity deletion works: True", - "Point Light_test: REDO entity deletion works: True", - # PostFX Layer Component - "PostFX Layer Entity successfully created", - "PostFX Layer_test: Component added to the entity: True", - "PostFX Layer_test: Component removed after UNDO: True", - "PostFX Layer_test: Component added after REDO: True", - "PostFX Layer_test: Entered game mode: True", - "PostFX Layer_test: Exit game mode: True", - "PostFX Layer_test: Entity is hidden: True", - "PostFX Layer_test: Entity is shown: True", - "PostFX Layer_test: Entity deleted: True", - "PostFX Layer_test: UNDO entity deletion works: True", - "PostFX Layer_test: REDO entity deletion works: True", - # Radius Weight Modifier Component - "Radius Weight Modifier Entity successfully created", - "Radius Weight Modifier_test: Component added to the entity: True", - "Radius Weight Modifier_test: Component removed after UNDO: True", - "Radius Weight Modifier_test: Component added after REDO: True", - "Radius Weight Modifier_test: Entered game mode: True", - "Radius Weight Modifier_test: Exit game mode: True", - "Radius Weight Modifier_test: Entity is hidden: True", - "Radius Weight Modifier_test: Entity is shown: True", - "Radius Weight Modifier_test: Entity deleted: True", - "Radius Weight Modifier_test: UNDO entity deletion works: True", - "Radius Weight Modifier_test: REDO entity deletion works: True", - # Light Component - "Light Entity successfully created", - "Light_test: Component added to the entity: True", - "Light_test: Component removed after UNDO: True", - "Light_test: Component added after REDO: True", - "Light_test: Entered game mode: True", - "Light_test: Exit game mode: True", - "Light_test: Entity is hidden: True", - "Light_test: Entity is shown: True", - "Light_test: Entity deleted: True", - "Light_test: UNDO entity deletion works: True", - "Light_test: REDO entity deletion works: True", - ] - - unexpected_lines = [ - "failed to open", - "Traceback (most recent call last):", - ] - - hydra.launch_and_validate_results( - request, - TEST_DIRECTORY, - editor, - "hydra_AtomEditorComponents_AddedToEntity.py", - timeout=EDITOR_TIMEOUT, - expected_lines=expected_lines, - unexpected_lines=unexpected_lines, - halt_on_unexpected=True, - null_renderer=True, - cfg_args=cfg_args, - ) + # It requires at least one test + def test_Dummy(self, request, editor, level, workspace, project, launcher_platform): + pass diff --git a/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_SandboxSuite.py b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_SandboxSuite.py new file mode 100644 index 0000000000..a82d5c5fd4 --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/atom_renderer/test_Atom_SandboxSuite.py @@ -0,0 +1,219 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +""" + +import logging +import os +import pytest + +import ly_test_tools.environment.file_system as file_system + +import editor_python_test_tools.hydra_test_utils as hydra + +logger = logging.getLogger(__name__) +EDITOR_TIMEOUT = 60 +TEST_DIRECTORY = os.path.join(os.path.dirname(__file__), "atom_hydra_scripts") + + +@pytest.mark.parametrize("project", ["AutomatedTesting"]) +@pytest.mark.parametrize("launcher_platform", ['windows_editor']) +@pytest.mark.parametrize("level", ["tmp_level"]) +class TestAtomEditorComponents(object): + @pytest.fixture(autouse=True) + def setup_teardown(self, request, workspace, project, level): + # Cleanup our temp level + file_system.delete( + [os.path.join(workspace.paths.engine_root(), project, "Levels", "AtomLevels", level)], True, True) + + def teardown(): + # Cleanup our temp level + file_system.delete( + [os.path.join(workspace.paths.engine_root(), project, "Levels", "AtomLevels", level)], True, True) + + request.addfinalizer(teardown) + + @pytest.mark.test_case_id( + "C32078130", # Tone Mapper + "C32078129", # Light + "C32078131", # Radius Weight Modifier + "C32078127", # PostFX Layer + "C32078126", # Point Light + "C32078125", # Physical Sky + "C32078115", # Global Skylight (IBL) + "C32078121", # Exposure Control + "C32078120", # Directional Light + "C32078119", # DepthOfField + "C32078118") # Decal + def test_AtomEditorComponents_AddedToEntity(self, request, editor, level, workspace, project, launcher_platform): + cfg_args = [level] + + expected_lines = [ + # Area Light Component + "Area Light Entity successfully created", + "Area Light_test: Component added to the entity: True", + "Area Light_test: Component removed after UNDO: True", + "Area Light_test: Component added after REDO: True", + "Area Light_test: Entered game mode: True", + "Area Light_test: Entity enabled after adding required components: True", + "Area Light_test: Entity is hidden: True", + "Area Light_test: Entity is shown: True", + "Area Light_test: Entity deleted: True", + "Area Light_test: UNDO entity deletion works: True", + "Area Light_test: REDO entity deletion works: True", + # Decal Component + "Decal Entity successfully created", + "Decal_test: Component added to the entity: True", + "Decal_test: Component removed after UNDO: True", + "Decal_test: Component added after REDO: True", + "Decal_test: Entered game mode: True", + "Decal_test: Exit game mode: True", + "Decal Settings|Decal Settings|Material: SUCCESS", + "Decal_test: Entity is hidden: True", + "Decal_test: Entity is shown: True", + "Decal_test: Entity deleted: True", + "Decal_test: UNDO entity deletion works: True", + "Decal_test: REDO entity deletion works: True", + # DepthOfField Component + "DepthOfField Entity successfully created", + "DepthOfField_test: Component added to the entity: True", + "DepthOfField_test: Component removed after UNDO: True", + "DepthOfField_test: Component added after REDO: True", + "DepthOfField_test: Entered game mode: True", + "DepthOfField_test: Exit game mode: True", + "DepthOfField_test: Entity disabled initially: True", + "DepthOfField_test: Entity enabled after adding required components: True", + "DepthOfField Controller|Configuration|Camera Entity: SUCCESS", + "DepthOfField_test: Entity is hidden: True", + "DepthOfField_test: Entity is shown: True", + "DepthOfField_test: Entity deleted: True", + "DepthOfField_test: UNDO entity deletion works: True", + "DepthOfField_test: REDO entity deletion works: True", + # Directional Light Component + "Directional Light Entity successfully created", + "Directional Light_test: Component added to the entity: True", + "Directional Light_test: Component removed after UNDO: True", + "Directional Light_test: Component added after REDO: True", + "Directional Light_test: Entered game mode: True", + "Directional Light_test: Exit game mode: True", + "Directional Light Controller|Configuration|Shadow|Camera: SUCCESS", + "Directional Light_test: Entity is hidden: True", + "Directional Light_test: Entity is shown: True", + "Directional Light_test: Entity deleted: True", + "Directional Light_test: UNDO entity deletion works: True", + "Directional Light_test: REDO entity deletion works: True", + # Exposure Control Component + "Exposure Control Entity successfully created", + "Exposure Control_test: Component added to the entity: True", + "Exposure Control_test: Component removed after UNDO: True", + "Exposure Control_test: Component added after REDO: True", + "Exposure Control_test: Entered game mode: True", + "Exposure Control_test: Exit game mode: True", + "Exposure Control_test: Entity disabled initially: True", + "Exposure Control_test: Entity enabled after adding required components: True", + "Exposure Control_test: Entity is hidden: True", + "Exposure Control_test: Entity is shown: True", + "Exposure Control_test: Entity deleted: True", + "Exposure Control_test: UNDO entity deletion works: True", + "Exposure Control_test: REDO entity deletion works: True", + # Global Skylight (IBL) Component + "Global Skylight (IBL) Entity successfully created", + "Global Skylight (IBL)_test: Component added to the entity: True", + "Global Skylight (IBL)_test: Component removed after UNDO: True", + "Global Skylight (IBL)_test: Component added after REDO: True", + "Global Skylight (IBL)_test: Entered game mode: True", + "Global Skylight (IBL)_test: Exit game mode: True", + "Global Skylight (IBL) Controller|Configuration|Diffuse Image: SUCCESS", + "Global Skylight (IBL) Controller|Configuration|Specular Image: SUCCESS", + "Global Skylight (IBL)_test: Entity is hidden: True", + "Global Skylight (IBL)_test: Entity is shown: True", + "Global Skylight (IBL)_test: Entity deleted: True", + "Global Skylight (IBL)_test: UNDO entity deletion works: True", + "Global Skylight (IBL)_test: REDO entity deletion works: True", + # Physical Sky Component + "Physical Sky Entity successfully created", + "Physical Sky component was added to entity", + "Entity has a Physical Sky component", + "Physical Sky_test: Component added to the entity: True", + "Physical Sky_test: Component removed after UNDO: True", + "Physical Sky_test: Component added after REDO: True", + "Physical Sky_test: Entered game mode: True", + "Physical Sky_test: Exit game mode: True", + "Physical Sky_test: Entity is hidden: True", + "Physical Sky_test: Entity is shown: True", + "Physical Sky_test: Entity deleted: True", + "Physical Sky_test: UNDO entity deletion works: True", + "Physical Sky_test: REDO entity deletion works: True", + # Point Light Component + "Point Light Entity successfully created", + "Point Light_test: Component added to the entity: True", + "Point Light_test: Component removed after UNDO: True", + "Point Light_test: Component added after REDO: True", + "Point Light_test: Entered game mode: True", + "Point Light_test: Exit game mode: True", + "Point Light_test: Entity is hidden: True", + "Point Light_test: Entity is shown: True", + "Point Light_test: Entity deleted: True", + "Point Light_test: UNDO entity deletion works: True", + "Point Light_test: REDO entity deletion works: True", + # PostFX Layer Component + "PostFX Layer Entity successfully created", + "PostFX Layer_test: Component added to the entity: True", + "PostFX Layer_test: Component removed after UNDO: True", + "PostFX Layer_test: Component added after REDO: True", + "PostFX Layer_test: Entered game mode: True", + "PostFX Layer_test: Exit game mode: True", + "PostFX Layer_test: Entity is hidden: True", + "PostFX Layer_test: Entity is shown: True", + "PostFX Layer_test: Entity deleted: True", + "PostFX Layer_test: UNDO entity deletion works: True", + "PostFX Layer_test: REDO entity deletion works: True", + # Radius Weight Modifier Component + "Radius Weight Modifier Entity successfully created", + "Radius Weight Modifier_test: Component added to the entity: True", + "Radius Weight Modifier_test: Component removed after UNDO: True", + "Radius Weight Modifier_test: Component added after REDO: True", + "Radius Weight Modifier_test: Entered game mode: True", + "Radius Weight Modifier_test: Exit game mode: True", + "Radius Weight Modifier_test: Entity is hidden: True", + "Radius Weight Modifier_test: Entity is shown: True", + "Radius Weight Modifier_test: Entity deleted: True", + "Radius Weight Modifier_test: UNDO entity deletion works: True", + "Radius Weight Modifier_test: REDO entity deletion works: True", + # Light Component + "Light Entity successfully created", + "Light_test: Component added to the entity: True", + "Light_test: Component removed after UNDO: True", + "Light_test: Component added after REDO: True", + "Light_test: Entered game mode: True", + "Light_test: Exit game mode: True", + "Light_test: Entity is hidden: True", + "Light_test: Entity is shown: True", + "Light_test: Entity deleted: True", + "Light_test: UNDO entity deletion works: True", + "Light_test: REDO entity deletion works: True", + ] + + unexpected_lines = [ + "failed to open", + "Traceback (most recent call last):", + ] + + hydra.launch_and_validate_results( + request, + TEST_DIRECTORY, + editor, + "hydra_AtomEditorComponents_AddedToEntity.py", + timeout=EDITOR_TIMEOUT, + expected_lines=expected_lines, + unexpected_lines=unexpected_lines, + halt_on_unexpected=True, + null_renderer=True, + cfg_args=cfg_args, + ) diff --git a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py index 1887d5736e..f00227c47f 100755 --- a/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py +++ b/AutomatedTesting/Gem/PythonTests/automatedtesting_shared/base.py @@ -94,13 +94,13 @@ class TestAutomationBase: editor_starttime = time.time() self.logger.debug("Running automated test") testcase_module_filepath = self._get_testcase_module_filepath(testcase_module) - pycmd = ["--runpythontest", testcase_module_filepath, "-BatchMode", "-autotest_mode", "-NullRenderer"] + extra_cmdline_args + pycmd = ["--runpythontest", testcase_module_filepath, "-BatchMode", "-autotest_mode", "-rhi=null"] + extra_cmdline_args editor.args.extend(pycmd) # args are added to the WinLauncher start command editor.start(backupFiles = False, launch_ap = False) try: editor.wait(TestAutomationBase.MAX_TIMEOUT) except WaitTimeoutError: - errors.append(TestRunError("TIMEOUT", "Editor did not close after {TestAutomationBase.MAX_TIMEOUT} seconds, verify the test is ending and the application didn't freeze")) + errors.append(TestRunError("TIMEOUT", f"Editor did not close after {TestAutomationBase.MAX_TIMEOUT} seconds, verify the test is ending and the application didn't freeze")) editor.kill() output = editor.get_output() @@ -118,16 +118,16 @@ class TestAutomationBase: else: error_str = "Test failed, no output available..\n" errors.append(TestRunError("FAILED TEST", error_str)) - if return_code != TestAutomationBase.TEST_FAIL_RETCODE: # Crashed + if return_code and return_code != TestAutomationBase.TEST_FAIL_RETCODE: # Crashed crash_info = "-- No crash log available --" - error_log = os.path.join(workspace.paths.project_log(), 'error.log') + crash_log = os.path.join(workspace.paths.project_log(), 'error.log') try: - waiter.wait_for(lambda: os.path.exists(error_log), timeout=TestAutomationBase.WAIT_FOR_CRASH_LOG) + waiter.wait_for(lambda: os.path.exists(crash_log), timeout=TestAutomationBase.WAIT_FOR_CRASH_LOG) except AssertionError: pass try: - with open(error_log) as f: + with open(crash_log) as f: crash_info = f.read() except Exception as ex: crash_info += f"\n{str(ex)}" diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_TreeNavigation.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_TreeNavigation.py index dc0565d100..6019cdf247 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_TreeNavigation.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/AssetBrowser_TreeNavigation.py @@ -21,8 +21,8 @@ import azlmbr.legacy.general as general import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper +import editor_python_test_tools.pyside_utils as pyside_utils class AssetBrowserTreeNavigationTest(EditorTestHelper): @@ -66,7 +66,7 @@ class AssetBrowserTreeNavigationTest(EditorTestHelper): return collapse_success and expand_success # This is the hierarchy we are expanding (4 steps inside) - self.file_path = ("AutomatedTesting", "Assets", "ImageGradients", "lumberyard_gsi.png") + self.file_path = ("AutomatedTesting", "Assets", "ImageGradients", "image_grad_test_gsi.png") # 1) Open a new level self.test_success = self.create_level( diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Docking_BasicDockedTools.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Docking_BasicDockedTools.py index b390b95c47..21d5a0ee30 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Docking_BasicDockedTools.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Docking_BasicDockedTools.py @@ -22,8 +22,8 @@ import azlmbr.entity as entity import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper +import editor_python_test_tools.pyside_utils as pyside_utils class TestDockingBasicDockedTools(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py index c7fa19e372..208ef40d41 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_EditMenuOptions.py @@ -19,8 +19,8 @@ import sys import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper +import editor_python_test_tools.pyside_utils as pyside_utils class TestEditMenuOptions(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_FileMenuOptions.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_FileMenuOptions.py index d8140c25c0..3e174af2bd 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_FileMenuOptions.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_FileMenuOptions.py @@ -20,8 +20,8 @@ import sys import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper +import editor_python_test_tools.pyside_utils as pyside_utils class TestFileMenuOptions(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py index 1e364b5964..05ee802d19 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py +++ b/AutomatedTesting/Gem/PythonTests/editor/EditorScripts/Menus_ViewMenuOptions.py @@ -19,8 +19,8 @@ import sys import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper -import automatedtesting_shared.pyside_utils as pyside_utils +from editor_python_test_tools.editor_test_helper import EditorTestHelper +import editor_python_test_tools.pyside_utils as pyside_utils class TestViewMenuOptions(EditorTestHelper): diff --git a/AutomatedTesting/Gem/PythonTests/editor/conftest.py b/AutomatedTesting/Gem/PythonTests/editor/conftest.py index 328c5ebad4..3260b8834a 100644 --- a/AutomatedTesting/Gem/PythonTests/editor/conftest.py +++ b/AutomatedTesting/Gem/PythonTests/editor/conftest.py @@ -19,7 +19,7 @@ logger = logging.getLogger(__name__) layout = { - 'path': r'Software\Amazon\Lumberyard\Editor\fancyWindowLayouts', + 'path': r'Software\Amazon\O3DE\Editor\fancyWindowLayouts', 'value': 'last' } restore_camera = { diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py b/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py deleted file mode 100755 index a3d4739fd8..0000000000 --- a/AutomatedTesting/Gem/PythonTests/editor/test_SearchFiltering.py +++ /dev/null @@ -1,71 +0,0 @@ -""" -All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -its licensors. - -For complete copyright and license terms please see the LICENSE at the root of this -distribution (the "License"). All use of this software is governed by the License, -or, if provided, by the license below or the license accompanying this file. Do not -remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -""" - -""" -C13660194 : Asset Browser - Filtering -""" - -import os -import pytest - -# Bail on the test if ly_test_tools doesn't exist. -pytest.importorskip('ly_test_tools') -import ly_test_tools.environment.file_system as file_system -import editor_python_test_tools.hydra_test_utils as hydra - -test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") -log_monitor_timeout = 90 - - -@pytest.mark.parametrize('project', ['AutomatedTesting']) -@pytest.mark.parametrize('level', ['tmp_level']) -@pytest.mark.usefixtures("automatic_process_killer") -@pytest.mark.parametrize("launcher_platform", ['windows_editor']) -class TestSearchFiltering(object): - - @pytest.fixture(autouse=True) - def setup_teardown(self, request, workspace, project, level): - def teardown(): - file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True) - - request.addfinalizer(teardown) - - file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True) - - @pytest.mark.test_case_id("C13660194") - @pytest.mark.SUITE_periodic - def test_SearchFiltering_Asset_Browser_Filtering(self, request, editor, level, launcher_platform): - expected_lines = [ - "cedar.fbx asset is filtered in Asset Browser", - "Animation file type(s) is present in the file tree: True", - "FileTag file type(s) and Animation file type(s) is present in the file tree: True", - "FileTag file type(s) is present in the file tree after removing Animation filter: True", - ] - - unexpected_lines = [ - "Asset Browser opened: False", - "Animation file type(s) is present in the file tree: False", - "FileTag file type(s) and Animation file type(s) is present in the file tree: False", - "FileTag file type(s) is present in the file tree after removing Animation filter: False", - ] - - hydra.launch_and_validate_results( - request, - test_directory, - editor, - "AssetBrowser_SearchFiltering.py", - expected_lines, - unexpected_lines=unexpected_lines, - cfg_args=[level], - auto_test_mode=False, - run_python="--runpython", - timeout=log_monitor_timeout, - ) diff --git a/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py b/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py deleted file mode 100755 index 069d09f144..0000000000 --- a/AutomatedTesting/Gem/PythonTests/editor/test_TreeNavigation.py +++ /dev/null @@ -1,62 +0,0 @@ -""" -All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -its licensors. - -For complete copyright and license terms please see the LICENSE at the root of this -distribution (the "License"). All use of this software is governed by the License, -or, if provided, by the license below or the license accompanying this file. Do not -remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -""" - -""" -C13660195: Asset Browser - File Tree Navigation -""" - -import os -import pytest - -# Bail on the test if ly_test_tools doesn't exist. -pytest.importorskip('ly_test_tools') -import ly_test_tools.environment.file_system as file_system -import editor_python_test_tools.hydra_test_utils as hydra - -test_directory = os.path.join(os.path.dirname(__file__), "EditorScripts") -log_monitor_timeout = 90 - - -@pytest.mark.parametrize('project', ['AutomatedTesting']) -@pytest.mark.parametrize('level', ['tmp_level']) -@pytest.mark.usefixtures("automatic_process_killer") -@pytest.mark.parametrize("launcher_platform", ['windows_editor']) -class TestTreeNavigation(object): - - @pytest.fixture(autouse=True) - def setup_teardown(self, request, workspace, project, level): - def teardown(): - file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True) - - request.addfinalizer(teardown) - - file_system.delete([os.path.join(workspace.paths.engine_root(), project, "Levels", level)], True, True) - - @pytest.mark.test_case_id("C13660195") - @pytest.mark.SUITE_periodic - def test_TreeNavigation_Asset_Browser(self, request, editor, level, launcher_platform): - expected_lines = [ - "Collapse/Expand tests: True", - "Asset visibility test: True", - "Scrollbar visibility test: True", - "TreeNavigation_Asset_Browser: result=SUCCESS" - ] - - hydra.launch_and_validate_results( - request, - test_directory, - editor, - "TreeNavigation_Asset_Browser.py", - expected_lines, - run_python="--runpython", - cfg_args=[level], - timeout=log_monitor_timeout, - ) diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py index 65b5198213..2db8534696 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_AltitudeFilter.py @@ -85,7 +85,8 @@ class TestAltitudeFilter(object): @pytest.mark.test_case_id("C4847478") @pytest.mark.SUITE_periodic - def test_AltitudeFilterFilterStageToggle(self, request, editor, level, workspace, launcher_platform): + @pytest.mark.xfail # LYN-3275 + def test_AltitudeFilter_FilterStageToggle(self, request, editor, level, workspace, launcher_platform): cfg_args = [level] expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py index e74ecc8bd1..93149c9490 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_LayerSpawner.py @@ -101,6 +101,7 @@ class TestLayerSpawner(object): @pytest.mark.test_case_id("C4765973") @pytest.mark.SUITE_periodic + @pytest.mark.xfail # LYN-3275 def test_LayerSpawner_FilterStageToggle(self, request, editor, level, workspace, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py index 5e8ffe4d50..c04390e647 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_MeshBlocker.py @@ -46,6 +46,7 @@ class TestMeshBlocker(object): """ @pytest.mark.test_case_id("C3980834") @pytest.mark.SUITE_periodic + @pytest.mark.xfail # LYN-3273 def test_MeshBlocker_InstancesBlockedByMesh(self, request, editor, level, launcher_platform): expected_lines = [ "'Instance Spawner' created", @@ -69,6 +70,7 @@ class TestMeshBlocker(object): """ @pytest.mark.test_case_id("C4766030") @pytest.mark.SUITE_periodic + @pytest.mark.xfail # LYN-3273 def test_MeshBlocker_InstancesBlockedByMeshHeightTuning(self, request, editor, level, launcher_platform): expected_lines = [ "'Instance Spawner' created", diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py index 47ff17bfa6..ac3e0abb4f 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/dyn_veg/test_PositionModifier.py @@ -60,6 +60,7 @@ class TestPositionModifier(object): @pytest.mark.test_case_id("C4874100") @pytest.mark.SUITE_sandbox + @pytest.mark.xfail # LYN-3275 def test_PositionModifier_AutoSnapToSurfaceWorks(self, request, editor, level, launcher_platform): expected_lines = [ diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityRemovedOnNodeDelete.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityRemovedOnNodeDelete.py index d210bce7e2..38f8641b4c 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityRemovedOnNodeDelete.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/EditorScripts/AreaNodes_EntityRemovedOnNodeDelete.py @@ -21,7 +21,7 @@ import azlmbr.math as math import azlmbr.paths sys.path.append(os.path.join(azlmbr.paths.devroot, 'AutomatedTesting', 'Gem', 'PythonTests')) -from automatedtesting_shared.editor_test_helper import EditorTestHelper +from editor_python_test_tools.editor_test_helper import EditorTestHelper editorId = azlmbr.globals.property.LANDSCAPE_CANVAS_EDITOR_ID createdEntityId = None diff --git a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py index 4805d46e75..cb19b77088 100755 --- a/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py +++ b/AutomatedTesting/Gem/PythonTests/largeworlds/landscape_canvas/test_AreaNodes.py @@ -22,7 +22,7 @@ import pytest # Bail on the test if ly_test_tools doesn't exist. pytest.importorskip('ly_test_tools') import ly_test_tools.environment.file_system as file_system -import automateeditor_python_test_toolsdtesting_shared.hydra_test_utils as hydra +import editor_python_test_tools.hydra_test_utils as hydra test_directory = os.path.join(os.path.dirname(__file__), 'EditorScripts') diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py index eae5ea547a..904b5b0189 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861501_PhysXCollider_RenderMeshAutoAssigned.py @@ -24,7 +24,7 @@ class Tests(): # fmt: on -def run(): +def C14861501_PhysXCollider_RenderMeshAutoAssigned(): """ Summary: Create entity with Mesh component and assign a render mesh to the Mesh component. Add Physics Collider component @@ -61,7 +61,7 @@ def run(): from asset_utils import Asset # Asset paths - STATIC_MESH = os.path.join("assets", "c14861501_physxcollider_rendermeshautoassigned", "spherebot", "r0-b_body.cgf") + STATIC_MESH = os.path.join("assets", "c14861501_physxcollider_rendermeshautoassigned", "spherebot", "r0-b_body.azmodel") PHYSX_MESH = os.path.join( "assets", "c14861501_physxcollider_rendermeshautoassigned", "spherebot", "r0-b_body.pxmesh" ) @@ -80,8 +80,8 @@ def run(): # 4) Assign a render mesh asset to Mesh component (the fbx mesh having both Static mesh and PhysX collision Mesh) mesh_asset = Asset.find_asset_by_path(STATIC_MESH) - mesh_component.set_component_property_value("MeshComponentRenderNode|Mesh asset", mesh_asset.id) - mesh_asset.id = mesh_component.get_component_property_value("MeshComponentRenderNode|Mesh asset") + mesh_component.set_component_property_value("Controller|Configuration|Mesh Asset", mesh_asset.id) + mesh_asset.id = mesh_component.get_component_property_value("Controller|Configuration|Mesh Asset") Report.result(Tests.assign_mesh_asset, mesh_asset.get_path() == STATIC_MESH.replace(os.sep, "/")) # 5) Add PhysX Collider component @@ -95,4 +95,8 @@ def run(): if __name__ == "__main__": - run() + import ImportPathHelper as imports + imports.init() + + from utils import Report + Report.start_test(C14861501_PhysXCollider_RenderMeshAutoAssigned) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py b/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py index 6ea81ea2ff..075c3f5b61 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861502_PhysXCollider_AssetAutoAssigned.py @@ -62,8 +62,8 @@ def C14861502_PhysXCollider_AssetAutoAssigned(): # Open 3D Engine Imports import azlmbr.legacy.general as general - MESH_ASSET_PATH = os.path.join("Objects", "SphereBot", "r0-b_body.cgf") - MESH_PROPERTY_PATH = "MeshComponentRenderNode|Mesh asset" + MESH_ASSET_PATH = os.path.join("Objects", "SphereBot", "r0-b_body.azmodel") + MESH_PROPERTY_PATH = "Controller|Configuration|Mesh Asset" TESTED_PROPERTY_PATH = "Shape Configuration|Asset|PhysX Mesh" helper.init_idle() diff --git a/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py b/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py index abc79ba1b0..bbaabf67f6 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C14861504_RenderMeshAsset_WithNoPxAsset.py @@ -69,7 +69,7 @@ def run(): import azlmbr.asset as azasset # Asset paths - STATIC_MESH = os.path.join("assets", "c14861504_rendermeshasset_withnopxasset", "test_asset.cgf") + STATIC_MESH = os.path.join("assets", "c14861504_rendermeshasset_withnopxasset", "test_asset.azmodel") helper.init_idle() # 1) Load the empty level @@ -85,8 +85,8 @@ def run(): # 4) Assign a render mesh asset to Mesh component (the fbx mesh having both Static mesh and PhysX collision Mesh) mesh_asset = Asset.find_asset_by_path(STATIC_MESH) - mesh_component.set_component_property_value("MeshComponentRenderNode|Mesh asset", mesh_asset.id) - mesh_asset.id = mesh_component.get_component_property_value("MeshComponentRenderNode|Mesh asset") + mesh_component.set_component_property_value("Controller|Configuration|Mesh Asset", mesh_asset.id) + mesh_asset.id = mesh_component.get_component_property_value("Controller|Configuration|Mesh Asset") Report.result(Tests.assign_mesh_asset, mesh_asset.get_path() == STATIC_MESH.replace(os.sep, "/")) # 5) Add PhysX Collider component diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py b/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py index a92927a9db..858e778f07 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4044695_PhysXCollider_AddMultipleSurfaceFbx.py @@ -27,7 +27,7 @@ class Tests(): # fmt: on -def run(): +def C4044695_PhysXCollider_AddMultipleSurfaceFbx(): """ Summary: Create entity with Mesh and PhysX Collider components and assign a fbx file in both the components. @@ -45,12 +45,7 @@ def run(): 4) Select the PhysicsAsset shape in the PhysX Collider component 5) Assign the fbx file in PhysX Mesh and Mesh component 6) Check if multiple material slots show up under Materials section in the PhysX Collider component - - Note: - - This test file must be called from the Open 3D Engine Editor command terminal - - Any passed and failed tests are written to the Editor.log file. - Parsing the file or running a log_monitor are required to observe the test results. - + :return: None """ # Builtins @@ -70,7 +65,7 @@ def run(): SURFACE_TAG_COUNT = 4 # Number of surface tags included in used asset # Asset paths - STATIC_MESH = os.path.join("assets", "c4044695_physxcollider_addmultiplesurfacefbx", "test.cgf") + STATIC_MESH = os.path.join("assets", "c4044695_physxcollider_addmultiplesurfacefbx", "test.azmodel") PHYSX_MESH = os.path.join("assets", "c4044695_physxcollider_addmultiplesurfacefbx", "test.pxmesh") helper.init_idle() @@ -100,8 +95,8 @@ def run(): Report.result(Tests.assign_px_mesh_asset, px_asset.get_path() == PHYSX_MESH.replace(os.sep, "/")) mesh_asset = Asset.find_asset_by_path(STATIC_MESH) - mesh_component.set_component_property_value("MeshComponentRenderNode|Mesh asset", mesh_asset.id) - mesh_asset.id = mesh_component.get_component_property_value("MeshComponentRenderNode|Mesh asset") + mesh_component.set_component_property_value("Controller|Configuration|Mesh Asset", mesh_asset.id) + mesh_asset.id = mesh_component.get_component_property_value("Controller|Configuration|Mesh Asset") Report.result(Tests.assign_mesh_asset, mesh_asset.get_path() == STATIC_MESH.replace(os.sep, "/")) # 6) Check if multiple material slots show up under Materials section in the PhysX Collider component @@ -116,4 +111,8 @@ def run(): if __name__ == "__main__": - run() + import ImportPathHelper as imports + imports.init() + + from utils import Report + Report.start_test(C4044695_PhysXCollider_AddMultipleSurfaceFbx) diff --git a/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py b/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py index 906c6db55b..72442601e4 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py +++ b/AutomatedTesting/Gem/PythonTests/physics/C4976236_AddPhysxColliderComponent.py @@ -27,7 +27,7 @@ class Tests(): def C4976236_AddPhysxColliderComponent(): """ Summary: - Load level with Entity having PhysX Collider component. Verify that editor remains stable in Game mode. + Opens an empty level and creates an Entity with PhysX Collider. Verify that editor remains stable in Game mode. Expected Behavior: The Editor is stable there are no warnings or errors. @@ -37,16 +37,10 @@ def C4976236_AddPhysxColliderComponent(): 2) Create test entity 3) Start the Tracer to catch any errors and warnings 4) Add the PhysX Collider component and change shape to box - 5) Add Mesh component and an asset - 6) Enter game mode - 7) Verify there are no errors and warnings in the logs - 8) Exit game mode - 9) Close the editor - - Note: - - This test file must be called from the Open 3D Engine Editor command terminal - - Any passed and failed tests are written to the Editor.log file. - Parsing the file or running a log_monitor are required to observe the test results. + 5) Enter game mode + 6) Verify there are no errors and warnings in the logs + 7) Exit game mode + 8) Close the editor :return: None """ @@ -60,7 +54,7 @@ def C4976236_AddPhysxColliderComponent(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.utils import Tracer from asset_utils import Asset - + helper.init_idle() # 1) Load the level helper.open_level("Physics", "Base") @@ -74,17 +68,12 @@ def C4976236_AddPhysxColliderComponent(): # 4) Add the PhysX Collider component and change shape to box collider_component = test_entity.add_component("PhysX Collider") Report.result(Tests.add_physx_collider, test_entity.has_component("PhysX Collider")) - collider_component.set_component_property_value('Shape Configuration|Shape', 1) + collider_component.set_component_property_value('Shape Configuration|Shape', azlmbr.physics.ShapeType_Box) - # 5) Add Mesh component and an asset - mesh_component = test_entity.add_component("Mesh") - asset = Asset.find_asset_by_path(r"Objects\default\primitive_cube.cgf") - mesh_component.set_component_property_value('MeshComponentRenderNode|Mesh asset', asset.id) - - # 6) Enter game mode + # 5) Enter game mode helper.enter_game_mode(Tests.enter_game_mode) - # 7) Verify there are no errors and warnings in the logs + # 6) Verify there are no errors and warnings in the logs success_condition = not (section_tracer.has_errors or section_tracer.has_warnings) Report.result(Tests.no_errors_and_warnings_found, success_condition) if not success_condition: @@ -92,9 +81,8 @@ def C4976236_AddPhysxColliderComponent(): Report.info(f"Warnings found: {section_tracer.warnings}") if section_tracer.has_errors: Report.info(f"Errors found: {section_tracer.errors}") - Report.failure(Tests.no_errors_and_warnings_found) - # 8) Exit game mode + # 7) Exit game mode helper.exit_game_mode(Tests.exit_game_mode) diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py new file mode 100644 index 0000000000..67e855a00e --- /dev/null +++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Main.py @@ -0,0 +1,37 @@ +""" +All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +its licensors. + +For complete copyright and license terms please see the LICENSE at the root of this +distribution (the "License"). All use of this software is governed by the License, +or, if provided, by the license below or the license accompanying this file. Do not +remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + +""" + +# This suite consists of all test cases that are passing and have been verified. + +import pytest +import os +import sys + +from .FileManagement import FileManagement as fm +from ly_test_tools import LAUNCHERS + +sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesting_shared') + +from base import TestAutomationBase + + +revert_physics_config = fm.file_revert_list(['physxdebugconfiguration.setreg', 'physxdefaultsceneconfiguration.setreg', 'physxsystemconfiguration.setreg'], 'AutomatedTesting/Registry') + + +@pytest.mark.SUITE_main +@pytest.mark.parametrize("launcher_platform", ['windows_editor']) +@pytest.mark.parametrize("project", ["AutomatedTesting"]) +class TestAutomation(TestAutomationBase): + + def test_C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC(self, request, workspace, editor, launcher_platform): + from . import C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC as test_module + self._run_test(request, workspace, editor, test_module) \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Active.py b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py similarity index 96% rename from AutomatedTesting/Gem/PythonTests/physics/TestSuite_Active.py rename to AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py index 805e4f7d79..ad8ae6481f 100755 --- a/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Active.py +++ b/AutomatedTesting/Gem/PythonTests/physics/TestSuite_Periodic.py @@ -27,26 +27,16 @@ from base import TestAutomationBase revert_physics_config = fm.file_revert_list(['physxdebugconfiguration.setreg', 'physxdefaultsceneconfiguration.setreg', 'physxsystemconfiguration.setreg'], 'AutomatedTesting/Registry') -@pytest.mark.SUITE_main +@pytest.mark.SUITE_periodic @pytest.mark.parametrize("launcher_platform", ['windows_editor']) @pytest.mark.parametrize("project", ["AutomatedTesting"]) class TestAutomation(TestAutomationBase): - # Marking the test as an expected failure due to sporadic failure on Automated Review: SPEC-3146 - # The test still runs, but a failure of the test doesn't result in the test run failing - @pytest.mark.xfail( - reason="This test seems to fail sometimes due to it being the first test in the testsuite, we'll duplicate it temporarly." - "Need to figure out the reason why this is the case") - @revert_physics_config - def test_C000000_RigidBody_EnablingGravityWorksPoC_DUPLICATE(self, request, workspace, editor, launcher_platform): - from . import C100000_RigidBody_EnablingGravityWorksPoC as test_module - self._run_test(request, workspace, editor, test_module) - @revert_physics_config def test_C3510642_Terrain_NotCollideWithTerrain(self, request, workspace, editor, launcher_platform): from . import C3510642_Terrain_NotCollideWithTerrain as test_module self._run_test(request, workspace, editor, test_module) - + @revert_physics_config def test_C4976195_RigidBodies_InitialLinearVelocity(self, request, workspace, editor, launcher_platform): from . import C4976195_RigidBodies_InitialLinearVelocity as test_module @@ -530,8 +520,4 @@ class TestAutomation(TestAutomationBase): def test_C100000_RigidBody_EnablingGravityWorksPoC(self, request, workspace, editor, launcher_platform): from . import C100000_RigidBody_EnablingGravityWorksPoC as test_module - self._run_test(request, workspace, editor, test_module) - - def test_C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC(self, request, workspace, editor, launcher_platform): - from . import C111111_RigidBody_EnablingGravityWorksUsingNotificationsPoC as test_module - self._run_test(request, workspace, editor, test_module) + self._run_test(request, workspace, editor, test_module) \ No newline at end of file diff --git a/AutomatedTesting/Levels/Physics/Base/Base.ly b/AutomatedTesting/Levels/Physics/Base/Base.ly index 97546ff3a2..f99dc672b0 100644 --- a/AutomatedTesting/Levels/Physics/Base/Base.ly +++ b/AutomatedTesting/Levels/Physics/Base/Base.ly @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:75cb1c8454aafc3de81351450a9480f91cb98d926a6e47f87a5ffe91e1d5a7d5 -size 4745 +oid sha256:f63204a86af8bc0963a4823d047a2e222cc19aabd14570d0789dc90cdc82970c +size 2017 diff --git a/AutomatedTesting/Levels/Physics/Base/leveldata/TimeOfDay.xml b/AutomatedTesting/Levels/Physics/Base/leveldata/TimeOfDay.xml index 456d609b8a..6ea168cc6b 100644 --- a/AutomatedTesting/Levels/Physics/Base/leveldata/TimeOfDay.xml +++ b/AutomatedTesting/Levels/Physics/Base/leveldata/TimeOfDay.xml @@ -1,356 +1,356 @@ - - + + - - + + - + - - + + - - + + - + - + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - + - + - - + + - - + + - - + + - - + + - + - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - - + + - - + + - - + + - + - + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - - + + - + - + - + - - + + - - + + - + - + - - + + - + - - + + - + - - + + - + - + - + - - + + - - + + - + - + - - + + - - + + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - + - + - - + + - + - - + + - + - - + + - + - + - - + + diff --git a/AutomatedTesting/game.cfg b/AutomatedTesting/game.cfg index d9d8461ea0..f50112436f 100644 --- a/AutomatedTesting/game.cfg +++ b/AutomatedTesting/game.cfg @@ -1,7 +1,7 @@ sys_game_name = "AutomatedTesting" sys_localization_folder = Localization ca_useIMG_CAF = 0 -sys_asserts=2 +sys_asserts=1 -- Enable warnings when asset loads take longer than the given millisecond threshold cl_assetLoadWarningEnable=true diff --git a/Code/CryEngine/CrySystem/SystemInit.cpp b/Code/CryEngine/CrySystem/SystemInit.cpp index cd8ce36beb..fcbf0b8215 100644 --- a/Code/CryEngine/CrySystem/SystemInit.cpp +++ b/Code/CryEngine/CrySystem/SystemInit.cpp @@ -247,7 +247,7 @@ CUNIXConsole* pUnixConsole; #define LOCALIZATION_TRANSLATIONS_LIST_FILE_NAME "Libs/Localization/localization.xml" -#define LOAD_LEGACY_RENDERER_FOR_EDITOR true // If you set this to false you must for now also set 'ed_useAtomNativeViewport' to true (see /Code/Sandbox/Editor/ViewManager.cpp) +#define LOAD_LEGACY_RENDERER_FOR_EDITOR false // If you set this to true you must also set 'ed_useAtomNativeViewport' to false (see /Code/Sandbox/Editor/ViewManager.cpp) #define LOAD_LEGACY_RENDERER_FOR_LAUNCHER false ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp b/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp index f01e42a443..52eae22fee 100644 --- a/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp +++ b/Code/Framework/AzFramework/AzFramework/Physics/ShapeConfiguration.cpp @@ -26,6 +26,22 @@ namespace Physics ->Field("Scale", &ShapeConfiguration::m_scale) ; } + + if (auto behaviorContext = azrtti_cast(context)) + { + #define REFLECT_SHAPETYPE_ENUM_VALUE(EnumValue) \ + behaviorContext->EnumProperty<(int)Physics::ShapeType::EnumValue>("ShapeType_"#EnumValue) \ + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Automation) \ + ->Attribute(AZ::Script::Attributes::Module, "physics"); + + // Note: Here we only expose the types that are available to the user in the editor + REFLECT_SHAPETYPE_ENUM_VALUE(Box); + REFLECT_SHAPETYPE_ENUM_VALUE(Sphere); + REFLECT_SHAPETYPE_ENUM_VALUE(Cylinder); + REFLECT_SHAPETYPE_ENUM_VALUE(PhysicsAsset); + + #undef REFLECT_SHAPETYPE_ENUM_VALUE + } } void SphereShapeConfiguration::Reflect(AZ::ReflectContext* context) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h index cca5d1b9e4..83e40474d6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h @@ -348,6 +348,11 @@ namespace AzToolsFramework */ virtual bool AreAnyEntitiesSelected() = 0; + /*! + * Returns the number of selected entities. + */ + virtual int GetSelectedEntitiesCount() = 0; + /*! * Retrieves the set of selected entities. * \return a list of entity Ids. diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp index 22c1390828..50315e9d7a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.cpp @@ -395,6 +395,7 @@ namespace AzToolsFramework ->Event("MarkEntityDeselected", &ToolsApplicationRequests::MarkEntityDeselected) ->Event("IsSelected", &ToolsApplicationRequests::IsSelected) ->Event("AreAnyEntitiesSelected", &ToolsApplicationRequests::AreAnyEntitiesSelected) + ->Event("GetSelectedEntitiesCount", &ToolsApplicationRequests::GetSelectedEntitiesCount) ; behaviorContext->EBus("ToolsApplicationNotificationBus") diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.h index 0f038422ce..6c836ac888 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Application/ToolsApplication.h @@ -101,6 +101,7 @@ namespace AzToolsFramework SourceControlFileInfo GetSceneSourceControlInfo() override; bool AreAnyEntitiesSelected() override { return !m_selectedEntities.empty(); } + int GetSelectedEntitiesCount() override { return m_selectedEntities.size(); } const EntityIdList& GetSelectedEntities() override { return m_selectedEntities; } const EntityIdList& GetHighlightedEntities() override { return m_highlightedEntities; } void SetSelectedEntities(const EntityIdList& selectedEntities) override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp index 34fd4a4941..81233069a9 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Entity/PrefabEditorEntityOwnershipService.cpp @@ -242,19 +242,6 @@ namespace AzToolsFramework return false; } } - else - { - // The template is already loaded, this is the case of either saving as same name or different name(loaded from before). - // Update the template with the changes - AzToolsFramework::Prefab::PrefabDom dom; - bool success = AzToolsFramework::Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(*m_rootInstance, dom); - if (!success) - { - AZ_Error("Prefab", false, "Failed to convert current root instance into a DOM when saving file '%.*s'", AZ_STRING_ARG(filename)); - return false; - } - m_prefabSystemComponent->UpdatePrefabTemplate(templateId, dom); - } Prefab::TemplateId prevTemplateId = m_rootInstance->GetTemplateId(); m_rootInstance->SetTemplateId(templateId); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp index bd02f3cd9b..836140eb74 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Instance/InstanceSerializer.cpp @@ -200,7 +200,7 @@ namespace AzToolsFramework } return context.Report(result, - result.GetProcessing() == JSR::Processing::Completed ? "Succesfully loaded instance information for prefab." : + result.GetProcessing() == JSR::Processing::Completed ? "Successfully loaded instance information for prefab." : "Failed to load instance information for prefab"); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Link/Link.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Link/Link.cpp index 621a00b0bf..4dd31814b7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Link/Link.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/Link/Link.cpp @@ -230,6 +230,10 @@ namespace AzToolsFramework AZ_Assert(instanceDom.IsObject(), "Link Id '%u' cannot be added because the DOM of the instance is not an object.", m_id); instanceDom.AddMember(rapidjson::StringRef(PrefabDomUtils::LinkIdName), rapidjson::Value().SetUint64(m_id), allocator); } + else + { + linkIdReference->get().SetUint64(m_id); + } } } // namespace Prefab diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp index 0c826ae817..1e9cc35230 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp @@ -392,12 +392,27 @@ namespace AzToolsFramework if (patch.IsArray() && !patch.Empty() && beforeState.IsObject()) { - // Update the state of the entity - PrefabUndoEntityUpdate* state = aznew PrefabUndoEntityUpdate(AZStd::to_string(static_cast(entityId))); - state->SetParent(parentUndoBatch); - state->Capture(beforeState, afterState, entityId); + if (IsInstanceContainerEntity(entityId) && !IsLevelInstanceContainerEntity(entityId)) + { + m_instanceToTemplateInterface->AppendEntityAliasToPatchPaths(patch, entityId); - state->Redo(); + // Save these changes as patches to the link + PrefabUndoLinkUpdate* linkUpdate = + aznew PrefabUndoLinkUpdate(AZStd::to_string(static_cast(entityId))); + linkUpdate->SetParent(parentUndoBatch); + linkUpdate->Capture(patch, owningInstance->get().GetLinkId()); + + linkUpdate->Redo(); + } + else + { + // Update the state of the entity + PrefabUndoEntityUpdate* state = aznew PrefabUndoEntityUpdate(AZStd::to_string(static_cast(entityId))); + state->SetParent(parentUndoBatch); + state->Capture(beforeState, afterState, entityId); + + state->Redo(); + } } // Update the cache diff --git a/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntitySelectionTests.cpp b/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntitySelectionTests.cpp index 6625e56470..66ccf09aaf 100644 --- a/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntitySelectionTests.cpp +++ b/Code/Framework/AzToolsFramework/Tests/Entity/EditorEntitySelectionTests.cpp @@ -81,12 +81,17 @@ namespace UnitTest ToolsApplicationRequestBus::BroadcastResult( anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected); + int selectedEntitiesCount = 0; + ToolsApplicationRequestBus::BroadcastResult( + selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount); + EntityIdList selectedEntityIds; ToolsApplicationRequestBus::BroadcastResult( selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities); EXPECT_TRUE(testEntitySelected); EXPECT_TRUE(anyEntitySelected); + EXPECT_EQ(selectedEntitiesCount, 1); EXPECT_EQ(selectedEntityIds.size(), 1); EXPECT_EQ(selectedEntityIds.front(), testEntityId); @@ -100,11 +105,15 @@ namespace UnitTest ToolsApplicationRequestBus::BroadcastResult( anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected); + ToolsApplicationRequestBus::BroadcastResult( + selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount); + ToolsApplicationRequestBus::BroadcastResult( selectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities); EXPECT_FALSE(testEntitySelected); EXPECT_FALSE(anyEntitySelected); + EXPECT_EQ(selectedEntitiesCount, 0); EXPECT_TRUE(selectedEntityIds.empty()); } @@ -141,11 +150,16 @@ namespace UnitTest ToolsApplicationRequestBus::BroadcastResult( anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected); + int selectedEntitiesCount = 0; + ToolsApplicationRequestBus::BroadcastResult( + selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount); + EntityIdList actualSelectedEntityIds; ToolsApplicationRequestBus::BroadcastResult( actualSelectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities); EXPECT_TRUE(anyEntitySelected); + EXPECT_EQ(selectedEntitiesCount, expectedSelectedEntityIds.size()); EXPECT_EQ(actualSelectedEntityIds.size(), expectedSelectedEntityIds.size()); for (auto& id : expectedSelectedEntityIds) { @@ -160,10 +174,14 @@ namespace UnitTest ToolsApplicationRequestBus::BroadcastResult( anyEntitySelected, &ToolsApplicationRequests::AreAnyEntitiesSelected); + ToolsApplicationRequestBus::BroadcastResult( + selectedEntitiesCount, &ToolsApplicationRequests::GetSelectedEntitiesCount); + ToolsApplicationRequestBus::BroadcastResult( actualSelectedEntityIds, &ToolsApplicationRequests::GetSelectedEntities); EXPECT_TRUE(anyEntitySelected); + EXPECT_EQ(selectedEntitiesCount, expectedSelectedEntityIds.size()); EXPECT_EQ(actualSelectedEntityIds.size(), expectedSelectedEntityIds.size()); for (auto& id : expectedSelectedEntityIds) { diff --git a/Code/Sandbox/Editor/CryEdit.cpp b/Code/Sandbox/Editor/CryEdit.cpp index a474706910..c6a2ece984 100644 --- a/Code/Sandbox/Editor/CryEdit.cpp +++ b/Code/Sandbox/Editor/CryEdit.cpp @@ -5232,6 +5232,13 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[]) AzQtComponents::Utilities::HandleDpiAwareness(AzQtComponents::Utilities::SystemDpiAware); Editor::EditorQtApplication app(argc, argv); + if (app.arguments().contains("-autotest_mode")) + { + // Nullroute all stdout to null for automated tests, this way we make sure + // that the test result output is not polluted with unrelated output data. + theApp->RedirectStdoutToNull(); + } + // Hook the trace bus to catch errors, boot the AZ app after the QApplication is up int ret = 0; @@ -5249,13 +5256,6 @@ extern "C" int AZ_DLL_EXPORT CryEditMain(int argc, char* argv[]) return -1; } - if (app.arguments().contains("-autotest_mode")) - { - // Nullroute all stdout to null for automated tests, this way we make sure - // that the test result output is not polluted with unrelated output data. - theApp->RedirectStdoutToNull(); - } - AzToolsFramework::EditorEvents::Bus::Broadcast(&AzToolsFramework::EditorEvents::NotifyQtApplicationAvailable, &app); #if defined(AZ_PLATFORM_MAC) diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index a656c27d98..25588e85a7 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -232,7 +232,6 @@ int EditorViewportWidget::OnCreate() { m_renderer = GetIEditor()->GetRenderer(); m_engine = GetIEditor()->Get3DEngine(); - assert(m_engine); CreateRenderContext(); @@ -793,8 +792,14 @@ void EditorViewportWidget::OnRender() // This is necessary so that automated editor tests using the null renderer to test systems like dynamic vegetation // are still able to manipulate the current logical camera position, even if nothing is rendered. GetIEditor()->GetSystem()->SetViewCamera(m_Camera); - GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera()); - m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__); + if (GetIEditor()->GetRenderer()) + { + GetIEditor()->GetRenderer()->SetCamera(gEnv->pSystem->GetViewCamera()); + } + if (m_engine) + { + m_engine->RenderWorld(0, SRenderingPassInfo::CreateGeneralPassRenderingInfo(m_Camera), __FUNCTION__); + } return; } @@ -886,7 +891,7 @@ void EditorViewportWidget::OnBeginPrepareRender() fov = 2 * atanf((h * tan(fov / 2)) / maxTargetHeight); } } - m_Camera.SetFrustum(w, h, fov, fNearZ, gEnv->p3DEngine->GetMaxViewDistance()); + m_Camera.SetFrustum(w, h, fov, fNearZ); } GetIEditor()->GetSystem()->SetViewCamera(m_Camera); @@ -2606,8 +2611,7 @@ bool EditorViewportWidget::GetActiveCameraPosition(AZ::Vector3& cameraPos) { if (GetIEditor()->IsInGameMode()) { - const Vec3 camPos = m_engine->GetRenderingCamera().GetPosition(); - cameraPos = LYVec3ToAZVec3(camPos); + cameraPos = m_renderViewport->GetViewportContext()->GetCameraTransform().GetTranslation(); } else { diff --git a/Code/Sandbox/Editor/GameExporter.cpp b/Code/Sandbox/Editor/GameExporter.cpp index 00836018cf..9039fca70d 100644 --- a/Code/Sandbox/Editor/GameExporter.cpp +++ b/Code/Sandbox/Editor/GameExporter.cpp @@ -139,7 +139,10 @@ bool CGameExporter::Export(unsigned int flags, [[maybe_unused]] EEndian eExportE // Make sure we unload any unused CGFs before exporting so that they don't end up in // the level data. - pEditor->Get3DEngine()->FreeUnusedCGFResources(); + if (pEditor->Get3DEngine()) + { + pEditor->Get3DEngine()->FreeUnusedCGFResources(); + } CCryEditDoc* pDocument = pEditor->GetDocument(); @@ -282,7 +285,7 @@ void CGameExporter::ExportVisAreas(const char* pszGamePath, EEndian eExportEndia SHotUpdateInfo exportInfo; I3DEngine* p3DEngine = pEditor->Get3DEngine(); - if (eExportEndian == GetPlatformEndian()) // skip second export, this data is common for PC and consoles + if (p3DEngine && (eExportEndian == GetPlatformEndian())) // skip second export, this data is common for PC and consoles { std::vector* pTempBrushTable = NULL; std::vector<_smart_ptr>* pTempMatsTable = NULL; @@ -367,25 +370,28 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission) QString missionFileName; QString currentMissionFileName; I3DEngine* p3DEngine = pEditor->Get3DEngine(); - for (int i = 0; i < pDocument->GetMissionCount(); i++) + if (p3DEngine) { - CMission* pMission = pDocument->GetMission(i); - - QString name = pMission->GetName(); - name.replace(' ', '_'); - missionFileName = QStringLiteral("Mission_%1.xml").arg(name); - - XmlNodeRef missionDescNode = missionsNode->newChild("Mission"); - missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data()); - missionDescNode->setAttr("File", missionFileName.toUtf8().data()); - missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount()); - - int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount(); - missionDescNode->setAttr("ProgressBarRange", nProgressBarRange); - - if (pMission == pCurrentMission) + for (int i = 0; i < pDocument->GetMissionCount(); i++) { - currentMissionFileName = missionFileName; + CMission* pMission = pDocument->GetMission(i); + + QString name = pMission->GetName(); + name.replace(' ', '_'); + missionFileName = QStringLiteral("Mission_%1.xml").arg(name); + + XmlNodeRef missionDescNode = missionsNode->newChild("Mission"); + missionDescNode->setAttr("Name", pMission->GetName().toUtf8().data()); + missionDescNode->setAttr("File", missionFileName.toUtf8().data()); + missionDescNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount()); + + int nProgressBarRange = m_numExportedMaterials / 10 + p3DEngine->GetLoadedObjectCount(); + missionDescNode->setAttr("ProgressBarRange", nProgressBarRange); + + if (pMission == pCurrentMission) + { + currentMissionFileName = missionFileName; + } } } @@ -413,7 +419,10 @@ void CGameExporter::ExportLevelData(const QString& path, bool bExportMission) XmlNodeRef missionNode = rootAction->createNode("Mission"); pCurrentMission->Export(missionNode, objectsNode); - missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount()); + if (p3DEngine) + { + missionNode->setAttr("CGFCount", p3DEngine->GetLoadedObjectCount()); + } //if (!CFileUtil::OverwriteFile( path+currentMissionFileName )) // return; @@ -483,6 +492,11 @@ void CGameExporter::ExportLevelInfo(const QString& path) ////////////////////////////////////////////////////////////////////////// void CGameExporter::ExportMapInfo(XmlNodeRef& node) { + if (!GetIEditor()->Get3DEngine()) + { + return; + } + XmlNodeRef info = node->newChild("LevelInfo"); IEditor* pEditor = GetIEditor(); diff --git a/Code/Sandbox/Editor/InfoBar.cpp b/Code/Sandbox/Editor/InfoBar.cpp index a1a1f7b055..e6860c38c8 100644 --- a/Code/Sandbox/Editor/InfoBar.cpp +++ b/Code/Sandbox/Editor/InfoBar.cpp @@ -22,7 +22,6 @@ #include "Include/ITransformManipulator.h" #include "ActionManager.h" #include "Settings.h" -#include "Objects/SelectionGroup.h" #include "Include/IObjectManager.h" #include "MathConversion.h" @@ -191,10 +190,12 @@ void CInfoBar::IdleUpdate() Vec3 marker = GetIEditor()->GetMarkerPosition(); - CSelectionGroup* selection = GetIEditor()->GetSelection(); - if (selection->GetCount() != m_numSelected) + int selectedEntitiesCount = 0; + AzToolsFramework::ToolsApplicationRequestBus::BroadcastResult( + selectedEntitiesCount, &AzToolsFramework::ToolsApplicationRequests::GetSelectedEntitiesCount); + if (selectedEntitiesCount != m_numSelected) { - m_numSelected = selection->GetCount(); + m_numSelected = selectedEntitiesCount; updateUI = true; } diff --git a/Code/Sandbox/Editor/Material/MaterialManager.cpp b/Code/Sandbox/Editor/Material/MaterialManager.cpp index dee903dfe4..3c21a74d97 100644 --- a/Code/Sandbox/Editor/Material/MaterialManager.cpp +++ b/Code/Sandbox/Editor/Material/MaterialManager.cpp @@ -525,6 +525,11 @@ void CMaterialManager::OnEditorNotifyEvent(EEditorNotifyEvent event) ////////////////////////////////////////////////////////////////////////// void CMaterialManager::ReloadDirtyMaterials() { + if (!GetIEditor()->Get3DEngine()) + { + return; + } + IMaterialManager* runtimeMaterialManager = GetIEditor()->Get3DEngine()->GetMaterialManager(); uint32 mtlCount = 0; @@ -743,12 +748,15 @@ int CMaterialManager::GetHighlightFlags(CMaterial* pMaterial) const result |= eHighlight_NoSurfaceType; } - if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager()) + if (GetIEditor()->Get3DEngine()) { - const ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data()); - if (pSurfaceType && pSurfaceType->GetBreakability() != 0) + if (ISurfaceTypeManager* pSurfaceManager = GetIEditor()->Get3DEngine()->GetMaterialManager()->GetSurfaceTypeManager()) { - result |= eHighlight_Breakable; + const ISurfaceType* pSurfaceType = pSurfaceManager->GetSurfaceTypeByName(surfaceTypeName.toUtf8().data()); + if (pSurfaceType && pSurfaceType->GetBreakability() != 0) + { + result |= eHighlight_Breakable; + } } } diff --git a/Code/Sandbox/Editor/Mission.cpp b/Code/Sandbox/Editor/Mission.cpp index 57f2033f3b..b9668f1c80 100644 --- a/Code/Sandbox/Editor/Mission.cpp +++ b/Code/Sandbox/Editor/Mission.cpp @@ -212,8 +212,11 @@ void CMission::SyncContent(bool bRetrieve, bool bIgnoreObjects, [[maybe_unused]] else { // Save time of day. - m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay"); - GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, false); + if (GetIEditor()->Get3DEngine()) + { + m_timeOfDay = XmlHelpers::CreateXmlNode("TimeOfDay"); + GetIEditor()->Get3DEngine()->GetTimeOfDay()->Serialize(m_timeOfDay, false); + } if (!bIgnoreObjects) { diff --git a/Code/Sandbox/Editor/ShaderCache.cpp b/Code/Sandbox/Editor/ShaderCache.cpp index 5a5b0d8f58..3beeb9a7c4 100644 --- a/Code/Sandbox/Editor/ShaderCache.cpp +++ b/Code/Sandbox/Editor/ShaderCache.cpp @@ -138,6 +138,7 @@ bool CLevelShaderCache::SaveBuffer(QString& textBuffer) void CLevelShaderCache::Update() { IRenderer* pRenderer = gEnv->pRenderer; + if (pRenderer) { QString buf; char* str = NULL; diff --git a/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h b/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h index f4b7a3165e..e2f53c33f9 100644 --- a/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h +++ b/Code/Tools/SceneAPI/SceneCore/DataTypes/GraphData/IMeshVertexColorData.h @@ -97,6 +97,9 @@ namespace AZ }; } // DataTypes } // SceneAPI + + AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::Color, "{937E3BF8-5204-4D40-A8DA-C8F083C89F9F}"); + } // AZ namespace AZStd diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.cpp index 083adeff50..b54aa1e421 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.cpp @@ -11,6 +11,8 @@ */ #include +#include +#include namespace AZ { @@ -18,6 +20,31 @@ namespace AZ { namespace GraphData { + void AnimationData::Reflect(ReflectContext* context) + { + SerializeContext* serializeContext = azrtti_cast(context); + if (serializeContext) + { + serializeContext->Class() + ->Version(1); + } + + BehaviorContext* behaviorContext = azrtti_cast(context); + if (behaviorContext) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene") + ->Method("GetKeyFrameCount", &SceneAPI::DataTypes::IAnimationData::GetKeyFrameCount) + ->Method("GetKeyFrame", &SceneAPI::DataTypes::IAnimationData::GetKeyFrame) + ->Method("GetTimeStepBetweenFrames", &SceneAPI::DataTypes::IAnimationData::GetTimeStepBetweenFrames); + + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene"); + } + } + AnimationData::AnimationData() : m_timeStepBetweenFrames(1.0/30.0) // default value { @@ -61,6 +88,32 @@ namespace AZ } + void BlendShapeAnimationData::Reflect(ReflectContext* context) + { + SerializeContext* serializeContext = azrtti_cast(context); + if (serializeContext) + { + serializeContext->Class() + ->Version(1); + } + + BehaviorContext* behaviorContext = azrtti_cast(context); + if (behaviorContext) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene") + ->Method("GetBlendShapeName", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetBlendShapeName) + ->Method("GetKeyFrameCount", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetKeyFrameCount) + ->Method("GetKeyFrame", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetKeyFrame) + ->Method("GetTimeStepBetweenFrames", &SceneAPI::DataTypes::IBlendShapeAnimationData::GetTimeStepBetweenFrames); + + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene"); + } + } + BlendShapeAnimationData::BlendShapeAnimationData() : m_timeStepBetweenFrames(1 / 30.0) // default value { diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.h b/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.h index 6f3f9a05f5..af44618878 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.h +++ b/Code/Tools/SceneAPI/SceneData/GraphData/AnimationData.h @@ -30,6 +30,8 @@ namespace AZ public: AZ_RTTI(AnimationData, "{D350732E-4727-41C8-95E0-FBAF5F2AC074}", SceneAPI::DataTypes::IAnimationData); + static void Reflect(ReflectContext* context); + SCENE_DATA_API AnimationData(); SCENE_DATA_API ~AnimationData() override = default; SCENE_DATA_API virtual void AddKeyFrame(const SceneAPI::DataTypes::MatrixType& keyFrameTransform); @@ -53,6 +55,8 @@ namespace AZ public: AZ_RTTI(BlendShapeAnimationData, "{02766CCF-BDA7-46B6-9BB1-58A90C1AD6AA}", SceneAPI::DataTypes::IBlendShapeAnimationData); + static void Reflect(ReflectContext* context); + SCENE_DATA_API BlendShapeAnimationData(); SCENE_DATA_API ~BlendShapeAnimationData() override = default; SCENE_DATA_API void CloneAttributesFrom(const IGraphObject* sourceObject) override; diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp index a26f07ae53..902928d404 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.cpp @@ -12,9 +12,13 @@ #include #include +#include +#include namespace AZ { + AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::IBlendShapeData::Face, "{C972EC9A-3A5C-47CD-9A92-ECB4C0C0451C}"); + namespace SceneData { namespace GraphData @@ -23,6 +27,82 @@ namespace AZ BlendShapeData::~BlendShapeData() = default; + void BlendShapeData::Reflect(ReflectContext* context) + { + SerializeContext* serializeContext = azrtti_cast(context); + if (serializeContext) + { + serializeContext->Class() + ->Version(1); + } + + BehaviorContext* behaviorContext = azrtti_cast(context); + if (behaviorContext) + { + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene") + ->Method("GetUsedControlPointCount", &SceneAPI::DataTypes::IBlendShapeData::GetUsedControlPointCount) + ->Method("GetControlPointIndex", &SceneAPI::DataTypes::IBlendShapeData::GetControlPointIndex) + ->Method("GetUsedPointIndexForControlPoint", &SceneAPI::DataTypes::IBlendShapeData::GetUsedPointIndexForControlPoint) + ->Method("GetVertexCount", &SceneAPI::DataTypes::IBlendShapeData::GetVertexCount) + ->Method("GetFaceCount", &SceneAPI::DataTypes::IBlendShapeData::GetFaceCount) + ->Method("GetFaceInfo", &SceneAPI::DataTypes::IBlendShapeData::GetFaceInfo) + ->Method("GetPosition", &SceneAPI::DataTypes::IBlendShapeData::GetPosition) + ->Method("GetNormal", &SceneAPI::DataTypes::IBlendShapeData::GetNormal) + ->Method("GetFaceVertexIndex", &SceneAPI::DataTypes::IBlendShapeData::GetFaceVertexIndex); + + behaviorContext->Class("BlendShapeDataFace") + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene") + ->Method("GetVertexIndex", [](const SceneAPI::DataTypes::IBlendShapeData::Face& self, int index) + { + if (index >= 0 && index < 3) + { + return self.vertexIndex[index]; + } + return aznumeric_cast(0); + }); + + behaviorContext->Class() + ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) + ->Attribute(AZ::Script::Attributes::Module, "scene") + ->Method("GetUV", &BlendShapeData::GetUV) + ->Method("GetTangent", [](const BlendShapeData& self, size_t index) + { + if (index < self.GetTangents().size()) + { + return self.GetTangents().at(index); + } + AZ_Error("SceneGraphData", false, "Cannot get to tangent at index(%zu)", index); + return Vector4::CreateZero(); + }) + ->Method("GetBitangent", [](const BlendShapeData& self, size_t index) + { + if (index < self.GetBitangents().size()) + { + return self.GetBitangents().at(index); + } + AZ_Error("SceneGraphData", false, "Cannot get to bitangents at index(%zu)", index); + return Vector3::CreateZero(); + }) + ->Method("GetColor", [](const BlendShapeData& self, AZ::u8 colorSetIndex, AZ::u8 colorIndex) + { + SceneAPI::DataTypes::Color color(0,0,0,0); + if (colorSetIndex < MaxNumColorSets) + { + const AZStd::vector& colorChannel = self.GetColors(colorSetIndex); + if (colorIndex < colorChannel.size()) + { + return colorChannel[colorIndex]; + } + } + AZ_Error("SceneGraphData", false, "Cannot get to color setIndex(%d) at colorIndex(%d)", colorSetIndex, colorIndex); + return color; + }); + } + } + void BlendShapeData::AddPosition(const Vector3& position) { m_positions.push_back(position); diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h index 0626b6b6cf..9ae287da46 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h +++ b/Code/Tools/SceneAPI/SceneData/GraphData/BlendShapeData.h @@ -31,6 +31,8 @@ namespace AZ public: AZ_RTTI(BlendShapeData, "{FF875C22-2E4F-4CE3-BA49-09BF78C70A09}", SceneAPI::DataTypes::IBlendShapeData) + SCENE_DATA_API static void Reflect(ReflectContext* context); + // Maximum number of color sets matches limitation set in assImp (AI_MAX_NUMBER_OF_COLOR_SETS) static constexpr AZ::u8 MaxNumColorSets = 8; // Maximum number of uv sets matches limitation set in assImp (AI_MAX_NUMBER_OF_TEXTURECOORDS) diff --git a/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexColorData.cpp b/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexColorData.cpp index fe3cede475..a5ed4132ea 100644 --- a/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexColorData.cpp +++ b/Code/Tools/SceneAPI/SceneData/GraphData/MeshVertexColorData.cpp @@ -16,8 +16,6 @@ namespace AZ { - AZ_TYPE_INFO_SPECIALIZE(SceneAPI::DataTypes::Color, "{937E3BF8-5204-4D40-A8DA-C8F083C89F9F}"); - namespace SceneData { namespace GraphData @@ -40,7 +38,7 @@ namespace AZ ->Method("GetCount", &MeshVertexColorData::GetCount ) ->Method("GetColor", &MeshVertexColorData::GetColor); - behaviorContext->Class("MeshVertexColor") + behaviorContext->Class("VertexColor") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "scene") ->Property("red", BehaviorValueGetter(&AZ::SceneAPI::DataTypes::Color::red), nullptr) diff --git a/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp b/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp index 6a04e071d7..a9e0c7b1a5 100644 --- a/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp +++ b/Code/Tools/SceneAPI/SceneData/ReflectionRegistrar.cpp @@ -81,8 +81,9 @@ namespace AZ SceneData::SceneNodeSelectionList::Reflect(context); // Graph objects - context->Class()->Version(1); - context->Class()->Version(1); + AZ::SceneData::GraphData::AnimationData::Reflect(context); + AZ::SceneData::GraphData::BlendShapeAnimationData::Reflect(context); + AZ::SceneData::GraphData::BlendShapeData::Reflect(context); AZ::SceneData::GraphData::BoneData::Reflect(context); AZ::SceneData::GraphData::MaterialData::Reflect(context); AZ::SceneData::GraphData::MeshData::Reflect(context); @@ -107,6 +108,9 @@ namespace AZ AZ::SceneData::GraphData::MeshVertexUVData::Reflect(context); AZ::SceneData::GraphData::MeshVertexTangentData::Reflect(context); AZ::SceneData::GraphData::MeshVertexBitangentData::Reflect(context); + AZ::SceneData::GraphData::AnimationData::Reflect(context); + AZ::SceneData::GraphData::BlendShapeAnimationData::Reflect(context); + AZ::SceneData::GraphData::BlendShapeData::Reflect(context); } } // namespace SceneAPI } // namespace AZ diff --git a/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp b/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp index 404950b4c0..79c6cfea7e 100644 --- a/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp +++ b/Code/Tools/SceneAPI/SceneData/Tests/GraphData/GraphDataBehaviorTests.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include namespace AZ { @@ -101,6 +103,53 @@ namespace AZ tangentData->SetTangentSetIndex(2); return true; } + else if (data.get_type_info().m_id == azrtti_typeid()) + { + auto* animationData = AZStd::any_cast(&data); + animationData->ReserveKeyFrames(3); + animationData->AddKeyFrame(DataTypes::MatrixType::CreateFromValue(1.0)); + animationData->AddKeyFrame(DataTypes::MatrixType::CreateFromValue(2.0)); + animationData->AddKeyFrame(DataTypes::MatrixType::CreateFromValue(3.0)); + animationData->SetTimeStepBetweenFrames(4.0); + return true; + } + else if (data.get_type_info().m_id == azrtti_typeid()) + { + auto* blendShapeAnimationData = AZStd::any_cast(&data); + blendShapeAnimationData->SetBlendShapeName("mockBlendShapeName"); + blendShapeAnimationData->ReserveKeyFrames(3); + blendShapeAnimationData->AddKeyFrame(1.0); + blendShapeAnimationData->AddKeyFrame(2.0); + blendShapeAnimationData->AddKeyFrame(3.0); + blendShapeAnimationData->SetTimeStepBetweenFrames(4.0); + return true; + } + else if (data.get_type_info().m_id == azrtti_typeid()) + { + auto* blendShapeData = AZStd::any_cast(&data); + blendShapeData->AddPosition({ 1.0, 2.0, 3.0 }); + blendShapeData->AddPosition({ 2.0, 3.0, 4.0 }); + blendShapeData->AddPosition({ 3.0, 4.0, 5.0 }); + blendShapeData->AddNormal({ 0.1, 0.2, 0.3 }); + blendShapeData->AddNormal({ 0.2, 0.3, 0.4 }); + blendShapeData->AddNormal({ 0.3, 0.4, 0.5 }); + blendShapeData->AddTangentAndBitangent(Vector4{ 0.1f, 0.2f, 0.3f, 0.4f }, { 0.0, 0.1, 0.2 }); + blendShapeData->AddTangentAndBitangent(Vector4{ 0.2f, 0.3f, 0.4f, 0.5f }, { 0.1, 0.2, 0.3 }); + blendShapeData->AddTangentAndBitangent(Vector4{ 0.3f, 0.4f, 0.5f, 0.6f }, { 0.2, 0.3, 0.4 }); + blendShapeData->AddUV(Vector2{ 0.9, 0.8 }, 0); + blendShapeData->AddUV(Vector2{ 0.7, 0.7 }, 1); + blendShapeData->AddUV(Vector2{ 0.6, 0.6 }, 2); + blendShapeData->AddColor(DataTypes::Color{ 0.1, 0.2, 0.3, 0.4 }, 0); + blendShapeData->AddColor(DataTypes::Color{ 0.2, 0.3, 0.4, 0.5 }, 1); + blendShapeData->AddColor(DataTypes::Color{ 0.3, 0.4, 0.5, 0.6 }, 2); + blendShapeData->AddFace({ 0, 1, 2 }); + blendShapeData->AddFace({ 1, 2, 0 }); + blendShapeData->AddFace({ 2, 0, 1 }); + blendShapeData->SetVertexIndexToControlPointIndexMap(0, 1); + blendShapeData->SetVertexIndexToControlPointIndexMap(1, 2); + blendShapeData->SetVertexIndexToControlPointIndexMap(2, 0); + return true; + } return false; } @@ -296,6 +345,116 @@ namespace AZ ExpectExecute("TestExpectIntegerEquals(meshVertexTangentData:GetTangentSetIndex(), 2)"); ExpectExecute("TestExpectTrue(meshVertexTangentData:GetTangentSpace(), MeshVertexTangentData.EMotionFX)"); } + + TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_AnimationData_AccessWorks) + { + ExpectExecute("animationData = AnimationData()"); + ExpectExecute("TestExpectTrue(animationData ~= nil)"); + ExpectExecute("MockGraphData.FillData(animationData)"); + ExpectExecute("TestExpectIntegerEquals(animationData:GetKeyFrameCount(), 3)"); + ExpectExecute("TestExpectFloatEquals(animationData:GetTimeStepBetweenFrames(), 4.0)"); + ExpectExecute("TestExpectFloatEquals(animationData:GetKeyFrame(0).basisX.x, 1.0)"); + ExpectExecute("TestExpectFloatEquals(animationData:GetKeyFrame(1).basisX.y, 2.0)"); + ExpectExecute("TestExpectFloatEquals(animationData:GetKeyFrame(2).basisX.z, 3.0)"); + } + + TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_BlendShapeAnimationData_AccessWorks) + { + ExpectExecute("blendShapeAnimationData = BlendShapeAnimationData()"); + ExpectExecute("TestExpectTrue(blendShapeAnimationData ~= nil)"); + ExpectExecute("MockGraphData.FillData(blendShapeAnimationData)"); + ExpectExecute("TestExpectTrue(blendShapeAnimationData:GetBlendShapeName() == 'mockBlendShapeName')"); + ExpectExecute("TestExpectIntegerEquals(blendShapeAnimationData:GetKeyFrameCount(), 3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetKeyFrame(0), 1.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetKeyFrame(1), 2.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetKeyFrame(2), 3.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeAnimationData:GetTimeStepBetweenFrames(), 4.0)"); + } + + TEST_F(GrapDatahBehaviorScriptTest, SceneGraph_BlendShapeData_AccessWorks) + { + ExpectExecute("blendShapeData = BlendShapeData()"); + ExpectExecute("TestExpectTrue(blendShapeData ~= nil)"); + ExpectExecute("MockGraphData.FillData(blendShapeData)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedControlPointCount(), 3)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetVertexCount(), 3)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceCount(), 3)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceVertexIndex(0, 2), 2)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceVertexIndex(1, 0), 1)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetFaceVertexIndex(2, 1), 0)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetControlPointIndex(0), 1)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetControlPointIndex(1), 2)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetControlPointIndex(2), 0)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedPointIndexForControlPoint(0), 2)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedPointIndexForControlPoint(1), 0)"); + ExpectExecute("TestExpectIntegerEquals(blendShapeData:GetUsedPointIndexForControlPoint(2), 1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(0).x, 1.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(0).y, 2.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(0).z, 3.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(1).x, 2.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(1).y, 3.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(1).z, 4.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(2).x, 3.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(2).y, 4.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetPosition(2).z, 5.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(0).x, 0.1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(0).y, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(0).z, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(1).x, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(1).y, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(1).z, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(2).x, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(2).y, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetNormal(2).z, 0.5)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(0):GetVertexIndex(0), 0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(0):GetVertexIndex(1), 1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(0):GetVertexIndex(2), 2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(1):GetVertexIndex(0), 1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(1):GetVertexIndex(1), 2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(1):GetVertexIndex(2), 0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(2):GetVertexIndex(0), 2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(2):GetVertexIndex(1), 0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetFaceInfo(2):GetVertexIndex(2), 1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 0).x, 0.9)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 0).y, 0.8)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 1).x, 0.7)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 1).y, 0.7)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 2).x, 0.6)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetUV(0, 2).y, 0.6)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).red, 0.1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).green, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).blue, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(0, 0).alpha, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).red, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).green, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).blue, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(1, 0).alpha, 0.5)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).red, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).green, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).blue, 0.5)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetColor(2, 0).alpha, 0.6)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).x, 0.1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).y, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).z, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(0).w, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).x, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).y, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).z, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(1).w, 0.5)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).x, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).y, 0.4)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).z, 0.5)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetTangent(2).w, 0.6)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(0).x, 0.0)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(0).y, 0.1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(0).z, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(1).x, 0.1)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(1).y, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(1).z, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).x, 0.2)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).y, 0.3)"); + ExpectExecute("TestExpectFloatEquals(blendShapeData:GetBitangent(2).z, 0.4)"); + } } } } diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli index fd6961c50d..f9bfb75fea 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli @@ -13,6 +13,7 @@ #pragma once #include +#include #include #include "MaterialInputs/BaseColorInput.azsli" diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_DepthPass_WithPS.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_DepthPass_WithPS.azsl index 81601860ed..28968b5941 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_DepthPass_WithPS.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_DepthPass_WithPS.azsl @@ -10,7 +10,6 @@ * */ -#include #include #include "./EnhancedPBR_Common.azsli" #include diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index 27d7d7f65c..36c8e81a94 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -10,11 +10,25 @@ * */ -#include #include "EnhancedPBR_Common.azsli" + +// SRGs #include -#include +#include + +// Pass Output +#include + +// Utility #include +#include + +// Custom Surface & Lighting +#include + +// Decals +#include + // ---------- Material Parameters ---------- @@ -39,6 +53,8 @@ COMMON_OPTIONS_DETAIL_MAPS() #include "MaterialInputs/TransmissionInput.azsli" +// ---------- Vertex Shader ---------- + struct VSInput { // Base fields (required by the template azsli file)... @@ -67,8 +83,6 @@ struct VSOutput float2 m_detailUv[UvSetCount] : UV3; }; -#include -#include #include VSOutput EnhancedPbr_ForwardPassVS(VSInput IN) @@ -94,6 +108,9 @@ VSOutput EnhancedPbr_ForwardPassVS(VSInput IN) return OUT; } + +// ---------- Pixel Shader ---------- + PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depth) { // ------- Tangents & Bitangets ------- @@ -144,6 +161,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float } } + Surface surface; + surface.position = IN.m_worldPosition; + // ------- Alpha & Clip ------- float2 baseColorUv = IN.m_uv[MaterialSrg::m_baseColorMapUvIndex]; @@ -172,7 +192,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float3x3 uvMatrix = MaterialSrg::m_normalMapUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3(); // By design, only UV0 is allowed to apply transforms. float detailLayerNormalFactor = MaterialSrg::m_detail_normal_factor * detailLayerBlendFactor; - float3 normal = GetDetailedNormalInputWS( + surface.normal = GetDetailedNormalInputWS( isFrontFace, IN.m_normal, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], MaterialSrg::m_normalMap, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_normalFactor, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, uvMatrix, o_normal_useTexture, tangents[MaterialSrg::m_detail_allMapsUvIndex], bitangents[MaterialSrg::m_detail_allMapsUvIndex], MaterialSrg::m_detail_normal_texture, MaterialSrg::m_sampler, detailUv, detailLayerNormalFactor, MaterialSrg::m_detail_normal_flipX, MaterialSrg::m_detail_normal_flipY, MaterialSrg::m_detailUvMatrix, o_detail_normal_useTexture); @@ -196,26 +216,19 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, MaterialSrg::m_metallicFactor, o_metallic_useTexture); } - // ------- Roughness ------- - - float2 roughnessUv = IN.m_uv[MaterialSrg::m_roughnessMapUvIndex]; - float roughness = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor, - MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture); - // ------- Specular ------- float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex]; float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture); - // ------- Emissive ------- + surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic); - float2 emissiveUv = IN.m_uv[MaterialSrg::m_emissiveMapUvIndex]; - float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture); + // ------- Roughness ------- - // ------- Occlusion ------- - - float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); - float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); + float2 roughnessUv = IN.m_uv[MaterialSrg::m_roughnessMapUvIndex]; + surface.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor, + MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture); + surface.CalculateRoughnessA(); // ------- Subsurface ------- @@ -226,33 +239,99 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float2 transmissionUv = IN.m_uv[MaterialSrg::m_transmissionThicknessMapUvIndex]; float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness); + surface.transmission.tint = transmissionTintThickness.rgb; + surface.transmission.thickness = transmissionTintThickness.w; + surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams; + + // ------- Anisotropy ------- + + if (o_enableAnisotropy) + { + // Convert the angle from [0..1] = [0 .. 180 degrees] to radians [0 .. PI] + const float anisotropyAngle = MaterialSrg::m_anisotropicAngle * PI; + const float anisotropyFactor = MaterialSrg::m_anisotropicFactor; + surface.anisotropy.Init(surface.normal, tangents[0], bitangents[0], anisotropyAngle, anisotropyFactor, surface.roughnessA); + } + + // ------- Lighting Data ------- + + LightingData lightingData; + + // Light iterator + lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); + lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); + + // Directional light shadow coordinates + lightingData.shadowCoords = IN.m_shadowCoords; + + // ------- Occlusion ------- + + lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); + + // ------- Emissive ------- + + float2 emissiveUv = IN.m_uv[MaterialSrg::m_emissiveMapUvIndex]; + lightingData.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture); // ------- Clearcoat ------- - float clearCoatFactor = 0.0; - float clearCoatRoughness = 0.0; - float3 clearCoatNormal = float3(0.0, 0.0, 0.0); - // TODO: Clean up the double uses of these clear coat flags - if(o_clearCoat_enabled && o_clearCoat_feature_enabled) + // [GFX TODO][ATOM-14603]: Clean up the double uses of these clear coat flags + if(o_clearCoat_feature_enabled) { - float3x3 uvMatrix = MaterialSrg::m_clearCoatNormalMapUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3(); - GetClearCoatInputs(MaterialSrg::m_clearCoatInfluenceMap, IN.m_uv[MaterialSrg::m_clearCoatInfluenceMapUvIndex], MaterialSrg::m_clearCoatFactor, o_clearCoat_factor_useTexture, - MaterialSrg::m_clearCoatRoughnessMap, IN.m_uv[MaterialSrg::m_clearCoatRoughnessMapUvIndex], MaterialSrg::m_clearCoatRoughness, o_clearCoat_roughness_useTexture, - MaterialSrg::m_clearCoatNormalMap, IN.m_uv[MaterialSrg::m_clearCoatNormalMapUvIndex], IN.m_normal, o_clearCoat_normal_useTexture, MaterialSrg::m_clearCoatNormalStrength, - uvMatrix, tangents[MaterialSrg::m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_clearCoatNormalMapUvIndex], - MaterialSrg::m_sampler, isFrontFace, - clearCoatFactor, clearCoatRoughness, clearCoatNormal); + if(o_clearCoat_enabled) + { + float3x3 uvMatrix = MaterialSrg::m_clearCoatNormalMapUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3(); + GetClearCoatInputs(MaterialSrg::m_clearCoatInfluenceMap, IN.m_uv[MaterialSrg::m_clearCoatInfluenceMapUvIndex], MaterialSrg::m_clearCoatFactor, o_clearCoat_factor_useTexture, + MaterialSrg::m_clearCoatRoughnessMap, IN.m_uv[MaterialSrg::m_clearCoatRoughnessMapUvIndex], MaterialSrg::m_clearCoatRoughness, o_clearCoat_roughness_useTexture, + MaterialSrg::m_clearCoatNormalMap, IN.m_uv[MaterialSrg::m_clearCoatNormalMapUvIndex], IN.m_normal, o_clearCoat_normal_useTexture, MaterialSrg::m_clearCoatNormalStrength, + uvMatrix, tangents[MaterialSrg::m_clearCoatNormalMapUvIndex], bitangents[MaterialSrg::m_clearCoatNormalMapUvIndex], + MaterialSrg::m_sampler, isFrontFace, + surface.clearCoat.factor, surface.clearCoat.roughness, surface.clearCoat.normal); + } + + // manipulate base layer f0 if clear coat is enabled + // modify base layer's normal incidence reflectance + // for the derivation of the following equation please refer to: + // https://google.github.io/filament/Filament.md.html#materialsystem/clearcoatmodel/baselayermodification + float3 f0 = (1.0 - 5.0 * sqrt(surface.specularF0)) / (5.0 - sqrt(surface.specularF0)); + surface.specularF0 = lerp(surface.specularF0, f0 * f0, surface.clearCoat.factor); } + + // Diffuse and Specular response (used in IBL calculations) + lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); + lightingData.diffuseResponse = 1.0 - lightingData.specularResponse; + + if(o_clearCoat_feature_enabled) + { + // Clear coat layer has fixed IOR = 1.5 and transparent => F0 = (1.5 - 1)^2 / (1.5 + 1)^2 = 0.04 + lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor); + } + + // ------- Multiscatter ------- + + lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation); // ------- Lighting Calculation ------- - // Convert the angle from [0..1] = [0 .. 180 degrees] to radians [0 .. PI] - const float2 anisotropy = float2(MaterialSrg::m_anisotropicAngle * PI, MaterialSrg::m_anisotropicFactor); + // Apply Decals + ApplyDecals(lightingData.tileIterator, surface); - PbrLightingOutput lightingOutput = PbrLighting(IN, - baseColor, metallic, roughness, specularF0Factor, - normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + // Apply Direct Lighting + ApplyDirectLighting(surface, lightingData); + + // Apply Image Based Lighting (IBL) + ApplyIBL(surface, lightingData); + + // Finalize Lighting + lightingData.FinalizeLighting(surface.transmission.tint); + + if (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent) + { + alpha = FresnelSchlickWithRoughness(lightingData.NdotV, alpha, surface.roughnessLinear).x; // Increase opacity at grazing angles. + } + + PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha); // ------- Opacity ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader index 9a90dddac8..7964e3c84a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.shader @@ -50,5 +50,5 @@ ] }, - "DrawList" : "forward" -} + "DrawList" : "forwardWithSubsurfaceOutput" +} diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass_EDS.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass_EDS.shader index 0d4b558e85..f7fcfd6c21 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass_EDS.shader +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass_EDS.shader @@ -49,5 +49,5 @@ ] }, - "DrawList" : "forward" + "DrawList" : "forwardWithSubsurfaceOutput" } diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Shadowmap_WithPS.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Shadowmap_WithPS.azsl index f1021e354b..15b58c4deb 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Shadowmap_WithPS.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Shadowmap_WithPS.azsl @@ -11,7 +11,6 @@ */ #include -#include #include "EnhancedPBR_Common.azsli" #include #include diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index d490283c52..84095ac163 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -10,11 +10,24 @@ * */ -#include #include "Skin_Common.azsli" + +// SRGs #include -#include +#include + +// Pass Output +#include + +// Utility #include +#include // TODO: Remove this after OpacityMode is removed from LightingModel + +// Custom Surface & Lighting +#include + +// Decals +#include // ---------- Material Parameters ---------- @@ -53,6 +66,8 @@ option bool o_blendMask_isBound; #include "MaterialInputs/TransmissionInput.azsli" +// ---------- Vertex Shader ---------- + struct VSInput { // Base fields (required by the template azsli file)... @@ -89,8 +104,6 @@ struct VSOutput float4 m_blendMask : UV8; }; -#include // TODO: Remove this after OpacityMode is removed from LightingModel -#include #include VSOutput SkinVS(VSInput IN) @@ -131,6 +144,9 @@ VSOutput SkinVS(VSInput IN) return OUT; } + +// ---------- Pixel Shader ---------- + float3 ApplyBaseColorWrinkleMap(bool shouldApply, float3 baseColor, Texture2D map, sampler mapSampler, float2 uv, float factor) { if (shouldApply) @@ -177,6 +193,9 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) PrepareGeneratedTangent(IN.m_normal, IN.m_worldPosition, isFrontFace, IN.m_uv, UvSetCount, tangents, bitangents, startIndex); } + Surface surface; + surface.position = IN.m_worldPosition; + // ------- Detail Layer Setup ------- // When the detail maps and the detail blend mask are on the same UV, they both use the transformed detail UVs because they are 'attached' to each other @@ -212,19 +231,18 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture4, normalMapSample, MaterialSrg::m_wrinkle_normal_texture4, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, IN.m_blendMask.a); } - float3 normalWS; if(o_detail_normal_useTexture) { float3 normalTS = GetTangentSpaceNormal(normalMapSample, uvMatrix, MaterialSrg::m_normalFactor); bool applyOverlay = true; - normalWS = ApplyNormalMapOverlayWS(applyOverlay, IN.m_normal, normalTS, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], + surface.normal = ApplyNormalMapOverlayWS(applyOverlay, IN.m_normal, normalTS, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], MaterialSrg::m_detail_normal_texture, MaterialSrg::m_sampler, IN.m_detailUv, MaterialSrg::m_detail_normal_flipX, MaterialSrg::m_detail_normal_flipY, detailLayerNormalFactor, tangents[MaterialSrg::m_detail_allMapsUvIndex], bitangents[MaterialSrg::m_detail_allMapsUvIndex], MaterialSrg::m_detailUvMatrix); } else { - normalWS = GetWorldSpaceNormal(normalMapSample, IN.m_normal, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], + surface.normal = GetWorldSpaceNormal(normalMapSample, IN.m_normal, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, MaterialSrg::m_normalFactor); } @@ -265,23 +283,29 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) baseColor = ApplyTextureOverlay(o_detail_baseColor_useTexture, baseColor, MaterialSrg::m_detail_baseColor_texture, MaterialSrg::m_sampler, IN.m_detailUv, detailLayerBaseColorFactor); - - // ------- Roughness ------- - - float2 roughnessUv = IN.m_uv[MaterialSrg::m_roughnessMapUvIndex]; - float roughness = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor, - MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture); - - // ------- Occlusion ------- - - float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); - float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); + if(o_wrinkleLayers_enabled && o_wrinkleLayers_showBlendMaskValues && o_blendMask_isBound) + { + // Overlay debug colors to highlight the different blend weights coming from the vertex color stream. + if(o_wrinkleLayers_count > 0) { baseColor = lerp(baseColor, float3(1,0,0), IN.m_blendMask.r); } + if(o_wrinkleLayers_count > 1) { baseColor = lerp(baseColor, float3(0,1,0), IN.m_blendMask.g); } + if(o_wrinkleLayers_count > 2) { baseColor = lerp(baseColor, float3(0,0,1), IN.m_blendMask.b); } + if(o_wrinkleLayers_count > 3) { baseColor = lerp(baseColor, float3(1,1,1), IN.m_blendMask.a); } + } // ------- Specular ------- float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex]; float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture); + surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor); + + // ------- Roughness ------- + + float2 roughnessUv = IN.m_uv[MaterialSrg::m_roughnessMapUvIndex]; + surface.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor, + MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture); + surface.CalculateRoughnessA(); + // ------- Subsurface ------- float2 subsurfaceUv = IN.m_uv[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex]; @@ -291,29 +315,49 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) float2 transmissionUv = IN.m_uv[MaterialSrg::m_transmissionThicknessMapUvIndex]; float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness); + surface.transmission.tint = transmissionTintThickness.rgb; + surface.transmission.thickness = transmissionTintThickness.w; + surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams; + + // ------- Lighting Data ------- + + LightingData lightingData; + + // Light iterator + lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); + lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); + + // Directional light shadow coordinates + lightingData.shadowCoords = IN.m_shadowCoords; + + // Diffuse and Specular response (used in IBL calculations) + lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); + lightingData.diffuseResponse = 1.0 - lightingData.specularResponse; + + // ------- Occlusion ------- + + lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); + lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); // ------- Lighting Calculation ------- - if(o_wrinkleLayers_enabled && o_wrinkleLayers_showBlendMaskValues && o_blendMask_isBound) - { - // Overlay debug colors to highlight the different blend weights coming from the vertex color stream. - if(o_wrinkleLayers_count > 0) { baseColor = lerp(baseColor, float3(1,0,0), IN.m_blendMask.r); } - if(o_wrinkleLayers_count > 1) { baseColor = lerp(baseColor, float3(0,1,0), IN.m_blendMask.g); } - if(o_wrinkleLayers_count > 2) { baseColor = lerp(baseColor, float3(0,0,1), IN.m_blendMask.b); } - if(o_wrinkleLayers_count > 3) { baseColor = lerp(baseColor, float3(1,1,1), IN.m_blendMask.a); } - } + surface.clearCoat.factor = 0.0; + surface.clearCoat.roughness = 0.0; + surface.clearCoat.normal = float3(0.0, 0.0, 0.0); - float metallic = 0; - float3 emissive = float3(0,0,0); - float2 anisotropy = float2(0,0); - float clearCoatFactor = 0.0; - float clearCoatRoughness = 0.0; - float3 clearCoatNormal = float3(0.0, 0.0, 0.0); - float alpha = 1; + // Apply Decals + ApplyDecals(lightingData.tileIterator, surface); - PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, - normalWS, tangents[0], bitangents[0], anisotropy, - emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + // Apply Direct Lighting + ApplyDirectLighting(surface, lightingData); + + // Apply Image Based Lighting (IBL) + ApplyIBL(surface, lightingData); + + // Finalize Lighting + lightingData.FinalizeLighting(surface.transmission.tint); + + PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData); // ------- Preparing output ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.shader b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.shader index 592a8eeb34..b2bfd5e6bb 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.shader +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.shader @@ -42,5 +42,5 @@ ] }, - "DrawList" : "forward" + "DrawList" : "forwardWithSubsurfaceOutput" } diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index 9754698101..20bf7c1f2a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -13,6 +13,7 @@ #pragma once #include +#include #include #include "MaterialInputs/BaseColorInput.azsli" diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl index a7338188a2..560c7ab7eb 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR_ForwardPass.azsl @@ -10,10 +10,23 @@ * */ +// SRGs #include #include +#include + +// Pass Output #include + +// Utility #include +#include + +// Custom Surface & Lighting +#include + +// Decals +#include // ---------- Material Parameters ---------- @@ -47,6 +60,9 @@ DEFINE_LAYER_OPTIONS(o_layer3_) #include "MaterialInputs/TransmissionInput.azsli" #include "StandardMultilayerPBR_Common.azsli" + +// ---------- Vertex Shader ---------- + struct VSInput { // Base fields (required by the template azsli file)... @@ -83,8 +99,6 @@ struct VSOutput float3 m_blendMask : UV7; }; -#include -#include #include VSOutput ForwardPassVS(VSInput IN) @@ -115,6 +129,9 @@ VSOutput ForwardPassVS(VSInput IN) return OUT; } + +// ---------- Pixel Shader ---------- + PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depth) { depth = IN.m_position.z; @@ -144,14 +161,14 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float if(o_debugDrawMode == DebugDrawMode::BlendMaskValues) { float3 blendMaskValues = GetBlendMaskValues(IN.m_uv[MaterialSrg::m_blendMaskUvIndex], IN.m_blendMask); - return MakeDebugOutput(IN, blendMaskValues); + return DebugOutput(blendMaskValues); } if(o_debugDrawMode == DebugDrawMode::DepthMaps) { GetDepth_Setup(IN.m_blendMask); float depth = GetDepth(IN.m_uv[MaterialSrg::m_parallaxUvIndex], float2(0,0), float2(0,0)); - return MakeDebugOutput(IN, float3(depth,depth,depth)); + return DebugOutput(float3(depth,depth,depth)); } // ------- Parallax ------- @@ -179,6 +196,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float } } + Surface surface; + surface.position = IN.m_worldPosition; + // ------- Setup the per-layer UV transforms ------- float2 uvLayer1[UvSetCount]; @@ -222,7 +242,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float3 normalTS = ReorientTangentSpaceNormal(layer1_normalTS, layer2_normalTS); normalTS = ReorientTangentSpaceNormal(normalTS, layer3_normalTS); // [GFX TODO][ATOM-14591]: This will only work if the normal maps all use the same UV stream. We would need to add support for having them in different UV streams. - float3 normalWS = normalize(TangentSpaceToWorld(normalTS, IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex])); + surface.normal = normalize(TangentSpaceToWorld(normalTS, IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex])); // ------- Base Color ------- @@ -244,14 +264,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float layer3_metallic = GetMetallicInput(MaterialSrg::m_layer3_m_metallicMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_metallicMapUvIndex], MaterialSrg::m_layer3_m_metallicFactor, o_layer3_o_metallic_useTexture); metallic = BlendLayers(layer1_metallic, layer2_metallic, layer3_metallic, blendMaskValues); } - - // ------- Roughness ------- - - float layer1_roughness = GetRoughnessInput(MaterialSrg::m_layer1_m_roughnessMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_roughnessMapUvIndex], MaterialSrg::m_layer1_m_roughnessFactor, MaterialSrg::m_layer1_m_roughnessLowerBound, MaterialSrg::m_layer1_m_roughnessUpperBound, o_layer1_o_roughness_useTexture); - float layer2_roughness = GetRoughnessInput(MaterialSrg::m_layer2_m_roughnessMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_roughnessMapUvIndex], MaterialSrg::m_layer2_m_roughnessFactor, MaterialSrg::m_layer2_m_roughnessLowerBound, MaterialSrg::m_layer2_m_roughnessUpperBound, o_layer2_o_roughness_useTexture); - float layer3_roughness = GetRoughnessInput(MaterialSrg::m_layer3_m_roughnessMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_roughnessMapUvIndex], MaterialSrg::m_layer3_m_roughnessFactor, MaterialSrg::m_layer3_m_roughnessLowerBound, MaterialSrg::m_layer3_m_roughnessUpperBound, o_layer3_o_roughness_useTexture); - float roughness = BlendLayers(layer1_roughness, layer2_roughness, layer3_roughness, blendMaskValues); - + // ------- Specular ------- float layer1_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer1_m_specularF0Map, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularF0MapUvIndex], MaterialSrg::m_layer1_m_specularF0Factor, o_layer1_o_specularF0_useTexture); @@ -259,24 +272,16 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float layer3_specularF0Factor = GetSpecularInput(MaterialSrg::m_layer3_m_specularF0Map, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularF0MapUvIndex], MaterialSrg::m_layer3_m_specularF0Factor, o_layer3_o_specularF0_useTexture); float specularF0Factor = BlendLayers(layer1_specularF0Factor, layer2_specularF0Factor, layer3_specularF0Factor, blendMaskValues); - // ------- Emissive ------- - - float3 layer1_emissive = GetEmissiveInput(MaterialSrg::m_layer1_m_emissiveMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_emissiveMapUvIndex], MaterialSrg::m_layer1_m_emissiveIntensity, MaterialSrg::m_layer1_m_emissiveColor.rgb, o_layer1_o_emissiveEnabled, o_layer1_o_emissive_useTexture); - float3 layer2_emissive = GetEmissiveInput(MaterialSrg::m_layer2_m_emissiveMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_emissiveMapUvIndex], MaterialSrg::m_layer2_m_emissiveIntensity, MaterialSrg::m_layer2_m_emissiveColor.rgb, o_layer2_o_emissiveEnabled, o_layer2_o_emissive_useTexture); - float3 layer3_emissive = GetEmissiveInput(MaterialSrg::m_layer3_m_emissiveMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_emissiveMapUvIndex], MaterialSrg::m_layer3_m_emissiveIntensity, MaterialSrg::m_layer3_m_emissiveColor.rgb, o_layer3_o_emissiveEnabled, o_layer3_o_emissive_useTexture); - float3 emissive = BlendLayers(layer1_emissive, layer2_emissive, layer3_emissive, blendMaskValues); + surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic); - // ------- Occlusion ------- - - float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture); - float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture); - float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture); - float diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues); + // ------- Roughness ------- - float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture); - float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture); - float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture); - float specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues); + float layer1_roughness = GetRoughnessInput(MaterialSrg::m_layer1_m_roughnessMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_roughnessMapUvIndex], MaterialSrg::m_layer1_m_roughnessFactor, MaterialSrg::m_layer1_m_roughnessLowerBound, MaterialSrg::m_layer1_m_roughnessUpperBound, o_layer1_o_roughness_useTexture); + float layer2_roughness = GetRoughnessInput(MaterialSrg::m_layer2_m_roughnessMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_roughnessMapUvIndex], MaterialSrg::m_layer2_m_roughnessFactor, MaterialSrg::m_layer2_m_roughnessLowerBound, MaterialSrg::m_layer2_m_roughnessUpperBound, o_layer2_o_roughness_useTexture); + float layer3_roughness = GetRoughnessInput(MaterialSrg::m_layer3_m_roughnessMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_roughnessMapUvIndex], MaterialSrg::m_layer3_m_roughnessFactor, MaterialSrg::m_layer3_m_roughnessLowerBound, MaterialSrg::m_layer3_m_roughnessUpperBound, o_layer3_o_roughness_useTexture); + surface.roughnessLinear = BlendLayers(layer1_roughness, layer2_roughness, layer3_roughness, blendMaskValues); + + surface.CalculateRoughnessA(); // ------- Subsurface ------- @@ -287,14 +292,46 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float float2 transmissionUv = IN.m_uv[MaterialSrg::m_transmissionThicknessMapUvIndex]; float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness); + surface.transmission.tint = transmissionTintThickness.rgb; + surface.transmission.thickness = transmissionTintThickness.w; + surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams; + + // ------- Lighting Data ------- + + LightingData lightingData; + + // Light iterator + lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); + lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); + + // Directional light shadow coordinates + lightingData.shadowCoords = IN.m_shadowCoords; + + // ------- Emissive ------- + + float3 layer1_emissive = GetEmissiveInput(MaterialSrg::m_layer1_m_emissiveMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_emissiveMapUvIndex], MaterialSrg::m_layer1_m_emissiveIntensity, MaterialSrg::m_layer1_m_emissiveColor.rgb, o_layer1_o_emissiveEnabled, o_layer1_o_emissive_useTexture); + float3 layer2_emissive = GetEmissiveInput(MaterialSrg::m_layer2_m_emissiveMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_emissiveMapUvIndex], MaterialSrg::m_layer2_m_emissiveIntensity, MaterialSrg::m_layer2_m_emissiveColor.rgb, o_layer2_o_emissiveEnabled, o_layer2_o_emissive_useTexture); + float3 layer3_emissive = GetEmissiveInput(MaterialSrg::m_layer3_m_emissiveMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_emissiveMapUvIndex], MaterialSrg::m_layer3_m_emissiveIntensity, MaterialSrg::m_layer3_m_emissiveColor.rgb, o_layer3_o_emissiveEnabled, o_layer3_o_emissive_useTexture); + lightingData.emissiveLighting = BlendLayers(layer1_emissive, layer2_emissive, layer3_emissive, blendMaskValues); + + // ------- Occlusion ------- + + float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture); + float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture); + float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture); + lightingData.diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues); + + float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture); + float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture); + float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture); + lightingData.specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues); // ------- Clearcoat ------- - float clearCoatFactor = 0.0f; - float clearCoatRoughness = 0.0f; - float3 clearCoatNormal = float3(0.0, 0.0, 0.0); if(o_clearCoat_feature_enabled) { + // --- Layer 1 --- + float layer1_clearCoatFactor = 0.0f; float layer1_clearCoatRoughness = 0.0f; float3 layer1_clearCoatNormal = float3(0.0, 0.0, 0.0); @@ -310,6 +347,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float layer1_clearCoatFactor, layer1_clearCoatRoughness, layer1_clearCoatNormal); } + // --- Layer 2 --- + float layer2_clearCoatFactor = 0.0f; float layer2_clearCoatRoughness = 0.0f; float3 layer2_clearCoatNormal = float3(0.0, 0.0, 0.0); @@ -325,6 +364,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float layer2_clearCoatFactor, layer2_clearCoatRoughness, layer2_clearCoatNormal); } + // --- Layer 3 --- + float layer3_clearCoatFactor = 0.0f; float layer3_clearCoatRoughness = 0.0f; float3 layer3_clearCoatNormal = float3(0.0, 0.0, 0.0); @@ -340,22 +381,58 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float layer3_clearCoatFactor, layer3_clearCoatRoughness, layer3_clearCoatNormal); } - clearCoatFactor = BlendLayers(layer1_clearCoatFactor, layer2_clearCoatFactor, layer3_clearCoatFactor, blendMaskValues); - clearCoatRoughness = BlendLayers(layer1_clearCoatRoughness, layer2_clearCoatRoughness, layer3_clearCoatRoughness, blendMaskValues); + // --- Blend Layers --- + + surface.clearCoat.factor = BlendLayers(layer1_clearCoatFactor, layer2_clearCoatFactor, layer3_clearCoatFactor, blendMaskValues); + surface.clearCoat.roughness = BlendLayers(layer1_clearCoatRoughness, layer2_clearCoatRoughness, layer3_clearCoatRoughness, blendMaskValues); // [GFX TODO][ATOM-14592] This is not the right way to blend the normals. We need to use ReorientTangentSpaceNormal(), and that requires GetClearCoatInputs() to return the normal in TS instead of WS. - clearCoatNormal = BlendLayers(layer1_clearCoatNormal, layer2_clearCoatNormal, layer3_clearCoatNormal, blendMaskValues); - clearCoatNormal = normalize(clearCoatNormal); + surface.clearCoat.normal = BlendLayers(layer1_clearCoatNormal, layer2_clearCoatNormal, layer3_clearCoatNormal, blendMaskValues); + surface.clearCoat.normal = normalize(surface.clearCoat.normal); + + // manipulate base layer f0 if clear coat is enabled + // modify base layer's normal incidence reflectance + // for the derivation of the following equation please refer to: + // https://google.github.io/filament/Filament.md.html#materialsystem/clearcoatmodel/baselayermodification + float3 f0 = (1.0 - 5.0 * sqrt(surface.specularF0)) / (5.0 - sqrt(surface.specularF0)); + surface.specularF0 = lerp(surface.specularF0, f0 * f0, surface.clearCoat.factor); } + // Diffuse and Specular response (used in IBL calculations) + lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); + lightingData.diffuseResponse = 1.0 - lightingData.specularResponse; + + if(o_clearCoat_feature_enabled) + { + // Clear coat layer has fixed IOR = 1.5 and transparent => F0 = (1.5 - 1)^2 / (1.5 + 1)^2 = 0.04 + lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor); + } + + // ------- Multiscatter ------- + + lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation); + // ------- Lighting Calculation ------- - const float2 anisotropy = 0.0; // Does not affect calculations unless 'o_enableAnisotropy' is enabled + // Apply Decals + ApplyDecals(lightingData.tileIterator, surface); - PbrLightingOutput lightingOutput = PbrLighting(IN, - baseColor, metallic, roughness, specularF0Factor, - normalWS, tangents[0], bitangents[0], anisotropy, - emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode); + // Apply Direct Lighting + ApplyDirectLighting(surface, lightingData); + + // Apply Image Based Lighting (IBL) + ApplyIBL(surface, lightingData); + + // Finalize Lighting + lightingData.FinalizeLighting(surface.transmission.tint); + + + if (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent) + { + alpha = FresnelSchlickWithRoughness(lightingData.NdotV, alpha, surface.roughnessLinear).x; // Increase opacity at grazing angles. + } + + PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha); // ------- Opacity ------- @@ -375,7 +452,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // Pack factor and quality, drawback: because of precision limit of float16 cannot represent exact 1, maximum representable value is 0.9961 uint factorAndQuality = dot(round(float2(saturate(surfaceScatteringFactor), MaterialSrg::m_subsurfaceScatteringQuality) * 255), float2(256, 1)); lightingOutput.m_diffuseColor.w = factorAndQuality * (o_enableSubsurfaceScattering ? 1.0 : -1.0); - lightingOutput.m_scatterDistance = MaterialSrg::m_scatterDistance; } @@ -394,7 +470,6 @@ ForwardPassOutputWithDepth ForwardPassPS(VSOutput IN, bool isFrontFace : SV_IsFr OUT.m_specularF0 = lightingOutput.m_specularF0; OUT.m_albedo = lightingOutput.m_albedo; OUT.m_normal = lightingOutput.m_normal; - OUT.m_scatterDistance = lightingOutput.m_scatterDistance; OUT.m_depth = depth; return OUT; } @@ -412,7 +487,6 @@ ForwardPassOutput ForwardPassPS_EDS(VSOutput IN, bool isFrontFace : SV_IsFrontFa OUT.m_specularF0 = lightingOutput.m_specularF0; OUT.m_albedo = lightingOutput.m_albedo; OUT.m_normal = lightingOutput.m_normal; - OUT.m_scatterDistance = lightingOutput.m_scatterDistance; return OUT; } diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Common.azsli index 70137a88c1..1a7e039da3 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Common.azsli @@ -13,6 +13,7 @@ #pragma once #include +#include #include #include "MaterialInputs/BaseColorInput.azsli" diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DepthPass_WithPS.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DepthPass_WithPS.azsl index 2e64f5102a..4d4f7b195a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DepthPass_WithPS.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_DepthPass_WithPS.azsl @@ -10,7 +10,6 @@ * */ -#include #include #include "./StandardPBR_Common.azsli" #include diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl index 4c3da2b7d0..d3bc72d162 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_ForwardPass.azsl @@ -10,11 +10,25 @@ * */ -#include #include "StandardPBR_Common.azsli" + +// SRGs #include +#include + +// Pass Output #include + +// Utility #include +#include + +// Custom Surface & Lighting +#include + +// Decals +#include + // ---------- Material Parameters ---------- @@ -38,6 +52,8 @@ COMMON_OPTIONS_PARALLAX() #include "MaterialInputs/TransmissionInput.azsli" +// ---------- Vertex Shader ---------- + struct VSInput { // Base fields (required by the template azsli file)... @@ -66,8 +82,6 @@ struct VSOutput float2 m_uv[UvSetCount] : UV1; }; -#include -#include #include VSOutput StandardPbr_ForwardPassVS(VSInput IN) @@ -85,6 +99,9 @@ VSOutput StandardPbr_ForwardPassVS(VSInput IN) return OUT; } + +// ---------- Pixel Shader ---------- + PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float depth) { // ------- Tangents & Bitangets ------- @@ -112,7 +129,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float { float3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3(); float3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrixInverse : CreateIdentity3x3(); - GetParallaxInput(IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex], MaterialSrg::m_depthFactor, + GetParallaxInput(IN.m_normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex], MaterialSrg::m_depthFactor, ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse, IN.m_uv[MaterialSrg::m_parallaxUvIndex], IN.m_worldPosition, depth); @@ -130,7 +147,6 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float Surface surface; surface.position = IN.m_worldPosition.xyz; - // ------- Alpha & Clip ------- float2 baseColorUv = IN.m_uv[MaterialSrg::m_baseColorMapUvIndex]; @@ -162,9 +178,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Specular ------- float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex]; - float specularF0 = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture); + float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture); - surface.SetAlbedoAndSpecularF0(baseColor, specularF0, metallic); + surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic); // ------- Roughness ------- @@ -175,25 +191,8 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Subsurface ------- - float2 subsurfaceUv = IN.m_uv[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex]; - float surfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, MaterialSrg::m_subsurfaceScatteringFactor); - - // ------- Transmission ------- - - float2 transmissionUv = IN.m_uv[MaterialSrg::m_transmissionThicknessMapUvIndex]; - float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness); - surface.transmission.tint = transmissionTintThickness.rgb; - surface.transmission.thickness = transmissionTintThickness.w; - surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams; - - // ------- Anisotropy ------- - - if (o_enableAnisotropy) - { - const float anisotropyAngle = 0.0f; - const float anisotropyFactor = 0.0f; - surface.anisotropy.Init(surface.normal, tangents[0], bitangents[0], anisotropyAngle, anisotropyFactor, surface.roughnessA); - } + float surfaceScatteringFactor = 0.0f; + surface.transmission.InitializeToZero(); // ------- Lighting Data ------- @@ -250,9 +249,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor); } - // Multiscatter compensation factor - lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation); + // ------- Multiscatter ------- + lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation); // ------- Lighting Calculation ------- @@ -312,8 +311,8 @@ ForwardPassOutputWithDepth StandardPbr_ForwardPassPS(VSOutput IN, bool isFrontFa OUT.m_specularF0 = lightingOutput.m_specularF0; OUT.m_albedo = lightingOutput.m_albedo; OUT.m_normal = lightingOutput.m_normal; - OUT.m_scatterDistance = lightingOutput.m_scatterDistance; OUT.m_depth = depth; + return OUT; } @@ -330,7 +329,6 @@ ForwardPassOutput StandardPbr_ForwardPassPS_EDS(VSOutput IN, bool isFrontFace : OUT.m_specularF0 = lightingOutput.m_specularF0; OUT.m_albedo = lightingOutput.m_albedo; OUT.m_normal = lightingOutput.m_normal; - OUT.m_scatterDistance = lightingOutput.m_scatterDistance; return OUT; } diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Shadowmap_WithPS.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Shadowmap_WithPS.azsl index 4decbcd0df..e792c25778 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Shadowmap_WithPS.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/StandardPBR_Shadowmap_WithPS.azsl @@ -11,7 +11,6 @@ */ #include -#include #include "StandardPBR_Common.azsli" #include #include diff --git a/Gems/Atom/Feature/Common/Assets/Passes/ForwardMSAA.pass b/Gems/Atom/Feature/Common/Assets/Passes/ForwardMSAA.pass index 8c7e70efec..52cf3a2aaa 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/ForwardMSAA.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/ForwardMSAA.pass @@ -148,22 +148,6 @@ }, "LoadAction": "Clear" } - }, - { - "Name": "ScatterDistanceOutput", - "SlotType": "Output", - "ScopeAttachmentUsage": "RenderTarget", - "LoadStoreAction": { - "ClearValue": { - "Value": [ - 0.0, - 0.0, - 0.0, - 0.0 - ] - }, - "LoadAction": "Clear" - } } ], "ImageAttachments": [ @@ -258,23 +242,6 @@ "AssetRef": { "FilePath": "Textures/BRDFTexture.attimage" } - }, - { - "Name": "ScatterDistanceImage", - "SizeSource": { - "Source": { - "Pass": "Parent", - "Attachment": "SwapChainOutput" - } - }, - "MultisampleSource": { - "Pass": "This", - "Attachment": "DepthStencilInputOutput" - }, - "ImageDescriptor": { - "Format": "R11G11B10_FLOAT", - "SharedQueueMask": "Graphics" - } } ], "Connections": [ @@ -319,13 +286,6 @@ "Pass": "This", "Attachment": "BRDFTexture" } - }, - { - "LocalSlot": "ScatterDistanceOutput", - "AttachmentRef": { - "Pass": "This", - "Attachment": "ScatterDistanceImage" - } } ] } diff --git a/Gems/Atom/Feature/Common/Assets/Passes/ForwardSubsurfaceMSAA.pass b/Gems/Atom/Feature/Common/Assets/Passes/ForwardSubsurfaceMSAA.pass new file mode 100644 index 0000000000..7c3c49a0c9 --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/Passes/ForwardSubsurfaceMSAA.pass @@ -0,0 +1,158 @@ +{ + "Type": "JsonSerialization", + "Version": 1, + "ClassName": "PassAsset", + "ClassData": { + "PassTemplate": { + "Name": "ForwardSubsurfaceMSAAPassTemplate", + "PassClass": "RasterPass", + "Slots": [ + // Inputs... + { + "Name": "BRDFTextureInput", + "ShaderInputName": "m_brdfMap", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader" + }, + { + "Name": "DirectionalLightShadowmap", + "ShaderInputName": "m_directionalLightShadowmap", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader", + "ImageViewDesc": { + "IsArray": 1 + } + }, + { + "Name": "ExponentialShadowmapDirectional", + "ShaderInputName": "m_directionalLightExponentialShadowmap", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader", + "ImageViewDesc": { + "IsArray": 1 + } + }, + { + "Name": "ProjectedShadowmap", + "ShaderInputName": "m_projectedShadowmaps", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader", + "ImageViewDesc": { + "IsArray": 1 + } + }, + { + "Name": "ExponentialShadowmapProjected", + "ShaderInputName": "m_projectedExponentialShadowmap", + "SlotType": "Input", + "ScopeAttachmentUsage": "Shader", + "ImageViewDesc": { + "IsArray": 1 + } + }, + { + "Name": "TileLightData", + "SlotType": "Input", + "ShaderInputName": "m_tileLightData", + "ScopeAttachmentUsage": "Shader" + }, + { + "Name": "LightListRemapped", + "SlotType": "Input", + "ShaderInputName": "m_lightListRemapped", + "ScopeAttachmentUsage": "Shader" + }, + // Input/Outputs... + { + "Name": "DepthStencilInputOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "DepthStencil" + }, + { + "Name": "DiffuseOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget" + }, + { + "Name": "SpecularOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget" + }, + { + "Name": "AlbedoOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget" + }, + { + "Name": "SpecularF0Output", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget" + }, + { + "Name": "NormalOutput", + "SlotType": "InputOutput", + "ScopeAttachmentUsage": "RenderTarget" + }, + // Outputs... + { + "Name": "ScatterDistanceOutput", + "SlotType": "Output", + "ScopeAttachmentUsage": "RenderTarget", + "LoadStoreAction": { + "ClearValue": { + "Value": [ + 0.0, + 0.0, + 0.0, + 0.0 + ] + }, + "LoadAction": "Clear" + } + } + ], + "ImageAttachments": [ + { + "Name": "BRDFTexture", + "Lifetime": "Imported", + "AssetRef": { + "FilePath": "Textures/BRDFTexture.attimage" + } + }, + { + "Name": "ScatterDistanceImage", + "SizeSource": { + "Source": { + "Pass": "Parent", + "Attachment": "SwapChainOutput" + } + }, + "MultisampleSource": { + "Pass": "This", + "Attachment": "DepthStencilInputOutput" + }, + "ImageDescriptor": { + "Format": "R11G11B10_FLOAT", + "SharedQueueMask": "Graphics" + } + } + ], + "Connections": [ + { + "LocalSlot": "BRDFTextureInput", + "AttachmentRef": { + "Pass": "This", + "Attachment": "BRDFTexture" + } + }, + { + "LocalSlot": "ScatterDistanceOutput", + "AttachmentRef": { + "Pass": "This", + "Attachment": "ScatterDistanceImage" + } + } + ] + } + } +} \ No newline at end of file diff --git a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass index 42ba51ebec..dda120e164 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass +++ b/Gems/Atom/Feature/Common/Assets/Passes/OpaqueParent.pass @@ -127,6 +127,106 @@ } } }, + { + "Name": "ForwardSubsurfaceMSAAPass", + "TemplateName": "ForwardSubsurfaceMSAAPassTemplate", + "Connections": [ + // Inputs... + { + "LocalSlot": "DirectionalLightShadowmap", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "DirectionalShadowmap" + } + }, + { + "LocalSlot": "ExponentialShadowmapDirectional", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "DirectionalESM" + } + }, + { + "LocalSlot": "ProjectedShadowmap", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "ProjectedShadowmap" + } + }, + { + "LocalSlot": "ExponentialShadowmapProjected", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "ProjectedESM" + } + }, + { + "LocalSlot": "TileLightData", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "TileLightData" + } + }, + { + "LocalSlot": "LightListRemapped", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "LightListRemapped" + } + }, + // Input/Outputs... + { + "LocalSlot": "DepthStencilInputOutput", + "AttachmentRef": { + "Pass": "Parent", + "Attachment": "DepthStencil" + } + }, + { + "LocalSlot": "DiffuseOutput", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "DiffuseOutput" + } + }, + { + "LocalSlot": "SpecularOutput", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "SpecularOutput" + } + }, + { + "LocalSlot": "AlbedoOutput", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "AlbedoOutput" + } + }, + { + "LocalSlot": "SpecularF0Output", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "SpecularF0Output" + } + }, + { + "LocalSlot": "NormalOutput", + "AttachmentRef": { + "Pass": "ForwardMSAAPass", + "Attachment": "NormalOutput" + } + } + ], + "PassData": { + "$type": "RasterPassData", + "DrawListTag": "forwardWithSubsurfaceOutput", + "PipelineViewTag": "MainCamera", + "PassSrgAsset": { + "FilePath": "shaderlib/atom/features/pbr/forwardpasssrg.azsli:PassSrg" + } + } + }, { "Name": "DiffuseGlobalIlluminationPass", "TemplateName": "DiffuseGlobalIlluminationPassTemplate", @@ -320,7 +420,7 @@ { "LocalSlot": "Input", "AttachmentRef": { - "Pass": "ForwardMSAAPass", + "Pass": "ForwardSubsurfaceMSAAPass", "Attachment": "ScatterDistanceOutput" } } diff --git a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset index d83a96385f..b83ab65ff2 100644 --- a/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset +++ b/Gems/Atom/Feature/Common/Assets/Passes/PassTemplates.azasset @@ -48,6 +48,10 @@ "Name": "ForwardMSAAPassTemplate", "Path": "Passes/ForwardMSAA.pass" }, + { + "Name": "ForwardSubsurfaceMSAAPassTemplate", + "Path": "Passes/ForwardSubsurfaceMSAA.pass" + }, { "Name": "MainPipeline", "Path": "Passes/MainPipeline.pass" diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/AlphaUtils.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/AlphaUtils.azsli index 99f56f1fd3..09d8332ee8 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/AlphaUtils.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/AlphaUtils.azsli @@ -12,7 +12,6 @@ #pragma once -// TODO: Move this to LightingModel.azsli option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opacity_mode; void CheckClipping(float alpha, float opacityFactor) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 2df17a41a9..62f77dd701 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -1,7 +1,23 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + #pragma once +// ------------------------------------------------------------------------------ +// NOTE: The following must be included or defined before including this file: +// - Surface - LightingData +// --------------------------------------------------------------------------------- + #include -#include // Analytical integation (approximation) of diffusion profile over radius, could be replaced by other pre integrated kernels // such as sum of Gaussian diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Decals.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Decals.azsli index b452f08c22..d2eb978eb6 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Decals.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Decals.azsli @@ -12,23 +12,27 @@ #pragma once +// ------------------------------------------------------------------------------ +// NOTE: The following must be included or defined before including this file: +// - Surface +// --------------------------------------------------------------------------------- + #include #include #include -#include void ApplyDecal(uint currDecalIndex, inout Surface surface); void ApplyDecals(inout LightCullingTileIterator tileIterator, inout Surface surface) { tileIterator.LoadAdvance(); - - while( !tileIterator.IsDone() ) - { - uint currDecalIndex = tileIterator.GetValue(); + + while( !tileIterator.IsDone() ) + { + uint currDecalIndex = tileIterator.GetValue(); tileIterator.LoadAdvance(); - ApplyDecal(currDecalIndex, surface); + ApplyDecal(currDecalIndex, surface); } } @@ -44,13 +48,13 @@ float GetDecalAttenuation(float3 surfNormal, float3 decalUp, float decalAngleAtt void ApplyDecal(uint currDecalIndex, inout Surface surface) { - ViewSrg::Decal decal = ViewSrg::m_decals[currDecalIndex]; + ViewSrg::Decal decal = ViewSrg::m_decals[currDecalIndex]; float3x3 decalRot = MatrixFromQuaternion(decal.m_quaternion); - float3 localPos = surface.position - decal.m_position; + float3 localPos = surface.position - decal.m_position; localPos = mul(localPos, decalRot); - + float3 decalUVW = localPos * rcp(decal.m_halfSize); if(decalUVW.x >= -1.0f && decalUVW.x <= 1.0f && decalUVW.y >= -1.0f && decalUVW.y <= 1.0f && @@ -70,25 +74,23 @@ void ApplyDecal(uint currDecalIndex, inout Surface surface) switch(textureArrayIndex) { case 0: - baseMap = ViewSrg::m_decalTextureArray0.Sample(PassSrg::LinearSampler, decalUV); + baseMap = ViewSrg::m_decalTextureArray0.Sample(PassSrg::LinearSampler, decalUV); break; case 1: - baseMap = ViewSrg::m_decalTextureArray1.Sample(PassSrg::LinearSampler, decalUV); + baseMap = ViewSrg::m_decalTextureArray1.Sample(PassSrg::LinearSampler, decalUV); break; case 2: - baseMap = ViewSrg::m_decalTextureArray2.Sample(PassSrg::LinearSampler, decalUV); + baseMap = ViewSrg::m_decalTextureArray2.Sample(PassSrg::LinearSampler, decalUV); break; case 3: - baseMap = ViewSrg::m_decalTextureArray3.Sample(PassSrg::LinearSampler, decalUV); + baseMap = ViewSrg::m_decalTextureArray3.Sample(PassSrg::LinearSampler, decalUV); break; case 4: - baseMap = ViewSrg::m_decalTextureArray4.Sample(PassSrg::LinearSampler, decalUV); + baseMap = ViewSrg::m_decalTextureArray4.Sample(PassSrg::LinearSampler, decalUV); break; } - float opacity = baseMap.a * decal.m_opacity * GetDecalAttenuation(surface.normal, decalRot[2], decal.m_angleAttenuation); - surface.albedo = lerp(surface.albedo, baseMap.rgb, opacity); - } + float opacity = baseMap.a * decal.m_opacity * GetDecalAttenuation(surface.normal, decalRot[2], decal.m_angleAttenuation); + surface.albedo = lerp(surface.albedo, baseMap.rgb, opacity); + } } - - diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli index 5b47c1bb7e..acc215f1c9 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli @@ -17,7 +17,6 @@ struct ForwardPassOutput float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled - float3 m_scatterDistance : SV_Target5; }; struct ForwardPassOutputWithDepth @@ -29,6 +28,5 @@ struct ForwardPassOutputWithDepth float4 m_albedo : SV_Target2; float4 m_specularF0 : SV_Target3; float4 m_normal : SV_Target4; - float3 m_scatterDistance : SV_Target5; float m_depth : SV_Depth; }; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardSubsurfacePassOutput.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardSubsurfacePassOutput.azsli new file mode 100644 index 0000000000..351e33eaf5 --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/ForwardSubsurfacePassOutput.azsli @@ -0,0 +1,34 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +struct ForwardPassOutput +{ + // m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled + float4 m_diffuseColor : SV_Target0; + float4 m_specularColor : SV_Target1; + float4 m_albedo : SV_Target2; + float4 m_specularF0 : SV_Target3; + float4 m_normal : SV_Target4; + float3 m_scatterDistance : SV_Target5; +}; + +struct ForwardPassOutputWithDepth +{ + // m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled + float4 m_diffuseColor : SV_Target0; + float4 m_specularColor : SV_Target1; + float4 m_albedo : SV_Target2; + float4 m_specularF0 : SV_Target3; + float4 m_normal : SV_Target4; + float3 m_scatterDistance : SV_Target5; + float m_depth : SV_Depth; +}; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/EnhancedLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/EnhancedLighting.azsli new file mode 100644 index 0000000000..010de59ec9 --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/EnhancedLighting.azsli @@ -0,0 +1,115 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#pragma once + +// Include options first +#include + +// Then include custom surface and lighting data types +#include +#include + +#include +#include + +// Then define the Diffuse and Specular lighting functions +float3 GetDiffuseLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight) +{ + float3 diffuse; + if(o_enableSubsurfaceScattering) + { + // Use diffuse brdf contains double Fresnel (enter/exit surface) terms if subsurface scattering is enabled + diffuse = NormalizedDisneyDiffuse(surface.albedo, surface.normal, lightingData.dirToCamera, dirToLight, surface.roughnessLinear); + } + else + { + diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight); + } + + if(o_clearCoat_feature_enabled) + { + // Attenuate diffuse term by clear coat's fresnel term to account for energy loss + float HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera)); + diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor); + } + + diffuse *= lightIntensity; + return diffuse; +} + +float3 GetSpecularLighting(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight) +{ + float3 specular; + if (o_enableAnisotropy) + { + specular = AnisotropicGGX( lightingData.dirToCamera, dirToLight, surface.normal, surface.anisotropy.tangent, surface.anisotropy.bitangent, surface.anisotropy.anisotropyFactors, + surface.specularF0, lightingData.NdotV, lightingData.multiScatterCompensation ); + } + else + { + specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation); + } + + if(o_clearCoat_feature_enabled) + { + float3 halfVector = normalize(dirToLight + lightingData.dirToCamera); + float NdotH = saturate(dot(surface.clearCoat.normal, halfVector)); + float NdotL = saturate(dot(surface.clearCoat.normal, dirToLight)); + float HdotL = saturate(dot(halfVector, dirToLight)); + + // HdotV = HdotL due to the definition of half vector + float3 clearCoatF = FresnelSchlick(HdotL, 0.04) * surface.clearCoat.factor; + float clearCoatRoughness = max(surface.clearCoat.roughness * surface.clearCoat.roughness, 0.0005f); + float3 clearCoatSpecular = ClearCoatGGX(NdotH, HdotL, NdotL, surface.clearCoat.normal, clearCoatRoughness, clearCoatF ); + + specular = specular * (1.0 - clearCoatF) * (1.0 - clearCoatF) + clearCoatSpecular; + } + + specular *= lightIntensity; + + return specular; +} + + +// Then include everything else +#include +#include + + +struct PbrLightingOutput +{ + float4 m_diffuseColor; + float4 m_specularColor; + float4 m_albedo; + float4 m_specularF0; + float4 m_normal; + float3 m_scatterDistance; +}; + + +PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingData, float alpha) +{ + PbrLightingOutput lightingOutput; + + lightingOutput.m_diffuseColor = float4(lightingData.diffuseLighting, alpha); + lightingOutput.m_specularColor = float4(lightingData.specularLighting, 1.0); + + // albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc) + lightingOutput.m_specularF0 = float4(surface.specularF0, surface.roughnessLinear); + lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse * lightingData.diffuseAmbientOcclusion; + lightingOutput.m_albedo.a = lightingData.specularOcclusion; + lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal); + lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; + + return lightingOutput; +} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/SkinLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/SkinLighting.azsli new file mode 100644 index 0000000000..9f18d43f8b --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/SkinLighting.azsli @@ -0,0 +1,106 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#pragma once + +// Include options first +#include + +// Then include custom surface and lighting data types +#include +#include + +#include +#include + +// Then define the Diffuse and Specular lighting functions +float3 GetDiffuseLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight) +{ + float3 diffuse; + if(o_enableSubsurfaceScattering) + { + // Use diffuse brdf contains double Fresnel (enter/exit surface) terms if subsurface scattering is enabled + diffuse = NormalizedDisneyDiffuse(surface.albedo, surface.normal, lightingData.dirToCamera, dirToLight, surface.roughnessLinear); + } + else + { + diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight); + } + + if(o_clearCoat_feature_enabled) + { + // Attenuate diffuse term by clear coat's fresnel term to account for energy loss + float HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera)); + diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor); + } + + diffuse *= lightIntensity; + return diffuse; +} + +float3 GetSpecularLighting(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight) +{ + float3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation); + + if(o_clearCoat_feature_enabled) + { + float3 halfVector = normalize(dirToLight + lightingData.dirToCamera); + float NdotH = saturate(dot(surface.clearCoat.normal, halfVector)); + float NdotL = saturate(dot(surface.clearCoat.normal, dirToLight)); + float HdotL = saturate(dot(halfVector, dirToLight)); + + // HdotV = HdotL due to the definition of half vector + float3 clearCoatF = FresnelSchlick(HdotL, 0.04) * surface.clearCoat.factor; + float clearCoatRoughness = max(surface.clearCoat.roughness * surface.clearCoat.roughness, 0.0005f); + float3 clearCoatSpecular = ClearCoatGGX(NdotH, HdotL, NdotL, surface.clearCoat.normal, clearCoatRoughness, clearCoatF ); + + specular = specular * (1.0 - clearCoatF) * (1.0 - clearCoatF) + clearCoatSpecular; + } + + specular *= lightIntensity; + + return specular; +} + + +// Then include everything else +#include +#include + + +struct PbrLightingOutput +{ + float4 m_diffuseColor; + float4 m_specularColor; + float4 m_albedo; + float4 m_specularF0; + float4 m_normal; + float3 m_scatterDistance; +}; + + +PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingData) +{ + PbrLightingOutput lightingOutput; + + lightingOutput.m_diffuseColor = float4(lightingData.diffuseLighting, 1.0f); + lightingOutput.m_specularColor = float4(lightingData.specularLighting, 1.0f); + + // albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc) + lightingOutput.m_specularF0 = float4(surface.specularF0, surface.roughnessLinear); + lightingOutput.m_albedo.rgb = surface.albedo * lightingData.diffuseResponse * lightingData.diffuseAmbientOcclusion; + lightingOutput.m_albedo.a = lightingData.specularOcclusion; + lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal); + lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; + + return lightingOutput; +} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli index d0fb78a6d5..45aabeede4 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli @@ -19,6 +19,50 @@ #include #include +#include +#include + +// Then define the Diffuse and Specular lighting functions +float3 GetDiffuseLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight) +{ + float3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight); + + if(o_clearCoat_feature_enabled) + { + // Attenuate diffuse term by clear coat's fresnel term to account for energy loss + float HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera)); + diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor); + } + + diffuse *= lightIntensity; + return diffuse; +} + +float3 GetSpecularLighting(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight) +{ + float3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation); + + if(o_clearCoat_feature_enabled) + { + float3 halfVector = normalize(dirToLight + lightingData.dirToCamera); + float NdotH = saturate(dot(surface.clearCoat.normal, halfVector)); + float NdotL = saturate(dot(surface.clearCoat.normal, dirToLight)); + float HdotL = saturate(dot(halfVector, dirToLight)); + + // HdotV = HdotL due to the definition of half vector + float3 clearCoatF = FresnelSchlick(HdotL, 0.04) * surface.clearCoat.factor; + float clearCoatRoughness = max(surface.clearCoat.roughness * surface.clearCoat.roughness, 0.0005f); + float3 clearCoatSpecular = ClearCoatGGX(NdotH, HdotL, NdotL, surface.clearCoat.normal, clearCoatRoughness, clearCoatF ); + + specular = specular * (1.0 - clearCoatF) * (1.0 - clearCoatF) + clearCoatSpecular; + } + + specular *= lightIntensity; + + return specular; +} + + // Then include everything else #include #include @@ -31,7 +75,6 @@ struct PbrLightingOutput float4 m_albedo; float4 m_specularF0; float4 m_normal; - float4 m_clearCoatNormal; float3 m_scatterDistance; }; @@ -50,11 +93,17 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(surface.normal); lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f; - // layout: (packedNormal.x, packedNormal.y, strength factor, clear coat roughness (not base material's roughness)) - lightingOutput.m_clearCoatNormal = float4(EncodeNormalSphereMap(surface.clearCoat.normal), o_clearCoat_feature_enabled ? surface.clearCoat.factor : 0.0, surface.clearCoat.roughness); - return lightingOutput; } +PbrLightingOutput DebugOutput(float3 color) +{ + PbrLightingOutput output = (PbrLightingOutput)0; + float defaultNormal = float3(0.0f, 0.0f, 1.0f); + output.m_diffuseColor = float4(color.rgb, 1.0f); + output.m_normal.rgb = EncodeNormalSignedOctahedron(defaultNormal); + + return output; +} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli deleted file mode 100644 index a3a9c9ffd1..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingModel.azsli +++ /dev/null @@ -1,205 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#pragma once - -#include - -#include -#include - -#include - -#include -#include - -#include -#include - -#include -#include - -// VSInput, VSOutput, ObjectSrg must be defined before including this file. - -// DEPRECATED: Please use the VertexHelper(...) function in VertexHelper.azsli instead. -//! @param skipShadowCoords can be useful for example when PixelDepthOffset is enable, because the pixel shader will have to run before the final world position is known -void PbrVsHelper(in VSInput IN, inout VSOutput OUT, float3 worldPosition, bool skipShadowCoords = false) -{ - OUT.m_worldPosition = worldPosition; - OUT.m_position = mul(ViewSrg::m_viewProjectionMatrix, float4(OUT.m_worldPosition, 1.0)); - - float4x4 objectToWorld = ObjectSrg::GetWorldMatrix(); - float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose(); - - ConstructTBN(IN.m_normal, IN.m_tangent, IN.m_bitangent, objectToWorld, objectToWorldIT, OUT.m_normal, OUT.m_tangent, OUT.m_bitangent); - - // directional light shadow - const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; - if (o_enableShadows && !skipShadowCoords && shadowIndex < SceneSrg::m_directionalLightCount) - { - DirectionalLightShadow::GetShadowCoords( - shadowIndex, - worldPosition, - OUT.m_shadowCoords); - } -} - - -// DEPRECATED: Please use the functions in StandardLighting.azsli instead. -// For an example on how to use those functions, see StandardPBR_forwardPass.azsl -PbrLightingOutput PbrLighting( VSOutput IN, - float3 baseColor, - float metallic, - float roughness, - float specularF0Factor, - float3 normal, - float3 vtxTangent, - float3 vtxBitangent, - float2 anisotropy, // angle and factor - float3 emissive, - float diffuseAmbientOcclusion, - float specularOcclusion, - float4 transmissionTintThickness, - float4 transmissionParams, - float clearCoatFactor, - float clearCoatRoughness, - float3 clearCoatNormal, - float alpha, - OpacityMode opacityMode) -{ - float3 worldPosition = IN.m_worldPosition; - float4 position = IN.m_position; - float3 shadowCoords[ViewSrg::MaxCascadeCount] = IN.m_shadowCoords; - - // ______________________________________________________________________________________________ - // Surface - - Surface surface; - - surface.position = worldPosition; - surface.normal = normal; - surface.roughnessLinear = roughness; - surface.transmission.tint = transmissionTintThickness.rgb; - surface.transmission.thickness = transmissionTintThickness.w; - surface.transmission.transmissionParams = transmissionParams; - surface.clearCoat.factor = clearCoatFactor; - surface.clearCoat.roughness = clearCoatRoughness; - surface.clearCoat.normal = clearCoatNormal; - - surface.CalculateRoughnessA(); - surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic); - surface.anisotropy.Init(normal, vtxTangent, vtxBitangent, anisotropy.x, anisotropy.y, surface.roughnessA); - - // ______________________________________________________________________________________________ - // LightingData - - LightingData lightingData; - - // Light iterator - lightingData.tileIterator.Init(position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); - lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); - - lightingData.emissiveLighting = emissive; - lightingData.diffuseAmbientOcclusion = diffuseAmbientOcclusion; - lightingData.specularOcclusion = specularOcclusion; - - // Directional light shadow coordinates - lightingData.shadowCoords = shadowCoords; - - // manipulate base layer f0 if clear coat is enabled - if(o_clearCoat_feature_enabled) - { - // modify base layer's normal incidence reflectance - // for the derivation of the following equation please refer to: - // https://google.github.io/filament/Filament.md.html#materialsystem/clearcoatmodel/baselayermodification - float3 f0 = (1.0 - 5.0 * sqrt(surface.specularF0)) / (5.0 - sqrt(surface.specularF0)); - surface.specularF0 = lerp(surface.specularF0, f0 * f0, clearCoatFactor); - } - - // Diffuse and Specular response (used in IBL calculations) - lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); - lightingData.diffuseResponse = 1.0 - lightingData.specularResponse; - - if(o_clearCoat_feature_enabled) - { - // Clear coat layer has fixed IOR = 1.5 and transparent => F0 = (1.5 - 1)^2 / (1.5 + 1)^2 = 0.04 - lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor); - } - - // Multiscatter compensation factor - lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation); - - // ______________________________________________________________________________________________ - // Lighting - - // Apply Decals - ApplyDecals(lightingData.tileIterator, surface); - - // Apply Direct Lighting - ApplyDirectLighting(surface, lightingData); - - // Apply Image Based Lighting (IBL) - ApplyIBL(surface, lightingData); - - // Finalize Lighting - lightingData.FinalizeLighting(surface.transmission.tint); - - if (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent) - { - alpha = FresnelSchlickWithRoughness(lightingData.NdotV, alpha, surface.roughnessLinear).x; // Increase opacity at grazing angles. - } - - PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha); - - return lightingOutput; -} - -//! Populates a PbrLightingOutput struct with values that can be used to render a simple debug color in the PBR pipeline. -//! Note that this will not give you a the exact color screen pixels since it is used in the PBR pipeline, it may -//! still have lighting or other affects applied on top of it. But this is still a convenient way to quickly get some -//! colors on screen. -//! @param IN the pixel shader input structure -//! @param debugColor the color to be drawn -//! @param normalWS world space normal vector -//! @return a PbrLightingOutput as returned by the main PbrLighting() function - -PbrLightingOutput MakeDebugOutput(VSOutput IN, float3 debugColor, float3 normalWS) -{ - // We happen to set this up initially using baseColor, but we could consider adding an option to use - // emissive instead to avoid depending on scene lighting. - const float3 baseColor = debugColor; - const float metallic = 0; - const float roughness = 1; - const float specularF0Factor = 0.5; - const float3 normal = normalWS; - const float3 emissive = {0,0,0}; - const float occlusion = 1; - const float clearCoatFactor = 0.0f; - const float clearCoatRoughness = 0.0f; - const float3 clearCoatNormal = {0,0,0}; - const float4 transmissionTintThickness = {0,0,0,0}; - const float4 transmissionParams = {0,0,0,0}; - const float2 anisotropy = 0.0; // Does not affect calculations unless 'o_enableAnisotropy' is enabled - const float alpha = 1.0; - - PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, - normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); - - return lightingOutput; -} - -//! Same as above, using the vertex normal -PbrLightingOutput MakeDebugOutput(VSOutput IN, float3 debugColor) -{ - return MakeDebugOutput(IN, debugColor, normalize(IN.m_normal)); -} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli index a668691b75..ac28000148 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli @@ -16,71 +16,9 @@ #include #include -#include -#include -#include option bool o_area_light_validation = false; -float3 GetDiffuseLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight) -{ - float3 diffuse; - if(o_enableSubsurfaceScattering) - { - // Use diffuse brdf contains double Fresnel (enter/exit surface) terms if subsurface scattering is enabled - diffuse = NormalizedDisneyDiffuse(surface.albedo, surface.normal, lightingData.dirToCamera, dirToLight, surface.roughnessLinear); - } - else - { - diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight); - } - - if(o_clearCoat_feature_enabled) - { - // Attenuate diffuse term by clear coat's fresnel term to account for energy loss - float HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera)); - diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor); - } - - diffuse *= lightIntensity; - return diffuse; -} - -float3 GetSpecularLighting(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight) -{ - float3 specular; - if (o_enableAnisotropy) - { - //AnisotropicGGX( float3 dirToCamera, float3 dirToLight, float3 normal, float3 tangent, float3 bitangent, float2 anisotropyFactors, - // float3 specularF0, float NdotV, float multiScatterCompensation ) - - specular = AnisotropicGGX( lightingData.dirToCamera, dirToLight, surface.normal, surface.anisotropy.tangent, surface.anisotropy.bitangent, surface.anisotropy.anisotropyFactors, - surface.specularF0, lightingData.NdotV, lightingData.multiScatterCompensation ); - } - else - { - specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation); - } - - if(o_clearCoat_feature_enabled) - { - float3 halfVector = normalize(dirToLight + lightingData.dirToCamera); - float NdotH = saturate(dot(surface.clearCoat.normal, halfVector)); - float NdotL = saturate(dot(surface.clearCoat.normal, dirToLight)); - float HdotL = saturate(dot(halfVector, dirToLight)); - - // HdotV = HdotL due to the definition of half vector - float3 clearCoatF = FresnelSchlick(HdotL, 0.04) * surface.clearCoat.factor; - float clearCoatRoughness = max(surface.clearCoat.roughness * surface.clearCoat.roughness, 0.0005f); - float3 clearCoatSpecular = ClearCoatGGX(NdotH, HdotL, NdotL, surface.clearCoat.normal, clearCoatRoughness, clearCoatF ); - - specular = specular * (1.0 - clearCoatF) * (1.0 - clearCoatF) + clearCoatSpecular; - } - - specular *= lightIntensity; - - return specular; -} //! Adjust the intensity of specular light based on the radius of the light source and roughness of the surface to approximate energy conservation. float GetIntensityAdjustedByRadiusAndRoughness(float roughnessA, float radius, float distance2) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli index fa60e9485d..0f6c16f619 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli @@ -18,7 +18,6 @@ * rather than transmit. **/ -#include #include #include "Ggx.azsli" #include "Fresnel.azsli" @@ -81,9 +80,6 @@ float3 DiffuseTitanfall(float roughnessA, float3 albedo, float3 normal, float3 d } - - - // ------- Specular Lighting ------- //! Computes specular response from surfaces with microgeometry. The common form for microfacet diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surface.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surface.azsli deleted file mode 100644 index 104eaf140e..0000000000 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surface.azsli +++ /dev/null @@ -1,68 +0,0 @@ -/* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ - -#pragma once - -// //! The surface struct should contain all the info for a pixel that can be -// //! passed onto the rendering logic for shading. -// //! Note that metallic workflow can be supported by first converting to these physical properties first. -// struct Surface -// { -// float3 position; -// float3 normal; -// float3 tangentAniso; //! surface space tangent for anisotropic use -// float3 bitangentAniso; //! surface space bitangent for anisotropic use -// float2 anisotropyFactors; //! anisotory factors along the tangent and the bitangent directions -// float3 albedo; -// float3 specularF0; //!< actual fresnel f0 spectral value of the surface (as opposed to a "factor") -// float3 multiScatterCompensation; //!< the constant scaling term to approximate multiscattering contribution in specular BRDF -// float roughnessLinear; //!< perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use -// float roughnessA; //!< actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations -// float thickness; //!< pre baked local thickness, used for transmission -// float4 transmissionParams; //!< parameters: thick mode->(attenuation coefficient, power, distortion, scale), thin mode: (float3 scatter distance, scale) -// float clearCoatFactor; //!< clear coat strength factor -// float clearCoatRoughness; //!< clear coat linear roughness (not base layer one) -// float3 clearCoatNormal; //!< normal used for top layer clear coat -// }; -// -// //! Calculate and fill the data required for fast directional anisotropty surface response. -// //! Assumption: the normal and roughnessA surface properties were filled and are valid -// //! Notice that since the newly created surface tangent and bitangent will be rotated -// //! according to the anisotropy direction and should not be used for other purposes uness -// //! rotated back. -// void CalculateSurfaceDirectionalAnisotropicData( -// inout Surface surface, float2 anisotropyAngleAndFactor, -// float3 vtxTangent, float3 vtxBitangent ) -// { -// const float anisotropyAngle = anisotropyAngleAndFactor.x; -// const float anisotropyFactor = anisotropyAngleAndFactor.y; -// -// surface.anisotropyFactors = max( 0.01, -// float2( surface.roughnessA * (1.0 + anisotropyFactor), -// surface.roughnessA * (1.0 - anisotropyFactor) ) -// ); -// -// if (anisotropyAngle > 0.01) -// { -// // Base rotation according to anisotropic main direction -// float aniSin, aniCos; -// sincos(anisotropyAngle, aniSin, aniCos); -// -// // Rotate the vertex tangent to get new aligned to surface normal tangent -// vtxTangent = aniCos * vtxTangent - aniSin * vtxBitangent; -// } -// -// // Now create the new surface base according to the surface normal -// // If rotation was required it was already applied to the tangent, hence to the bitangent -// surface.bitangentAniso = normalize(cross(surface.normal, vtxTangent)); -// surface.tangentAniso = cross(surface.bitangentAniso, surface.normal); -// } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/BasePbrSurfaceData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/BasePbrSurfaceData.azsli index da4c44e1d8..ecb2a2f09b 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/BasePbrSurfaceData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/BasePbrSurfaceData.azsli @@ -43,7 +43,7 @@ class BasePbrSurfaceData void CalculateRoughnessA(); //! Sets albedo and specularF0 using metallic workflow - void SetAlbedoAndSpecularF0(float3 baseColor, float inSpecularF0, float metallic); + void SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic); }; // ------- Functions ------- @@ -63,6 +63,9 @@ void BasePbrSurfaceData::ApplySpecularAA() float kernelRoughnessA2 = min(2.0 * variance , varianceThresh ); float filteredRoughnessA2 = saturate ( roughnessA2 + kernelRoughnessA2 ); roughnessA2 = filteredRoughnessA2; + + roughnessA = sqrt(roughnessA2); + roughnessLinear = sqrt(roughnessA); } void BasePbrSurfaceData::CalculateRoughnessA() @@ -82,9 +85,9 @@ void BasePbrSurfaceData::CalculateRoughnessA() } } -void BasePbrSurfaceData::SetAlbedoAndSpecularF0(float3 baseColor, float inSpecularF0, float metallic) +void BasePbrSurfaceData::SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic) { - float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * inSpecularF0; + float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor; // Compute albedo and specularF0 based on metalness albedo = lerp(baseColor, float3(0.0f, 0.0f, 0.0f), metallic); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli index c0fc626075..71f0d8a0e8 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli @@ -17,4 +17,13 @@ class ClearCoatSurfaceData float factor; //!< clear coat strength factor float roughness; //!< clear coat linear roughness (not base layer one) float3 normal; //!< normal used for top layer clear coat + + void InitializeToZero(); }; + +void ClearCoatSurfaceData::InitializeToZero() +{ + factor = 0.0f; + roughness = 0.0f; + normal = float3(0.0f, 0.0f, 0.0f); +} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/EnhancedSurface.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/EnhancedSurface.azsli new file mode 100644 index 0000000000..baa50436dc --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/EnhancedSurface.azsli @@ -0,0 +1,90 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#pragma once + +#include +#include +#include +#include + +class Surface +{ + AnisotropicSurfaceData anisotropy; + ClearCoatSurfaceData clearCoat; + TransmissionSurfaceData transmission; + + // ------- BasePbrSurfaceData ------- + + float3 position; //!< Position in world-space + float3 normal; //!< Normal in world-space + float3 albedo; //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value + float3 specularF0; //!< Fresnel f0 spectral value of the surface + float roughnessLinear; //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use + float roughnessA; //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations + float roughnessA2; //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance + + //! Applies specular anti-aliasing to roughnessA2 + void ApplySpecularAA(); + + //! Calculates roughnessA and roughnessA2 after roughness has been set + void CalculateRoughnessA(); + + //! Sets albedo and specularF0 using metallic workflow + void SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic); + +}; + + +// Specular Anti-Aliasing technique from this paper: +// http://www.jp.square-enix.com/tech/library/pdf/ImprovedGeometricSpecularAA.pdf +void Surface::ApplySpecularAA() +{ + // Constants for formula below + const float screenVariance = 0.25f; + const float varianceThresh = 0.18f; + + // Specular Anti-Aliasing + float3 dndu = ddx_fine( normal ); + float3 dndv = ddy_fine( normal ); + float variance = screenVariance * (dot( dndu , dndu ) + dot( dndv , dndv )); + float kernelRoughnessA2 = min(2.0 * variance , varianceThresh ); + float filteredRoughnessA2 = saturate ( roughnessA2 + kernelRoughnessA2 ); + roughnessA2 = filteredRoughnessA2; +} + +void Surface::CalculateRoughnessA() +{ + // The roughness value in microfacet calculations (called "alpha" in the literature) does not give perceptually + // linear results. Disney found that squaring the roughness value before using it in microfacet equations causes + // the user-provided roughness parameter to be more perceptually linear. We keep both values available as some + // equations need roughnessLinear (i.e. IBL sampling) while others need roughnessA (i.e. GGX equations). + // See Burley's Disney PBR: https://pdfs.semanticscholar.org/eeee/3b125c09044d3e2f58ed0e4b1b66a677886d.pdf + + roughnessA = max(roughnessLinear * roughnessLinear, MinRoughnessA); + + roughnessA2 = roughnessA * roughnessA; + if(o_applySpecularAA) + { + ApplySpecularAA(); + } +} + +void Surface::SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic) +{ + float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor; + + // Compute albedo and specularF0 based on metalness + albedo = lerp(baseColor, float3(0.0f, 0.0f, 0.0f), metallic); + specularF0 = lerp(dielectricSpecularF0, baseColor, metallic); +} + diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/SkinSurface.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/SkinSurface.azsli new file mode 100644 index 0000000000..44a502b1b7 --- /dev/null +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/SkinSurface.azsli @@ -0,0 +1,86 @@ +/* +* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or +* its licensors. +* +* For complete copyright and license terms please see the LICENSE at the root of this +* distribution (the "License"). All use of this software is governed by the License, +* or, if provided, by the license below or the license accompanying this file. Do not +* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* +*/ + +#pragma once + +#include +#include +#include +#include + +class Surface +{ + ClearCoatSurfaceData clearCoat; + TransmissionSurfaceData transmission; + + // ------- BasePbrSurfaceData ------- + + float3 position; //!< Position in world-space + float3 normal; //!< Normal in world-space + float3 albedo; //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value + float3 specularF0; //!< Fresnel f0 spectral value of the surface + float roughnessLinear; //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use + float roughnessA; //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations + float roughnessA2; //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance + + //! Applies specular anti-aliasing to roughnessA2 + void ApplySpecularAA(); + + //! Calculates roughnessA and roughnessA2 after roughness has been set + void CalculateRoughnessA(); + + //! Sets albedo and specularF0 using metallic workflow + void SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor); + +}; + + +// Specular Anti-Aliasing technique from this paper: +// http://www.jp.square-enix.com/tech/library/pdf/ImprovedGeometricSpecularAA.pdf +void Surface::ApplySpecularAA() +{ + // Constants for formula below + const float screenVariance = 0.25f; + const float varianceThresh = 0.18f; + + // Specular Anti-Aliasing + float3 dndu = ddx_fine( normal ); + float3 dndv = ddy_fine( normal ); + float variance = screenVariance * (dot( dndu , dndu ) + dot( dndv , dndv )); + float kernelRoughnessA2 = min(2.0 * variance , varianceThresh ); + float filteredRoughnessA2 = saturate ( roughnessA2 + kernelRoughnessA2 ); + roughnessA2 = filteredRoughnessA2; +} + +void Surface::CalculateRoughnessA() +{ + // The roughness value in microfacet calculations (called "alpha" in the literature) does not give perceptually + // linear results. Disney found that squaring the roughness value before using it in microfacet equations causes + // the user-provided roughness parameter to be more perceptually linear. We keep both values available as some + // equations need roughnessLinear (i.e. IBL sampling) while others need roughnessA (i.e. GGX equations). + // See Burley's Disney PBR: https://pdfs.semanticscholar.org/eeee/3b125c09044d3e2f58ed0e4b1b66a677886d.pdf + + roughnessA = max(roughnessLinear * roughnessLinear, MinRoughnessA); + + roughnessA2 = roughnessA * roughnessA; + if(o_applySpecularAA) + { + ApplySpecularAA(); + } +} + +void Surface::SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor) +{ + albedo = baseColor; + specularF0 = MaxDielectricSpecularF0 * specularF0Factor; +} + diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli index 9d4163c474..bb63d27df0 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli @@ -17,10 +17,8 @@ #include #include -class Surface //: BasePbrSurfaceData +class Surface { - //BasePbrSurfaceData pbr; - AnisotropicSurfaceData anisotropy; ClearCoatSurfaceData clearCoat; TransmissionSurfaceData transmission; @@ -41,7 +39,7 @@ class Surface //: BasePbrSurfaceData void CalculateRoughnessA(); //! Sets albedo and specularF0 using metallic workflow - void SetAlbedoAndSpecularF0(float3 baseColor, float inSpecularF0, float metallic); + void SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic); }; @@ -80,9 +78,9 @@ void Surface::CalculateRoughnessA() } } -void Surface::SetAlbedoAndSpecularF0(float3 baseColor, float inSpecularF0, float metallic) +void Surface::SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic) { - float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * inSpecularF0; + float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor; // Compute albedo and specularF0 based on metalness albedo = lerp(baseColor, float3(0.0f, 0.0f, 0.0f), metallic); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli index 987e4ea575..cff91d5180 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli @@ -17,4 +17,13 @@ class TransmissionSurfaceData float3 tint; float thickness; //!< pre baked local thickness, used for transmission float4 transmissionParams; //!< parameters: thick mode->(attenuation coefficient, power, distortion, scale), thin mode: (float3 scatter distance, scale) + + void InitializeToZero(); }; + +void TransmissionSurfaceData::InitializeToZero() +{ + tint = float3(0.0f, 0.0f, 0.0f); + thickness = 0.0f; + transmissionParams = float4(0.0f, 0.0f, 0.0f, 0.0f); +} diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Vertex/VertexHelper.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Vertex/VertexHelper.azsli index 24cca8dc87..eaac9d82df 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Vertex/VertexHelper.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Vertex/VertexHelper.azsli @@ -13,7 +13,9 @@ #pragma once // ------------------------------------------------------------------------------ -// NOTE: VSInput, VSOutput, ObjectSrg must be defined before including this file. +// NOTE: The following must be included or defined before including this file: +// - VSInput - ObjectSrg +// - VSOutput - PassSrg // --------------------------------------------------------------------------------- // Options @@ -23,8 +25,6 @@ #include #include #include -#include -#include // Math #include @@ -33,7 +33,6 @@ // Shadow Coords #include - //! @param skipShadowCoords can be useful for example when PixelDepthOffset is enable, because the pixel shader will have to run before the final world position is known void VertexHelper(in VSInput IN, inout VSOutput OUT, float3 worldPosition, bool skipShadowCoords = false) { diff --git a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake index fd199d59f1..f14fb4f4a0 100644 --- a/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake +++ b/Gems/Atom/Feature/Common/Assets/atom_feature_common_asset_files.cmake @@ -140,6 +140,7 @@ set(FILES Passes/Forward.pass Passes/ForwardCheckerboard.pass Passes/ForwardMSAA.pass + Passes/ForwardSubsurfaceMSAA.pass Passes/FullscreenCopy.pass Passes/FullscreenOutputOnly.pass Passes/ImGui.pass @@ -164,6 +165,7 @@ set(FILES Passes/MSAAResolveDepth.pass Passes/OpaqueParent.pass Passes/PostProcessParent.pass + Passes/ProjectedShadowmaps.pass Passes/RayTracingAccelerationStructure.pass Passes/ReflectionComposite.pass Passes/ReflectionCopyFrameBuffer.pass @@ -190,7 +192,6 @@ set(FILES Passes/SMAAConvertToPerceptualColor.pass Passes/SMAAEdgeDetection.pass Passes/SMAANeighborhoodBlending.pass - Passes/ProjectedShadowmaps.pass Passes/SsaoCompute.pass Passes/SsaoHalfRes.pass Passes/SsaoParent.pass @@ -229,14 +230,15 @@ set(FILES ShaderLib/Atom/Features/PBR/DefaultObjectSrg.azsli ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli ShaderLib/Atom/Features/PBR/ForwardPassSrg.azsli + ShaderLib/Atom/Features/PBR/ForwardSubsurfacePassOutput.azsli ShaderLib/Atom/Features/PBR/Hammersley.azsli - ShaderLib/Atom/Features/PBR/LightingModel.azsli ShaderLib/Atom/Features/PBR/LightingOptions.azsli ShaderLib/Atom/Features/PBR/LightingUtils.azsli - ShaderLib/Atom/Features/PBR/Surface.azsli ShaderLib/Atom/Features/PBR/TransparentPassSrg.azsli ShaderLib/Atom/Features/PBR/Lighting/DualSpecularLighting.azsli + ShaderLib/Atom/Features/PBR/Lighting/EnhancedLighting.azsli ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli + ShaderLib/Atom/Features/PBR/Lighting/SkinLighting.azsli ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -248,6 +250,8 @@ set(FILES ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli ShaderLib/Atom/Features/PBR/Lights/PolygonLight.azsli ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli + ShaderLib/Atom/Features/PBR/Lights/SimplePointLight.azsli + ShaderLib/Atom/Features/PBR/Lights/SimpleSpotLight.azsli ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli ShaderLib/Atom/Features/PBR/Microfacet/Fresnel.azsli ShaderLib/Atom/Features/PBR/Microfacet/Ggx.azsli @@ -255,6 +259,8 @@ set(FILES ShaderLib/Atom/Features/PBR/Surfaces/BasePbrSurfaceData.azsli ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli ShaderLib/Atom/Features/PBR/Surfaces/DualSpecularSurface.azsli + ShaderLib/Atom/Features/PBR/Surfaces/EnhancedSurface.azsli + ShaderLib/Atom/Features/PBR/Surfaces/SkinSurface.azsli ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli ShaderLib/Atom/Features/PostProcessing/Aces.azsli @@ -270,9 +276,12 @@ set(FILES ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli ShaderLib/Atom/Features/Shadow/JitterTablePcf.azsli + ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli ShaderLib/Atom/Features/Shadow/Shadow.azsli ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli - ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli + ShaderLib/Atom/Features/Vertex/VertexHelper.azsli + ShaderResourceGroups/RayTracingSceneSrg.azsli + ShaderResourceGroups/RayTracingSceneSrgAll.azsli ShaderResourceGroups/SceneSrg.azsli ShaderResourceGroups/SceneSrgAll.azsli ShaderResourceGroups/SceneTimeSrg.azsli diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering.material index 847782c37a..37a9b1144e 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering.material @@ -1,6 +1,6 @@ { "description": "", - "materialType": "Materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/EnhancedPBR.materialtype", "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { @@ -9,8 +9,8 @@ "influenceMap": "TestData/Textures/checker8x8_512.png", "scatterColor": [ 1.0, - 0.19937437772750855, - 0.07179369777441025, + 0.20000000298023225, + 0.07058823853731156, 1.0 ], "scatterDistance": 40.0, diff --git a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering_Transmission.material b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering_Transmission.material index 53546d6c27..dbaf6cb587 100644 --- a/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering_Transmission.material +++ b/Gems/Atom/TestData/TestData/Materials/StandardPbrTestCases/015_SubsurfaceScattering_Transmission.material @@ -1,11 +1,12 @@ { "description": "", - "materialType": "Materials/Types/StandardPBR.materialtype", + "materialType": "Materials/Types/EnhancedPBR.materialtype", "parentMaterial": "", "propertyLayoutVersion": 3, "properties": { "subsurfaceScattering": { "enableSubsurfaceScattering": true, + "enableTransmission": true, "scatterDistance": 64.6464614868164, "subsurfaceScatterFactor": 1.0, "thicknessMap": "TestData/Textures/checker8x8_512.png", diff --git a/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl b/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl index 770da549d0..793b71b3af 100644 --- a/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl +++ b/Gems/Atom/TestData/TestData/Materials/Types/AutoBrick_ForwardPass.azsl @@ -14,9 +14,12 @@ #include "AutoBrick_Common.azsli" #include #include +#include #include #include #include +#include +#include struct VSInput { @@ -38,7 +41,6 @@ struct VSOutput float2 m_uv : UV1; }; -#include #include VSOutput AutoBrick_ForwardPassVS(VSInput IN) @@ -129,8 +131,6 @@ float GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy) ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) { - ForwardPassOutput OUT; - float3x3 identityUvMatrix = { 1,0,0, 0,1,0, @@ -164,23 +164,62 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) GetSurfaceShape(IN.m_uv, surfaceDepth, surfaceNormal); const float3 normal = TangentSpaceToWorld(surfaceNormal, normalize(IN.m_normal), normalize(IN.m_tangent), normalize(IN.m_bitangent)); - const float diffuseAmbientOcclusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor; - const float specularOcclusion = 1; - const float metallic = 0; - const float roughness = 1; - const float specularF0Factor = 0.5; - const float3 emissive = {0,0,0}; - const float clearCoatFactor = 0.0; - const float clearCoatRoughness = 0.0; - const float3 clearCoatNormal = {0,0,0}; - const float4 transmissionTintThickness = {0,0,0,0}; - const float4 transmissionParams = {0,0,0,0}; - const float2 anisotropy = 0.0; - const float alpha = 1.0; + // ------- Surface ------- - PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, - normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + Surface surface; + + // Position, Normal, Roughness + surface.position = IN.m_worldPosition.xyz; + surface.normal = normalize(normal); + surface.roughnessLinear = 1.0f; + surface.CalculateRoughnessA(); + + // Albedo, SpecularF0 + const float metallic = 0.0f; + const float specularF0Factor = 0.5f; + surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic); + + // Clear Coat, Transmission + surface.clearCoat.InitializeToZero(); + surface.transmission.InitializeToZero(); + + // ------- LightingData ------- + + LightingData lightingData; + + // Light iterator + lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); + lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); + + // Shadow + lightingData.shadowCoords = IN.m_shadowCoords; + lightingData.diffuseAmbientOcclusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor; + + // Diffuse and Specular response + lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); + lightingData.diffuseResponse = 1.0f - lightingData.specularResponse; + + const float alpha = 1.0f; + + // ------- Lighting Calculation ------- + + // Apply Decals + ApplyDecals(lightingData.tileIterator, surface); + + // Apply Direct Lighting + ApplyDirectLighting(surface, lightingData); + + // Apply Image Based Lighting (IBL) + ApplyIBL(surface, lightingData); + + // Finalize Lighting + lightingData.FinalizeLighting(surface.transmission.tint); + + PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha); + + // ------- Output ------- + + ForwardPassOutput OUT; OUT.m_diffuseColor = lightingOutput.m_diffuseColor; OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled @@ -188,7 +227,6 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN) OUT.m_specularF0 = lightingOutput.m_specularF0; OUT.m_albedo = lightingOutput.m_albedo; OUT.m_normal = lightingOutput.m_normal; - OUT.m_scatterDistance = float3(0,0,0); return OUT; } diff --git a/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl b/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl index c11a092333..96d5f05e6e 100644 --- a/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl +++ b/Gems/Atom/TestData/TestData/Materials/Types/MinimalPBR_ForwardPass.azsl @@ -12,10 +12,13 @@ #include #include +#include #include #include #include #include +#include +#include ShaderResourceGroup MinimalPBRSrg : SRG_PerMaterial { @@ -42,7 +45,6 @@ struct VSOutput float3 m_shadowCoords[ViewSrg::MaxCascadeCount] : UV3; }; -#include #include VSOutput MinimalPBR_MainPassVS(VSInput IN) @@ -58,26 +60,60 @@ VSOutput MinimalPBR_MainPassVS(VSInput IN) ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN) { - ForwardPassOutput OUT; - - const float3 baseColor = MinimalPBRSrg::m_baseColor; - const float metallic = MinimalPBRSrg::m_metallic; - const float roughness = MinimalPBRSrg::m_roughness; - const float specularF0Factor = 0.5; - const float3 normal = normalize(IN.m_normal); - const float3 emissive = {0,0,0}; - const float occlusion = 1; - const float clearCoatFactor = 0.0; - const float clearCoatRoughness = 0.0; - const float3 clearCoatNormal = {0,0,0}; - const float4 transmissionTintThickness = {0,0,0,0}; - const float4 transmissionParams = {0,0,0,0}; - const float2 anisotropy = 0.0; // Does not affect calculations unless 'o_enableAnisotropy' is enabled - const float alpha = 1.0; + // ------- Surface ------- - PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor, - normal, IN.m_tangent, IN.m_bitangent, anisotropy, - emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque); + Surface surface; + + // Position, Normal, Roughness + surface.position = IN.m_worldPosition.xyz; + surface.normal = normalize(IN.m_normal); + surface.roughnessLinear = MinimalPBRSrg::m_roughness; + surface.CalculateRoughnessA(); + + // Albedo, SpecularF0 + const float specularF0Factor = 0.5f; + surface.SetAlbedoAndSpecularF0(MinimalPBRSrg::m_baseColor, specularF0Factor, MinimalPBRSrg::m_metallic); + + // Clear Coat, Transmission + surface.clearCoat.InitializeToZero(); + surface.transmission.InitializeToZero(); + + // ------- LightingData ------- + + LightingData lightingData; + + // Light iterator + lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData); + lightingData.Init(surface.position, surface.normal, surface.roughnessLinear); + + // Shadow, Occlusion + lightingData.shadowCoords = IN.m_shadowCoords; + + // Diffuse and Specular response + lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); + lightingData.diffuseResponse = 1.0f - lightingData.specularResponse; + + const float alpha = 1.0f; + + // ------- Lighting Calculation ------- + + // Apply Decals + ApplyDecals(lightingData.tileIterator, surface); + + // Apply Direct Lighting + ApplyDirectLighting(surface, lightingData); + + // Apply Image Based Lighting (IBL) + ApplyIBL(surface, lightingData); + + // Finalize Lighting + lightingData.FinalizeLighting(surface.transmission.tint); + + PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha); + + // ------- Output ------- + + ForwardPassOutput OUT; OUT.m_diffuseColor = lightingOutput.m_diffuseColor; OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled @@ -85,7 +121,6 @@ ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN) OUT.m_specularF0 = lightingOutput.m_specularF0; OUT.m_albedo = lightingOutput.m_albedo; OUT.m_normal = lightingOutput.m_normal; - OUT.m_scatterDistance = float3(0,0,0); return OUT; } diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp index eac4213867..976b8f4267 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.cpp @@ -53,16 +53,20 @@ namespace AZ ->Attribute(AZ::Edit::Attributes::ViewportIcon, "editor/icons/components/viewport/component_placeholder.png") ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("Game", 0x232b318c)) ->Attribute(AZ::Edit::Attributes::AutoExpand, true) + ->Attribute(AZ::Edit::Attributes::Visibility, AZ::Edit::PropertyVisibility::ShowChildrenOnly) ->Attribute(AZ::Edit::Attributes::PrimaryAssetType, AZ::AzTypeInfo::Uuid()) - ->ClassElement(AZ::Edit::ClassElements::Group, "Cubemap") + ->ClassElement(AZ::Edit::ClassElements::Group, "Cubemap Bake") ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->DataElement(AZ::Edit::UIHandlers::Default, &EditorReflectionProbeComponent::m_useBakedCubemap, "Use Baked Cubemap", "Selects between a cubemap that captures the environment at location in the scene or a preauthored cubemap") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorReflectionProbeComponent::OnUseBakedCubemapChanged) ->UIElement(AZ::Edit::UIHandlers::Button, "Bake Reflection Probe", "Bake Reflection Probe") ->Attribute(AZ::Edit::Attributes::NameLabelOverride, "") ->Attribute(AZ::Edit::Attributes::ButtonText, "Bake Reflection Probe") ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorReflectionProbeComponent::BakeReflectionProbe) ->Attribute(AZ::Edit::Attributes::Visibility, &EditorReflectionProbeComponent::GetBakedCubemapVisibilitySetting) + ->ClassElement(AZ::Edit::ClassElements::Group, "Cubemap") + ->Attribute(AZ::Edit::Attributes::AutoExpand, true) + ->DataElement(AZ::Edit::UIHandlers::Default, &EditorReflectionProbeComponent::m_useBakedCubemap, "Use Baked Cubemap", "Selects between a cubemap that captures the environment at location in the scene or a preauthored cubemap") + ->Attribute(AZ::Edit::Attributes::ChangeValidate, &EditorReflectionProbeComponent::OnUseBakedCubemapValidate) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorReflectionProbeComponent::OnUseBakedCubemapChanged) ->DataElement(AZ::Edit::UIHandlers::MultiLineEdit, &EditorReflectionProbeComponent::m_bakedCubeMapRelativePath, "Baked Cubemap Path", "Baked Cubemap Path") ->Attribute(AZ::Edit::Attributes::ReadOnly, true) ->Attribute(AZ::Edit::Attributes::Visibility, &EditorReflectionProbeComponent::GetBakedCubemapVisibilitySetting) @@ -188,6 +192,16 @@ namespace AZ return false; } + AZ::Outcome EditorReflectionProbeComponent::OnUseBakedCubemapValidate([[maybe_unused]] void* newValue, [[maybe_unused]] const AZ::Uuid& valueType) + { + if (!m_controller.m_featureProcessor) + { + return AZ::Failure(AZStd::string("This Reflection Probe entity is hidden, it must be visible in order to change the cubemap type.")); + } + + return AZ::Success(); + } + AZ::u32 EditorReflectionProbeComponent::OnUseBakedCubemapChanged() { // save setting to the configuration diff --git a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.h b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.h index 5b992ae5aa..eba9575ec4 100644 --- a/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.h +++ b/Gems/AtomLyIntegration/CommonFeatures/Code/Source/ReflectionProbe/EditorReflectionProbeComponent.h @@ -47,6 +47,9 @@ namespace AZ void DisplayEntityViewport(const AzFramework::ViewportInfo& viewportInfo, AzFramework::DebugDisplayRequests& debugDisplay) override; private: + // validation + AZ::Outcome OnUseBakedCubemapValidate(void* newValue, const AZ::Uuid& valueType); + // change notifications AZ::u32 OnUseBakedCubemapChanged(); AZ::u32 OnAuthoredCubemapChanged(); diff --git a/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.cpp b/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.cpp index d0b24cb203..518db289e2 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Assets/ActorAsset.cpp @@ -68,6 +68,8 @@ namespace EMotionFX &actorSettings, ""); + assetData->ReleaseEMotionFXData(); + if (!assetData->m_emfxActor) { AZ_Error("EMotionFX", false, "Failed to initialize actor asset %s", asset.ToString().c_str()); @@ -77,7 +79,6 @@ namespace EMotionFX assetData->m_emfxActor->SetIsOwnedByRuntime(true); // Note: Render actor depends on the mesh asset, so we need to manually create it after mesh asset has been loaded. - return static_cast(assetData->m_emfxActor); } diff --git a/Gems/EMotionFX/Code/Source/Integration/Assets/AnimGraphAsset.cpp b/Gems/EMotionFX/Code/Source/Integration/Assets/AnimGraphAsset.cpp index 82bb487d2e..a8b9746789 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Assets/AnimGraphAsset.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Assets/AnimGraphAsset.cpp @@ -90,6 +90,7 @@ namespace EMotionFX } } + assetData->ReleaseEMotionFXData(); AZ_Error("EMotionFX", assetData->m_emfxAnimGraph, "Failed to initialize anim graph asset %s", asset.GetHint().c_str()); return static_cast(assetData->m_emfxAnimGraph); } diff --git a/Gems/EMotionFX/Code/Source/Integration/Assets/AssetCommon.h b/Gems/EMotionFX/Code/Source/Integration/Assets/AssetCommon.h index 2936076258..ca0f6d996d 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Assets/AssetCommon.h +++ b/Gems/EMotionFX/Code/Source/Integration/Assets/AssetCommon.h @@ -36,6 +36,12 @@ namespace EMotionFX : AZ::Data::AssetData(id) {} + void ReleaseEMotionFXData() + { + m_emfxNativeData.clear(); + m_emfxNativeData.shrink_to_fit(); + } + AZStd::vector m_emfxNativeData; }; diff --git a/Gems/EMotionFX/Code/Source/Integration/Assets/MotionAsset.cpp b/Gems/EMotionFX/Code/Source/Integration/Assets/MotionAsset.cpp index 6bcc572ec6..2d95066b13 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Assets/MotionAsset.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Assets/MotionAsset.cpp @@ -47,6 +47,7 @@ namespace EMotionFX assetData->m_emfxMotion->SetIsOwnedByRuntime(true); } + assetData->ReleaseEMotionFXData(); AZ_Error("EMotionFX", assetData->m_emfxMotion, "Failed to initialize motion asset %s", asset.GetHint().c_str()); return (assetData->m_emfxMotion); } diff --git a/Gems/EMotionFX/Code/Source/Integration/Assets/MotionSetAsset.cpp b/Gems/EMotionFX/Code/Source/Integration/Assets/MotionSetAsset.cpp index f437cea256..a49dd95986 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Assets/MotionSetAsset.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Assets/MotionSetAsset.cpp @@ -232,6 +232,7 @@ namespace EMotionFX // Set motion set's motion load callback, so if EMotion FX queries back for a motion, // we can pull the one managed through an AZ::Asset. assetData->m_emfxMotionSet->SetCallback(aznew CustomMotionSetCallback(asset)); + assetData->ReleaseEMotionFXData(); return true; } diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp index d60ecf622e..2e0ca16af2 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.cpp @@ -43,6 +43,7 @@ namespace EMotionFX ->Field("BlendIn", &Configuration::m_blendInTime) ->Field("BlendOut", &Configuration::m_blendOutTime) ->Field("PlayOnActivation", &Configuration::m_playOnActivation) + ->Field("InPlace", &Configuration::m_inPlace) ; AZ::EditContext* editContext = serializeContext->GetEditContext(); @@ -61,7 +62,9 @@ namespace EMotionFX ->Attribute(AZ::Edit::Attributes::Min, 0.0f) ->DataElement(AZ::Edit::UIHandlers::Default, &Configuration::m_blendOutTime, "Blend Out Time", "Determines the blend out time in seconds") ->Attribute(AZ::Edit::Attributes::Min, 0.0f) - ->DataElement(AZ::Edit::UIHandlers::Default, &Configuration::m_playOnActivation, "Play on active", "Playing animation immediately after activition.") + ->DataElement(AZ::Edit::UIHandlers::Default, &Configuration::m_playOnActivation, "Play on active", "Playing animation immediately after activation.") + ->DataElement(AZ::Edit::UIHandlers::Default, &Configuration::m_inPlace, "In-place", + "Plays the animation in-place and removes any positional and rotational changes from root joints.") ; } } @@ -128,6 +131,7 @@ namespace EMotionFX , m_blendInTime(0.0f) , m_blendOutTime(0.0f) , m_playOnActivation(true) + , m_inPlace(false) { } @@ -235,7 +239,7 @@ namespace EMotionFX void SimpleMotionComponent::PlayMotion() { - m_motionInstance = PlayMotionInternal(m_actorInstance.get(), m_configuration, /*deleteOnZeroWeight*/true, /*inPlace*/false); + m_motionInstance = PlayMotionInternal(m_actorInstance.get(), m_configuration, /*deleteOnZeroWeight*/true); } void SimpleMotionComponent::RemoveMotionInstanceFromActor(EMotionFX::MotionInstance* motionInstance) @@ -425,7 +429,7 @@ namespace EMotionFX return m_configuration.m_blendOutTime; } - EMotionFX::MotionInstance* SimpleMotionComponent::PlayMotionInternal(const EMotionFX::ActorInstance* actorInstance, const SimpleMotionComponent::Configuration& cfg, bool deleteOnZeroWeight, bool inPlace) + EMotionFX::MotionInstance* SimpleMotionComponent::PlayMotionInternal(const EMotionFX::ActorInstance* actorInstance, const SimpleMotionComponent::Configuration& cfg, bool deleteOnZeroWeight) { if (!actorInstance || !cfg.m_motionAsset.IsReady()) { @@ -439,6 +443,7 @@ namespace EMotionFX auto* motionAsset = cfg.m_motionAsset.GetAs(); if (!motionAsset) + { AZ_Error("EMotionFX", motionAsset, "Motion asset is not valid."); return nullptr; @@ -456,7 +461,7 @@ namespace EMotionFX info.mCanOverwrite = false; info.mBlendInTime = cfg.m_blendInTime; info.mBlendOutTime = cfg.m_blendOutTime; - info.mInPlace = inPlace; + info.mInPlace = cfg.m_inPlace; return actorInstance->GetMotionSystem()->PlayMotion(motionAsset->m_emfxMotion.get(), &info); } diff --git a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h index 4e3173a3b8..5f5066b9bb 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h +++ b/Gems/EMotionFX/Code/Source/Integration/Components/SimpleMotionComponent.h @@ -46,7 +46,7 @@ namespace EMotionFX struct Configuration { AZ_TYPE_INFO(Configuration, "{DA661C5F-E79E-41C3-B055-5F5A4E353F84}") - Configuration(); + Configuration(); AZ::Data::Asset m_motionAsset; ///< Assigned motion asset bool m_loop; ///< Toggles looping of the motion @@ -56,7 +56,8 @@ namespace EMotionFX float m_playspeed; ///< Determines the rate at which the motion is played float m_blendInTime; ///< Determines the blend in time in seconds. float m_blendOutTime; ///< Determines the blend out time in seconds. - bool m_playOnActivation; ///< Determines if the motion should be played immediately + bool m_playOnActivation; ///< Determines if the motion should be played immediately + bool m_inPlace; ///< Determines if the motion should be played in-place. static void Reflect(AZ::ReflectContext* context); }; @@ -121,7 +122,7 @@ namespace EMotionFX void RemoveMotionInstanceFromActor(EMotionFX::MotionInstance* motionInstance); - static EMotionFX::MotionInstance* PlayMotionInternal(const EMotionFX::ActorInstance* actorInstance, const SimpleMotionComponent::Configuration& cfg, bool deleteOnZeroWeight, bool inPlace); + static EMotionFX::MotionInstance* PlayMotionInternal(const EMotionFX::ActorInstance* actorInstance, const SimpleMotionComponent::Configuration& cfg, bool deleteOnZeroWeight); Configuration m_configuration; ///< Component configuration. EMotionFXPtr m_actorInstance; ///< Associated actor instance (retrieved from Actor Component). diff --git a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp index 228a82856d..1d09b3e255 100644 --- a/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp +++ b/Gems/EMotionFX/Code/Source/Integration/Editor/Components/EditorSimpleMotionComponent.cpp @@ -170,7 +170,7 @@ namespace EMotionFX // The Editor allows scrubbing back and forth on animation blending transitions, so don't delete // motion instances if it's blend weight is zero. // The Editor preview should preview the motion in place to prevent off center movement. - m_motionInstance = SimpleMotionComponent::PlayMotionInternal(m_actorInstance, m_configuration, /*deleteOnZeroWeight*/false, /*inPlace*/true); + m_motionInstance = SimpleMotionComponent::PlayMotionInternal(m_actorInstance, m_configuration, /*deleteOnZeroWeight*/false); } } diff --git a/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp b/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp index d2d119a02d..53f5be5bc4 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp +++ b/Gems/EditorPythonBindings/Code/Source/PythonSystemComponent.cpp @@ -653,8 +653,8 @@ namespace EditorPythonBindings } else { - // something when wrong with executing the test script - AZ::Debug::Trace::Terminate(1); + // something went wrong with executing the test script + AZ::Debug::Trace::Terminate(0xF); } } diff --git a/Gems/LmbrCentral/Code/Source/Rendering/EditorLightComponent.cpp b/Gems/LmbrCentral/Code/Source/Rendering/EditorLightComponent.cpp index f46f60dd7b..e9ac845a88 100644 --- a/Gems/LmbrCentral/Code/Source/Rendering/EditorLightComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Rendering/EditorLightComponent.cpp @@ -805,7 +805,10 @@ namespace LmbrCentral AzToolsFramework::EditorEvents::Bus::Handler::BusDisconnect(); AZ::TransformNotificationBus::Handler::BusDisconnect(); - gEnv->p3DEngine->FreeRenderNodeState(&m_cubemapPreview); + if (gEnv->p3DEngine) + { + gEnv->p3DEngine->FreeRenderNodeState(&m_cubemapPreview); + } m_light.DestroyRenderLight(); m_light.SetEntity(AZ::EntityId()); @@ -903,6 +906,11 @@ namespace LmbrCentral void EditorLightComponent::OnViewCubemapChanged() { + if (!gEnv->p3DEngine) + { + return; + } + if (m_viewCubemap) { gEnv->p3DEngine->RegisterEntity(&m_cubemapPreview); @@ -1944,6 +1952,11 @@ namespace LmbrCentral AzToolsFramework::EditorRequestBus::BroadcastResult(m_editor, &AzToolsFramework::EditorRequests::GetEditor); } + if (!m_editor->Get3DEngine()) + { + return; + } + if (!m_materialManager) { m_materialManager = m_editor->Get3DEngine()->GetMaterialManager(); diff --git a/Gems/LmbrCentral/Code/Source/Rendering/LightInstance.cpp b/Gems/LmbrCentral/Code/Source/Rendering/LightInstance.cpp index d3564f228d..0c5da629ed 100644 --- a/Gems/LmbrCentral/Code/Source/Rendering/LightInstance.cpp +++ b/Gems/LmbrCentral/Code/Source/Rendering/LightInstance.cpp @@ -136,13 +136,16 @@ namespace const char* texturePath = configuration.m_projectorTexture.GetAssetPath().c_str(); const int flags = FT_DONT_STREAM; - lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture(texturePath, flags); - - if (!lightParams.m_pLightImage || !lightParams.m_pLightImage->IsTextureLoaded()) + if (gEnv->pRenderer) { - GetISystem()->Warning(VALIDATOR_MODULE_RENDERER, VALIDATOR_WARNING, 0, texturePath, - "Light projector texture not found: %s", texturePath); - lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture("Textures/defaults/red.dds", flags); + lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture(texturePath, flags); + + if (!lightParams.m_pLightImage || !lightParams.m_pLightImage->IsTextureLoaded()) + { + GetISystem()->Warning(VALIDATOR_MODULE_RENDERER, VALIDATOR_WARNING, 0, texturePath, + "Light projector texture not found: %s", texturePath); + lightParams.m_pLightImage = gEnv->pRenderer->EF_LoadTexture("Textures/defaults/red.dds", flags); + } } } break; @@ -180,8 +183,11 @@ namespace diffuseMap.insert(dotPos, "_diff"); } - lightParams.SetSpecularCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(specularMap.c_str(), FT_DONT_STREAM)); - lightParams.SetDiffuseCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(diffuseMap.c_str(), FT_DONT_STREAM)); + if (gEnv->pRenderer) + { + lightParams.SetSpecularCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(specularMap.c_str(), FT_DONT_STREAM)); + lightParams.SetDiffuseCubemap(gEnv->pRenderer->EF_LoadCubemapTexture(diffuseMap.c_str(), FT_DONT_STREAM)); + } if (lightParams.GetDiffuseCubemap() && lightParams.GetSpecularCubemap()) { @@ -401,7 +407,7 @@ namespace LmbrCentral template void LightInstance::CreateRenderLightInternal(const ConfigurationType& configuration, ConfigToLightParamsFunc configToLightParams) { - if (m_renderLight || !configuration.m_visible) + if (m_renderLight || !configuration.m_visible || !gEnv->p3DEngine) { return; } diff --git a/Gems/NvCloth/Assets/slices/Cloth/Chicken_Actor.slice b/Gems/NvCloth/Assets/slices/Cloth/Chicken_Actor.slice index e146d46fe2..6f64caf5f2 100644 --- a/Gems/NvCloth/Assets/slices/Cloth/Chicken_Actor.slice +++ b/Gems/NvCloth/Assets/slices/Cloth/Chicken_Actor.slice @@ -154,7 +154,7 @@ - + @@ -379,20 +379,7 @@ - - - - - - - - - - - - - - + @@ -405,7 +392,7 @@ - + @@ -413,6 +400,19 @@ + + + + + + + + + + + + + @@ -437,7 +437,7 @@ - + @@ -449,7 +449,7 @@ - + @@ -461,7 +461,7 @@ - + @@ -477,7 +477,7 @@ - + @@ -489,7 +489,7 @@ - + @@ -501,7 +501,7 @@ - + diff --git a/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds.slice b/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds.slice index 214e6ce3b0..c8709b3a6a 100644 --- a/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds.slice +++ b/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds.slice @@ -200,7 +200,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -276,7 +276,7 @@ - + diff --git a/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds_broken.slice b/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds_broken.slice index 979616f8f3..e3ef330b3e 100644 --- a/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds_broken.slice +++ b/Gems/NvCloth/Assets/slices/Cloth/cloth_blinds_broken.slice @@ -200,7 +200,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -276,7 +276,7 @@ - + diff --git a/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_four.slice b/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_four.slice index b2bcb265fe..0a32a4191a 100644 --- a/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_four.slice +++ b/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_four.slice @@ -200,7 +200,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -276,7 +276,7 @@ - + diff --git a/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_two.slice b/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_two.slice index f93956890c..369cb76841 100644 --- a/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_two.slice +++ b/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_corners_two.slice @@ -200,7 +200,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -276,7 +276,7 @@ - + diff --git a/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_edge.slice b/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_edge.slice index 0d6a7d7f30..b44a440d4d 100644 --- a/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_edge.slice +++ b/Gems/NvCloth/Assets/slices/Cloth/cloth_locked_edge.slice @@ -200,7 +200,7 @@ - + @@ -228,7 +228,7 @@ - + @@ -260,7 +260,7 @@ - + @@ -276,7 +276,7 @@ - + diff --git a/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp b/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp index 18f86f558b..8d9731c9e6 100644 --- a/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp +++ b/Gems/NvCloth/Code/Source/Components/EditorClothComponent.cpp @@ -482,14 +482,14 @@ namespace NvCloth { bool foundNode = AZStd::find(m_meshNodeList.cbegin(), m_meshNodeList.cend(), m_config.m_meshNode) != m_meshNodeList.cend(); - if (!foundNode && !m_previousMeshNode.empty()) + if (!foundNode && !m_lastKnownMeshNode.empty()) { // Check the if the mesh node previously selected is still part of the mesh list // to keep using it and avoid the user to select it again in the combo box. - foundNode = AZStd::find(m_meshNodeList.cbegin(), m_meshNodeList.cend(), m_previousMeshNode) != m_meshNodeList.cend(); + foundNode = AZStd::find(m_meshNodeList.cbegin(), m_meshNodeList.cend(), m_lastKnownMeshNode) != m_meshNodeList.cend(); if (foundNode) { - m_config.m_meshNode = m_previousMeshNode; + m_config.m_meshNode = m_lastKnownMeshNode; } } @@ -502,7 +502,7 @@ namespace NvCloth } } - m_previousMeshNode = ""; + m_lastKnownMeshNode = ""; if (m_simulateInEditor) { @@ -517,7 +517,12 @@ namespace NvCloth void EditorClothComponent::OnModelPreDestroy() { - m_previousMeshNode = m_config.m_meshNode; + if (m_config.m_meshNode != Internal::StatusMessageSelectNode && + m_config.m_meshNode != Internal::StatusMessageNoAsset && + m_config.m_meshNode != Internal::StatusMessageNoClothNodes) + { + m_lastKnownMeshNode = m_config.m_meshNode; + } m_meshNodeList = { {Internal::StatusMessageNoAsset} }; m_config.m_meshNode = Internal::StatusMessageNoAsset; diff --git a/Gems/NvCloth/Code/Source/Components/EditorClothComponent.h b/Gems/NvCloth/Code/Source/Components/EditorClothComponent.h index 1339fe1c6d..9727895a43 100644 --- a/Gems/NvCloth/Code/Source/Components/EditorClothComponent.h +++ b/Gems/NvCloth/Code/Source/Components/EditorClothComponent.h @@ -70,7 +70,7 @@ namespace NvCloth // This list is not serialized, it's compiled when the asset has been received via MeshComponentNotificationBus. MeshNodeList m_meshNodeList; - AZStd::string m_previousMeshNode; + AZStd::string m_lastKnownMeshNode; AZStd::unordered_set m_meshNodesWithBackstopData; diff --git a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp index c470c05c58..eb4235766c 100644 --- a/Gems/PhysX/Code/Source/EditorColliderComponent.cpp +++ b/Gems/PhysX/Code/Source/EditorColliderComponent.cpp @@ -88,33 +88,33 @@ namespace PhysX editContext->Class( "EditorProxyShapeConfig", "PhysX Base shape collider") ->DataElement(AZ::Edit::UIHandlers::ComboBox, &EditorProxyShapeConfig::m_shapeType, "Shape", "The shape of the collider") - ->EnumAttribute(Physics::ShapeType::Sphere, "Sphere") - ->EnumAttribute(Physics::ShapeType::Box, "Box") - ->EnumAttribute(Physics::ShapeType::Capsule, "Capsule") - ->EnumAttribute(Physics::ShapeType::PhysicsAsset, "PhysicsAsset") - ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree) - // note: we do not want the user to be able to change shape types while in ComponentMode (there will - // potentially be different ComponentModes for different shape types) - ->Attribute(AZ::Edit::Attributes::ReadOnly, &AzToolsFramework::ComponentModeFramework::InComponentMode) + ->EnumAttribute(Physics::ShapeType::Sphere, "Sphere") + ->EnumAttribute(Physics::ShapeType::Box, "Box") + ->EnumAttribute(Physics::ShapeType::Capsule, "Capsule") + ->EnumAttribute(Physics::ShapeType::PhysicsAsset, "PhysicsAsset") + ->Attribute(AZ::Edit::Attributes::ChangeNotify, AZ::Edit::PropertyRefreshLevels::EntireTree) + // note: we do not want the user to be able to change shape types while in ComponentMode (there will + // potentially be different ComponentModes for different shape types) + ->Attribute(AZ::Edit::Attributes::ReadOnly, &AzToolsFramework::ComponentModeFramework::InComponentMode) ->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyShapeConfig::m_sphere, "Sphere", "Configuration of sphere shape") - ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsSphereConfig) - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) + ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsSphereConfig) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) ->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyShapeConfig::m_box, "Box", "Configuration of box shape") - ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsBoxConfig) - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) + ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsBoxConfig) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) ->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyShapeConfig::m_capsule, "Capsule", "Configuration of capsule shape") - ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsCapsuleConfig) - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) + ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsCapsuleConfig) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) ->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyShapeConfig::m_physicsAsset, "Asset", "Configuration of asset shape") - ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsAssetConfig) - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) + ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::IsAssetConfig) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) ->DataElement(AZ::Edit::UIHandlers::Default, &EditorProxyShapeConfig::m_subdivisionLevel, "Subdivision level", "The level of subdivision if a primitive shape is replaced with a convex mesh due to scaling") - ->Attribute(AZ::Edit::Attributes::Min, Utils::MinCapsuleSubdivisionLevel) - ->Attribute(AZ::Edit::Attributes::Max, Utils::MaxCapsuleSubdivisionLevel) - ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::ShowingSubdivisionLevel) - ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) + ->Attribute(AZ::Edit::Attributes::Min, Utils::MinCapsuleSubdivisionLevel) + ->Attribute(AZ::Edit::Attributes::Max, Utils::MaxCapsuleSubdivisionLevel) + ->Attribute(AZ::Edit::Attributes::Visibility, &EditorProxyShapeConfig::ShowingSubdivisionLevel) + ->Attribute(AZ::Edit::Attributes::ChangeNotify, &EditorProxyShapeConfig::OnConfigurationChanged) ; } } diff --git a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp index d345778f71..e7090ea4a6 100644 --- a/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp +++ b/Gems/ScriptCanvas/Code/Editor/View/Widgets/VariablePanel/SlotTypeSelectorWidget.cpp @@ -80,6 +80,13 @@ namespace ScriptCanvasEditor QObject::connect(ui->slotName, &QLineEdit::returnPressed, this, &SlotTypeSelectorWidget::OnReturnPressed); QObject::connect(ui->slotName, &QLineEdit::textChanged, this, &SlotTypeSelectorWidget::OnNameChanged); QObject::connect(ui->variablePalette, &QTableView::clicked, this, [this]() { ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); }); + QObject::connect(ui->variablePalette, &VariablePaletteTableView::CreateNamedVariable, this, [this](const AZStd::string& variableName, const ScriptCanvas::Data::Type& variableType) + { + // only emitted on container types + OnCreateVariable(variableType); + OnNameChanged(variableName.c_str()); + accept(); + }); // Tell the widget to auto create our context menu, for now setContextMenuPolicy(Qt::ActionsContextMenu); diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp index 957b8c64d1..2b063a8b22 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/SubgraphInterface.cpp @@ -127,7 +127,7 @@ namespace ScriptCanvas return false; } - if (!(datum == rhs.datum)) + if (!(datum.GetType() == rhs.datum.GetType())) { return false; } diff --git a/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_FunctionContainerInputFunction.scriptcanvas b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_FunctionContainerInputFunction.scriptcanvas new file mode 100644 index 0000000000..b09c192e66 --- /dev/null +++ b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_FunctionContainerInputFunction.scriptcanvas @@ -0,0 +1,2370 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_FunctionContainerInputTest.scriptcanvas b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_FunctionContainerInputTest.scriptcanvas new file mode 100644 index 0000000000..55605f684f --- /dev/null +++ b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_FunctionContainerInputTest.scriptcanvas @@ -0,0 +1,567 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp index 53f124476f..3e02e90ae9 100644 --- a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp +++ b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp @@ -130,6 +130,11 @@ TEST_F(ScriptCanvasTestFixture, InterpretedEventHandlerDisconnect) RunUnitTestGraph("LY_SC_UnitTest_EventHandlerDisconnect", runSpec); } +TEST_F(ScriptCanvasTestFixture, FunctionContainerInputTest) +{ + RunUnitTestGraph("LY_SC_UnitTest_FunctionContainerInputTest"); +} + TEST_F(ScriptCanvasTestFixture, InterpretedFixBoundMultipleResults) { RunUnitTestGraph("LY_SC_UnitTest_FixBoundMultipleResults"); diff --git a/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/failed_test_rerun_command.py b/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/failed_test_rerun_command.py index e8e0b02501..c67d6721cf 100755 --- a/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/failed_test_rerun_command.py +++ b/Tools/LyTestTools/ly_test_tools/_internal/pytest_plugin/failed_test_rerun_command.py @@ -22,7 +22,7 @@ def _get_test_launcher_cmd(build_dir=None): """ build_arg = "" if build_dir: - build_arg = f"--build-directory {build_dir} " + build_arg = f" --build-directory {build_dir} " python_runner = "python.cmd" if not WINDOWS: diff --git a/cmake/3rdParty/FindOpenSSL.cmake b/cmake/3rdParty/FindOpenSSL.cmake deleted file mode 100644 index 63a3fee9db..0000000000 --- a/cmake/3rdParty/FindOpenSSL.cmake +++ /dev/null @@ -1,17 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -ly_add_external_target( - NAME OpenSSL - VERSION 1.1.1b-noasm-az - INCLUDE_DIRECTORIES include - COMPILE_DEFINITIONS OPENSSL_ENABLED -) diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index 8be3abbf3c..9f63185ab3 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -30,3 +30,4 @@ ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-android TARGETS mik ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-android TARGETS googletest PACKAGE_HASH 95671be75287a61c9533452835c3647e9c1b30f81b34b43bcb0ec1997cc23894) ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-android TARGETS GoogleBenchmark PACKAGE_HASH 20b46e572211a69d7d94ddad1c89ec37bb958711d6ad4025368ac89ea83078fb) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-android TARGETS libsamplerate PACKAGE_HASH bf13662afe65d02bcfa16258a4caa9b875534978227d6f9f36c9cfa92b3fb12b) +ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-android TARGETS OpenSSL PACKAGE_HASH 4036d4019d722f0e1b7a1621bf60b5a17ca6a65c9c78fd8701cee1131eec8480) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index 49628ef456..7ccd118413 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -45,3 +45,4 @@ ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-linux TARGETS Goog ly_associate_package(PACKAGE_NAME unwind-1.2.1-linux TARGETS unwind PACKAGE_HASH 3453265fb056e25432f611a61546a25f60388e315515ad39007b5925dd054a77) ly_associate_package(PACKAGE_NAME qt-5.15.2-linux TARGETS Qt PACKAGE_HASH 3857fbb2fc5581cdb71d80a7f9298c83ef06073d4e1ccd86a32b4f88782b6f14) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-linux TARGETS libsamplerate PACKAGE_HASH 41643c31bc6b7d037f895f89d8d8d6369e906b92eff42b0fe05ee6a100f06261) +ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev2-linux TARGETS OpenSSL PACKAGE_HASH b779426d1e9c5ddf71160d5ae2e639c3b956e0fb5e9fcaf9ce97c4526024e3bc) diff --git a/cmake/3rdParty/Platform/Linux/OpenSSL_linux.cmake b/cmake/3rdParty/Platform/Linux/OpenSSL_linux.cmake deleted file mode 100644 index 4e02b53abb..0000000000 --- a/cmake/3rdParty/Platform/Linux/OpenSSL_linux.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(OPENSSL_LIBS - ${BASE_PATH}/bin/linux-x86_64-clang-$,debug,release>/libcrypto.so - ${BASE_PATH}/bin/linux-x86_64-clang-$,debug,release>/libssl.so -) - -set(OPENSSL_RUNTIME_DEPENDENCIES - ${BASE_PATH}/bin/linux-x86_64-clang-$,debug,release>/libcrypto.so - ${BASE_PATH}/bin/linux-x86_64-clang-$,debug,release>/libssl.so - ${BASE_PATH}/bin/linux-x86_64-clang-$,debug,release>/libcrypto.so.1.1 - ${BASE_PATH}/bin/linux-x86_64-clang-$,debug,release>/libssl.so.1.1 -) diff --git a/cmake/3rdParty/Platform/Linux/cmake_linux_files.cmake b/cmake/3rdParty/Platform/Linux/cmake_linux_files.cmake index 69aa0a5a2f..bd2fd969eb 100644 --- a/cmake/3rdParty/Platform/Linux/cmake_linux_files.cmake +++ b/cmake/3rdParty/Platform/Linux/cmake_linux_files.cmake @@ -13,6 +13,5 @@ set(FILES BuiltInPackages_linux.cmake dyad_linux.cmake FbxSdk_linux.cmake - OpenSSL_linux.cmake Wwise_linux.cmake ) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index 53e7066e99..3cff2c92d8 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -46,5 +46,6 @@ ly_associate_package(PACKAGE_NAME etc2comp-9cd0f9cae0-rev1-mac TARGETS etc ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-mac TARGETS mikkelsen PACKAGE_HASH 83af99ca8bee123684ad254263add556f0cf49486c0b3e32e6d303535714e505) ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-mac TARGETS googletest PACKAGE_HASH cbf020d5ef976c5db8b6e894c6c63151ade85ed98e7c502729dd20172acae5a8) ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-mac TARGETS GoogleBenchmark PACKAGE_HASH ad25de0146769c91e179953d845de2bec8ed4a691f973f47e3eb37639381f665) +ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-mac TARGETS OpenSSL PACKAGE_HASH 28adc1c0616ac0482b2a9d7b4a3a3635a1020e87b163f8aba687c501cf35f96c) ly_associate_package(PACKAGE_NAME qt-5.15.2-mac TARGETS Qt PACKAGE_HASH ac248833d65838e4bcef50f30c9ff02ba9464ff64b9ada52de2ad6045d38baec) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-mac TARGETS libsamplerate PACKAGE_HASH b912af40c0ac197af9c43d85004395ba92a6a859a24b7eacd920fed5854a97fe) diff --git a/cmake/3rdParty/Platform/Mac/OpenSSL_mac.cmake b/cmake/3rdParty/Platform/Mac/OpenSSL_mac.cmake deleted file mode 100644 index 022b56dd0c..0000000000 --- a/cmake/3rdParty/Platform/Mac/OpenSSL_mac.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(OPENSSL_LIBS - ${BASE_PATH}/lib/darwin-x86_64-$,debug,release>/libcrypto.a - ${BASE_PATH}/lib/darwin-x86_64-$,debug,release>/libssl.a -) diff --git a/cmake/3rdParty/Platform/Mac/cmake_mac_files.cmake b/cmake/3rdParty/Platform/Mac/cmake_mac_files.cmake index d6024636bc..7d7679c3aa 100644 --- a/cmake/3rdParty/Platform/Mac/cmake_mac_files.cmake +++ b/cmake/3rdParty/Platform/Mac/cmake_mac_files.cmake @@ -13,6 +13,5 @@ set(FILES BuiltInPackages_mac.cmake FbxSdk_mac.cmake OpenGLInterface_mac.cmake - OpenSSL_mac.cmake Wwise_mac.cmake ) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index e5993a0dec..249cc7f2c2 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -54,4 +54,5 @@ ly_associate_package(PACKAGE_NAME openimageio-2.1.16.0-rev2-windows TARGETS Ope ly_associate_package(PACKAGE_NAME qt-5.15.2-windows TARGETS Qt PACKAGE_HASH edaf954c647c99727bfd313dab2959803d2df0873914bb96368c3d8286eed6d9) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-windows TARGETS libsamplerate PACKAGE_HASH dcf3c11a96f212a52e2c9241abde5c364ee90b0f32fe6eeb6dcdca01d491829f) ly_associate_package(PACKAGE_NAME OpenMesh-8.1-rev1-windows TARGETS OpenMesh PACKAGE_HASH 1c1df639358526c368e790dfce40c45cbdfcfb1c9a041b9d7054a8949d88ee77) -ly_associate_package(PACKAGE_NAME civetweb-1.8-rev1-windows TARGETS civetweb PACKAGE_HASH 36d0e58a59bcdb4dd70493fb1b177aa0354c945b06c30416348fd326cf323dd4) \ No newline at end of file +ly_associate_package(PACKAGE_NAME civetweb-1.8-rev1-windows TARGETS civetweb PACKAGE_HASH 36d0e58a59bcdb4dd70493fb1b177aa0354c945b06c30416348fd326cf323dd4) +ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev2-windows TARGETS OpenSSL PACKAGE_HASH 9af1c50343f89146b4053101a7aeb20513319a3fe2f007e356d7ce25f9241040) diff --git a/cmake/3rdParty/Platform/Windows/OpenSSL_windows.cmake b/cmake/3rdParty/Platform/Windows/OpenSSL_windows.cmake deleted file mode 100644 index 6f2c240b94..0000000000 --- a/cmake/3rdParty/Platform/Windows/OpenSSL_windows.cmake +++ /dev/null @@ -1,18 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(OPENSSL_LIBS - ${BASE_PATH}/lib/vc140_x64_$,debug,release>/libcrypto.lib - ${BASE_PATH}/lib/vc140_x64_$,debug,release>/libssl.lib - crypt32.lib -) - -set(ENV{OPENSSL_HOME} ${BASE_PATH}) \ No newline at end of file diff --git a/cmake/3rdParty/Platform/Windows/cmake_windows_files.cmake b/cmake/3rdParty/Platform/Windows/cmake_windows_files.cmake index 3b42452990..9ae74b7e6a 100644 --- a/cmake/3rdParty/Platform/Windows/cmake_windows_files.cmake +++ b/cmake/3rdParty/Platform/Windows/cmake_windows_files.cmake @@ -15,6 +15,5 @@ set(FILES dyad_windows.cmake FbxSdk_windows.cmake libav_windows.cmake - OpenSSL_windows.cmake Wwise_windows.cmake ) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index 43858fa244..e742f0c463 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -31,3 +31,4 @@ ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-ios TARGETS mikkels ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-ios TARGETS googletest PACKAGE_HASH 2f121ad9784c0ab73dfaa58e1fee05440a82a07cc556bec162eeb407688111a7) ly_associate_package(PACKAGE_NAME googlebenchmark-1.5.0-rev2-ios TARGETS GoogleBenchmark PACKAGE_HASH c2ffaed2b658892b1bcf81dee4b44cd1cb09fc78d55584ef5cb8ab87f2d8d1ae) ly_associate_package(PACKAGE_NAME libsamplerate-0.2.1-rev2-ios TARGETS libsamplerate PACKAGE_HASH 7656b961697f490d4f9c35d2e61559f6fc38c32102e542a33c212cd618fc2119) +ly_associate_package(PACKAGE_NAME OpenSSL-1.1.1b-rev1-ios TARGETS OpenSSL PACKAGE_HASH cd0dfce3086a7172777c63dadbaf0ac3695b676119ecb6d0614b5fb1da03462f) diff --git a/cmake/3rdParty/Platform/iOS/OpenSSL_ios.cmake b/cmake/3rdParty/Platform/iOS/OpenSSL_ios.cmake deleted file mode 100644 index 7fc983d879..0000000000 --- a/cmake/3rdParty/Platform/iOS/OpenSSL_ios.cmake +++ /dev/null @@ -1,15 +0,0 @@ -# -# All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -# its licensors. -# -# For complete copyright and license terms please see the LICENSE at the root of this -# distribution (the "License"). All use of this software is governed by the License, -# or, if provided, by the license below or the license accompanying this file. Do not -# remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# - -set(OPENSSL_LIBS - ${BASE_PATH}/lib/ios_arm64_$,debug,release>/libcrypto.a - ${BASE_PATH}/lib/ios_arm64_$,debug,release>/libssl.a -) diff --git a/cmake/3rdParty/Platform/iOS/cmake_ios_files.cmake b/cmake/3rdParty/Platform/iOS/cmake_ios_files.cmake index e32a9f75bb..2a2a6737e5 100644 --- a/cmake/3rdParty/Platform/iOS/cmake_ios_files.cmake +++ b/cmake/3rdParty/Platform/iOS/cmake_ios_files.cmake @@ -11,7 +11,6 @@ set(FILES BuiltInPackages_ios.cmake - OpenSSL_ios.cmake RadTelemetry_ios.cmake Wwise_ios.cmake -) \ No newline at end of file +) diff --git a/cmake/3rdParty/cmake_files.cmake b/cmake/3rdParty/cmake_files.cmake index 9fc90e42e5..d37fcba840 100644 --- a/cmake/3rdParty/cmake_files.cmake +++ b/cmake/3rdParty/cmake_files.cmake @@ -16,7 +16,6 @@ set(FILES FindFbxSdk.cmake Findlibav.cmake FindOpenGLInterface.cmake - FindOpenSSL.cmake FindRadTelemetry.cmake FindVkValidation.cmake FindWwise.cmake