Răsfoiți Sursa

Half Float support plus other gpu perf related optimizations for mobile/VR pipeline. (#13742)

* Gpu perf pass for VR forward pass. It includes support for the following
- Half float support
    - This was done via introducing a new keyword called 'real' and PAL-ifying it across different platforms
	- Half float support is enabled for android and ios
	- Most of the relevant material types like BasePBR, StandardPBR, EnhancedStandardPBR were converted over to use floats so other shaders that were not converted over will show precision loss warnings if they call into functions that switched over to use real keyword
	- Positions and UVs still use full float
- Removing all branches related to shader debugging code by default
- Remove reflection probe parallax correction
- Remove reflection probe blending
- Remove specular anti aliasing
- Various other cleanup tasks

Signed-off-by: moudgils <[email protected]>

* Further changes to support half float support work after the material abstraction work went in.

Signed-off-by: moudgils <[email protected]>

* Address crashes related to using dx12 with openxr plus another misc crash

Signed-off-by: moudgils <[email protected]>

* Address some more warnings

Signed-off-by: moudgils <[email protected]>

* Minor cleanup

Signed-off-by: moudgils <[email protected]>

* More cleanup

Signed-off-by: moudgils <[email protected]>

* Another minor fix

Signed-off-by: moudgils <[email protected]>

* Addressed minor feedback

Signed-off-by: moudgils <[email protected]>

* Bumped minor version for Atom gem

Signed-off-by: moudgils <[email protected]>

* Fixed Skybox for Multiview platform and minor feedback

Signed-off-by: moudgils <[email protected]>

* Removing changes that got added by accident

Signed-off-by: moudgils <[email protected]>

---------

Signed-off-by: moudgils <[email protected]>
moudgils 2 ani în urmă
părinte
comite
2a77126030
100 a modificat fișierele cu 1166 adăugiri și 967 ștergeri
  1. 14 9
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Android/Vulkan/AzslcHeader.azsli
  2. 3 1
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Null/AzslcHeader.azsli
  3. 8 0
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Vulkan/AzslcHeader.azsli
  4. 10 0
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Mac/Metal/AzslcHeader.azsli
  5. 9 0
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/DX12/AzslcHeader.azsli
  6. 11 1
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/Vulkan/AzslcHeader.azsli
  7. 9 0
      Gems/Atom/Asset/Shader/Code/AZSL/Platform/iOS/Metal/AzslcHeader.azsli
  8. 2 2
      Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp
  9. 7 1
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/ForwardPass_BaseLighting.azsli
  10. 10 5
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/ForwardPass_StandardLighting.azsli
  11. 6 2
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/ForwardPass_StandardLighting_CustomZ.azsli
  12. 12 4
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/MultiViewForwardPassVertexAndPixel.azsli
  13. 6 2
      Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/Transparent_StandardLighting.azsli
  14. 4 4
      Gems/Atom/Feature/Common/Assets/Materials/Special/DebugVertexStreams.azsl
  15. 53 53
      Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.azsli
  16. 9 8
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/BlendUtility.azsli
  17. 3 3
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCcToAcesCg.azsli
  18. 3 3
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCgToAcesCc.azsli
  19. 1 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_LinearSrgb.azsli
  20. 1 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Aces_To_AcesCg.azsli
  21. 1 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/CalculateLuminance_AcesCg.azsli
  22. 2 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/CalculateLuminance_LinearSrgb.azsli
  23. 1 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_AcesCg.azsli
  24. 2 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_Srgb.azsli
  25. 2 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Srgb_To_LinearSrgb.azsli
  26. 23 9
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/TransformColor.azsli
  27. 3 3
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Debug.azsli
  28. 1 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/MatrixUtility.azsli
  29. 1 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/AlphaUtils.azsli
  30. 12 12
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli
  31. 8 1
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Decals.azsli
  32. 33 33
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli
  33. 19 20
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli
  34. 4 0
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingOptions.azsli
  35. 29 15
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingUtils.azsli
  36. 8 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli
  37. 15 15
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli
  38. 10 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli
  39. 50 37
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli
  40. 16 16
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli
  41. 3 4
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Lights.azsli
  42. 9 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli
  43. 7 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PolygonLight.azsli
  44. 9 3
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli
  45. 6 6
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/SimplePointLight.azsli
  46. 13 12
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/SimpleSpotLight.azsli
  47. 14 8
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/MaterialUtils.azsli
  48. 54 54
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli
  49. 8 8
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Fresnel.azsli
  50. 28 28
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Ggx.azsli
  51. 8 8
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/AnisotropicSurfaceData.azsli
  52. 6 6
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli
  53. 31 25
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli
  54. 14 14
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli
  55. 81 81
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ParallaxMapping.azsli
  56. 34 34
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli
  57. 2 2
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PostProcessing/Tonemap.azsli
  58. 20 0
      Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli
  59. 1 1
      Gems/Atom/Feature/Common/Assets/Shaders/LightCulling/LightCulling.azsl
  60. 4 4
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli
  61. 28 28
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_LightingData.azsli
  62. 1 1
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_LightingEval.azsli
  63. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_PixelGeometryData.azsli
  64. 7 7
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_PixelGeometryEval.azsli
  65. 12 12
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceData.azsli
  66. 11 11
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceEval.azsli
  67. 6 7
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_LightingBrdf.azsli
  68. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryData.azsli
  69. 7 7
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryEval.azsli
  70. 22 22
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceData.azsli
  71. 33 33
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceEval.azsli
  72. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_PixelGeometryData.azsli
  73. 11 11
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_PixelGeometryEval.azsli
  74. 39 39
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_SurfaceEval.azsli
  75. 5 5
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/EvaluateTangentFrame.azsli
  76. 12 12
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/MultilayerParallaxDepth.azsli
  77. 16 16
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/ParallaxDepth.azsli
  78. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/ParallaxShadowUtil.azsli
  79. 4 4
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli
  80. 6 6
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/AlphaInput.azsli
  81. 6 4
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/BaseColorInput.azsli
  82. 9 9
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/ClearCoatInput.azsli
  83. 24 24
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/DetailMapsInput.azsli
  84. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/EmissiveInput.azsli
  85. 2 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/MetallicInput.azsli
  86. 19 18
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/NormalInput.azsli
  87. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/OcclusionInput.azsli
  88. 14 14
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/ParallaxInput.azsli
  89. 2 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/RoughnessInput.azsli
  90. 2 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/SpecularInput.azsli
  91. 2 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/SubsurfaceInput.azsli
  92. 2 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/TransmissionInput.azsli
  93. 2 2
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_LightingBrdf.azsli
  94. 4 4
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_PixelGeometryData.azsli
  95. 9 9
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_PixelGeometryEval.azsli
  96. 14 14
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_SurfaceData.azsli
  97. 35 35
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_SurfaceEval.azsli
  98. 5 5
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_LightingBrdf.azsli
  99. 1 1
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_LightingEval.azsli
  100. 3 3
      Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryData.azsli

+ 14 - 9
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Android/Vulkan/AzslcHeader.azsli

@@ -16,15 +16,20 @@
 
 static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
 
-// Uniform limitation need to be taken into consideration for mobile devices. This would help alleviate device lost errors if the constant buffer
-// size overshoots the device's memory constraints. An example is a large number of constant buffers associated with mesh instances that would result in device lost,
-// but otherwise OK on PC. We can separate out the number of instances for the different platforms with this define.
-// [ATOM-14949]
-#define AZ_TRAIT_CONSTANT_BUFFER_LIMITATIONS 1
+//In Vulkan not all texture formats can be sampled using linear filtering. This causes validation errors on Android, so we downgrade to 
+//point sample for certain formats that are not supported on Android and switch from linear to point filtering for depth related 
+//textures (since linear filtering for non linear textures is not correct).
+#define AZ_TRAIT_DOWNGRADE_LINEAR_SAMPLE 1
 
-// Different constant buffer alignment on platforms
-#define AZ_TRAIT_CONSTANT_BUFFER_ALIGNMENT      16
+//Assuming unbounded array suport for Android
+#define UNBOUNDED_SIZE
 
-#define AZ_TRAIT_DOWNGRADE_LINEAR_SAMPLE 1
+// use half float for android
+#define real half
+#define real2 half2
+#define real3 half3
+#define real4 half4
+#define real3x3 half3x3
+#define real3x4 half3x4
+#define real4x4 half4x4
 
-#define UNBOUNDED_SIZE

+ 3 - 1
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Null/AzslcHeader.azsli

@@ -11,4 +11,6 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 
-#define UNBOUNDED_SIZE
+//Linux supports unbounded array
+#define UNBOUNDED_SIZE
+

+ 8 - 0
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Linux/Vulkan/AzslcHeader.azsli

@@ -14,3 +14,11 @@
 #define UNBOUNDED_SIZE
 static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0 / 255.0, 1);
 
+// Full floats for Linux
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4

+ 10 - 0
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Mac/Metal/AzslcHeader.azsli

@@ -18,3 +18,13 @@
 #define UNBOUNDED_SIZE 100000
 
 static const float4 s_AzslDebugColor = float4(85.0 / 255.0, 85.0 / 255.0, 85.0 / 255.0, 1);
+
+
+// Full floats for Mac
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4

+ 9 - 0
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/DX12/AzslcHeader.azsli

@@ -11,7 +11,16 @@
 * after appending this header and pre-processing with mcpp ahead of azslc.
 */
 
+//PC supports unbounded array
 #define UNBOUNDED_SIZE 
 
 static const float4 s_AzslDebugColor = float4(16.0 / 255.0, 124.0 / 255.0, 16.0 / 255.0, 1);
 
+// Full floats for windows DX12 PC
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4

+ 11 - 1
Gems/Atom/Asset/Shader/Code/AZSL/Platform/Windows/Vulkan/AzslcHeader.azsli

@@ -17,4 +17,14 @@ static const float4 s_AzslDebugColor = float4(165.0 / 255.0, 30.0 / 255.0, 36.0
 // Different constant buffer alignment on platforms
 #define AZ_TRAIT_CONSTANT_BUFFER_ALIGNMENT      128
 
-#define UNBOUNDED_SIZE
+//PC supports unbounded array
+#define UNBOUNDED_SIZE
+
+// Full floats for windows vulkan PC
+#define real float
+#define real2 float2
+#define real3 float3
+#define real4 float4
+#define real3x3 float3x3
+#define real3x4 float3x4
+#define real4x4 float4x4

+ 9 - 0
Gems/Atom/Asset/Shader/Code/AZSL/Platform/iOS/Metal/AzslcHeader.azsli

@@ -21,3 +21,12 @@
 #define UB_DIRECTBINDING_NOTSUPPPORTED
 
 static const float4 s_AzslDebugColor = float4(85.0 / 255.0, 85.0 / 255.0, 85.0 / 255.0, 1);
+
+// use half float for ios
+#define real half
+#define real2 half2
+#define real3 half3
+#define real4 half4
+#define real3x3 half3x3
+#define real3x4 half3x4
+#define real4x4 half4x4

+ 2 - 2
Gems/Atom/Asset/Shader/Code/Source/Editor/AzslShaderBuilderSystemComponent.cpp

@@ -83,7 +83,7 @@ namespace AZ
             // Register Shader Asset Builder
             AssetBuilderSDK::AssetBuilderDesc shaderAssetBuilderDescriptor;
             shaderAssetBuilderDescriptor.m_name = "Shader Asset Builder";
-            shaderAssetBuilderDescriptor.m_version = 118; // material pipeline MATERIAL_TYPE_AZSLI_FILE_PATH trick
+            shaderAssetBuilderDescriptor.m_version = 119; // Half float support
             shaderAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern( AZStd::string::format("*.%s", RPI::ShaderSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
             shaderAssetBuilderDescriptor.m_busId = azrtti_typeid<ShaderAssetBuilder>();
             shaderAssetBuilderDescriptor.m_createJobFunction = AZStd::bind(&ShaderAssetBuilder::CreateJobs, &m_shaderAssetBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2);
@@ -108,7 +108,7 @@ namespace AZ
                 shaderVariantAssetBuilderDescriptor.m_name = "Shader Variant Asset Builder";
                 // Both "Shader Variant Asset Builder" and "Shader Asset Builder" produce ShaderVariantAsset products. If you update
                 // ShaderVariantAsset you will need to update BOTH version numbers, not just "Shader Variant Asset Builder".
-                shaderVariantAssetBuilderDescriptor.m_version = 34; // Listens for *.hashedvariantlist and *.hashedvariantinfo files.
+                shaderVariantAssetBuilderDescriptor.m_version = 35; // // Half float support
                 shaderVariantAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern(AZStd::string::format("*.%s", HashedVariantListSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
                 shaderVariantAssetBuilderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern(AZStd::string::format("*.%s", HashedVariantInfoSourceData::Extension), AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard));
                 shaderVariantAssetBuilderDescriptor.m_busId = azrtti_typeid<ShaderVariantAssetBuilder>();

+ 7 - 1
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/ForwardPass_BaseLighting.azsli

@@ -14,17 +14,23 @@
 #define UNIFIED_FORWARD_OUTPUT          1
 #define FORCE_IBL_IN_FORWARD_PASS       1
 #define ENABLE_AREA_LIGHT_VALIDATION    0
+#define FORCE_EARLY_DEPTH_STENCIL 1
 #define OUTPUT_DEPTH 0
 #define FORCE_OPAQUE 1
 #define OUTPUT_SUBSURFACE 0
 #define ENABLE_TRANSMISSION 0
-#define ENABLE_SHADER_DEBUGGING 1
+#define ENABLE_SHADER_DEBUGGING 0
 #define ENABLE_CLEAR_COAT 0
 #define ENABLE_SHADOWS 0
 #define ENABLE_LIGHT_CULLING 0
 #define ENABLE_AREA_LIGHTS 0
 #define ENABLE_PHYSICAL_SKY 0
 #define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS              0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
+
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 

+ 10 - 5
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/ForwardPass_StandardLighting.azsli

@@ -11,21 +11,26 @@
 // TODO(MaterialPipeline): In the end, after all refactoring and rearranging of our shader code is done, some of these flags might become unnecessary and should be re-evaluated.
 // Some of these setting used to be in ShaderQualityOptions.azsli as a basic/limited solution for multiple pipelines.
 // TODO(MaterialPipeline), instead of UNIFIED_FORWARD_OUTPUT, fork ForwardPassOutput.azsli
-#define UNIFIED_FORWARD_OUTPUT          1
-#define FORCE_IBL_IN_FORWARD_PASS       1
-#define ENABLE_AREA_LIGHT_VALIDATION    0
+#define UNIFIED_FORWARD_OUTPUT 1
+#define FORCE_IBL_IN_FORWARD_PASS 1
 #define FORCE_EARLY_DEPTH_STENCIL 1
-
+#define OUTPUT_DEPTH 0
 #define FORCE_OPAQUE 1
 #define OUTPUT_SUBSURFACE 0
+
 #define ENABLE_TRANSMISSION 0
-#define ENABLE_SHADER_DEBUGGING 1
+#define ENABLE_SHADER_DEBUGGING 0
 #define ENABLE_CLEAR_COAT 0
 #define ENABLE_SHADOWS 0
 #define ENABLE_LIGHT_CULLING 0
 #define ENABLE_AREA_LIGHTS 0
+#define ENABLE_AREA_LIGHT_VALIDATION    0
 #define ENABLE_PHYSICAL_SKY 0
 #define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS 0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 

+ 6 - 2
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/ForwardPass_StandardLighting_CustomZ.azsli

@@ -19,13 +19,17 @@
 #define FORCE_OPAQUE 1
 #define OUTPUT_SUBSURFACE 0
 #define ENABLE_TRANSMISSION 0
-#define ENABLE_SHADER_DEBUGGING 1
-#define ENABLE_CLEAR_COAT 1
+#define ENABLE_SHADER_DEBUGGING 0
+#define ENABLE_CLEAR_COAT 0
 #define ENABLE_SHADOWS 0
 #define ENABLE_LIGHT_CULLING 0
 #define ENABLE_AREA_LIGHTS 0
 #define ENABLE_PHYSICAL_SKY 0
 #define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS 0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 

+ 12 - 4
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/MultiViewForwardPassVertexAndPixel.azsli

@@ -8,9 +8,9 @@
 
 #pragma once
 
-#define OUTPUT_DEPTH 0 // Never use custom depth, the VR pipeline is too optimized to support PDO.
 #include <Atom/Features/Pipeline/Forward/ForwardPassOutput.azsli>
 #include <Atom/Features/PostProcessing/Tonemap.azsli>
+#include <Atom/Features/ColorManagement/TransformColor.azsli>
 
 // --- Vertex Shader ---
 
@@ -39,17 +39,25 @@ ForwardPassOutput PixelShader(VsOutput IN, bool isFrontFace : SV_IsFrontFace)
 
     ForwardPassOutput OUT;
 
-    float3 color = lightingData.diffuseLighting.rgb + lightingData.specularLighting.rgb + lightingData.emissiveLighting.rgb;
+    real3 color = lightingData.diffuseLighting.rgb + lightingData.specularLighting.rgb + lightingData.emissiveLighting.rgb;
 
 #if ENABLE_MERGE_FILMIC_TONEMAP
     // Apply manual exposure compensation
-    color = ApplyManualExposure(color, ViewSrg::GetExposureValueCompensation());
+    color = ApplyManualExposure(color, real(ViewSrg::GetExposureValueCompensation()));
     
-    // We could add Aces support here as well if perf allows.
+    //Convert to linearsrg space as we are in acescg space and we will not be applying aces tonemap
+    color = AcesCg_To_LinearSrgb(color);
+
+    // We could add other forms of tonemapping in future via shader options.
     color = ApplyFilmicTonemap(color);
 #endif
 
     OUT.m_color.rgb = color;
+    OUT.m_color.a = 1.0;
+
+#if OUTPUT_DEPTH
+    OUT.m_depth = IN.position.z;
+#endif
 
     return OUT;
 }

+ 6 - 2
Gems/Atom/Feature/Common/Assets/Materials/Pipelines/MultiView/Transparent_StandardLighting.azsli

@@ -18,13 +18,17 @@
 #define FORCE_OPAQUE 0
 #define OUTPUT_SUBSURFACE 0
 #define ENABLE_TRANSMISSION 0
-#define ENABLE_SHADER_DEBUGGING 1
-#define ENABLE_CLEAR_COAT 1
+#define ENABLE_SHADER_DEBUGGING 0
+#define ENABLE_CLEAR_COAT 0
 #define ENABLE_SHADOWS 0
 #define ENABLE_LIGHT_CULLING 0
 #define ENABLE_AREA_LIGHTS 0
 #define ENABLE_PHYSICAL_SKY 0
 #define ENABLE_MERGE_FILMIC_TONEMAP 1
+#define ENABLE_DECALS              0
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+#define ENABLE_REFLECTIONPROBE_BLENDING 0
+#define ENABLE_SPECULARAA 0
 
 //////////////////////////////////////////////////////////////////////////////////////////////////
 

+ 4 - 4
Gems/Atom/Feature/Common/Assets/Materials/Special/DebugVertexStreams.azsl

@@ -99,11 +99,11 @@ float3 OffsetColor(float3 color)
 
 PixelOutput MainPS(VSOutput IN)
 {
-    float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
-    float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
+    real4x4 objectToWorld = real4x4(ObjectSrg::GetWorldMatrix());
+    real3x3 objectToWorldIT = real3x3(ObjectSrg::GetWorldMatrixInverseTranspose());
 
-    float3 normalWS, tangentWS, bitangentWS;
-    ConstructTBN(IN.m_normal, IN.m_tangent, objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
+    real3 normalWS, tangentWS, bitangentWS;
+    ConstructTBN(real3(IN.m_normal), real4(IN.m_tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
     PixelOutput OUT;
     

+ 53 - 53
Gems/Atom/Feature/Common/Assets/Materials/Types/StandardMultilayerPBR.azsli

@@ -119,9 +119,9 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     PixelGeometryData EvaluatePixelGeometry_StandardMultilayerPBR(
         inout float4 positionSV,
         float3 positionWS,
-        float3 normalWS,
-        float3 tangentWS,
-        float3 bitangentWS,
+        real3 normalWS,
+        real3 tangentWS,
+        real3 bitangentWS,
         float2 uvs[UvSetCount],
         bool isFrontFace,
         float3 vertexBlendMask)
@@ -142,11 +142,11 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     
     PixelGeometryData EvaluatePixelGeometry_StandardMultilayerPBR(inout VsOutput IN, bool isFrontFace)
     {
-        float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
-        float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
+        real4x4 objectToWorld = real4x4(ObjectSrg::GetWorldMatrix());
+        real3x3 objectToWorldIT = real3x3(ObjectSrg::GetWorldMatrixInverseTranspose());
 
-        float3 normalWS, tangentWS, bitangentWS;
-        ConstructTBN(IN.normal, IN.tangent, objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
+        real3 normalWS, tangentWS, bitangentWS;
+        ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
         return EvaluatePixelGeometry_StandardMultilayerPBR(
             IN.position,
@@ -242,9 +242,9 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
 
         float2 m_vertexUv[UvSetCount];
         float3x3 m_uvMatrix;
-        float3 m_normal;
-        float3 m_tangents[UvSetCount];
-        float3 m_bitangents[UvSetCount];
+        real3 m_normal;
+        real3 m_tangents[UvSetCount];
+        real3 m_bitangents[UvSetCount];
 
         sampler m_sampler;
 
@@ -259,26 +259,26 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
     //! This data is ready to be copied into a Surface and/or LightingData struct for the lighting system to consume.
     class ProcessedMaterialInputs
     {
-        float3 m_normalTS;   //!< Normal in tangent-space
-        float3 m_baseColor;
-        float m_specularF0Factor;
-        float m_metallic;
-        float m_roughness;
-        float3 m_emissiveLighting;
-        float m_diffuseAmbientOcclusion;
-        float m_specularOcclusion;
+        real3 m_normalTS;   //!< Normal in tangent-space
+        real3 m_baseColor;
+        real m_specularF0Factor;
+        real m_metallic;
+        real m_roughness;
+        real3 m_emissiveLighting;
+        real m_diffuseAmbientOcclusion;
+        real m_specularOcclusion;
     #if ENABLE_CLEAR_COAT
         ClearCoatSurfaceData m_clearCoat;
     #endif
     
         void InitializeToZero()
         {
-            m_normalTS = float3(0,0,0);
-            m_baseColor = float3(0,0,0);
+            m_normalTS = real3(0,0,0);
+            m_baseColor = real3(0,0,0);
             m_specularF0Factor = 0;
-            m_metallic = 0.0f;
-            m_roughness = 0.0f;
-            m_emissiveLighting = float3(0,0,0);
+            m_metallic = 0.0;
+            m_roughness = 0.0;
+            m_emissiveLighting = real3(0,0,0);
             m_diffuseAmbientOcclusion = 0;
             m_specularOcclusion = 0;
     #if ENABLE_CLEAR_COAT
@@ -297,28 +297,28 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         transformedUv[0] = mul(inputs.m_uvMatrix, float3(inputs.m_vertexUv[0], 1.0)).xy;
         transformedUv[1] = inputs.m_vertexUv[1];
     
-        float3x3 normalUvMatrix = inputs.m_normalMapUvIndex == 0 ? inputs.m_uvMatrix : CreateIdentity3x3();
-        result.m_normalTS = GetNormalInputTS(inputs.m_normalMap, inputs.m_sampler, transformedUv[inputs.m_normalMapUvIndex], inputs.m_flipNormalX, inputs.m_flipNormalY, normalUvMatrix, inputs.m_normal_useTexture, inputs.m_normalFactor);
+        real3x3 normalUvMatrix = inputs.m_normalMapUvIndex == 0 ? real3x3(inputs.m_uvMatrix) : real3x3(CreateIdentity3x3());
+        result.m_normalTS = GetNormalInputTS(inputs.m_normalMap, inputs.m_sampler, transformedUv[inputs.m_normalMapUvIndex], inputs.m_flipNormalX, inputs.m_flipNormalY, normalUvMatrix, inputs.m_normal_useTexture, real(inputs.m_normalFactor));
     
-        float3 sampledBaseColor = GetBaseColorInput(inputs.m_baseColorMap, inputs.m_sampler, transformedUv[inputs.m_baseColorMapUvIndex], inputs.m_baseColor.rgb, inputs.m_baseColor_useTexture);
-        result.m_baseColor = BlendBaseColor(sampledBaseColor, inputs.m_baseColor.rgb, inputs.m_baseColorFactor, inputs.m_baseColorTextureBlendMode, inputs.m_baseColor_useTexture);
-        result.m_specularF0Factor = GetSpecularInput(inputs.m_specularF0Map, inputs.m_sampler, transformedUv[inputs.m_specularF0MapUvIndex], inputs.m_specularF0Factor, inputs.m_specularF0_useTexture);
-        result.m_metallic = GetMetallicInput(inputs.m_metallicMap, inputs.m_sampler, transformedUv[inputs.m_metallicMapUvIndex], inputs.m_metallicFactor, inputs.m_metallic_useTexture);
-        result.m_roughness = GetRoughnessInput(inputs.m_roughnessMap, MaterialSrg::m_sampler, transformedUv[inputs.m_roughnessMapUvIndex], inputs.m_roughnessFactor, inputs.m_roughnessLowerBound, inputs.m_roughnessUpperBound, inputs.m_roughness_useTexture);
-
-        result.m_emissiveLighting = GetEmissiveInput(inputs.m_emissiveMap, inputs.m_sampler, transformedUv[inputs.m_emissiveMapUvIndex], inputs.m_emissiveIntensity, inputs.m_emissiveColor.rgb, 0.0, 1.0, inputs.m_emissiveEnabled, inputs.m_emissive_useTexture);
-        result.m_diffuseAmbientOcclusion = GetOcclusionInput(inputs.m_diffuseOcclusionMap, inputs.m_sampler, transformedUv[inputs.m_diffuseOcclusionMapUvIndex], inputs.m_diffuseOcclusionFactor, inputs.m_diffuseOcclusion_useTexture);
-        result.m_specularOcclusion = GetOcclusionInput(inputs.m_specularOcclusionMap, MaterialSrg::m_sampler, transformedUv[inputs.m_specularOcclusionMapUvIndex], inputs.m_specularOcclusionFactor, inputs.m_specularOcclusion_useTexture);
+        real3 sampledBaseColor = GetBaseColorInput(inputs.m_baseColorMap, inputs.m_sampler, transformedUv[inputs.m_baseColorMapUvIndex], real3(inputs.m_baseColor.rgb), inputs.m_baseColor_useTexture);
+        result.m_baseColor = BlendBaseColor(sampledBaseColor, real3(inputs.m_baseColor.rgb), real(inputs.m_baseColorFactor), inputs.m_baseColorTextureBlendMode, inputs.m_baseColor_useTexture);
+        result.m_specularF0Factor = GetSpecularInput(inputs.m_specularF0Map, inputs.m_sampler, transformedUv[inputs.m_specularF0MapUvIndex], real(inputs.m_specularF0Factor), inputs.m_specularF0_useTexture);
+        result.m_metallic = GetMetallicInput(inputs.m_metallicMap, inputs.m_sampler, transformedUv[inputs.m_metallicMapUvIndex], real(inputs.m_metallicFactor), inputs.m_metallic_useTexture);
+        result.m_roughness = GetRoughnessInput(inputs.m_roughnessMap, MaterialSrg::m_sampler, transformedUv[inputs.m_roughnessMapUvIndex], real(inputs.m_roughnessFactor), real(inputs.m_roughnessLowerBound), real(inputs.m_roughnessUpperBound), inputs.m_roughness_useTexture);
+
+        result.m_emissiveLighting = GetEmissiveInput(inputs.m_emissiveMap, inputs.m_sampler, transformedUv[inputs.m_emissiveMapUvIndex], real(inputs.m_emissiveIntensity), real3(inputs.m_emissiveColor.rgb), 0.0, 1.0, inputs.m_emissiveEnabled, inputs.m_emissive_useTexture);
+        result.m_diffuseAmbientOcclusion = GetOcclusionInput(inputs.m_diffuseOcclusionMap, inputs.m_sampler, transformedUv[inputs.m_diffuseOcclusionMapUvIndex], real(inputs.m_diffuseOcclusionFactor), inputs.m_diffuseOcclusion_useTexture);
+        result.m_specularOcclusion = GetOcclusionInput(inputs.m_specularOcclusionMap, MaterialSrg::m_sampler, transformedUv[inputs.m_specularOcclusionMapUvIndex], real(inputs.m_specularOcclusionFactor), inputs.m_specularOcclusion_useTexture);
     
     #if ENABLE_CLEAR_COAT
         result.m_clearCoat.InitializeToZero();
         if(inputs.m_clearCoatEnabled)
         {
-            float3x3 clearCoatUvMatrix = inputs.m_clearCoatNormalMapUvIndex == 0 ? inputs.m_uvMatrix : CreateIdentity3x3();
+            real3x3 clearCoatUvMatrix = inputs.m_clearCoatNormalMapUvIndex == 0 ? real3x3(inputs.m_uvMatrix) : real3x3(CreateIdentity3x3());
 
-            GetClearCoatInputs(inputs.m_clearCoatInfluenceMap, transformedUv[inputs.m_clearCoatInfluenceMapUvIndex], inputs.m_clearCoatFactor, inputs.m_clearCoat_factor_useTexture,
-                                inputs.m_clearCoatRoughnessMap, transformedUv[inputs.m_clearCoatRoughnessMapUvIndex], inputs.m_clearCoatRoughness, inputs.m_clearCoat_roughness_useTexture,
-                                inputs.m_clearCoatNormalMap,    transformedUv[inputs.m_clearCoatNormalMapUvIndex], inputs.m_normal, inputs.m_clearCoat_normal_useTexture, inputs.m_clearCoatNormalStrength,
+            GetClearCoatInputs(inputs.m_clearCoatInfluenceMap, transformedUv[inputs.m_clearCoatInfluenceMapUvIndex], real(inputs.m_clearCoatFactor), inputs.m_clearCoat_factor_useTexture,
+                                inputs.m_clearCoatRoughnessMap, transformedUv[inputs.m_clearCoatRoughnessMapUvIndex], real(inputs.m_clearCoatRoughness), inputs.m_clearCoat_roughness_useTexture,
+                                inputs.m_clearCoatNormalMap,    transformedUv[inputs.m_clearCoatNormalMapUvIndex], inputs.m_normal, inputs.m_clearCoat_normal_useTexture, real(inputs.m_clearCoatNormalStrength),
                                 clearCoatUvMatrix, inputs.m_tangents[inputs.m_clearCoatNormalMapUvIndex], inputs.m_bitangents[inputs.m_clearCoatNormalMapUvIndex],
                                 inputs.m_sampler, inputs.m_isFrontFace,
                                 result.m_clearCoat.factor, result.m_clearCoat.roughness, result.m_clearCoat.normal);
@@ -407,9 +407,9 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
 
     Surface EvaluateSurface_StandardMultilayerPBR(
         float3 positionWS,
-        float3 normalWS,
-        float3 tangents[UvSetCount],
-        float3 bitangents[UvSetCount],
+        real3 normalWS,
+        real3 tangents[UvSetCount],
+        real3 bitangents[UvSetCount],
         float2 uvs[UvSetCount],
         bool isFrontFace,
         bool isDisplacementClipped,
@@ -422,28 +422,28 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         if(o_debugDrawMode == DebugDrawMode::BlendMask)
         {
             float3 blendMaskValues = GetApplicableBlendMaskValues(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask);
-            return MakeDebugSurface(positionWS, normalWS, blendMaskValues);
+            return MakeDebugSurface(positionWS, normalWS, real3(blendMaskValues));
         }
     
         if(o_debugDrawMode == DebugDrawMode::Displacement)
         {
-            float startDepth = -MaterialSrg::m_displacementMax;
-            float stopDepth = -MaterialSrg::m_displacementMin;
-            float depth = GetNormalizedDepth(startDepth, stopDepth, uvs[MaterialSrg::m_parallaxUvIndex], float2(0,0), float2(0,0));
-            float height = 1 - saturate(depth);
-            return MakeDebugSurface(positionWS, normalWS, float3(height,height,height));
+            real startDepth = real(-MaterialSrg::m_displacementMax);
+            real stopDepth = real(-MaterialSrg::m_displacementMin);
+            real depth = GetNormalizedDepth(startDepth, stopDepth, uvs[MaterialSrg::m_parallaxUvIndex], real2(0,0), real2(0,0));
+            real height = 1 - saturate(depth);
+            return MakeDebugSurface(positionWS, normalWS, real3(height,height,height));
         }
     
         if(o_debugDrawMode == DebugDrawMode::FinalBlendWeights)
         {
             float3 blendWeights = GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask);
-            return MakeDebugSurface(positionWS, normalWS, blendWeights);
+            return MakeDebugSurface(positionWS, normalWS, real3(blendWeights));
         }
 
         // ------- Calculate Layer Blend Mask Values -------
     
         // Now that any parallax has been calculated, we calculate the blend factors for any layers that are impacted by the parallax.
-        float3 blendWeights = GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask);
+        real3 blendWeights = (GetBlendWeights(blendSource, uvs[MaterialSrg::m_blendMaskUvIndex], vertexBlendMask));
         
         // ------- Layer 1 (base layer) -----------
 
@@ -500,7 +500,7 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
 
         // ------- Combine Normals ---------
 
-        float3 normalTS = float3(0,0,1);
+        real3 normalTS = real3(0,0,1);
         if(blendWeights.r > 0)
         {
             normalTS = lightingInputLayer1.m_normalTS;
@@ -519,9 +519,9 @@ option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opa
         
         // ------- Combine Albedo, roughness, specular, roughness ---------
 
-        float3 baseColor = BlendLayers(lightingInputLayer1.m_baseColor, lightingInputLayer2.m_baseColor, lightingInputLayer3.m_baseColor, blendWeights);
-        float specularF0Factor = BlendLayers(lightingInputLayer1.m_specularF0Factor, lightingInputLayer2.m_specularF0Factor, lightingInputLayer3.m_specularF0Factor, blendWeights);
-        float metallic = BlendLayers(lightingInputLayer1.m_metallic, lightingInputLayer2.m_metallic, lightingInputLayer3.m_metallic, blendWeights);
+        real3 baseColor = BlendLayers(lightingInputLayer1.m_baseColor, lightingInputLayer2.m_baseColor, lightingInputLayer3.m_baseColor, blendWeights);
+        real specularF0Factor = BlendLayers(lightingInputLayer1.m_specularF0Factor, lightingInputLayer2.m_specularF0Factor, lightingInputLayer3.m_specularF0Factor, blendWeights);
+        real metallic = BlendLayers(lightingInputLayer1.m_metallic, lightingInputLayer2.m_metallic, lightingInputLayer3.m_metallic, blendWeights);
     
         if(o_parallax_highlightClipping && isDisplacementClipped)
         {

+ 9 - 8
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/BlendUtility.azsli

@@ -13,13 +13,13 @@
 enum class TextureBlendMode { Multiply, LinearLight, Lerp, Overlay };
 
 // See https://en.wikipedia.org/wiki/Blend_modes#Dodge_and_burn
-float3 TextureBlend_LinearLight(float3 base, float3 mask)
+real3 TextureBlend_LinearLight(real3 base, real3 mask)
 {
     return saturate(base + 2 * mask - 1);
 }
 
 // See http://www.deepskycolors.com/archive/2010/04/21/formulas-for-Photoshop-blending-modes.html
-float3 TextureBlend_Overlay(float3 target, float3 blend)
+real3 TextureBlend_Overlay(real3 target, real3 blend)
 {
     return (target > 0.5) * (1.0 - (1.0 - 2.0 * (target - 0.5)) * (1.0 - blend)) +
            (target <= 0.5) * ((2.0 * target) * blend);
@@ -31,7 +31,7 @@ float3 TextureBlend_Overlay(float3 target, float3 blend)
 //! @param factor - A factor that controls the blend. The specific behavior depends on the blend mode.
 //! @param blendMode - Indicates the type of blend to perform
 //! @return the resulting blended color
-float3 ApplyTextureBlend(float3 color, float3 blendColor, float factor, TextureBlendMode blendMode)
+real3 ApplyTextureBlend(real3 color, real3 blendColor, real factor, TextureBlendMode blendMode)
 {
     if(blendMode == TextureBlendMode::Multiply)
     {
@@ -45,10 +45,11 @@ float3 ApplyTextureBlend(float3 color, float3 blendColor, float factor, TextureB
     {
         // [GFX TODO][ATOM-3237] See if we can avoid these extra color space conversions...
         // To get blend behavior that mimics photoshop, convert to sRGB
-        float3 blendColorSRGB = TransformColor(blendColor, ColorSpaceId::ACEScg, ColorSpaceId::SRGB);
-        float3 colorSRGB = TransformColor(color, ColorSpaceId::ACEScg, ColorSpaceId::SRGB);
+        //Acessg -> srgb
+        real3 blendColorSRGB = TransformColorAcesToSRGB(blendColor);
+        real3 colorSRGB = TransformColorAcesToSRGB(color);
                  
-        float3 finalColor = colorSRGB;
+        real3 finalColor = colorSRGB;
 
         if(blendMode == TextureBlendMode::LinearLight)
         {
@@ -60,8 +61,8 @@ float3 ApplyTextureBlend(float3 color, float3 blendColor, float factor, TextureB
         }
         
         // Convert back to ACEScg
-        finalColor = TransformColor(finalColor, ColorSpaceId::SRGB, ColorSpaceId::ACEScg);
-        
+        finalColor = TransformColorSRGBToAces(finalColor);
+
         // Apply factor
         finalColor = lerp(color, finalColor, factor);
 

+ 3 - 3
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCcToAcesCg.azsli

@@ -61,7 +61,7 @@ UNDISCLOSED.
 
 #include <Atom/Features/PostProcessing/Aces.azsli>
 
-float AcesCcToLinear(float value)
+real AcesCcToLinear(real value)
 {
   if (value < -0.3013698630) // (9.72-15)/17.52
     return (pow( 2., value*17.52-9.72) - pow( 2.,-16.))*2.0;
@@ -71,9 +71,9 @@ float AcesCcToLinear(float value)
     return HALF_MAX;
 }
 
-float3 AcesCcToAcesCg(float3 color)
+real3 AcesCcToAcesCg(real3 color)
 {
-    return float3(
+    return real3(
         AcesCcToLinear(color.r),
         AcesCcToLinear(color.g),
         AcesCcToLinear(color.b));

+ 3 - 3
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCgToAcesCc.azsli

@@ -59,7 +59,7 @@ UNDISCLOSED.
 
 #pragma once
 
-float LinearToAcesCc(float value)
+real LinearToAcesCc(real value)
 {
   if (value <= 0)
     return -0.3584474886; // =(log2( pow(2.,-16.))+9.72)/17.52
@@ -69,9 +69,9 @@ float LinearToAcesCc(float value)
     return (log2(value) + 9.72) / 17.52;
 }
 
-float3 AcesCgToAcesCc(float3 color)
+real3 AcesCgToAcesCc(real3 color)
 {
-    return float3(
+    return real3(
         LinearToAcesCc(color.r),
         LinearToAcesCc(color.g),
         LinearToAcesCc(color.b)

+ 1 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/AcesCg_To_LinearSrgb.azsli

@@ -10,7 +10,7 @@
 
 #include <Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli>
 
-float3 AcesCg_To_LinearSrgb(float3 color)
+real3 AcesCg_To_LinearSrgb(real3 color)
 {
     return mul(mul(XYZToSRGBMat, mul(D60ToD65Cat, AP1ToXYZMat)), color);
 }

+ 1 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Aces_To_AcesCg.azsli

@@ -10,7 +10,7 @@
 
 #include <Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli>
 
-float3 Aces_To_AcesCg(float3 color)
+real3 Aces_To_AcesCg(real3 color)
 {
     return mul(AP0ToAP1Mat, color);
 }

+ 1 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/CalculateLuminance_AcesCg.azsli

@@ -10,7 +10,7 @@
 
 #include <Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli>
 
-float CalculateLuminance_AcesCg(in float3 color)
+real CalculateLuminance_AcesCg(in real3 color)
 {
     // Calculate the Y value of XYZ color space.
     return dot(color, AP1ToXYZMat[1]);

+ 2 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/CalculateLuminance_LinearSrgb.azsli

@@ -10,8 +10,9 @@
 
 #include <Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli>
 
-float CalculateLuminance_LinearSrgb(in float3 color)
+real CalculateLuminance_LinearSrgb(in real3 color)
 {
     // Calculate the Y value of XYZ color space.
     return dot(color, SRGBToXYZMat[1]);
 }
+

+ 1 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_AcesCg.azsli

@@ -10,7 +10,7 @@
 
 #include <Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli>
 
-float3 LinearSrgb_To_AcesCg(float3 color)
+real3 LinearSrgb_To_AcesCg(real3 color)
 {
     return mul(mul(XYZToAP1Mat, mul(D65ToD60Cat, SRGBToXYZMat)), color);
 }

+ 2 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/LinearSrgb_To_Srgb.azsli

@@ -8,8 +8,8 @@
 
 #pragma once
 
-float3 LinearSrgb_To_Srgb(float3 color)
+real3 LinearSrgb_To_Srgb(real3 color)
 {
     // Copied from CryFx's ToAccurateSRGB()
-    return (color.xyz < 0.0031308) ? 12.92 * color.xyz : 1.055 * pow(color.xyz, 1.0 / 2.4) - float3(0.055, 0.055, 0.055);
+    return (color.xyz < 0.0031308) ? 12.92 * color.xyz : 1.055 * pow(color.xyz, 1.0 / 2.4) - real3(0.055, 0.055, 0.055);
 }

+ 2 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/GeneratedTransforms/Srgb_To_LinearSrgb.azsli

@@ -8,8 +8,8 @@
 
 #pragma once
 
-float3 Srgb_To_LinearSrgb(float3 color)
+real3 Srgb_To_LinearSrgb(real3 color)
 {
     // Copied from CryFx's ToAccurateLinear()
-    return (color.xyz < 0.04045h) ? color.xyz / 12.92h : pow((color.xyz + float3(0.055h, 0.055h, 0.055h)) / float3(1.055h, 1.055h, 1.055h), 2.4h);
+    return (color.xyz < 0.04045) ? color.xyz / 12.92h : pow((color.xyz + real3(0.055, 0.055, 0.055)) / real3(1.055, 1.055, 1.055), 2.4);
 }

+ 23 - 9
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ColorManagement/TransformColor.azsli

@@ -30,13 +30,27 @@ enum class ColorSpaceId
     Invalid
 };
 
-float3 TransformColor(in float3 color, ColorSpaceId fromColorSpace, ColorSpaceId toColorSpace)
+real3 TransformColorSRGBToAces(in real3 color)
+{
+    color = Srgb_To_LinearSrgb(color);
+    color = LinearSrgb_To_AcesCg(color);
+    return color;
+}
+
+real3 TransformColorAcesToSRGB(in real3 color)
+{
+    color = AcesCg_To_LinearSrgb(color);
+    color = LinearSrgb_To_Srgb(color);
+    return color;
+}
+
+real3 TransformColor(in real3 color, ColorSpaceId fromColorSpace, ColorSpaceId toColorSpace)
 {
     if(fromColorSpace == toColorSpace)
     {
         return color;
     }
-    
+
     if (fromColorSpace == ColorSpaceId::LinearSRGB && toColorSpace == ColorSpaceId::ACEScg)
     {
         color = LinearSrgb_To_AcesCg(color);
@@ -47,13 +61,11 @@ float3 TransformColor(in float3 color, ColorSpaceId fromColorSpace, ColorSpaceId
     }
     else if (fromColorSpace == ColorSpaceId::SRGB && toColorSpace == ColorSpaceId::ACEScg)
     {
-        color = Srgb_To_LinearSrgb(color);
-        color = LinearSrgb_To_AcesCg(color);
+        color = TransformColorSRGBToAces(color);
     }
     else if (fromColorSpace == ColorSpaceId::ACEScg && toColorSpace == ColorSpaceId::SRGB)
     {
-        color = AcesCg_To_LinearSrgb(color);
-        color = LinearSrgb_To_Srgb(color);
+        color = TransformColorAcesToSRGB(color);
     }
     else if (fromColorSpace == ColorSpaceId::ACEScg && toColorSpace == ColorSpaceId::LinearSRGB)
     {
@@ -73,15 +85,16 @@ float3 TransformColor(in float3 color, ColorSpaceId fromColorSpace, ColorSpaceId
     }
     else
     {
-        color = float3(1, 0, 1);
+        color = real3(1, 0, 1);
     }
 
     return color;
+    
 }
 
-float CalculateLuminance(in float3 color, ColorSpaceId colorSpace)
+real CalculateLuminance(in real3 color, ColorSpaceId colorSpace)
 {
-    float luminance = 0.0f;
+    real luminance = 0.0;
     switch (colorSpace)
     {
         case ColorSpaceId::LinearSRGB:
@@ -126,3 +139,4 @@ float3 HsvToRgb(float3 color)
     const float3 p = abs(frac(color.xxx + k.xyz) * 6.0f - k.www);
     return color.z * lerp(k.xxx, saturate(p - k.xxx), color.y);
 }
+

+ 3 - 3
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Debug.azsli

@@ -201,6 +201,6 @@ bool OverrideMetallicEnabled()
     return IsDebuggingEnabled() && GetDebugOption( RenderDebugOptions::OverrideMetallic );
 }
 
-float3 GetBaseColorOverride() { return SceneSrg::m_debugOverrideBaseColor; }
-float GetRoughnessOverride() { return SceneSrg::m_debugOverrideRoughness; }
-float GetMetallicOverride() { return SceneSrg::m_debugOverrideMetallic; }
+real3 GetBaseColorOverride() { return real3(SceneSrg::m_debugOverrideBaseColor); }
+real GetRoughnessOverride() { return real(SceneSrg::m_debugOverrideRoughness); }
+real GetMetallicOverride() { return real(SceneSrg::m_debugOverrideMetallic); }

+ 1 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/MatrixUtility.azsli

@@ -8,7 +8,7 @@
 
 #pragma once
 
-#define EPSILON 10e-5f
+#define EPSILON 10e-5
 
  
 float4x4 CreateIdentity4x4()

+ 1 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/AlphaUtils.azsli

@@ -10,7 +10,7 @@
 
 option enum class OpacityMode {Opaque, Cutout, Blended, TintedTransparent} o_opacity_mode;
 
-void CheckClipping(float alpha, float opacityFactor)
+void CheckClipping(real alpha, real opacityFactor)
 {
     switch(o_opacity_mode)
     {

+ 12 - 12
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli

@@ -17,9 +17,9 @@
 
 // Analytical integation (approximation) of diffusion profile over radius, could be replaced by other pre integrated kernels
 // such as sum of Gaussian (see T(s))
-float3 TransmissionKernel(float t, float3 s)
+real3 TransmissionKernel(real t, real3 s)
 {
-    float3 exponent = s * t;
+    real3 exponent = s * t;
     return 0.25 * (1.0 / exp(exponent) + 3.0 / exp(exponent / 3.0));
 }
 
@@ -37,13 +37,13 @@ float3 T(float s)
     float3(0.078, 0.0, 0.0) * exp(-s*s/7.41);
 }
 
-float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight, float transmissionDistance, float attenuationDistance)
+real3 GetBackLighting(Surface surface, LightingData lightingData, real3 lightIntensity, real3 dirToLight, real transmissionDistance, real attenuationDistance)
 {
-    float3 result = float3(0.0, 0.0, 0.0);
+    real3 result = real3(0.0, 0.0, 0.0);
 
 #if ENABLE_TRANSMISSION
 
-    float thickness = 0.0; 
+    real thickness = 0.0; 
     TransmissionSurfaceData transmission = surface.transmission;
 
     switch(o_transmission_mode)
@@ -57,8 +57,8 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI
 
             {
                 thickness = max(transmissionDistance, transmission.thickness);
-                float transmittance = pow( saturate( dot( lightingData.dirToCamera, -normalize( dirToLight + surface.normal * transmission.GetDistortion() ) ) ), transmission.GetPower() ) * transmission.GetScale();
-                float lamberAttenuation = exp(-thickness * transmission.GetAttenuationCoefficient()) * saturate(1.0 - thickness);
+                real transmittance = pow( saturate( dot( lightingData.dirToCamera, -normalize( dirToLight + surface.normal * transmission.GetDistortion() ) ) ), transmission.GetPower() ) * transmission.GetScale();
+                real lamberAttenuation = exp(-thickness * transmission.GetAttenuationCoefficient()) * saturate(1.0 - thickness);
                 result = transmittance * lamberAttenuation * lightIntensity;
             }
             break;
@@ -69,7 +69,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI
             
             {
                 // transmissionDistance < 0.0f means shadows are not enabled --> avoid unnecessary computation
-                if (transmissionDistance < 0.0f)
+                if (transmissionDistance < 0.0)
                 {
                     break;
                 }
@@ -78,15 +78,15 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI
                 // Albedo at front (surface point) is used to approximate irradiance at the back of the 
                 // object (observation 4 in [Jimenez J. et al, 2010])
                 // Increase angle of influence to avoid dark transition regions
-                float3 E = surface.albedo * saturate(transmission.GetTransmissionNdLBias() + dot(-surface.normal, dirToLight));
+                real3 E = surface.albedo * saturate(transmission.GetTransmissionNdLBias() + dot(-surface.normal, dirToLight));
 
                 // Transmission distance modulated by hardcoded constant C and the thickness exposed parameter 
                 // (in this case modulating the distance traversed by the light inside the object)
-                const float C = 300.0f;
-                float s = transmissionDistance * C * transmission.thickness;
+                const real C = 300.0;
+                real s = transmissionDistance * C * transmission.thickness;
                 
                 // Use scattering color to weight thin object transmission color
-                const float3 invScattering = rcp(max(transmission.scatterDistance, float(0.00001)));
+                const real3 invScattering = rcp(max(transmission.scatterDistance, real(0.00001)));
                 
 #if !USE_HUMAN_SKIN_PROFILE
                 // Generic profile based on scatter color

+ 8 - 1
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Decals.azsli

@@ -20,6 +20,7 @@
 
 void ApplyDecal(uint currDecalIndex, inout Surface surface);
 
+#if ENABLE_DECALS
 void ApplyDecals(inout LightCullingTileIterator tileIterator, inout Surface surface)
 {
 #if ENABLE_LIGHT_CULLING
@@ -111,7 +112,13 @@ void ApplyDecal(uint currDecalIndex, inout Surface surface)
         surface.albedo = lerp(surface.albedo, baseMap.rgb, albedoOpacity);      
 
         const float normalOpacity = baseMap.a * decal.m_normalMapOpacity * decalAttenuation;
-        const float3 normalMapWS = GetWorldSpaceNormal(normalMap, decalRot[2], decalRot[0], decalRot[1], 1.0f);      
+        const float3 normalMapWS = GetWorldSpaceNormal(normalMap, decalRot[2], decalRot[0], decalRot[1], 1.0);      
         surface.normal = normalize(lerp(surface.normal, normalMapWS, normalOpacity));
     }
 }
+#else
+void ApplyDecals(inout LightCullingTileIterator tileIterator, inout Surface surface)
+{
+    //Not Enabled
+}
+#endif

+ 33 - 33
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli

@@ -18,68 +18,68 @@ class LightingData
     LightCullingTileIterator tileIterator;
     
     // Lighting outputs
-    float3 diffuseLighting;
-    float3 specularLighting;
-    float3 translucentBackLighting;
+    real3 diffuseLighting;
+    real3 specularLighting;
+    real3 translucentBackLighting;
 
     // Factors for the amount of diffuse and specular lighting applied
-    float3 diffuseResponse;
-    float3 specularResponse;
+    real3 diffuseResponse;
+    real3 specularResponse;
 
     // (N . L) to accept below (N . L = 0) in scattering through thin objects
-    float transmissionNdLBias; 
+    real transmissionNdLBias; 
     
     // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection
-    float shrinkFactor;
+    real shrinkFactor;
 
     // Attenuation applied to hide artifacts due to low-res shadow maps 
-    float distanceAttenuation;
+    real distanceAttenuation;
 
     // Normalized direction from surface to camera
-    float3 dirToCamera;
+    real3 dirToCamera;
     
     // Scaling term to approximate multiscattering contribution in specular BRDF
-    float3 multiScatterCompensation;
+    real3 multiScatterCompensation;
 
     // Lighting emitted from the surface
-    float3 emissiveLighting;
+    real3 emissiveLighting;
 
     // BRDF texture values
-    float2 brdf;
+    real2 brdf;
 
     // Normal . View
-    float NdotV;
+    real NdotV;
 
     // Occlusion factors
     // 0 = dark, 1 = light
-    float diffuseAmbientOcclusion;
-    float specularOcclusion;
+    real diffuseAmbientOcclusion;
+    real specularOcclusion;
 
-    void Init(float3 positionWS, float3 normal, float roughnessLinear);
-    void CalculateMultiscatterCompensation(float3 specularF0, bool enabled);
+    void Init(real3 positionWS, real3 normal, real roughnessLinear);
+    void CalculateMultiscatterCompensation(real3 specularF0, bool enabled);
     void FinalizeLighting();
-    void FinalizeLighting(float3 transmissionTint);
+    void FinalizeLighting(real3 transmissionTint);
 };
 
-void LightingData::Init(float3 positionWS, float3 normal, float roughnessLinear)
+void LightingData::Init(real3 positionWS, real3 normal, real roughnessLinear)
 {
-    diffuseLighting = float3(0.0, 0.0, 0.0);
-    specularLighting = float3(0.0, 0.0, 0.0);
-    translucentBackLighting = float3(0.0, 0.0, 0.0);
-    multiScatterCompensation = float3(1.0f, 1.0f, 1.0f);
-    emissiveLighting = float3(0.0f, 0.0f, 0.0f);
-    diffuseAmbientOcclusion = 1.0f;
-    specularOcclusion = 1.0f;
+    diffuseLighting = real3(0.0, 0.0, 0.0);
+    specularLighting = real3(0.0, 0.0, 0.0);
+    translucentBackLighting = real3(0.0, 0.0, 0.0);
+    multiScatterCompensation = real3(1.0, 1.0, 1.0);
+    emissiveLighting = real3(0.0, 0.0, 0.0);
+    diffuseAmbientOcclusion = 1.0;
+    specularOcclusion = 1.0;
 
-    dirToCamera = normalize(ViewSrg::m_worldPosition.xyz - positionWS);
+    dirToCamera = normalize(real3(ViewSrg::m_worldPosition.xyz) - positionWS);
 
     // sample BRDF map (indexed by smoothness values rather than roughness)
     NdotV = saturate(dot(normal, dirToCamera));
-    float2 brdfUV = float2(NdotV, (1.0f - roughnessLinear));
-    brdf = PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, brdfUV).rg;
+    real2 brdfUV = real2(NdotV, (1.0 - roughnessLinear));
+    brdf = real2(PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, brdfUV).rg);
 }
 
-void LightingData::CalculateMultiscatterCompensation(float3 specularF0, bool enabled)
+void LightingData::CalculateMultiscatterCompensation(real3 specularF0, bool enabled)
 {
     multiScatterCompensation = GetMultiScatterCompensation(specularF0, brdf, enabled);
 }
@@ -90,15 +90,15 @@ void LightingData::FinalizeLighting()
 
     if(!IsSpecularLightingEnabled())
     {
-        specularLighting = float3(0, 0, 0);
+        specularLighting = real3(0, 0, 0);
     }
     if(!IsDiffuseLightingEnabled())
     {
-        diffuseLighting = float3(0, 0, 0);
+        diffuseLighting = real3(0, 0, 0);
     }
 }
 
-void LightingData::FinalizeLighting(float3 transmissionTint)
+void LightingData::FinalizeLighting(real3 transmissionTint)
 {
     FinalizeLighting();
 

+ 19 - 20
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli

@@ -21,26 +21,26 @@
 #include <Atom/Features/PBR/Microfacet/Brdf.azsli>
 
 // Then define the Diffuse and Specular lighting functions
-float3 GetDiffuseLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight)
+real3 GetDiffuseLighting(Surface surface, LightingData lightingData, real3 lightIntensity, real3 dirToLight)
 {
-    float3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight, lightingData.diffuseResponse);
+    real3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight, lightingData.diffuseResponse);
 
 #if ENABLE_CLEAR_COAT
     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));
+        real HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera));
         diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor);
     }
 #endif
-
+    
     diffuse *= lightIntensity;
     return diffuse;
 }
 
-float3 GetSpecularLighting(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight)
+real3 GetSpecularLighting(Surface surface, LightingData lightingData, const real3 lightIntensity, const real3 dirToLight)
 {
-    float3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation);
+    real3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation);
 
 #if ENABLE_CLEAR_COAT
     if(o_clearCoat_feature_enabled)
@@ -49,8 +49,7 @@ float3 GetSpecularLighting(Surface surface, LightingData lightingData, const flo
     }
 #endif
 
-    specular *= lightIntensity;
-    
+    specular *= lightIntensity;    
     return specular;
 }
 
@@ -60,23 +59,23 @@ float3 GetSpecularLighting(Surface surface, LightingData lightingData, const flo
 
 struct PbrLightingOutput
 {
-    float4 m_diffuseColor;
-    float4 m_specularColor;
-    float4 m_albedo;
-    float4 m_specularF0;
-    float4 m_normal;
+    real4 m_diffuseColor;
+    real4 m_specularColor;
+    real4 m_albedo;
+    real4 m_specularF0;
+    real4 m_normal;
 };
 
 
-PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingData, float alpha)
+PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingData, real alpha)
 {
     PbrLightingOutput lightingOutput;
 
-    lightingOutput.m_diffuseColor = float4(lightingData.diffuseLighting, alpha);
-    lightingOutput.m_specularColor = float4(lightingData.specularLighting, 1.0);
+    lightingOutput.m_diffuseColor = real4(lightingData.diffuseLighting, alpha);
+    lightingOutput.m_specularColor = real4(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_specularF0 = real4(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);
@@ -85,13 +84,13 @@ PbrLightingOutput GetPbrLightingOutput(Surface surface, LightingData lightingDat
     return lightingOutput;
 }
 
-PbrLightingOutput DebugOutput(float3 color)
+PbrLightingOutput DebugOutput(real3 color)
 {
     PbrLightingOutput output = (PbrLightingOutput)0;
 
-    float3 defaultNormal = float3(0.0f, 0.0f, 1.0f);
+    real3 defaultNormal = real3(0.0, 0.0, 1.0);
 
-    output.m_diffuseColor = float4(color.rgb, 1.0f);
+    output.m_diffuseColor = real4(color.rgb, 1.0);
     output.m_normal.rgb = EncodeNormalSignedOctahedron(defaultNormal);
 
     return output;

+ 4 - 0
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingOptions.azsli

@@ -26,6 +26,10 @@
 #define ENABLE_LIGHT_CULLING              1
 #endif
 
+#ifndef ENABLE_DECALS
+#define ENABLE_DECALS              1
+#endif
+
 #ifndef ENABLE_AREA_LIGHT_VALIDATION
 #define ENABLE_AREA_LIGHT_VALIDATION    1
 #endif

+ 29 - 15
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/LightingUtils.azsli

@@ -11,13 +11,17 @@
 #include <Atom/RPI/Math.azsli>
 
 //! Transform cubemap coordinates to the expected cubemap orientation
+half3 GetCubemapCoords(half3 original)
+{
+    return half3(-original.x, original.z, -original.y);
+}
 float3 GetCubemapCoords(float3 original)
 {
     return float3(-original.x, original.z, -original.y);
 }
 
 //! Compute multiscatter compensation multiplier
-float3 GetMultiScatterCompensation(float3 specularF0, float2 brdf, bool enabled)
+real3 GetMultiScatterCompensation(real3 specularF0, real2 brdf, bool enabled)
 {
     if (!enabled)
     {
@@ -34,16 +38,21 @@ float3 GetMultiScatterCompensation(float3 specularF0, float2 brdf, bool enabled)
     // which is the integral of microfacet BRDF by assuming fresnel term F == 1 that represents total single scattering reflectance
     // for more information about compensation term please see:
     // https://blog.selfshadow.com/publications/turquin/ms_comp_final.pdf
-    float3 compensation = specularF0 * ((1.0 / (brdf.x + brdf.y)) - 1.0);
+    real3 compensation = specularF0 * ((1.0 / (brdf.x + brdf.y)) - 1.0);
     return compensation + 1.0;
 }
 
 // returns the UV coordinates for the BRDF texture
 float2 GetBRDFTexCoords(float roughness, float NdotV)
 {
-    float smoothness = 1.0f - roughness;
+    float smoothness = 1.0 - roughness;
     return float2(saturate(NdotV), smoothness);
 }
+half2 GetBRDFTexCoords(half roughness, half NdotV)
+{
+    half smoothness = 1.0 - roughness;
+    return half2(saturate(NdotV), smoothness);
+}
 
 // returns the roughess mip for sampling the convolved specular cubemap
 float GetRoughnessMip(float roughness)
@@ -51,33 +60,38 @@ float GetRoughnessMip(float roughness)
     const float maxRoughnessMip = 5;
     return roughness * maxRoughnessMip;
 }
+half GetRoughnessMip(half roughness)
+{
+    const half maxRoughnessMip = 5;
+    return roughness * maxRoughnessMip;
+}
 
 // compute parallax corrected reflection vector, AABB version
 // we do this by finding the intersection with the volume and adjusting the reflection vector for the surface position 
 // https://seblagarde.wordpress.com/2012/09/29/image-based-lighting-approaches-and-parallax-corrected-cubemap/
-float3 ApplyParallaxCorrectionAABB(float3 aabbMin, float3 aabbMax, float3 aabbPos, float3 positionWS, float3 reflectDir)
+real3 ApplyParallaxCorrectionAABB(real3 aabbMin, real3 aabbMax, real3 aabbPos, real3 positionWS, real3 reflectDir)
 {
-    float3 rcpReflectDir = 1.0f / reflectDir;
-    float3 intersectA = (aabbMax - positionWS) * rcpReflectDir;
-    float3 intersectB = (aabbMin - positionWS) * rcpReflectDir;
-    float3 furthestIntersect = max(intersectA, intersectB);
-    float distance = min(min(furthestIntersect.x, furthestIntersect.y), furthestIntersect.z);
-    float3 intersectPos = reflectDir * distance + positionWS;
+    real3 rcpReflectDir = 1.0 / reflectDir;
+    real3 intersectA = (aabbMax - positionWS) * rcpReflectDir;
+    real3 intersectB = (aabbMin - positionWS) * rcpReflectDir;
+    real3 furthestIntersect = max(intersectA, intersectB);
+    real distance = min(min(furthestIntersect.x, furthestIntersect.y), furthestIntersect.z);
+    real3 intersectPos = reflectDir * distance + positionWS;
     return (intersectPos - aabbPos);
 }
 
 // compute parallax corrected reflection vector, OBB version
-float3 ApplyParallaxCorrectionOBB(float4x4 obbTransformInverse, float3 obbHalfExtents, float3 positionWS, float3 reflectDir)
+real3 ApplyParallaxCorrectionOBB(real4x4 obbTransformInverse, real3 obbHalfExtents, float3 positionWS, real3 reflectDir)
 {
     // Convert point and reflection direction to object space (object here being the reflection probe)
-    float3 p = mul(obbTransformInverse, float4(positionWS, 1.0f)).xyz;
-    float3 r = mul(obbTransformInverse, float4(reflectDir, 0.0f)).xyz;
+    real3 p = mul(obbTransformInverse, real4(positionWS, 1.0f)).xyz;
+    real3 r = mul(obbTransformInverse, real4(reflectDir, 0.0f)).xyz;
 
     // Apply parallax correction in object aligned space
-    r = ApplyParallaxCorrectionAABB(-obbHalfExtents, obbHalfExtents, float3(0.0f, 0.0f, 0.0f), p, r);
+    r = ApplyParallaxCorrectionAABB(-obbHalfExtents, obbHalfExtents, real3(0.0, 0.0, 0.0), p, r);
 
     // Rotate the result back to world space
-    float3x3 probeToWorldRotation = transpose(ExtractFloat3x3(obbTransformInverse));
+    real3x3 probeToWorldRotation = transpose(ExtractFloat3x3(obbTransformInverse));
     r = mul(probeToWorldRotation, r);
 
     return normalize(r);

+ 8 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli

@@ -11,6 +11,7 @@
 #include <Atom/Features/PBR/Lights/LightTypesCommon.azsli>
 #include <Atom/Features/PBR/Lights/PointLight.azsli>
 
+#if ENABLE_CAPSULE_LIGHTS
 // Get a uniformly distributed point on the surface of a capsule from the provided uniformly distributed 2d point. Uses
 // capsRatio to determine if the point should be on the caps or cylinder to ensure an even distribution. 
 void SampleCapsule(float2 randomPoint, ViewSrg::CapsuleLight light, float capToCylinderAreaRatio, float3x3 localToWorld, out float3 outPosition, out float3 outDirection)
@@ -229,7 +230,6 @@ void ValidateCapsuleLight(ViewSrg::CapsuleLight light, Surface surface, inout Li
 
 void ApplyCapsuleLightInternal(uint lightIndex, Surface surface, inout LightingData lightingData)
 {
-#if ENABLE_CAPSULE_LIGHTS
     if (o_enableCapsuleLights)
     {
         ViewSrg::CapsuleLight light = ViewSrg::m_capsuleLights[lightIndex];
@@ -245,7 +245,6 @@ void ApplyCapsuleLightInternal(uint lightIndex, Surface surface, inout LightingD
             ApplyCapsuleLight(light, surface, lightingData);
         }
     }
-#endif // ENABLE_CAPSULE_LIGHTS
 }
 
 void ApplyCapsuleLights(Surface surface, inout LightingData lightingData)
@@ -267,3 +266,10 @@ void ApplyCapsuleLights(Surface surface, inout LightingData lightingData)
     }
 #endif
 }
+#else
+void ApplyCapsuleLights(Surface surface, inout LightingData lightingData)
+{    
+    //Not Enabled
+}
+#endif
+

+ 15 - 15
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli

@@ -15,13 +15,13 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData, fl
 {
     // Shadowed check
     const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight;
-    float litRatio = 1.0f;
-    float camToSurfDist = distance(ViewSrg::m_worldPosition, surface.position);
+    float litRatio = 1.0;
+    real camToSurfDist = real(distance(ViewSrg::m_worldPosition, surface.position));
 
     // Distance travelled by the light inside the object. If not redefined to a non-negative value, it will take the following behavior:
     // - If transmission mode is thick object -> use transmission thickness parameter instead
     // - If transmission mode is thin object -> ignore back lighting
-    float transmissionDistance = -1.0f;
+    float transmissionDistance = -1.0;
 
 #if ENABLE_SHADOWS
     if (o_enableShadows && shadowIndex <  SceneSrg::m_directionalLightCount)
@@ -56,37 +56,37 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData, fl
     for (int index = 0; index < SceneSrg::m_directionalLightCount; index++)
     {
         SceneSrg::DirectionalLight light = SceneSrg::m_directionalLights[index];
-        float3 dirToLight = normalize(-light.m_direction);
+        real3 dirToLight = normalize(real3(-light.m_direction));
 
         // Adjust the direction of the light based on its angular diameter.
-        float3 reflectionDir = reflect(-lightingData.dirToCamera, surface.normal);
-        float3 lightDirToReflectionDir = reflectionDir - dirToLight;
-        float lightDirToReflectionDirLen = length(lightDirToReflectionDir);
+        real3 reflectionDir = reflect(-lightingData.dirToCamera, surface.normal);
+        real3 lightDirToReflectionDir = reflectionDir - dirToLight;
+        real lightDirToReflectionDirLen = length(lightDirToReflectionDir);
         lightDirToReflectionDir = lightDirToReflectionDir / lightDirToReflectionDirLen; // normalize the length
-        lightDirToReflectionDirLen = min(light.m_angularRadius, lightDirToReflectionDirLen);
+        lightDirToReflectionDirLen = min(real(light.m_angularRadius), lightDirToReflectionDirLen);
         dirToLight += lightDirToReflectionDir * lightDirToReflectionDirLen;
 
         // [GFX TODO][ATOM-2012] care of multiple directional light
         // Currently shadow check is done only for index == shadowIndex.
-        float currentLitRatio = 1.0f;
-        float currentTransmissionDistance = -1.0f;
+        real currentLitRatio = 1.0;
+        float currentTransmissionDistance = -1.0;
 
 #if ENABLE_SHADOWS
         if (o_enableShadows && index == shadowIndex)
         {
             // Add contribution only if current directional light is the active one for shadows
-            currentLitRatio = litRatio;
+            currentLitRatio = real(litRatio);
             currentTransmissionDistance = transmissionDistance;
         }
 #endif
 
         // Transmission contribution
 #if ENABLE_TRANSMISSION
-        lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance, camToSurfDist);
+        lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, real3(light.m_rgbIntensityLux), dirToLight, real(currentTransmissionDistance), camToSurfDist);
 #endif
         
-        lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio;
-        lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio;
+        lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, real3(light.m_rgbIntensityLux), dirToLight) * currentLitRatio;
+        lightingData.specularLighting += GetSpecularLighting(surface, lightingData, real3(light.m_rgbIntensityLux), dirToLight) * currentLitRatio;
 
 #if ENABLE_SHADER_DEBUGGING
         if(IsDebuggingEnabled_PLACEHOLDER() && GetRenderDebugViewMode() == RenderDebugViewMode::CascadeShadows)
@@ -100,7 +100,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData, fl
     // Add debug coloring for directional light shadow
     if (o_enableShadows && shadowIndex <  SceneSrg::m_directionalLightCount)
     {
-        lightingData.specularLighting = DirectionalLightShadow::AddDebugColoring(lightingData.specularLighting, shadowIndex, surface.position, surface.vertexNormal);
+        lightingData.specularLighting = real3(DirectionalLightShadow::AddDebugColoring(lightingData.specularLighting, shadowIndex, surface.position, real3(surface.vertexNormal)));
     }
 #endif
 }

+ 10 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli

@@ -11,6 +11,7 @@
 #include <Atom/Features/PBR/Lights/LightTypesCommon.azsli>
 #include <Atom/Features/Shadow/ProjectedShadow.azsli>
 
+#if ENABLE_DISK_LIGHTS
 enum DiskLightFlag
 {
     UseConeAngle = 1,
@@ -213,7 +214,6 @@ void ValidateDiskLight(ViewSrg::DiskLight light, Surface surface, inout Lighting
 
 void ApplyDiskLightInternal(uint lightIndex, Surface surface, inout LightingData lightingData)
 {
-#if ENABLE_DISK_LIGHTS
     if (o_enableDiskLights)
     {
         ViewSrg::DiskLight light = ViewSrg::m_diskLights[lightIndex];
@@ -229,7 +229,6 @@ void ApplyDiskLightInternal(uint lightIndex, Surface surface, inout LightingData
             ApplyDiskLight(light, surface, lightingData);
         }
     }
-#endif // ENABLE_DISK_LIGHTS
 }
 
 void ApplyDiskLights(Surface surface, inout LightingData lightingData)
@@ -251,3 +250,12 @@ void ApplyDiskLights(Surface surface, inout LightingData lightingData)
     }
 #endif
 }
+
+#else
+
+void ApplyDiskLights(Surface surface, inout LightingData lightingData)
+{    
+    //Not Enabled
+}
+
+#endif

+ 50 - 37
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Ibl.azsli

@@ -19,58 +19,71 @@
 #include <Atom/Features/PBR/Lights/ReflectionProbeData.azsli>
 #include <Atom/Features/PBR/LightingUtils.azsli>
 
-float3 GetIblDiffuse(
-    float3 normal, 
-    float3 albedo, 
-    float3 diffuseResponse)
+#ifndef ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION
+#define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 1
+#endif
+
+#ifndef ENABLE_REFLECTIONPROBE_BLENDING
+#define ENABLE_REFLECTIONPROBE_BLENDING 1
+#endif
+
+real3 GetIblDiffuse(
+    real3 normal, 
+    real3 albedo, 
+    real3 diffuseResponse)
 {
-    float3 irradianceDir = MultiplyVectorQuaternion(normal, SceneSrg::m_iblOrientation);
-    float3 diffuseSample = SceneSrg::m_diffuseEnvMap.Sample(SceneSrg::m_samplerEnv, GetCubemapCoords(irradianceDir)).rgb;
+    real3 irradianceDir = MultiplyVectorQuaternion(normal, real4(SceneSrg::m_iblOrientation));
+    real3 diffuseSample = real3(SceneSrg::m_diffuseEnvMap.Sample(SceneSrg::m_samplerEnv, GetCubemapCoords(irradianceDir)).rgb);
 
     return diffuseResponse * albedo * diffuseSample;
 }
 
-float3 GetIblSpecular(
+real3 GetIblSpecular(
     float3 position, 
-    float3 normal, 
-    float3 specularF0, 
-    float roughnessLinear, 
-    float3 dirToCamera, 
-    float2 brdf,
+    real3 normal, 
+    real3 specularF0, 
+    real roughnessLinear, 
+    real3 dirToCamera, 
+    real2 brdf,
     ReflectionProbeData reflectionProbe,
     TextureCube reflectionProbeCubemap)
 {
-    float3 reflectDir = reflect(-dirToCamera, normal);
-    reflectDir = MultiplyVectorQuaternion(reflectDir, SceneSrg::m_iblOrientation);    
+    real3 reflectDir = reflect(-dirToCamera, normal);
+    reflectDir = MultiplyVectorQuaternion(reflectDir, real4(SceneSrg::m_iblOrientation));    
 
     // global
-    float3 outSpecular = SceneSrg::m_specularEnvMap.SampleLevel(SceneSrg::m_samplerEnv, GetCubemapCoords(reflectDir), GetRoughnessMip(roughnessLinear)).rgb;
+    real3 outSpecular = real3(SceneSrg::m_specularEnvMap.SampleLevel(SceneSrg::m_samplerEnv, GetCubemapCoords(reflectDir), GetRoughnessMip(roughnessLinear)).rgb);
     outSpecular *= (specularF0 * brdf.x + brdf.y);
     
     // reflection probe
     if (reflectionProbe.m_useReflectionProbe)
     {
+#if ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION
         if (reflectionProbe.m_useParallaxCorrection)
         {
             reflectDir = ApplyParallaxCorrectionOBB(
-                GetReflectionProbeWorldMatrixInverse(reflectionProbe),
-                reflectionProbe.m_outerObbHalfLengths,
+                real4x4(GetReflectionProbeWorldMatrixInverse(reflectionProbe)),
+                real3(reflectionProbe.m_outerObbHalfLengths),
                 position,
                 reflectDir);
         }
-    
-        float3 probeSpecular = reflectionProbeCubemap.SampleLevel(SceneSrg::m_samplerEnv, GetCubemapCoords(reflectDir), GetRoughnessMip(roughnessLinear)).rgb;
+#endif
+        real3 probeSpecular = real3(reflectionProbeCubemap.SampleLevel(SceneSrg::m_samplerEnv, GetCubemapCoords(reflectDir), GetRoughnessMip(roughnessLinear)).rgb);
         probeSpecular *= (specularF0 * brdf.x + brdf.y);
-    
+
+#if ENABLE_REFLECTIONPROBE_BLENDING
         // compute blend amount based on world position in the reflection probe volume
-        float blendAmount = ComputeLerpBetweenInnerOuterOBBs(
-            (float3x4)GetReflectionProbeWorldMatrixInverse(reflectionProbe),
-            reflectionProbe.m_innerObbHalfLengths,
-            reflectionProbe.m_outerObbHalfLengths,
+        real blendAmount = ComputeLerpBetweenInnerOuterOBBs(
+            (real3x4)GetReflectionProbeWorldMatrixInverse(reflectionProbe),
+            real3(reflectionProbe.m_innerObbHalfLengths),
+            real3(reflectionProbe.m_outerObbHalfLengths),
             position);
-    
         outSpecular = lerp(outSpecular, probeSpecular, blendAmount);
+#else
+        outSpecular = probeSpecular;
+#endif 
     }
+    
     return outSpecular;
 }
 
@@ -80,40 +93,40 @@ void ApplyIBL(Surface surface, inout LightingData lightingData, bool useDiffuseI
 
     if(useIbl)
     {
-        float globalIblExposure = pow(2.0, SceneSrg::m_iblExposure);
+        real globalIblExposure = pow(2.0, real(SceneSrg::m_iblExposure));
         
         if(useDiffuseIbl)
         {
-            float3 iblDiffuse = GetIblDiffuse(surface.normal, surface.albedo, lightingData.diffuseResponse);
+            real3 iblDiffuse = GetIblDiffuse(surface.normal, surface.albedo, lightingData.diffuseResponse);
             lightingData.diffuseLighting += (iblDiffuse * globalIblExposure * lightingData.diffuseAmbientOcclusion);
         }
 
         if(useSpecularIbl)
         {
-            float3 iblSpecular = GetIblSpecular(surface.position, surface.normal, surface.specularF0, surface.roughnessLinear, lightingData.dirToCamera, lightingData.brdf, reflectionProbe, reflectionProbeCubemap);
+            real3 iblSpecular = GetIblSpecular(surface.position, surface.normal, surface.specularF0, surface.roughnessLinear, lightingData.dirToCamera, lightingData.brdf, reflectionProbe, reflectionProbeCubemap);
             iblSpecular *= lightingData.multiScatterCompensation;
-
+            
 #if ENABLE_CLEAR_COAT
-            if (o_clearCoat_feature_enabled && surface.clearCoat.factor > 0.0f)
+            if (o_clearCoat_feature_enabled && surface.clearCoat.factor > 0.0)
             {
-                float clearCoatNdotV = saturate(dot(surface.clearCoat.normal, lightingData.dirToCamera));
-                clearCoatNdotV = max(clearCoatNdotV, 0.01f);  // [GFX TODO][ATOM-4466] This is a current band-aid for specular noise at grazing angles.
-                float2 clearCoatBrdf = PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, GetBRDFTexCoords(surface.clearCoat.roughness, clearCoatNdotV)).rg;
+                real clearCoatNdotV = saturate(dot(surface.clearCoat.normal, lightingData.dirToCamera));
+                clearCoatNdotV = max(clearCoatNdotV, 0.01);  // [GFX TODO][ATOM-4466] This is a current band-aid for specular noise at grazing angles.
+                real2 clearCoatBrdf = real2(PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, GetBRDFTexCoords(surface.clearCoat.roughness, clearCoatNdotV)).rg);
 
                 // clear coat uses fixed IOR = 1.5 represents polyurethane which is the most common material for gloss clear coat
                 // coat layer assumed to be dielectric thus don't need multiple scattering compensation
-                float3 clearCoatSpecularF0 = float3(0.04f, 0.04f, 0.04f);
-                float3 clearCoatIblSpecular = GetIblSpecular(surface.position, surface.clearCoat.normal, clearCoatSpecularF0, surface.clearCoat.roughness, lightingData.dirToCamera, clearCoatBrdf, reflectionProbe, reflectionProbeCubemap);
+                real3 clearCoatSpecularF0 = real3(0.04, 0.04, 0.04);
+                real3 clearCoatIblSpecular = GetIblSpecular(surface.position, surface.clearCoat.normal, clearCoatSpecularF0, surface.clearCoat.roughness, lightingData.dirToCamera, clearCoatBrdf, reflectionProbe, reflectionProbeCubemap);
 
                 clearCoatIblSpecular *= surface.clearCoat.factor;
         
                 // attenuate base layer energy
-                float3 clearCoatResponse = FresnelSchlickWithRoughness(clearCoatNdotV, clearCoatSpecularF0, surface.clearCoat.roughness) * surface.clearCoat.factor;
+                real3 clearCoatResponse = FresnelSchlickWithRoughness(clearCoatNdotV, clearCoatSpecularF0, surface.clearCoat.roughness) * surface.clearCoat.factor;
                 iblSpecular = iblSpecular * (1.0 - clearCoatResponse) * (1.0 - clearCoatResponse) + clearCoatIblSpecular;
             }
 #endif
 
-            float exposure = reflectionProbe.m_useReflectionProbe ? pow(2.0, reflectionProbe.m_exposure) : globalIblExposure;
+            real exposure = reflectionProbe.m_useReflectionProbe ? pow(2.0, real(reflectionProbe.m_exposure)) : globalIblExposure;
             lightingData.specularLighting += (iblSpecular * exposure);
         }
     }

+ 16 - 16
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli

@@ -14,10 +14,10 @@
 #include <Atom/Features/PBR/Hammersley.azsli>
 
 //! 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)
+real GetIntensityAdjustedByRadiusAndRoughness(real roughnessA, real radius, real distance2)
 {
-    float roughnessAdjusted = saturate(roughnessA + (radius / (3.0 * sqrt(distance2))));
-    float intensityNormalization = max(roughnessA, 0.001f) / roughnessAdjusted;
+    real roughnessAdjusted = saturate(roughnessA + (radius / (3.0 * sqrt(distance2))));
+    real intensityNormalization = max(roughnessA, 0.001) / roughnessAdjusted;
     return intensityNormalization * intensityNormalization;
 }
 
@@ -25,25 +25,25 @@ float GetIntensityAdjustedByRadiusAndRoughness(float roughnessA, float radius, f
 void AddSampleContribution(
     in Surface surface,
     in LightingData lightingData,
-    in float3 lightSamplePoint,
-    in float3 lightSampleDirection,
-    in float bothDirectionsFactor,
-    inout float3 diffuseAcc,
-    inout float3 specularAcc,
-    inout float3 translucentAcc)
+    in real3 lightSamplePoint,
+    in real3 lightSampleDirection,
+    in real bothDirectionsFactor,
+    inout real3 diffuseAcc,
+    inout real3 specularAcc,
+    inout real3 translucentAcc)
 {
-    float3 posToLightSample = lightSamplePoint - surface.position;
-    float distanceToLight2 = dot(posToLightSample, posToLightSample);
-    float3 posToLightSampleDir = normalize(posToLightSample);
+    real3 posToLightSample = lightSamplePoint - real3(surface.position);
+    real distanceToLight2 = dot(posToLightSample, posToLightSample);
+    real3 posToLightSampleDir = normalize(posToLightSample);
 
     // Lambertian emitter
-    float intensity = dot(-lightSampleDirection, posToLightSampleDir);
+    real intensity = dot(-lightSampleDirection, posToLightSampleDir);
     // Handle if the light emits from both sides
     intensity = abs(clamp(intensity, bothDirectionsFactor, 1.0));
     // Attenuate with distance
     intensity /= distanceToLight2;
 
-    float3 intensityRgb = float3(intensity, intensity, intensity);
+    real3 intensityRgb = real3(intensity, intensity, intensity);
 
     diffuseAcc += GetDiffuseLighting(surface, lightingData, intensityRgb, posToLightSampleDir);
 
@@ -52,9 +52,9 @@ void AddSampleContribution(
     // - If transmission mode is thick object -> use transmission thickness parameter instead
     // - If transmission mode is thin object -> ignore back lighting
     // To detect and apply this behavior in the GetBackLighting function, we need to use a negative transmissionDistance 
-    const float transmissionDistance = -1.0f;
+    const real transmissionDistance = -1.0;
     // If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence
-    const float attenuationDistance = 0.0f;
+    const real attenuationDistance = 0.0;
     translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, transmissionDistance, attenuationDistance);
 
     specularAcc += GetSpecularLighting(surface, lightingData, intensityRgb, posToLightSampleDir);

+ 3 - 4
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/Lights.azsli

@@ -40,7 +40,7 @@ void ApplyDirectLighting(Surface surface, inout LightingData lightingData, float
             ApplyPolygonLights(surface, lightingData);
         }
     }
-    else if(GetRenderDebugViewMode() == RenderDebugViewMode::CascadeShadows)
+    else if(IsDebuggingEnabled_PLACEHOLDER() && GetRenderDebugViewMode() == RenderDebugViewMode::CascadeShadows)
     {
         if (o_enableDirectionalLights)
         {
@@ -49,11 +49,10 @@ void ApplyDirectLighting(Surface surface, inout LightingData lightingData, float
     }
     else if( UseDebugLight() )
     {
-        float3 lightIntensity = SceneSrg::m_debugLightingIntensity;
-        float3 lightDirection = SceneSrg::m_debugLightingDirection;
+        real3 lightIntensity = real3(SceneSrg::m_debugLightingIntensity);
+        real3 lightDirection = real3(SceneSrg::m_debugLightingDirection);
 
         lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, lightDirection);
         lightingData.specularLighting += GetSpecularLighting(surface, lightingData, lightIntensity, lightDirection);
     }
-
 }

+ 9 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli

@@ -11,6 +11,7 @@
 #include <Atom/Features/PBR/Lights/LightTypesCommon.azsli>
 #include <Atom/Features/Shadow/ProjectedShadow.azsli>
 
+#if ENABLE_SPHERE_LIGHTS
 int GetPointLightShadowCubemapFace(const float3 targetPos, const float3 lightPos)
 {
     const float3 toPoint = targetPos - lightPos;    
@@ -184,7 +185,6 @@ void ValidatePointLight(ViewSrg::PointLight light, Surface surface, inout Lighti
 
 void ApplyPointLightInternal(uint lightIndex, Surface surface, inout LightingData lightingData)
 {
-#if ENABLE_SPHERE_LIGHTS
     if (o_enableSphereLights)
     {
         ViewSrg::PointLight light = ViewSrg::m_pointLights[lightIndex];
@@ -200,7 +200,6 @@ void ApplyPointLightInternal(uint lightIndex, Surface surface, inout LightingDat
             ApplyPointLight(light, surface, lightingData);
         }
     }
-#endif // ENABLE_SPHERE_LIGHTS
 }
 
 void ApplyPointLights(Surface surface, inout LightingData lightingData)
@@ -222,3 +221,11 @@ void ApplyPointLights(Surface surface, inout LightingData lightingData)
     }
 #endif
 }
+
+#else
+
+void ApplyPointLights(Surface surface, inout LightingData lightingData)
+{
+    //Not Enabled
+}
+#endif

+ 7 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PolygonLight.azsli

@@ -12,6 +12,7 @@
 #include <Atom/Features/PBR/Lights/Ltc.azsli>
 #include <Atom/RPI/Math.azsli>
 
+#if ENABLE_POLYGON_LTC_LIGHTS
 // Polygon lights using Linearly Transformed Cosines
 void ApplyPoylgonLight(ViewSrg::PolygonLight light, Surface surface, inout LightingData lightingData)
 {
@@ -59,7 +60,6 @@ void ApplyPoylgonLight(ViewSrg::PolygonLight light, Surface surface, inout Light
 
 void ApplyPolygonLights(Surface surface, inout LightingData lightingData)
 {
-#if ENABLE_POLYGON_LTC_LIGHTS
     if (o_enablePolygonLights)
     {
         for (uint currLightIndex = 0; currLightIndex <  ViewSrg::m_polygonLightCount; ++currLightIndex)
@@ -69,5 +69,10 @@ void ApplyPolygonLights(Surface surface, inout LightingData lightingData)
             ApplyPoylgonLight(light, surface, lightingData);
         }
     }
-#endif
 }
+#else
+void ApplyPolygonLights(Surface surface, inout LightingData lightingData)
+{
+    return;
+}
+#endif

+ 9 - 3
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli

@@ -11,6 +11,7 @@
 #include <Atom/Features/PBR/Lights/LightTypesCommon.azsli>
 #include <Atom/Features/PBR/Lights/Ltc.azsli>
 
+#if ENABLE_QUAD_LIGHTS
 enum QuadLightFlag
 {
     None = 0x00,
@@ -253,8 +254,6 @@ void ValidateQuadLight(ViewSrg::QuadLight light, Surface surface, inout Lighting
 
 void ApplyQuadLightInternal(uint lightIndex, Surface surface, inout LightingData lightingData)
 {
-#if ENABLE_QUAD_LIGHTS
-
     if (o_enableQuadLightApprox || o_enableQuadLightLTC)
     {
         ViewSrg::QuadLight light = ViewSrg::m_quadLights[lightIndex];
@@ -270,7 +269,6 @@ void ApplyQuadLightInternal(uint lightIndex, Surface surface, inout LightingData
             ApplyQuadLight(light, surface, lightingData);
         }
     }
-#endif // ENABLE_QUAD_LIGHTS
 }
 
 void ApplyQuadLights(Surface surface, inout LightingData lightingData)
@@ -292,3 +290,11 @@ void ApplyQuadLights(Surface surface, inout LightingData lightingData)
     }
 #endif
 }
+
+#else
+
+void ApplyQuadLights(Surface surface, inout LightingData lightingData)
+{
+    //Not Enabled
+}
+#endif

+ 6 - 6
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/SimplePointLight.azsli

@@ -12,21 +12,21 @@
 
 void ApplySimplePointLight(ViewSrg::SimplePointLight light, Surface surface, inout LightingData lightingData)
 {
-    float3 posToLight = light.m_position - surface.position;
-    float d2 = dot(posToLight, posToLight); // light distance squared
-    float falloff = d2 * light.m_invAttenuationRadiusSquared;
+    real3 posToLight = real3(light.m_position - surface.position);
+    real d2 = dot(posToLight, posToLight); // light distance squared
+    real falloff = d2 * real(light.m_invAttenuationRadiusSquared);
     
     // Only calculate shading if light is in range
     if (falloff < 1.0f)
     {
         // Smoothly adjusts the light intensity so it reaches 0 at light.m_attenuationRadius distance
-        float radiusAttenuation = 1.0 - (falloff * falloff);
+        real radiusAttenuation = 1.0 - (falloff * falloff);
         radiusAttenuation = radiusAttenuation * radiusAttenuation;
         
         // Standard quadratic falloff
         d2 = max(0.001 * 0.001, d2); // clamp the light to at least 1mm away to avoid extreme values.
-        float3 lightIntensity = (light.m_rgbIntensityCandelas / d2) * radiusAttenuation;
-        float3 posToLightDir = normalize(posToLight);
+        real3 lightIntensity = (real3(light.m_rgbIntensityCandelas) / d2) * radiusAttenuation;
+        real3 posToLightDir = normalize(posToLight);
 
         // Diffuse contribution
         lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, posToLightDir);

+ 13 - 12
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/SimpleSpotLight.azsli

@@ -12,36 +12,37 @@
 
 void ApplySimpleSpotLight(ViewSrg::SimpleSpotLight light, Surface surface, inout LightingData lightingData)
 {
-    float3 posToLight = light.m_position - surface.position;
+    real3 posToLight = real3(light.m_position - surface.position);
     
-    float3 dirToLight = normalize(posToLight);
-    float dotWithDirection = dot(dirToLight, -normalize(light.m_direction));
+    real3 dirToLight = normalize(posToLight);
+    real dotWithDirection = dot(dirToLight, -normalize(real3(light.m_direction)));
 
     // If outside the outer cone angle return.
-    if (dotWithDirection < light.m_cosOuterConeAngle)
+    if (dotWithDirection < real(light.m_cosOuterConeAngle))
     {
         return;
     }
 
-    float d2 = dot(posToLight, posToLight); // light distance squared
-    float falloff = d2 * light.m_invAttenuationRadiusSquared;
+    real d2 = dot(posToLight, posToLight); // light distance squared
+    real falloff = d2 * real(light.m_invAttenuationRadiusSquared);
+    real cosInnerConeAngle = real(light.m_cosInnerConeAngle);
 
     // Only calculate shading if light is in range
-    if (falloff < 1.0f)
+    if (falloff < 1.0)
     {
         // Smoothly adjusts the light intensity so it reaches 0 at light.m_attenuationRadius distance
-        float radiusAttenuation = 1.0 - (falloff * falloff);
+        real radiusAttenuation = 1.0 - (falloff * falloff);
         radiusAttenuation = radiusAttenuation * radiusAttenuation;
         
         // Standard quadratic falloff
         d2 = max(0.001 * 0.001, d2); // clamp the light to at least 1mm away to avoid extreme values.
-        float3 lightIntensity = (light.m_rgbIntensityCandelas / d2) * radiusAttenuation;
-        float3 posToLightDir = normalize(posToLight);
+        real3 lightIntensity = (real3(light.m_rgbIntensityCandelas) / d2) * radiusAttenuation;
+        real3 posToLightDir = normalize(posToLight);
 
-        if (dotWithDirection < light.m_cosInnerConeAngle) // in penumbra
+        if (dotWithDirection < cosInnerConeAngle) // in penumbra
         {   
             // Normalize into 0.0 - 1.0 space.
-            float penumbraMask = (dotWithDirection - light.m_cosOuterConeAngle) / (light.m_cosInnerConeAngle - light.m_cosOuterConeAngle);
+            real penumbraMask = (dotWithDirection - cosInnerConeAngle) / (cosInnerConeAngle - real(light.m_cosOuterConeAngle));
             
             // Apply smoothstep
             penumbraMask = penumbraMask * penumbraMask * (3.0 - 2.0 * penumbraMask);

+ 14 - 8
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/MaterialUtils.azsli

@@ -8,16 +8,20 @@
 
 #pragma once
 
+#ifndef ENABLE_SPECULARAA
+#define ENABLE_SPECULARAA 1
+#endif
+
 #include <Atom/RPI/Math.azsli>
 #include <Atom/Features/PBR/SpecularAA.azsli>
 
 // For artists workflows, specular F0 for dialectric (non-metal) materials is exposed as a 0-1 scale
 // However the specular F0 for dialectrics is much lower than metals, so we expose this scaling factor here
-static const float3 MaxDielectricSpecularF0 = 0.08f;
+static const real3 MaxDielectricSpecularF0 = 0.08;
 
 // Make sure roughnessA is above 0 to avoid precision and divide by zero issues.
 // 0.0005f is sufficient for directional lights since they tend to be quite bright.
-static const float MinRoughnessA = 0.0005f;
+static const real MinRoughnessA = 0.0005;
 
 
 // The roughness value in microfacet calculations (called "alpha" in the literature) does not give perceptually
@@ -30,6 +34,7 @@ void CalculateRoughnessValues(float3 normal, inout float roughnessLinear, out fl
     roughnessA = max( Pow2(roughnessLinear), MinRoughnessA);
     roughnessA2 = Pow2(roughnessA);
 
+#if ENABLE_SPECULARAA
     if(o_applySpecularAA)
     {
         roughnessA2 = CalculateSpecularAA(normal, roughnessA2);
@@ -38,24 +43,25 @@ void CalculateRoughnessValues(float3 normal, inout float roughnessLinear, out fl
         roughnessA = sqrt(roughnessA2);
         roughnessLinear = sqrt(roughnessA);
     }
+#endif
 }
 
-float3 GetAlbedo(float3 baseColor, float metallic)
+real3 GetAlbedo(real3 baseColor, real metallic)
 {
-    return baseColor * (1.0f - metallic);
+    return baseColor * (1.0 - metallic);
 }
 
-float3 GetSpecularF0(float3 baseColor, float metallic, float specularF0Factor)
+real3 GetSpecularF0(real3 baseColor, real metallic, real specularF0Factor)
 {
-    float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor;
+    real3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor;
     return lerp(dielectricSpecularF0, baseColor, metallic);
 }
 
 // Manipulates surface specularF0 to apply a clear coat factor
-void ApplyClearCoatToSpecularF0(inout float3 specularF0, float clearCoatFactor)
+void ApplyClearCoatToSpecularF0(inout real3 specularF0, real clearCoatFactor)
 {
     // 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(specularF0)) / (5.0 - sqrt(specularF0));
+    real3 f0 = (1.0 - 5.0 * sqrt(specularF0)) / (5.0 - sqrt(specularF0));
     specularF0 = lerp(specularF0, f0 * f0, clearCoatFactor);
 }

+ 54 - 54
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli

@@ -22,55 +22,55 @@
 // ------- Diffuse Lighting -------
 
 //! Simple Lambertian BRDF. 
-float3 DiffuseLambertian(float3 albedo, float3 normal, float3 dirToLight, float3 diffuseResponse)
+real3 DiffuseLambertian(real3 albedo, real3 normal, real3 dirToLight, real3 diffuseResponse)
 {
-    float NdotL = saturate(dot(normal, dirToLight));
+    real NdotL = saturate(dot(normal, dirToLight));
     return albedo * NdotL * INV_PI * diffuseResponse;
 }
 
 // Normalized Disney diffuse function taken from Frostbite's PBR course notes (page 10):
 // https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/course-notes-moving-frostbite-to-pbr-v32.pdf
-float3 NormalizedDisneyDiffuse(float3 albedo, float3 normal, float3 dirToCamera, float3 dirToLight, float roughnessLinear)
+real3 NormalizedDisneyDiffuse(real3 albedo, real3 normal, real3 dirToCamera, real3 dirToLight, real roughnessLinear)
 {
-    float3 halfVector = normalize(dirToLight + dirToCamera);
-    float NdotV = saturate(dot(normal, dirToCamera));
-    float NdotL = saturate(dot(normal, dirToLight));
-    float HdotV = saturate(dot(halfVector, dirToCamera)); // Note that HdotL = HdotV, so we don't need to calculate both
-
-    float energyBias = lerp(0.0f, 0.5f, roughnessLinear);
-    float energyFactor = lerp(1.0f, 1.0f/1.51f, roughnessLinear);
-    float fd90 = energyBias + 2.0f * HdotV * HdotV * roughnessLinear;
-    float3 f0 = float3(1.0f, 1.0f, 1.0f);
-    float lightScatter = FresnelSchlickF90(NdotL, f0, fd90).r;
-    float viewScatter = FresnelSchlickF90(NdotV, f0, fd90).r;
+    real3 halfVector = normalize(dirToLight + dirToCamera);
+    real NdotV = saturate(dot(normal, dirToCamera));
+    real NdotL = saturate(dot(normal, dirToLight));
+    real HdotV = saturate(dot(halfVector, dirToCamera)); // Note that HdotL = HdotV, so we don't need to calculate both
+
+    real energyBias = lerp(0.0, 0.5, roughnessLinear);
+    real energyFactor = lerp(1.0, 1.0/1.51, roughnessLinear);
+    real fd90 = energyBias + 2.0 * HdotV * HdotV * roughnessLinear;
+    real3 f0 = real3(1.0, 1.0, 1.0);
+    real lightScatter = FresnelSchlickF90(NdotL, f0, fd90).r;
+    real viewScatter = FresnelSchlickF90(NdotV, f0, fd90).r;
 
     return albedo * lightScatter * viewScatter * energyFactor * NdotL * INV_PI;
 }
 
 //! Extended Lambertian + Fresnel diffuse model from Respawn's GDC2017 slides(page 113):
 //! https://twvideo01.ubm-us.net/o1/vault/gdc2017/Presentations/Hammon_Earl_PBR_Diffuse_Lighting.pdf
-float3 DiffuseTitanfall(float roughnessA, float3 albedo, float3 normal, float3 dirToLight, float3 dirToCamera)
+real3 DiffuseTitanfall(real roughnessA, real3 albedo, real3 normal, real3 dirToLight, real3 dirToCamera)
 {
-    float NdotL = saturate(dot(normal, dirToLight));
-    float NdotV = saturate(dot(normal, dirToCamera));
-    float LdotV = saturate(dot(dirToLight, dirToCamera));
+    real NdotL = saturate(dot(normal, dirToLight));
+    real NdotV = saturate(dot(normal, dirToCamera));
+    real LdotV = saturate(dot(dirToLight, dirToCamera));
 
     // Squared length of L + V <=> | L + V |^2
-    float LplusV_LenSq = 2.0 + 2.0 * LdotV;
-    float NdotH = (NdotL + NdotV) * rsqrt(LplusV_LenSq);
+    real LplusV_LenSq = 2.0 + 2.0 * LdotV;
+    real NdotH = (NdotL + NdotV) * rsqrt(LplusV_LenSq);
 
-    float facing = LplusV_LenSq * 0.25;
+    real facing = LplusV_LenSq * 0.25;
 
     // empirical formula for rough surfaces
-    float rough = facing * (0.9 - 0.4 * facing) * ((0.5 + NdotH) / NdotH);
+    real rough = facing * (0.9 - 0.4 * facing) * ((0.5 + NdotH) / NdotH);
 
     // used double Fresnel as the smooth term, 
     // though it can be replaced with other diffuse function as well like pure lambertian
-    float smooth = 1.05 * FresnelSchlickF90(NdotL, float3(1.0, 1.0, 1.0), 0.0).x * FresnelSchlickF90(NdotV, float3(1.0, 1.0, 1.0), 0.0).x;
-    float single = INV_PI * lerp(smooth, rough, roughnessA);
+    real smooth = 1.05 * FresnelSchlickF90(NdotL, real3(1.0, 1.0, 1.0), 0.0).x * FresnelSchlickF90(NdotV, real3(1.0, 1.0, 1.0), 0.0).x;
+    real single = INV_PI * lerp(smooth, rough, roughnessA);
 
     // coarse approximation of multiple scattering
-    float multi = 0.1159 * roughnessA;
+    real multi = 0.1159 * roughnessA;
 
     return albedo * (single + albedo * multi) * NdotL;
 }
@@ -84,18 +84,18 @@ float3 DiffuseTitanfall(float roughnessA, float3 albedo, float3 normal, float3 d
 //!
 //! @param roughnessA2  alpha roughness ^ 2 (alpha roughness is the unpacked form of artist authored linear roughness and is what is used for lighting calculations)
 //! @param specularF0   the fresnel f0 spectral value of the surface
-float3 SpecularGGX( float3 dirToCamera, float3 dirToLight, float3 normal, float3 specularF0, float NdotV, float roughnessA2, float3 multiScatterCompensation )
+real3 SpecularGGX( real3 dirToCamera, real3 dirToLight, real3 normal, real3 specularF0, real NdotV, real roughnessA2, real3 multiScatterCompensation )
 {
-    float3 halfVector = normalize(dirToLight + dirToCamera);
-    float NdotH = saturate(dot(normal, halfVector));
-    float NdotL = saturate(dot(normal, dirToLight));
-    float HdotV = saturate(dot(halfVector, dirToCamera)); // Note that HdotL = HdotV, so we don't need to calculate both
+    real3 halfVector = normalize(dirToLight + dirToCamera);
+    real NdotH = saturate(dot(normal, halfVector));
+    real NdotL = saturate(dot(normal, dirToLight));
+    real HdotV = saturate(dot(halfVector, dirToCamera)); // Note that HdotL = HdotV, so we don't need to calculate both
 
     // D, G and F from the lighting equation
     // Note: the division by (4.0 * NdotL * NdotV) is already factored out in the G function as an optimization
-    float D = NormalDistributionGGX(NdotH, roughnessA2);
-    float G = GeometricShadowingMaskingGGXCorrelated(NdotV, NdotL, roughnessA2);
-    float3 F = FresnelSchlick(HdotV, specularF0);
+    real D = NormalDistributionGGX(NdotH, roughnessA2);
+    real G = GeometricShadowingMaskingGGXCorrelated(NdotV, NdotL, roughnessA2);
+    real3 F = FresnelSchlick(HdotV, specularF0);
 
     D = max(0.0, D);
     G = max(0.0, G);
@@ -104,19 +104,19 @@ float3 SpecularGGX( float3 dirToCamera, float3 dirToLight, float3 normal, float3
     return multiScatterCompensation * (D * G * F * NdotL);
 }
 
-float3 AnisotropicGGX( float3 dirToCamera, float3 dirToLight, float3 normal, float3 tangent, float3 bitangent, float2 anisotropyFactors,
-                       float3 specularF0, float NdotV, float3 multiScatterCompensation )
+real3 AnisotropicGGX( real3 dirToCamera, real3 dirToLight, real3 normal, real3 tangent, real3 bitangent, real2 anisotropyFactors,
+                       real3 specularF0, real NdotV, real3 multiScatterCompensation )
 {
-    float3 halfVector = normalize(dirToLight + dirToCamera);
-    float NdotH = saturate(dot(normal, halfVector));
-    float NdotL = saturate(dot(normal, dirToLight));
-    float HdotV = saturate(dot(halfVector, dirToCamera)); // Note that HdotL = HdotV, so we don't need to calculate both
+    real3 halfVector = normalize(dirToLight + dirToCamera);
+    real NdotH = saturate(dot(normal, halfVector));
+    real NdotL = saturate(dot(normal, dirToLight));
+    real HdotV = saturate(dot(halfVector, dirToCamera)); // Note that HdotL = HdotV, so we don't need to calculate both
 
     // D, G and F from the lighting equation
     // Note: the division by (4.0 * NdotL * NdotV) is already factored out in the G function as an optimization
-    float D = NormalDistibution_AnisotropicGGX( NdotH, halfVector, tangent, bitangent, anisotropyFactors );
-    float G = ShadowingMasking_AnisotropicSmithGGXCorrelated(tangent, bitangent, dirToCamera, dirToLight, NdotV, NdotL, anisotropyFactors);
-    float3 F = FresnelSchlick(HdotV, specularF0);
+    real D = NormalDistibution_AnisotropicGGX( NdotH, halfVector, tangent, bitangent, anisotropyFactors );
+    real G = ShadowingMasking_AnisotropicSmithGGXCorrelated(tangent, bitangent, dirToCamera, dirToLight, NdotV, NdotL, anisotropyFactors);
+    real3 F = FresnelSchlick(HdotV, specularF0);
 
     D = max(0.0, D);
     G = max(0.0, G);
@@ -125,19 +125,19 @@ float3 AnisotropicGGX( float3 dirToCamera, float3 dirToLight, float3 normal, flo
     return multiScatterCompensation * (D * G * F * NdotL);
 }
 
-float3 ClearCoatGGX(float NdotH, float HdotL, float NdotL, float3 normal, float roughnessA, float3 F)
+real3 ClearCoatGGX(real NdotH, real HdotL, real NdotL, real3 normal, real roughnessA, real3 F)
 {
     // Specular Anti-Aliasing correction
-    float roughnessA2 = roughnessA * roughnessA;
+    real roughnessA2 = roughnessA * roughnessA;
     //if(o_applySpecularAA)
     //{
     //    roughnessA2 = ApplySpecularAA(roughnessA2, normal);
     //}
 
-    float D = NormalDistributionGGX(NdotH, roughnessA2);
+    real D = NormalDistributionGGX(NdotH, roughnessA2);
     // Kelemen geometry term : Kelemen. C. and Szirmay-Kalos. L. 2001
     // "A Microfacet Based Coupled Specular-Matte BRDF Model with Importance Sampling"
-    float G = 0.25 / max(HdotL * HdotL, 1e-4);
+    real G = 0.25 / max(HdotL * HdotL, 1e-4);
     
     D = max(0.0, D);
     G = max(0.0, G);
@@ -146,17 +146,17 @@ float3 ClearCoatGGX(float NdotH, float HdotL, float NdotL, float3 normal, float
     return D * G * F * NdotL;
 }
 
-float3 ClearCoatSpecular(const float3 dirToLight, const float3 dirToCamera, const float3 surfaceClearCoatNormal, float surfaceClearCoatFactor, float surfaceClearCoatRoughness, const float3 specular)
+real3 ClearCoatSpecular(const real3 dirToLight, const real3 dirToCamera, const real3 surfaceClearCoatNormal, real surfaceClearCoatFactor, real surfaceClearCoatRoughness, const real3 specular)
 {
-    float3 halfVector = normalize(dirToLight + dirToCamera);
-    float NdotH = saturate(dot(surfaceClearCoatNormal, halfVector));
-    float NdotL = saturate(dot(surfaceClearCoatNormal, dirToLight));
-    float HdotL = saturate(dot(halfVector, dirToLight));
+    real3 halfVector = normalize(dirToLight + dirToCamera);
+    real NdotH = saturate(dot(surfaceClearCoatNormal, halfVector));
+    real NdotL = saturate(dot(surfaceClearCoatNormal, dirToLight));
+    real HdotL = saturate(dot(halfVector, dirToLight));
 
     // HdotV = HdotL due to the definition of half vector
-    float3 clearCoatF = FresnelSchlick(HdotL, 0.04) * surfaceClearCoatFactor;
-    float clearCoatRoughness = max(surfaceClearCoatRoughness * surfaceClearCoatRoughness, 0.0005f);
-    float3 clearCoatSpecular = ClearCoatGGX(NdotH, HdotL, NdotL, surfaceClearCoatNormal, clearCoatRoughness, clearCoatF);
+    real3 clearCoatF = FresnelSchlick(HdotL, 0.04) * surfaceClearCoatFactor;
+    real clearCoatRoughness = max(surfaceClearCoatRoughness * surfaceClearCoatRoughness, 0.0005);
+    real3 clearCoatSpecular = ClearCoatGGX(NdotH, HdotL, NdotL, surfaceClearCoatNormal, clearCoatRoughness, clearCoatF);
 
     return specular * (1.0 - clearCoatF) + clearCoatSpecular;
 }

+ 8 - 8
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Fresnel.azsli

@@ -16,15 +16,15 @@
 //! @param H   half vector (which coincides with the normal vector at microlevel) 
 //! @param V   view vector (or light vector; the dot product is the same for both)
 //! @param F0  the characteristic specular reflectance of the material. Also referred to it as specular color.
-float3 FresnelSchlickF90(const float HdotV, const float3 F0, const float F90)
+real3 FresnelSchlickF90(const real HdotV, const real3 F0, const real F90)
 {
     // At angles where (View = Normal) the dot product HdotV is 1.0
-    return F0 + (F90 - F0) * pow(1.0f - HdotV, 5.0f);
+    return F0 + (F90 - F0) * pow(1.0 - HdotV, 5.0);
 }
 
-float3 FresnelSchlick(const float HdotV, const float3 F0)
+real3 FresnelSchlick(const real HdotV, const real3 F0)
 {
-    return FresnelSchlickF90(HdotV, F0, 1.0f);
+    return FresnelSchlickF90(HdotV, F0, 1.0);
 }
 
 //! Calculate fresnel reflectance using the Schlick method, taking roughness into account.
@@ -37,11 +37,11 @@ float3 FresnelSchlick(const float HdotV, const float3 F0)
 //! @param V   view vector (or light vector; the dot product is the same for both)
 //! @param specularF0  the characteristic specular reflectance of the material. Also referred to it as specular color.
 //! @param roughness  roughness value used to further attenuate the fresnel response. This is a "fudge factor" and may or may not be perceptually linear.
-float3 FresnelSchlickWithRoughness(const float NdotV, const float3 specularF0, const float roughness)
+real3 FresnelSchlickWithRoughness(const real NdotV, const real3 specularF0, const real roughness)
 {
-    float smoothness = 1.0f - roughness;
-    float3 F0 = specularF0;
+    real smoothness = 1.0 - roughness;
+    real3 F0 = specularF0;
 
-    return F0 + (max(smoothness, F0) - F0) * pow(1.0 - saturate(NdotV), 5.0f);
+    return F0 + (max(smoothness, F0) - F0) * pow(1.0 - saturate(NdotV), 5.0);
 }
 

+ 28 - 28
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Microfacet/Ggx.azsli

@@ -19,7 +19,7 @@
  */
 
 // a smaller epsilon is required for avoiding artifacts in the generated BRDF texture
-#define GGX_EPSILON 1e-8f
+#define GGX_EPSILON 1e-8
 
 #include <Atom/RPI/Math.azsli>
 
@@ -33,10 +33,10 @@
 //! @param N            macrosurface normal
 //! @param roughnessA2  alpha roughness ^ 2 (alpha roughness is the unpacked form of artist authored linear roughness and is what is used for lighting calculations)
 //! @return             factor for how much of the macrosurface has normals in the direction M. The value non-negative, but it's not normalized, so values are not restricted to [0, 1].
-float NormalDistributionGGX(const float NdotH, const float roughnessA2)
+real NormalDistributionGGX(const real NdotH, const real roughnessA2)
 {
     // Walter equation 33, simplified given that the positive characteristic function is handled elsewhere
-    float b = (NdotH * roughnessA2 - NdotH) * NdotH + 1.0;
+    real b = (NdotH * roughnessA2 - NdotH) * NdotH + 1.0;
     return roughnessA2 / (PI * b * b);
 }
 
@@ -48,13 +48,13 @@ float NormalDistributionGGX(const float NdotH, const float roughnessA2)
 //! @param L            direction to the light
 //! @param roughnessA2  alpha roughness ^ 2 (alpha roughness is the unpacked form of artist authored linear roughness and is what is used for lighting calculations)
 //! @return             probability that V and L are not masked.
-float GeometricShadowingMaskingGGXCorrelated(const float NdotV, const float NdotL, const float roughnessA2)
+real GeometricShadowingMaskingGGXCorrelated(const real NdotV, const real NdotL, const real roughnessA2)
 {
     // See Frostbite PBR guide (page 12)
     // https://media.contentapi.ea.com/content/dam/eacom/frostbite/files/course-notes-moving-frostbite-to-pbr-v32.pdf
-    float ggxV = NdotL * sqrt((-NdotV * roughnessA2 + NdotV) * NdotV + roughnessA2);
-    float ggxL = NdotV * sqrt((-NdotL * roughnessA2 + NdotL) * NdotL + roughnessA2);
-    return 0.5f / max(ggxV + ggxL, GGX_EPSILON);
+    real ggxV = NdotL * sqrt((-NdotV * roughnessA2 + NdotV) * NdotV + roughnessA2);
+    real ggxL = NdotV * sqrt((-NdotL * roughnessA2 + NdotL) * NdotL + roughnessA2);
+    return 0.5 / max(ggxV + ggxL, GGX_EPSILON);
 }
 
 
@@ -66,16 +66,16 @@ float GeometricShadowingMaskingGGXCorrelated(const float NdotV, const float Ndot
 //! @param t    - rotated surface tangent for calculating anisotropic response
 //! @param b    - rotated surface bitangent for calculating anisotropic response
 //! @param anisotropyFactors - anisotropic tangent and bitangent factor 
-float NormalDistibution_AnisotropicGGX( float NdotH, const float3 h, const float3 t, const float3 b, float2 anisotropyFactors )
+real NormalDistibution_AnisotropicGGX( real NdotH, const real3 h, const real3 t, const real3 b, real2 anisotropyFactors )
 {
-    const float atFactor = anisotropyFactors.x;
-    const float abFactor = anisotropyFactors.y;
-    float TdotH = dot(t, h);
-    float BdotH = dot(b, h);
-    float a2 = atFactor * abFactor;
-    float3 v = float3( abFactor * TdotH, atFactor * BdotH, a2 * NdotH);
-    float v2 = dot(v, v);
-    float w2 = a2 / max(EPSILON, v2);
+    const real atFactor = anisotropyFactors.x;
+    const real abFactor = anisotropyFactors.y;
+    real TdotH = dot(t, h);
+    real BdotH = dot(b, h);
+    real a2 = atFactor * abFactor;
+    real3 v = real3( abFactor * TdotH, atFactor * BdotH, a2 * NdotH);
+    real v2 = dot(v, v);
+    real w2 = a2 / max(EPSILON, v2);
     return a2 * w2 * w2 * (1.0 / PI);
 }
 
@@ -83,19 +83,19 @@ float NormalDistibution_AnisotropicGGX( float NdotH, const float3 h, const float
 //! @param t    - rotated surface tangent for calculating anisotropic response
 //! @param b    - rotated surface bitangent for calculating anisotropic response
 //! @param anisotropyFactors - anisotropic tangent and bitangent factor 
-float ShadowingMasking_AnisotropicSmithGGXCorrelated( 
-    const float3 t, const float3 b, const float3 dirToCamera, const float3 dirToLight, 
-    float NdotV, float NdotL, float2 anisotropyFactors ) 
+real ShadowingMasking_AnisotropicSmithGGXCorrelated( 
+    const real3 t, const real3 b, const real3 dirToCamera, const real3 dirToLight, 
+    real NdotV, real NdotL, real2 anisotropyFactors ) 
 {
-    const float atFactor = anisotropyFactors.x;
-    const float abFactor = anisotropyFactors.y;
-    float TdotV = dot(t, dirToCamera);
-    float BdotV = dot(b, dirToCamera);
-    float TdotL = dot(t, dirToLight);
-    float BdotL = dot(b, dirToLight);
-    float lambdaV = NdotL * length(float3(atFactor * TdotV, abFactor * BdotV, NdotV));
-    float lambdaL = NdotV * length(float3(atFactor * TdotL, abFactor * BdotL, NdotL));
-    float v = 0.5 / (lambdaV + lambdaL);
+    const real atFactor = anisotropyFactors.x;
+    const real abFactor = anisotropyFactors.y;
+    real TdotV = dot(t, dirToCamera);
+    real BdotV = dot(b, dirToCamera);
+    real TdotL = dot(t, dirToLight);
+    real BdotL = dot(b, dirToLight);
+    real lambdaV = NdotL * length(real3(atFactor * TdotV, abFactor * BdotV, NdotV));
+    real lambdaL = NdotV * length(real3(atFactor * TdotL, abFactor * BdotL, NdotL));
+    real v = 0.5 / (lambdaV + lambdaL);
     return min(v, FLOAT_16_MAX);
 }
 

+ 8 - 8
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/AnisotropicSurfaceData.azsli

@@ -14,28 +14,28 @@ option bool o_enableAnisotropy = false;
 
 class AnisotropicSurfaceData
 {
-    float3 tangent;                 //!< surface space tangent for anisotropic use
-    float3 bitangent;               //!< surface space bitangent for anisotropic use
-    float2 anisotropyFactors;       //!< anisotory factors along the tangent and the bitangent directions
+    real3 tangent;                 //!< surface space tangent for anisotropic use
+    real3 bitangent;               //!< surface space bitangent for anisotropic use
+    real2 anisotropyFactors;       //!< anisotory factors along the tangent and the bitangent directions
 
-    void Init(float3 normal, float3 vtxTangent, float3 vtxBitangent, float anisotropyAngle, float anisotropyFactor, float roughnessA);
+    void Init(real3 normal, real3 vtxTangent, real3 vtxBitangent, real anisotropyAngle, real anisotropyFactor, real roughnessA);
 };
 
 // ------- Functions -------
 
 //! 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 unless rotated back.
-void AnisotropicSurfaceData::Init(float3 normal, float3 vtxTangent, float3 vtxBitangent, float anisotropyAngle, float anisotropyFactor, float roughnessA)
+void AnisotropicSurfaceData::Init(real3 normal, real3 vtxTangent, real3 vtxBitangent, real anisotropyAngle, real anisotropyFactor, real roughnessA)
 {
     anisotropyFactors = max( 0.01,
-        float2( roughnessA * (1.0 + anisotropyFactor), 
-                roughnessA * (1.0 - anisotropyFactor) )
+        real2( roughnessA * (1.0 + anisotropyFactor), 
+               roughnessA * (1.0 - anisotropyFactor) )
     );
 
     if (anisotropyAngle > 0.01)
     {
         // Base rotation according to anisotropic main direction
-        float aniSin, aniCos;
+        real aniSin, aniCos;
         sincos(anisotropyAngle, aniSin, aniCos);
 
         // Rotate the vertex tangent to get new aligned to surface normal tangent

+ 6 - 6
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli

@@ -12,18 +12,18 @@
 
 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
+    real factor;           //!< clear coat strength factor
+    real roughness;        //!< clear coat linear roughness (not base layer one)
+    real3 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);
+    factor = 0.0;
+    roughness = 0.0;
+    normal = real3(0.0, 0.0, 0.0);
 }
 
 #endif

+ 31 - 25
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli

@@ -12,6 +12,10 @@
 #define ENABLE_CLEAR_COAT               1
 #endif
 
+#ifndef ENABLE_SPECULARAA
+#define ENABLE_SPECULARAA               1
+#endif
+
 #include <Atom/Features/PBR/MaterialUtils.azsli>
 #include <Atom/Features/PBR/SpecularAA.azsli>
 #include <Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli>
@@ -41,30 +45,30 @@ class Surface
 
     // ------- BasePbrSurfaceData -------
     
-    precise float3 position;    //!< Position in world-space
-    float3 normal;              //!< Normal in world-space
-    float3 vertexNormal;        //!< Vertex normal in world-space
-    float3 baseColor;           //!< Surface base color
-    float metallic;             //!< Surface metallic property
-    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
+    precise real3 position;    //!< Position in world-space
+    real3 normal;              //!< Normal in world-space
+    real3 vertexNormal;        //!< Vertex normal in world-space
+    real3 baseColor;           //!< Surface base color
+    real metallic;             //!< Surface metallic property
+    real roughnessLinear;      //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use
+    real roughnessA;           //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations
+    real roughnessA2;          //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance
 
     // Increase opacity at grazing angles for surfaces with a low m_opacityAffectsSpecularFactor.
     // For m_opacityAffectsSpecularFactor values close to 0, that indicates a transparent surface
     // like glass, so it becomes less transparent at grazing angles. For m_opacityAffectsSpecularFactor
     // values close to 1.0, that indicates the absence of a surface entirely, so this effect should
     // not apply.
-    float opacityAffectsSpecularFactor;
+    real opacityAffectsSpecularFactor;
 
     float opacityAffectsEmissiveFactor; //!< Allows emissive to be attenuated by alpha or not.
 
     //! Surface lighting data
-    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
-    float3 emissiveLighting;    //!< Emissive lighting
-    float diffuseAmbientOcclusion; //!< Diffuse ambient occlusion factor - [0, 1] :: [Dark, Bright]
-    float specularOcclusion;       //!< Specular occlusion factor - [0, 1] :: [Dark, Bright]
+    real3 albedo;              //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
+    real3 specularF0;          //!< Fresnel f0 spectral value of the surface
+    real3 emissiveLighting;    //!< Emissive lighting
+    real diffuseAmbientOcclusion; //!< Diffuse ambient occlusion factor - [0, 1] :: [Dark, Bright]
+    real specularOcclusion;       //!< Specular occlusion factor - [0, 1] :: [Dark, Bright]
 
     //! Applies specular anti-aliasing to roughnessA2 
     void ApplySpecularAA();
@@ -73,7 +77,7 @@ class Surface
     void CalculateRoughnessA();
 
     //! Sets albedo, base color, specularF0, and metallic properties using metallic workflow
-    void SetAlbedoAndSpecularF0(float3 baseColor, float specularF0Factor, float metallic);
+    void SetAlbedoAndSpecularF0(real3 baseColor, real specularF0Factor, real metallic);
 };
 
 // Specular Anti-Aliasing technique from this paper:
@@ -81,16 +85,16 @@ class Surface
 void Surface::ApplySpecularAA()
 {
     // Constants for formula below
-    const float screenVariance = 0.25f;
-    const float varianceThresh = 0.18f;
-
+    const float screenVariance = 0.25;
+    const float varianceThresh = 0.18;
+    
     // Specular Anti-Aliasing
-    float3 dndu = ddx_fine( normal );
-    float3 dndv = ddy_fine( normal );
+    float3 dndu = ddx_fine( float3(normal) );
+    float3 dndv = ddy_fine( float3(normal) );
     float variance = screenVariance * (dot( dndu , dndu ) + dot( dndv , dndv ));
     float kernelRoughnessA2 = min(2.0 * variance , varianceThresh );
     float filteredRoughnessA2 = saturate ( roughnessA2 + kernelRoughnessA2 );
-    roughnessA2 = filteredRoughnessA2;
+    roughnessA2 = real(filteredRoughnessA2);
 
     roughnessA = sqrt(roughnessA2);
     roughnessLinear = sqrt(roughnessA);
@@ -105,22 +109,24 @@ void Surface::CalculateRoughnessA()
     // See Burley's Disney PBR: https://pdfs.semanticscholar.org/eeee/3b125c09044d3e2f58ed0e4b1b66a677886d.pdf
 
     roughnessA = max(roughnessLinear * roughnessLinear, MinRoughnessA);
-
     roughnessA2 = roughnessA * roughnessA;
+
+#if ENABLE_SPECULARAA
     if(o_applySpecularAA)
     {
         ApplySpecularAA();
     }
+#endif
 }
 
-void Surface::SetAlbedoAndSpecularF0(float3 newBaseColor, float specularF0Factor, float newMetallic)
+void Surface::SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor, real newMetallic)
 {
     baseColor = newBaseColor;
     metallic = newMetallic;
 
-    float3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor;
+    real3 dielectricSpecularF0 = MaxDielectricSpecularF0 * specularF0Factor;
 
     // Compute albedo and specularF0 based on metalness
-    albedo = lerp(baseColor, float3(0.0f, 0.0f, 0.0f), metallic);
+    albedo = lerp(baseColor, real3(0.0, 0.0, 0.0), metallic);
     specularF0 = lerp(dielectricSpecularF0, baseColor, metallic);
 }

+ 14 - 14
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli

@@ -12,41 +12,41 @@
 
 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:  (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale)
-    float3 scatterDistance;          //!< scatter distance (same as in MaterialSrg) > 
+    real3 tint;
+    real thickness;                 //!< pre baked local thickness, used for transmission
+    real4 transmissionParams;       //!< parameters: thick mode->(attenuation coefficient, power, distortion, scale), thin mode:  (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale)
+    real3 scatterDistance;          //!< scatter distance (same as in MaterialSrg) > 
 
     void InitializeToZero();
 
     // ----- Thick mode getters -----
 
-    float GetAttenuationCoefficient() { return transmissionParams.x; }
-    float GetPower() { return transmissionParams.y; }
-    float GetDistortion() { return transmissionParams.z; }
+    real GetAttenuationCoefficient() { return transmissionParams.x; }
+    real GetPower() { return transmissionParams.y; }
+    real GetDistortion() { return transmissionParams.z; }
 
     // ----- Thin mode getters -----
 
     // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection
-    float GetShrinkFactor() { return transmissionParams.x; }
+    real GetShrinkFactor() { return transmissionParams.x; }
 
     // (N . L) to accept below (N . L = 0) in scattering through thin objects
-    float GetTransmissionNdLBias() { return transmissionParams.y; }
+    real GetTransmissionNdLBias() { return transmissionParams.y; }
 
     // Attenuation applied to hide artifacts due to low-res shadow maps 
-    float GetDistanceAttenuation() { return transmissionParams.z; }
+    real GetDistanceAttenuation() { return transmissionParams.z; }
 
     // ----- Common getters -----
 
-    float GetScale() { return transmissionParams.w; }
+    real GetScale() { return transmissionParams.w; }
 };
 
 void TransmissionSurfaceData::InitializeToZero()
 {
-    tint = float3(0.0f, 0.0f, 0.0f);
+    tint = real3(0.0, 0.0, 0.0);
     thickness = 0.0f;
-    transmissionParams = float4(0.0f, 0.0f, 0.0f, 0.0f);
-    scatterDistance = float3(0.0f, 0.0f, 0.0f);
+    transmissionParams = real4(0.0, 0.0, 0.0, 0.0);
+    scatterDistance = real3(0.0, 0.0, 0.0);
 }
 
 #endif

+ 81 - 81
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ParallaxMapping.azsli

@@ -79,14 +79,14 @@ DepthResult SampleDepthFromHeightmap(Texture2D map, sampler mapSampler, float2 u
 //! @param uv_ddx must be set to ddx_fine(uv)
 //! @param uv_ddy must be set to ddy_fine(uv)
 //! @param a depth value in the range [0,1]
-float GetNormalizedDepth(float startDepth, float stopDepth, float inverseDepthRange, float2 uv, float2 uv_ddx, float2 uv_ddy)
+real GetNormalizedDepth(real startDepth, real stopDepth, real inverseDepthRange, float2 uv, float2 uv_ddx, float2 uv_ddy)
 {
     // startDepth can be less than 0, representing a displacement above the mesh surface.
     // But since we don't currently support any vertex displacement, negative depth values would cause various 
     // problems especially when PDO is enabled, like parallax surfaces clipping through foreground geometry, and parallax 
     // surfaces disappearing at low angles. So we clamp all depth values to a minimum of 0.
 
-    float normalizedDepth = 0.0;
+    real normalizedDepth = 0.0;
 
     DepthResult depthResult = GetDepth(uv, uv_ddx, uv_ddy);
 
@@ -94,12 +94,12 @@ float GetNormalizedDepth(float startDepth, float stopDepth, float inverseDepthRa
     {
         if(DepthResultCode_Normalized == depthResult.m_resultCode)
         {    
-            float minNormalizedDepth = -startDepth * inverseDepthRange;
-            normalizedDepth = max(depthResult.m_depth, minNormalizedDepth);
+            real minNormalizedDepth = -startDepth * inverseDepthRange;
+            normalizedDepth = max(real(depthResult.m_depth), minNormalizedDepth);
         }
         else if(DepthResultCode_Absolute == depthResult.m_resultCode)
         {
-            float clampedAbsoluteDepth = max(depthResult.m_depth, 0.0);
+            real clampedAbsoluteDepth = max(real(depthResult.m_depth), 0.0);
             normalizedDepth = (clampedAbsoluteDepth - startDepth) * inverseDepthRange;
         }
     }
@@ -107,33 +107,33 @@ float GetNormalizedDepth(float startDepth, float stopDepth, float inverseDepthRa
     return normalizedDepth;
 }
 
-float GetNormalizedDepth(float startDepth, float stopDepth, float2 uv, float2 uv_ddx, float2 uv_ddy)
+real GetNormalizedDepth(real startDepth, real stopDepth, float2 uv, float2 uv_ddx, float2 uv_ddy)
 {
-    float inverseDepthRange = 1.0 / (stopDepth - startDepth);
+    real inverseDepthRange = 1.0 / (stopDepth - startDepth);
     return GetNormalizedDepth(startDepth, stopDepth, inverseDepthRange, uv, uv_ddx, uv_ddy);
 }
 
-void ApplyParallaxClippingHighlight(inout float3 baseColor)
+void ApplyParallaxClippingHighlight(inout real3 baseColor)
 {
-    baseColor = lerp(baseColor, float3(1.0, 0.0, 1.0), 0.5);
+    baseColor = lerp(baseColor, real3(1.0, 0.0, 1.0), 0.5);
 }
 
 struct ParallaxOffset
 {
-    float3 m_offsetTS;  //!< represents the intersection point relative to the geometry surface, in tangent space.
+    real3 m_offsetTS;  //!< represents the intersection point relative to the geometry surface, in tangent space.
     bool m_isClipped;   //!< Indicates whether the result is being clipped by the geometry surface, mainly for debug rendering. Only set when o_parallax_highlightClipping is true.
 };
 
 // dirToCameraTS should be in tangent space and normalized
 // From Reat-Time Rendering 3rd edition, p.192
-ParallaxOffset BasicParallaxMapping(float depthFactor, float2 uv, float3 dirToCameraTS)
+ParallaxOffset BasicParallaxMapping(real depthFactor, float2 uv, real3 dirToCameraTS)
 {
     // the amount to shift
-    float2 delta = dirToCameraTS.xy * GetNormalizedDepth(0, depthFactor, uv, ddx_fine(uv), ddy_fine(uv)) * depthFactor;
+    real2 delta = dirToCameraTS.xy * GetNormalizedDepth(0, depthFactor, uv, ddx_fine(uv), ddy_fine(uv)) * depthFactor;
     
     ParallaxOffset result;
 
-    result.m_offsetTS = float3(0,0,0);
+    result.m_offsetTS = real3(0,0,0);
     result.m_offsetTS.xy -= delta;
     result.m_isClipped = false;
     return result;
@@ -149,33 +149,33 @@ ParallaxOffset BasicParallaxMapping(float depthFactor, float2 uv, float3 dirToCa
 // @param dirToLightTS - normalized direction to a light source, in tangent space, for self-shadowing (if enabled via o_parallax_shadow).
 // @param numSteps - the number of steps to take when marching along the ray searching for intersection.
 // @param parallaxShadowAttenuation - returns a factor for attenuating a light source, for self-shadowing (if enabled via o_parallax_shadow).
-ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, float2 uv, float3 dirToCameraTS, float3 dirToLightTS, int numSteps, inout float parallaxShadowAttenuation)
+ParallaxOffset AdvancedParallaxMapping(real depthFactor, real depthOffset, float2 uv, real3 dirToCameraTS, real3 dirToLightTS, int numSteps, inout real parallaxShadowAttenuation)
 {
     ParallaxOffset result;
     result.m_isClipped = false;
 
-    float dirToCameraZInverse = 1.0 / dirToCameraTS.z;
-    float step =  1.0 / numSteps;
-    float currentStep = 0.0;
+    real dirToCameraZInverse = 1.0 / dirToCameraTS.z;
+    real step =  real(1.0 / numSteps);
+    real currentStep = 0.0;
 
     // the amount to shift per step, shift in the inverse direction of dirToCameraTS
-    float3 delta = -dirToCameraTS.xyz * depthFactor * dirToCameraZInverse * step;
+    real3 delta = -dirToCameraTS.xyz * depthFactor * dirToCameraZInverse * step;
 
     float2 ddx_uv = ddx_fine(uv);
     float2 ddy_uv = ddy_fine(uv);
 
-    float depthSearchStart = depthOffset;
-    float depthSearchEnd = depthSearchStart + depthFactor;
+    real depthSearchStart = depthOffset;
+    real depthSearchEnd = depthSearchStart + depthFactor;
     
-    float inverseDepthFactor = 1.0 / depthFactor;
+    real inverseDepthFactor = 1.0 / depthFactor;
 
     // This is the relative position at which we begin searching for intersection.
     // It is adjusted according to the depthOffset, raising or lowering the whole surface by depthOffset units.
-    float3 parallaxOffset = -dirToCameraTS.xyz * dirToCameraZInverse * depthOffset;
+    real3 parallaxOffset = -dirToCameraTS.xyz * dirToCameraZInverse * depthOffset;
     
     // Get an initial heightmap sample to start the intersection search, starting at our initial parallaxOffset position.
-    float currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
-    float prevSample;
+    real currentSample = GetNormalizedDepth(depthSearchStart, depthSearchEnd, inverseDepthFactor, uv + parallaxOffset.xy, ddx_uv, ddy_uv);
+    real prevSample;
     
     // Note that when depthOffset > 0, we could actually narrow the search so that instead of going through the entire [depthSearchStart,depthSearchEnd] range
     // of the heightmap, we could go through the range [0,depthSearchEnd]. This would give more accurate results and fewer artifacts
@@ -201,10 +201,10 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
             if(currentStep > 0.0)
             {
                 // linear interpolation between the previous offset and the current offset
-                float prevStep = currentStep - step;
-                float currentDiff = currentStep - currentSample;
-                float prevDiff = prevSample - prevStep;
-                float ratio = prevDiff/ (prevDiff + currentDiff);
+                real prevStep = currentStep - step;
+                real currentDiff = currentStep - currentSample;
+                real prevDiff = prevSample - prevStep;
+                real ratio = prevDiff/ (prevDiff + currentDiff);
 
                 parallaxOffset = lerp(parallaxOffset - delta, parallaxOffset, ratio);
             }
@@ -215,15 +215,15 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
             if(currentStep > 0.0)
             {
                 // Refining the parallax-offsetted uv, by binary searching around the naive intersection point
-                float depthSign = 1;
-                float3 reliefDelta = delta;
-                float reliefStep = step;
+                real depthSign = 1;
+                real3 reliefDelta = delta;
+                real reliefStep = step;
 
                 for(int i = 0; i < numSteps; i++)
                 {
                     reliefDelta *= 0.5;
                     reliefStep *= 0.5;
-                    depthSign = sign(currentSample - currentStep);
+                    depthSign = real(sign(currentSample - currentStep));
 
                     parallaxOffset += reliefDelta * depthSign;
                     currentStep += reliefStep * depthSign;
@@ -246,8 +246,8 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
                 currentSample = prevSample;
 
                 // Adjust precision
-                float3 adjustedDelta = delta * step;
-                float adjustedStep = step * step;
+                real3 adjustedDelta = delta * step;
+                real adjustedStep = step * step;
 
                 // Uses another loop with the same step numbers, this times only covers the distance between previous point and the rough intersection point.
                 while(currentSample > currentStep)
@@ -269,7 +269,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
     // can be noticeably above the surface and still needs to be clamped here. The main case is when depthFactor==0 and depthOffset<1.
     if(parallaxOffset.z > 0.0)
     {
-        parallaxOffset = float3(0,0,0);
+        parallaxOffset = real3(0,0,0);
     }
 
     if (o_parallax_highlightClipping)
@@ -277,7 +277,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
         // The most accurate way to report clipping is to sample the heightmap one last time at the final adjusted UV.
         // (trying to do it based on parallaxOffset.z values just leads to too many edge cases)
 
-        DepthResult depthResult = GetDepth(uv + parallaxOffset.xy, ddx_uv, ddy_uv);
+        DepthResult depthResult = GetDepth(float2(uv + parallaxOffset.xy), ddx_uv, ddy_uv);
         
         if(DepthResultCode_Normalized == depthResult.m_resultCode)
         {
@@ -292,23 +292,23 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
     if(o_parallax_shadow && any(dirToLightTS))
     {
         float2 shadowUV = uv + parallaxOffset.xy;
-        float shadowNumSteps = round(numSteps * currentStep);
-        float shadowStep = 1.0 / shadowNumSteps;
-        float dirToLightZInverse = 1.0 / dirToLightTS.z;
-        float2 shadowDelta = dirToLightTS.xy * depthFactor * dirToLightZInverse * shadowStep;
+        real shadowNumSteps = round(real(numSteps) * currentStep);
+        real shadowStep = real(1.0 / shadowNumSteps);
+        real dirToLightZInverse = 1.0 / dirToLightTS.z;
+        real2 shadowDelta = dirToLightTS.xy * depthFactor * dirToLightZInverse * shadowStep;
 
         bool rayUnderSurface = false;
-        float partialShadowFactor = 0;
+        real partialShadowFactor = 0;
 
         // Raytrace from found parallax-offsetted point to the light. 
         // parallaxShadowAttenuation represents how much the current point is shadowed.
-        for(int i = 0 ; i < shadowNumSteps; i++)
+        for(int i = 0 ; i < (int)shadowNumSteps; i++)
         {
             // light ray is under surface
             if(currentSample < currentStep)
             {
                 rayUnderSurface = true;
-                partialShadowFactor = max(partialShadowFactor, (currentStep - currentSample) * (1 - (i + 1) * shadowStep));
+                partialShadowFactor = max(partialShadowFactor, (currentStep - currentSample) * ((real)(1 - (i + 1)) * shadowStep));
             }
 
             shadowUV += shadowDelta;
@@ -331,7 +331,7 @@ ParallaxOffset AdvancedParallaxMapping(float depthFactor, float depthOffset, flo
 }
 
 // return offset in tangent space
-ParallaxOffset CalculateParallaxOffset(float depthFactor, float depthOffset, float2 uv, float3 dirToCameraTS, float3 dirToLightTS, inout float parallaxShadowAttenuation)
+ParallaxOffset CalculateParallaxOffset(real depthFactor, real depthOffset, float2 uv, real3 dirToCameraTS, real3 dirToLightTS, inout real parallaxShadowAttenuation)
 {
     if(o_parallax_algorithm == ParallaxAlgorithm::Basic)
     {
@@ -365,30 +365,30 @@ ParallaxOffset CalculateParallaxOffset(float depthFactor, float depthOffset, flo
 // @param uv - the UV coordinates on the surface, where the search will begin, used to sample the heightmap.
 // @param dirToCameraTS - normalized direction to the camera, in tangent space.
 // @param dirToLightTS - normalized direction to a light source, in tangent space, for self-shadowing (if enabled via o_parallax_shadow).
-ParallaxOffset GetParallaxOffset( float depthFactor, 
-                                  float depthOffset,
+ParallaxOffset GetParallaxOffset( real depthFactor, 
+                                  real depthOffset,
                                   float2 uv,
-                                  float3 dirToCameraWS,
-                                  float3 tangentWS,
-                                  float3 bitangentWS,
-                                  float3 normalWS,
-                                  float3x3 uvMatrix)
+                                  real3 dirToCameraWS,
+                                  real3 tangentWS,
+                                  real3 bitangentWS,
+                                  real3 normalWS,
+                                  real3x3 uvMatrix)
 {
     // Tangent space eye vector
-    float3 dirToCameraTS = normalize(WorldSpaceToTangent(dirToCameraWS, normalWS, tangentWS, bitangentWS));
+    real3 dirToCameraTS = normalize(WorldSpaceToTangent(dirToCameraWS, normalWS, tangentWS, bitangentWS));
 
     // uv transform matrix in 3d, ignore translation
-    float4x4 uv3DTransform;
-    uv3DTransform[0] = float4(uvMatrix[0].xy, 0, 0);
-    uv3DTransform[1] = float4(uvMatrix[1].xy, 0, 0);
-    uv3DTransform[2] = float4(0, 0, 1, 0);
-    uv3DTransform[3] = float4(0, 0, 0, 1);
+    real4x4 uv3DTransform;
+    uv3DTransform[0] = real4(uvMatrix[0].xy, 0, 0);
+    uv3DTransform[1] = real4(uvMatrix[1].xy, 0, 0);
+    uv3DTransform[2] = real4(0, 0, 1, 0);
+    uv3DTransform[3] = real4(0, 0, 0, 1);
     
     // Transform tangent space eye vector with UV matrix
-    float4 dirToCameraTransformed = mul(uv3DTransform, float4(dirToCameraTS, 0.0));
+    real4 dirToCameraTransformed = mul(uv3DTransform, real4(dirToCameraTS, 0.0));
 
-    float dummy = 1;
-    return CalculateParallaxOffset(depthFactor, depthOffset, uv, normalize(dirToCameraTransformed.xyz), float3(0,0,0), dummy);
+    real dummy = 1;
+    return CalculateParallaxOffset(depthFactor, depthOffset, uv, normalize(dirToCameraTransformed.xyz), real3(0,0,0), dummy);
 }
 
 struct PixelDepthOffset
@@ -399,33 +399,33 @@ struct PixelDepthOffset
 };
 
 // Calculate Pixel Depth Offset and new world position
-PixelDepthOffset CalcPixelDepthOffset(  float depthFactor, 
-                                        float3 tangentOffset,
+PixelDepthOffset CalcPixelDepthOffset(  real depthFactor, 
+                                        real3 tangentOffset,
                                         float3 posWS,
-                                        float3 tangentWS,
-                                        float3 bitangentWS,
-                                        float3 normalWS,
-                                        float3x3 uvMatrixInverse,
-                                        float4x4 objectToWorldMatrix,
-                                        float4x4 viewProjectionMatrix)
+                                        real3 tangentWS,
+                                        real3 bitangentWS,
+                                        real3 normalWS,
+                                        real3x3 uvMatrixInverse,
+                                        real4x4 objectToWorldMatrix,
+                                        real4x4 viewProjectionMatrix)
 {
     // uv transform inverse matrix in 3d, ignore translation
-    float4x4 uv3DTransformInverse;
-    uv3DTransformInverse[0] = float4(uvMatrixInverse[0].xy, 0, 0);
-    uv3DTransformInverse[1] = float4(uvMatrixInverse[1].xy, 0, 0);
-    uv3DTransformInverse[2] = float4(0, 0, 1, 0);
-    uv3DTransformInverse[3] = float4(0, 0, 0, 1);
+    real4x4 uv3DTransformInverse;
+    uv3DTransformInverse[0] = real4(uvMatrixInverse[0].xy, 0, 0);
+    uv3DTransformInverse[1] = real4(uvMatrixInverse[1].xy, 0, 0);
+    uv3DTransformInverse[2] = real4(0, 0, 1, 0);
+    uv3DTransformInverse[3] = real4(0, 0, 0, 1);
     
-    tangentOffset = mul(uv3DTransformInverse, float4(tangentOffset, 0.0)).xyz;
-    float3 worldOffset = TangentSpaceToWorld(tangentOffset, normalWS, tangentWS, bitangentWS);
+    tangentOffset = mul(uv3DTransformInverse, real4(tangentOffset, 0.0)).xyz;
+    real3 worldOffset = TangentSpaceToWorld(tangentOffset, normalWS, tangentWS, bitangentWS);
 
-    float scaleX = length(objectToWorldMatrix[0].xyz);
-    float scaleY = length(objectToWorldMatrix[1].xyz);
-    float scaleZ = length(objectToWorldMatrix[2].xyz);
-    worldOffset *= float3(scaleX, scaleY, scaleZ);
+    real scaleX = length(objectToWorldMatrix[0].xyz);
+    real scaleY = length(objectToWorldMatrix[1].xyz);
+    real scaleZ = length(objectToWorldMatrix[2].xyz);
+    worldOffset *= real3(scaleX, scaleY, scaleZ);
 
-    float3 worldOffsetPosition = posWS + worldOffset;
-    float4 clipOffsetPosition = mul(viewProjectionMatrix, float4(worldOffsetPosition, 1.0));
+    real3 worldOffsetPosition = real3(posWS) + worldOffset;
+    real4 clipOffsetPosition = mul(viewProjectionMatrix, real4(worldOffsetPosition, 1.0));
 
     PixelDepthOffset pdo;
     pdo.m_depthCS = clipOffsetPosition.w;

+ 34 - 34
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PostProcessing/AcesColorSpaceConversion.azsli

@@ -77,70 +77,70 @@ UNDISCLOSED.
 ////////////////////////////////////////////////////////////////////////////////
 // Color space conversion matrices
 
-static const float3x3 AP0ToXYZMat =
+static const real3x3 AP0ToXYZMat =
 {
-    0.95255238f, 0.00000000f, 0.00009368f,
-    0.34396642f, 0.72816616f, -0.07213254f,
-    -0.00000004f, 0.00000000f, 1.00882506f
+    0.95255238, 0.00000000, 0.00009368,
+    0.34396642, 0.72816616, -0.07213254,
+    -0.00000004, 0.00000000, 1.00882506
 };
 
-static const float3x3 XYZToAP0Mat =
+static const real3x3 XYZToAP0Mat =
 {
-    1.04981101f, -0.00000000f, -0.00009748f,
-    -0.49590296f, 1.37331295f, 0.09824003f,
-    0.00000004f, -0.00000000f, 0.99125212f
+    1.04981101, -0.00000000, -0.00009748,
+    -0.49590296, 1.37331295, 0.09824003,
+    0.00000004, -0.00000000, 0.99125212
 };
 
-static const float3x3 AP1ToXYZMat =
+static const real3x3 AP1ToXYZMat =
 {
-    0.66245413f, 0.13400421f, 0.15618768f,
-    0.27222872f, 0.67408168f, 0.05368952f,
-    -0.00557466f, 0.00406073f, 1.01033902f
+    0.66245413, 0.13400421, 0.15618768,
+    0.27222872, 0.67408168, 0.05368952,
+    -0.00557466, 0.00406073, 1.01033902
 };
 
-static const float3x3 XYZToAP1Mat =
+static const real3x3 XYZToAP1Mat =
 {
-    1.64102352f, -0.32480335f, -0.23642471f,
-    -0.66366309f, 1.61533189f, 0.01675635f,
-    0.01172191f, -0.00828444f, 0.98839492f
+    1.64102352, -0.32480335, -0.23642471,
+    -0.66366309, 1.61533189, 0.01675635,
+    0.01172191, -0.00828444, 0.98839492
 };
 
-static const float3x3 AP0ToAP1Mat = 
+static const real3x3 AP0ToAP1Mat = 
 {
-    1.45143950f, -0.23651081f, -0.21492855f,
-    -0.07655388f, 1.17623007f, -0.09967594f,
-    0.00831613f, -0.00603245f, 0.99771625f
+    1.45143950, -0.23651081, -0.21492855,
+    -0.07655388, 1.17623007, -0.09967594,
+    0.00831613, -0.00603245, 0.99771625
 };
 
-static const float3x3 AP1ToAP0Mat = 
+static const real3x3 AP1ToAP0Mat = 
 {
-    0.69545215f, 0.14067869f, 0.16386905f,
-    0.04479461f, 0.85967094f, 0.09553432f,
-    -0.00552587f, 0.00402521f, 1.00150073f
+    0.69545215, 0.14067869, 0.16386905,
+    0.04479461, 0.85967094, 0.09553432,
+    -0.00552587, 0.00402521, 1.00150073
 };
 
-static const float3x3 SRGBToXYZMat =
+static const real3x3 SRGBToXYZMat =
 {
-    0.41239089f, 0.35758430f, 0.18048084f,
-    0.21263906f, 0.71516860f, 0.07219233f,
-    0.01933082f, 0.11919472f, 0.95053232f
+    0.41239089, 0.35758430, 0.18048084,
+    0.21263906, 0.71516860, 0.07219233,
+    0.01933082, 0.11919472, 0.95053232
 };
 
-static const float3x3 XYZToSRGBMat =
+static const real3x3 XYZToSRGBMat =
 {
-    3.24096942f, -1.53738296f, -0.49861076f,
-    -0.96924388f, 1.87596786f, 0.04155510f,
-    0.05563002f, -0.20397684f, 1.05697131f,
+    3.24096942, -1.53738296, -0.49861076,
+    -0.96924388, 1.87596786, 0.04155510,
+    0.05563002, -0.20397684, 1.05697131,
 };
 
-static const float3x3 D65ToD60Cat =
+static const real3x3 D65ToD60Cat =
 {
     1.01303, 0.00610531, -0.014971,
     0.00769823, 0.998165, -0.00503203,
     -0.00284131, 0.00468516, 0.924507,
 };
 
-static const float3x3 D60ToD65Cat =
+static const real3x3 D60ToD65Cat =
 {
     0.987224, -0.00611327, 0.0159533,
     -0.00759836, 1.00186, 0.00533002,

+ 2 - 2
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PostProcessing/Tonemap.azsli

@@ -9,13 +9,13 @@
 #pragma once
 
 
-float3 ApplyFilmicTonemap(float3 color)
+real3 ApplyFilmicTonemap(real3 color)
 {
     // Apply filmic curve. 
     return (color * (6.2 * color + 0.5)) / (color * (6.2 * color + 1.7)+ 0.06);
 }
 
-float3 ApplyManualExposure(float3 color, float exposure)
+real3 ApplyManualExposure(real3 color, real exposure)
 {
     // Apply Manual exposure
     return color * pow(2.0, exposure);

+ 20 - 0
Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/ShaderQualityOptions.azsli

@@ -50,4 +50,24 @@
     #define ENABLE_MERGE_FILMIC_TONEMAP           1
     #endif
 
+    #ifndef ENABLE_DECALS
+    #define ENABLE_DECALS              0
+    #endif
+
+    #ifndef ENABLE_SHADER_DEBUGGING
+    #define ENABLE_SHADER_DEBUGGING           0
+    #endif
+
+    #ifndef ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION
+    #define ENABLE_REFLECTIONPROBE_PARALLAXCORRECTION 0
+    #endif
+
+    #ifndef ENABLE_REFLECTIONPROBE_BLENDING
+    #define ENABLE_REFLECTIONPROBE_BLENDING 0
+    #endif
+
+    #ifndef ENABLE_SPECULARAA
+    #define ENABLE_SPECULARAA 0
+    #endif
+
 #endif

+ 1 - 1
Gems/Atom/Feature/Common/Assets/Shaders/LightCulling/LightCulling.azsl

@@ -473,7 +473,7 @@ void CullDiskLights(uint groupIndex, TileLightData tileLightData, float3 aabb_ce
         float3 lightDirection = WorldToView_Vector(light.m_direction);
 
         bool potentiallyIntersects;
-        if (light.m_flags & DiskLightFlag::UseConeAngle > 0)
+        if ((light.m_flags & DiskLightFlag::UseConeAngle) > 0)
         {
             potentiallyIntersects = TestSphereVsCone(aabb_center, length(aabb_extents), lightPosition, lightDirection, light.m_cosOuterConeAngle, rsqrt(light.m_invAttenuationRadiusSquared) + light.m_bulbPositionOffset);
         }

+ 4 - 4
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_LightingBrdf.azsli

@@ -29,16 +29,16 @@
 #error Surface must be defined before including this file.
 #endif
 
-float3 GetDiffuseLighting_BasePBR(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight)
+real3 GetDiffuseLighting_BasePBR(Surface surface, LightingData lightingData, real3 lightIntensity, real3 dirToLight)
 {
-    float3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight, lightingData.diffuseResponse);
+    real3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight, lightingData.diffuseResponse);
     diffuse *= lightIntensity;
     return diffuse;
 }
 
-float3 GetSpecularLighting_BasePBR(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight)
+real3 GetSpecularLighting_BasePBR(Surface surface, LightingData lightingData, const real3 lightIntensity, const real3 dirToLight)
 {
-    float3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation);
+    real3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation);
     specular *= lightIntensity;
     return specular;
 }

+ 28 - 28
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_LightingData.azsli

@@ -26,64 +26,64 @@ class LightingData_BasePBR
     LightCullingTileIterator tileIterator;
     
     // Lighting outputs
-    float3 diffuseLighting;
-    float3 specularLighting;
+    real3 diffuseLighting;
+    real3 specularLighting;
 
     // Factors for the amount of diffuse and specular lighting applied
-    float3 diffuseResponse;
+    real3 diffuseResponse;
    
     // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection
-    float shrinkFactor;
+    real shrinkFactor;
 
     // Normalized direction from surface to camera
-    float3 dirToCamera;
+    real3 dirToCamera;
     
     // Scaling term to approximate multiscattering contribution in specular BRDF
-    float3 multiScatterCompensation;
+    real3 multiScatterCompensation;
 
     // Lighting emitted from the surface
-    float3 emissiveLighting;
+    real3 emissiveLighting;
 
     // BRDF texture values
-    float2 brdf;
+    real2 brdf;
 
     // Normal . View
-    float NdotV;
+    real NdotV;
 
 #if ENABLE_TRANSMISSION
-    float3 translucentBackLighting;
+    real3 translucentBackLighting;
 #endif
 
     // Occlusion factors (0 = dark, 1 = light)
-    float diffuseAmbientOcclusion;
-    float specularOcclusion;
+    real diffuseAmbientOcclusion;
+    real specularOcclusion;
 
-    void Init(float3 positionWS, float3 normal, float roughnessLinear);
-    void CalculateMultiscatterCompensation(float3 specularF0, bool enabled);
+    void Init(float3 positionWS, real3 normal, real roughnessLinear);
+    void CalculateMultiscatterCompensation(real3 specularF0, bool enabled);
     void FinalizeLighting(Surface surface);
 };
 
-void LightingData_BasePBR::Init(float3 positionWS, float3 normal, float roughnessLinear)
+void LightingData_BasePBR::Init(float3 positionWS, real3 normal, real roughnessLinear)
 {
-    diffuseLighting = float3(0.0, 0.0, 0.0);
-    specularLighting = float3(0.0, 0.0, 0.0);
-    multiScatterCompensation = float3(1.0f, 1.0f, 1.0f);
-    emissiveLighting = float3(0.0f, 0.0f, 0.0f);
+    diffuseLighting = real3(0.0, 0.0, 0.0);
+    specularLighting = real3(0.0, 0.0, 0.0);
+    multiScatterCompensation = real3(1.0, 1.0, 1.0);
+    emissiveLighting = real3(0.0, 0.0, 0.0);
 #if ENABLE_TRANSMISSION
-    translucentBackLighting = float3(0.0f, 0.0f, 0.0f);
+    translucentBackLighting = real3(0.0, 0.0, 0.0);
 #endif
-    diffuseAmbientOcclusion = 1.0f;
-    specularOcclusion = 1.0f;
+    diffuseAmbientOcclusion = 1.0;
+    specularOcclusion = 1.0;
 
-    dirToCamera = normalize(ViewSrg::m_worldPosition.xyz - positionWS);
+    dirToCamera = real3(normalize(ViewSrg::m_worldPosition.xyz - positionWS));
 
     // sample BRDF map (indexed by smoothness values rather than roughness)
     NdotV = saturate(dot(normal, dirToCamera));
-    float2 brdfUV = float2(NdotV, (1.0f - roughnessLinear));
-    brdf = PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, brdfUV).rg;
+    real2 brdfUV = real2(NdotV, (1.0 - roughnessLinear));
+    brdf = real2(PassSrg::m_brdfMap.Sample(PassSrg::LinearSampler, brdfUV).rg);
 }
 
-void LightingData_BasePBR::CalculateMultiscatterCompensation(float3 specularF0, bool enabled)
+void LightingData_BasePBR::CalculateMultiscatterCompensation(real3 specularF0, bool enabled)
 {
     multiScatterCompensation = GetMultiScatterCompensation(specularF0, brdf, enabled);
 }
@@ -94,11 +94,11 @@ void LightingData_BasePBR::FinalizeLighting(Surface surface)
 
     if(!IsSpecularLightingEnabled())
     {
-        specularLighting = float3(0, 0, 0);
+        specularLighting = real3(0, 0, 0);
     }
     if(!IsDiffuseLightingEnabled())
     {
-        diffuseLighting = float3(0, 0, 0);
+        diffuseLighting = real3(0, 0, 0);
     }
 
     // Transmitted light

+ 1 - 1
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_LightingEval.azsli

@@ -26,7 +26,7 @@ void InitializeLightingData_BasePBR(inout Surface surface, float4 screenPosition
     lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
     
     // Diffuse and Specular response (used in IBL calculations)
-    float3 specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
+    real3 specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
     lightingData.diffuseResponse = 1.0 - specularResponse;
 
     // Multiscatter

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_PixelGeometryData.azsli

@@ -18,9 +18,9 @@
 class PixelGeometryData_BasePBR 
 {
     float3 positionWS;
-    float3 vertexNormal;
+    real3 vertexNormal;
     float2 uvs[UvSetCount];
-    float3 tangents[UvSetCount];
-    float3 bitangents[UvSetCount];
+    real3 tangents[UvSetCount];
+    real3 bitangents[UvSetCount];
     bool isFrontFace;
 };

+ 7 - 7
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_PixelGeometryEval.azsli

@@ -19,9 +19,9 @@
 
 PixelGeometryData EvaluatePixelGeometry_BasePBR(
     float3 positionWS,
-    float3 normalWS,
-    float3 tangentWS,
-    float3 bitangentWS,
+    real3 normalWS,
+    real3 tangentWS,
+    real3 bitangentWS,
     float2 uvs[UvSetCount],
     bool isFrontFace)
 {
@@ -47,11 +47,11 @@ PixelGeometryData EvaluatePixelGeometry_BasePBR(
 
 PixelGeometryData EvaluatePixelGeometry_BasePBR(VsOutput IN, bool isFrontFace)
 {
-    float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
-    float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
+    real4x4 objectToWorld = real4x4(ObjectSrg::GetWorldMatrix());
+    real3x3 objectToWorldIT = real3x3(ObjectSrg::GetWorldMatrixInverseTranspose());
 
-    float3 normalWS, tangentWS, bitangentWS;
-    ConstructTBN(IN.normal, IN.tangent, objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
+    real3 normalWS, tangentWS, bitangentWS;
+    ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
     return EvaluatePixelGeometry_BasePBR(
         IN.worldPosition,

+ 12 - 12
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceData.azsli

@@ -20,24 +20,24 @@
 
 class SurfaceData_BasePBR
 {   
-    precise float3 position;    //!< Position in world-space
-    float3 normal;              //!< Normal in world-space
-    float3 vertexNormal;        //!< Vertex normal in world-space
-    float3 baseColor;           //!< Surface base color
-    float metallic;             //!< Surface metallic property
-    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
+    precise float3 position;   //!< Position in world-space
+    real3 normal;              //!< Normal in world-space
+    real3 vertexNormal;        //!< Vertex normal in world-space
+    real3 baseColor;           //!< Surface base color
+    real metallic;             //!< Surface metallic property
+    real roughnessLinear;      //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use
+    real roughnessA;           //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations
+    real roughnessA2;          //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance
 
     //! Surface lighting data
-    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
+    real3 albedo;              //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
+    real3 specularF0;          //!< Fresnel f0 spectral value of the surface
 
     //! Calculates roughnessA and roughnessA2 after roughness has been set
     void CalculateRoughnessA();
 
     //! Sets albedo, base color, specularF0, and metallic properties using metallic workflow
-    void SetAlbedoAndSpecularF0(float3 newBaseColor, float specularF0Factor, float newMetallic);
+    void SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor, real newMetallic);
 };
 
 void SurfaceData_BasePBR::CalculateRoughnessA()
@@ -45,7 +45,7 @@ void SurfaceData_BasePBR::CalculateRoughnessA()
     CalculateRoughnessValues(normal, roughnessLinear, roughnessA, roughnessA2);
 }
 
-void SurfaceData_BasePBR::SetAlbedoAndSpecularF0(float3 newBaseColor, float specularF0Factor, float newMetallic)
+void SurfaceData_BasePBR::SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor, real newMetallic)
 {
     baseColor = newBaseColor;
     metallic = newMetallic;

+ 11 - 11
Gems/Atom/Feature/Common/Assets/Shaders/Materials/BasePBR/BasePBR_SurfaceEval.azsli

@@ -19,9 +19,9 @@
 
 Surface EvaluateSurface_BasePBR(
     float3 positionWS,
-    float3 vertexNormal,
-    float3 tangents[UvSetCount],
-    float3 bitangents[UvSetCount],
+    real3 vertexNormal,
+    real3 tangents[UvSetCount],
+    real3 bitangents[UvSetCount],
     float2 uvs[UvSetCount],
     bool isFrontFace)
 {
@@ -32,33 +32,33 @@ Surface EvaluateSurface_BasePBR(
 
     surface.vertexNormal = vertexNormal;
     float2 normalUv = uvs[MaterialSrg::m_normalMapUvIndex];
-    float3x3 uvMatrix = MaterialSrg::m_normalMapUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3(); // By design, only UV0 is allowed to apply transforms.
+    real3x3 uvMatrix = MaterialSrg::m_normalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : real3x3(CreateIdentity3x3()); // By design, only UV0 is allowed to apply transforms.
     surface.normal = GetNormalInputWS(MaterialSrg::m_normalMap, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, isFrontFace, vertexNormal,
-                                       tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, o_normal_useTexture, MaterialSrg::m_normalFactor);
+                                       tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, o_normal_useTexture, real(MaterialSrg::m_normalFactor));
 
     // ------- Base Color -------
 
     float2 baseColorUv = uvs[MaterialSrg::m_baseColorMapUvIndex];
-    float3 sampledColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, MaterialSrg::m_baseColor.rgb, o_baseColor_useTexture);
-    float3 baseColor = BlendBaseColor(sampledColor, MaterialSrg::m_baseColor.rgb, MaterialSrg::m_baseColorFactor, o_baseColorTextureBlendMode, o_baseColor_useTexture);
+    real3 sampledColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, real3(MaterialSrg::m_baseColor.rgb), o_baseColor_useTexture);
+    real3 baseColor = BlendBaseColor(sampledColor, real3(MaterialSrg::m_baseColor.rgb), real(MaterialSrg::m_baseColorFactor), o_baseColorTextureBlendMode, o_baseColor_useTexture);
     
     // ------- Metallic -------
 
     float2 metallicUv = uvs[MaterialSrg::m_metallicMapUvIndex];
-    float metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, MaterialSrg::m_metallicFactor, o_metallic_useTexture);
+    real metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, real(MaterialSrg::m_metallicFactor), o_metallic_useTexture);
 
     // ------- Specular -------
 
     float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture);
+    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture);
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
 
     // ------- Roughness -------
 
     float2 roughnessUv = uvs[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.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, real(MaterialSrg::m_roughnessFactor),
+                                        real(MaterialSrg::m_roughnessLowerBound), real(MaterialSrg::m_roughnessUpperBound), o_roughness_useTexture);
     surface.CalculateRoughnessA();
 
     return surface;

+ 6 - 7
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_LightingBrdf.azsli

@@ -31,9 +31,9 @@
 #endif
 
 // Then define the Diffuse and Specular lighting functions
-float3 GetDiffuseLighting_EnhancedPBR(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight)
+real3 GetDiffuseLighting_EnhancedPBR(Surface surface, LightingData lightingData, real3 lightIntensity, real3 dirToLight)
 {
-    float3 diffuse;
+    real3 diffuse;
     if(o_enableSubsurfaceScattering)
     {
         // Use diffuse brdf contains double Fresnel (enter/exit surface) terms if subsurface scattering is enabled
@@ -48,7 +48,7 @@ float3 GetDiffuseLighting_EnhancedPBR(Surface surface, LightingData lightingData
     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));
+        real HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera));
         diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor);
     }
 #endif
@@ -57,9 +57,9 @@ float3 GetDiffuseLighting_EnhancedPBR(Surface surface, LightingData lightingData
     return diffuse;
 }
 
-float3 GetSpecularLighting_EnhancedPBR(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight)
+real3 GetSpecularLighting_EnhancedPBR(Surface surface, LightingData lightingData, const real3 lightIntensity, const real3 dirToLight)
 {
-    float3 specular;
+    real3 specular;
     if (o_enableAnisotropy)
     {
         specular = AnisotropicGGX( lightingData.dirToCamera, dirToLight, surface.normal, surface.anisotropy.tangent, surface.anisotropy.bitangent, surface.anisotropy.anisotropyFactors,
@@ -76,8 +76,7 @@ float3 GetSpecularLighting_EnhancedPBR(Surface surface, LightingData lightingDat
         specular = ClearCoatSpecular(dirToLight, lightingData.dirToCamera, surface.clearCoat.normal, surface.clearCoat.factor, surface.clearCoat.roughness, specular);
     }
 #endif
- 
-    specular *= lightIntensity;
     
+    specular *= lightIntensity;
     return specular;
 }

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryData.azsli

@@ -31,11 +31,11 @@
     class PixelGeometryData_EnhancedPBR 
     {
         float3 positionWS;
-        float3 vertexNormal;
+        real3 vertexNormal;
         float2 uvs[UvSetCount];
         float2 detailUvs[UvSetCount];
-        float3 tangents[UvSetCount];
-        float3 bitangents[UvSetCount];
+        real3 tangents[UvSetCount];
+        real3 bitangents[UvSetCount];
         bool isFrontFace;
         bool isDisplacementClipped;
     };

+ 7 - 7
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_PixelGeometryEval.azsli

@@ -22,9 +22,9 @@
 PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
     inout float4 positionSV,
     float3 positionWS,
-    float3 normalWS,
-    float3 tangentWS,
-    float3 bitangentWS,
+    real3 normalWS,
+    real3 tangentWS,
+    real3 bitangentWS,
     float2 uvs[UvSetCount],
     float2 detailUvs[UvSetCount],
     bool isFrontFace)
@@ -50,11 +50,11 @@ PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(
 
 PixelGeometryData EvaluatePixelGeometry_EnhancedPBR(inout VsOutput IN, bool isFrontFace)
 {
-    float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
-    float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
+    real4x4 objectToWorld = real4x4(ObjectSrg::GetWorldMatrix());
+    real3x3 objectToWorldIT = real3x3(ObjectSrg::GetWorldMatrixInverseTranspose());
 
-    float3 normalWS, tangentWS, bitangentWS;
-    ConstructTBN(IN.normal, IN.tangent, objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
+    real3 normalWS, tangentWS, bitangentWS;
+    ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
     return EvaluatePixelGeometry_EnhancedPBR(
         IN.position,

+ 22 - 22
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceData.azsli

@@ -29,9 +29,9 @@
 #endif
 
         //! Subsurface scattering parameters
-        float subsurfaceScatteringFactor;
-        float subsurfaceScatteringQuality;
-        float3 scatterDistance;
+        real subsurfaceScatteringFactor;
+        real subsurfaceScatteringQuality;
+        real3 scatterDistance;
     }
 
 #else
@@ -51,39 +51,39 @@
         // ------- BasePbrSurfaceData -------
     
         float3 position;            //!< Position in world-space
-        float3 normal;              //!< Normal in world-space
-        float3 vertexNormal;        //!< Vertex normal in world-space
-        float3 baseColor;           //!< Surface base color
-        float metallic;             //!< Surface metallic property
-        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
-        float alpha;
+        real3 normal;              //!< Normal in world-space
+        real3 vertexNormal;        //!< Vertex normal in world-space
+        real3 baseColor;           //!< Surface base color
+        real metallic;             //!< Surface metallic property
+        real roughnessLinear;      //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use
+        real roughnessA;           //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations
+        real roughnessA2;          //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance
+        real alpha;
 
         // Increase opacity at grazing angles for surfaces with a low m_opacityAffectsSpecularFactor.
         // For m_opacityAffectsSpecularFactor values close to 0, that indicates a transparent surface
         // like glass, so it becomes less transparent at grazing angles. For m_opacityAffectsSpecularFactor
         // values close to 1.0, that indicates the absence of a surface entirely, so this effect should
         // not apply.
-        float opacityAffectsSpecularFactor;
+        real opacityAffectsSpecularFactor;
 
         //! Subsurface scattering parameters
-        float subsurfaceScatteringFactor;
-        float subsurfaceScatteringQuality;
-        float3 scatterDistance;
+        real subsurfaceScatteringFactor;
+        real subsurfaceScatteringQuality;
+        real3 scatterDistance;
 
         //! Surface lighting inputs
-        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
-        float3 emissiveLighting;        //!< Emissive lighting
-        float diffuseAmbientOcclusion;  //!< Diffuse ambient occlusion factor - [0, 1] :: [Dark, Bright]
-        float specularOcclusion;        //!< Specular occlusion factor - [0, 1] :: [Dark, Bright]
+        real3 albedo;                  //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
+        real3 specularF0;              //!< Fresnel f0 spectral value of the surface
+        real3 emissiveLighting;        //!< Emissive lighting
+        real diffuseAmbientOcclusion;  //!< Diffuse ambient occlusion factor - [0, 1] :: [Dark, Bright]
+        real specularOcclusion;        //!< Specular occlusion factor - [0, 1] :: [Dark, Bright]
 
         //! 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);
+        void SetAlbedoAndSpecularF0(real3 baseColor, real specularF0Factor, real metallic);
     };
 
     void SurfaceData_EnhancedPBR::CalculateRoughnessA()
@@ -91,7 +91,7 @@
         CalculateRoughnessValues(normal, roughnessLinear, roughnessA, roughnessA2);
     }
 
-    void SurfaceData_EnhancedPBR::SetAlbedoAndSpecularF0(float3 newBaseColor, float specularF0Factor, float newMetallic)
+    void SurfaceData_EnhancedPBR::SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor, real newMetallic)
     {
         baseColor = newBaseColor;
         metallic = newMetallic;

+ 33 - 33
Gems/Atom/Feature/Common/Assets/Shaders/Materials/EnhancedPBR/EnhancedPBR_SurfaceEval.azsli

@@ -20,9 +20,9 @@
 
 Surface EvaluateSurface_EnhancedPBR(
     float3 positionWS,
-    float3 normalWS,
-    float3 tangents[UvSetCount],
-    float3 bitangents[UvSetCount],
+    real3 normalWS,
+    real3 tangents[UvSetCount],
+    real3 bitangents[UvSetCount],
     float2 uvs[UvSetCount],
     float2 detailUvs[UvSetCount],
     bool isFrontFace,
@@ -40,31 +40,31 @@ Surface EvaluateSurface_EnhancedPBR(
         detailUvs[MaterialSrg::m_detail_blendMask_uvIndex] : 
         uvs[MaterialSrg::m_detail_blendMask_uvIndex];        
 
-    const float detailLayerBlendFactor = GetDetailLayerBlendFactor(
+    const real detailLayerBlendFactor = GetDetailLayerBlendFactor(
         MaterialSrg::m_detail_blendMask_texture,
         MaterialSrg::m_sampler,
         detailBlendMaskUv,
         o_detail_blendMask_useTexture,
-        MaterialSrg::m_detail_blendFactor);
+        real(MaterialSrg::m_detail_blendFactor));
 
     // ------- Normal -------
     
     surface.vertexNormal = normalWS;
     float2 normalUv = uvs[MaterialSrg::m_normalMapUvIndex];
-    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;
+    real3x3 uvMatrix = MaterialSrg::m_normalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : real3x3(CreateIdentity3x3()); // By design, only UV0 is allowed to apply transforms.
+    real detailLayerNormalFactor = real(MaterialSrg::m_detail_normal_factor) * detailLayerBlendFactor;
     surface.normal = GetDetailedNormalInputWS(
         isFrontFace, normalWS,
-        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);
+        real3(tangents[MaterialSrg::m_normalMapUvIndex]),      real3(bitangents[MaterialSrg::m_normalMapUvIndex]),      MaterialSrg::m_normalMap,             MaterialSrg::m_sampler, normalUv, real(MaterialSrg::m_normalFactor),  MaterialSrg::m_flipNormalX,         MaterialSrg::m_flipNormalY,         uvMatrix,                               o_normal_useTexture,
+        real3(tangents[MaterialSrg::m_detail_allMapsUvIndex]), real3(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, real3x3(MaterialSrg::m_detailUvMatrix), o_detail_normal_useTexture);
 
     // ------- Base Color -------
 
-    float detailLayerBaseColorFactor = MaterialSrg::m_detail_baseColor_factor * detailLayerBlendFactor;
+    real detailLayerBaseColorFactor = real(MaterialSrg::m_detail_baseColor_factor) * detailLayerBlendFactor;
     float2 baseColorUv = uvs[MaterialSrg::m_baseColorMapUvIndex];
 
-    float3 baseColor = GetDetailedBaseColorInput(
-        MaterialSrg::m_baseColorMap,             MaterialSrg::m_sampler, baseColorUv, o_baseColor_useTexture,        MaterialSrg::m_baseColor,  MaterialSrg::m_baseColorFactor, o_baseColorTextureBlendMode,
+    real3 baseColor = GetDetailedBaseColorInput(
+        MaterialSrg::m_baseColorMap,             MaterialSrg::m_sampler, baseColorUv, o_baseColor_useTexture,        real3(MaterialSrg::m_baseColor),  real(MaterialSrg::m_baseColorFactor), o_baseColorTextureBlendMode,
         MaterialSrg::m_detail_baseColor_texture, MaterialSrg::m_sampler, detailUv,    o_detail_baseColor_useTexture, detailLayerBaseColorFactor);
     
     // ------- Parallax Clipping -------
@@ -81,43 +81,43 @@ Surface EvaluateSurface_EnhancedPBR(
 
     // ------- Metallic -------
 
-    float metallic = 0;
+    real metallic = 0;
     if(!o_enableSubsurfaceScattering)   // If subsurface scattering is enabled skip texture lookup for metallic, as this quantity won't be used anyway
     {
         float2 metallicUv = uvs[MaterialSrg::m_metallicMapUvIndex];
-        metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, MaterialSrg::m_metallicFactor, o_metallic_useTexture);
+        metallic = GetMetallicInput(MaterialSrg::m_metallicMap, MaterialSrg::m_sampler, metallicUv, real(MaterialSrg::m_metallicFactor), o_metallic_useTexture);
     }
 
     // ------- Specular -------
 
     float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture);
+    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture);
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
 
     // ------- Roughness -------
 
     float2 roughnessUv = uvs[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.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, real(MaterialSrg::m_roughnessFactor),
+                                        real(MaterialSrg::m_roughnessLowerBound), real(MaterialSrg::m_roughnessUpperBound), o_roughness_useTexture);
     surface.CalculateRoughnessA();
 
     // ------- Subsurface -------
 
     float2 subsurfaceUv = uvs[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
-    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, MaterialSrg::m_subsurfaceScatteringFactor);
-    surface.subsurfaceScatteringQuality = MaterialSrg::m_subsurfaceScatteringQuality;
-    surface.scatterDistance = MaterialSrg::m_scatterDistance;
+    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, real(MaterialSrg::m_subsurfaceScatteringFactor));
+    surface.subsurfaceScatteringQuality = real(MaterialSrg::m_subsurfaceScatteringQuality);
+    surface.scatterDistance = real3(MaterialSrg::m_scatterDistance);
 
     // ------- Transmission -------
     
 #if ENABLE_TRANSMISSION
     float2 transmissionUv = uvs[MaterialSrg::m_transmissionThicknessMapUvIndex];
-    float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness);
+    real4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, real4(MaterialSrg::m_transmissionTintThickness));
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.thickness = transmissionTintThickness.w;
-    surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams;
-    surface.transmission.scatterDistance = MaterialSrg::m_scatterDistance;
+    surface.transmission.transmissionParams = real4(MaterialSrg::m_transmissionParams);
+    surface.transmission.scatterDistance = real3(MaterialSrg::m_scatterDistance);
 #endif
 
     // ------- Anisotropy -------
@@ -125,20 +125,20 @@ Surface EvaluateSurface_EnhancedPBR(
     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;
+        const real anisotropyAngle = real(MaterialSrg::m_anisotropicAngle) * PI;
+        const real anisotropyFactor = real(MaterialSrg::m_anisotropicFactor);
         surface.anisotropy.Init(surface.normal, tangents[0], bitangents[0], anisotropyAngle, anisotropyFactor, surface.roughnessA);
     }
 
     // ------- Emissive -------
 
     float2 emissiveUv = uvs[MaterialSrg::m_emissiveMapUvIndex];
-    surface.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, MaterialSrg::m_emissiveAffectedByAlpha, surface.alpha, o_emissiveEnabled, o_emissive_useTexture);
+    surface.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, real(MaterialSrg::m_emissiveIntensity), real3(MaterialSrg::m_emissiveColor.rgb), real(MaterialSrg::m_emissiveAffectedByAlpha), surface.alpha,  o_emissiveEnabled, o_emissive_useTexture);
 
     // ------- Occlusion -------
     
-    surface.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
-    surface.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
+    surface.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_diffuseOcclusionMapUvIndex], real(MaterialSrg::m_diffuseOcclusionFactor), o_diffuseOcclusion_useTexture);
+    surface.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, uvs[MaterialSrg::m_specularOcclusionMapUvIndex], real(MaterialSrg::m_specularOcclusionFactor), o_specularOcclusion_useTexture);
 
     // ------- Clearcoat -------
     
@@ -148,10 +148,10 @@ Surface EvaluateSurface_EnhancedPBR(
     {
         if(o_clearCoat_enabled)
         {
-            float3x3 uvMatrix = MaterialSrg::m_clearCoatNormalMapUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3();
-            GetClearCoatInputs(MaterialSrg::m_clearCoatInfluenceMap, uvs[MaterialSrg::m_clearCoatInfluenceMapUvIndex], MaterialSrg::m_clearCoatFactor, o_clearCoat_factor_useTexture,
-                               MaterialSrg::m_clearCoatRoughnessMap, uvs[MaterialSrg::m_clearCoatRoughnessMapUvIndex], MaterialSrg::m_clearCoatRoughness, o_clearCoat_roughness_useTexture,
-                               MaterialSrg::m_clearCoatNormalMap,    uvs[MaterialSrg::m_clearCoatNormalMapUvIndex], normalWS, o_clearCoat_normal_useTexture, MaterialSrg::m_clearCoatNormalStrength,
+            real3x3 uvMatrix = MaterialSrg::m_clearCoatNormalMapUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : real3x3(CreateIdentity3x3());
+            GetClearCoatInputs(MaterialSrg::m_clearCoatInfluenceMap, uvs[MaterialSrg::m_clearCoatInfluenceMapUvIndex], real(MaterialSrg::m_clearCoatFactor), o_clearCoat_factor_useTexture,
+                               MaterialSrg::m_clearCoatRoughnessMap, uvs[MaterialSrg::m_clearCoatRoughnessMapUvIndex], real(MaterialSrg::m_clearCoatRoughness), o_clearCoat_roughness_useTexture,
+                               MaterialSrg::m_clearCoatNormalMap,    uvs[MaterialSrg::m_clearCoatNormalMapUvIndex], normalWS, o_clearCoat_normal_useTexture, real(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);
@@ -163,7 +163,7 @@ Surface EvaluateSurface_EnhancedPBR(
     
     // ------- Opacity -------
 
-    surface.opacityAffectsSpecularFactor = MaterialSrg::m_opacityAffectsSpecularFactor;
+    surface.opacityAffectsSpecularFactor = real(MaterialSrg::m_opacityAffectsSpecularFactor);
 
     return surface;
 }

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_PixelGeometryData.azsli

@@ -21,10 +21,10 @@ class PixelGeometryData_Eye
 {
     // BasePBR
     float3 positionWS;
-    float3 vertexNormal;
+    real3 vertexNormal;
     float2 uvs[UvSetCount];
-    float3 tangents[UvSetCount];
-    float3 bitangents[UvSetCount];
+    real3 tangents[UvSetCount];
+    real3 bitangents[UvSetCount];
     bool isFrontFace;
 
     // Eye

+ 11 - 11
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_PixelGeometryEval.azsli

@@ -22,9 +22,9 @@
 // way to handle this.
 PixelGeometryData EvaluatePixelGeometry_Eye(
     float3 positionWS,
-    float3 normalWS,
-    float3 tangentWS,
-    float3 bitangentWS,
+    real3 normalWS,
+    real3 tangentWS,
+    real3 bitangentWS,
     float2 uvs[UvSetCount],
     bool isFrontFace,
     bool evaluateTangentFrame)
@@ -57,9 +57,9 @@ PixelGeometryData EvaluatePixelGeometry_Eye(
 
 PixelGeometryData EvaluatePixelGeometry_Eye(
     float3 positionWS,
-    float3 normalWS,
-    float3 tangentWS,
-    float3 bitangentWS,
+    real3 normalWS,
+    real3 tangentWS,
+    real3 bitangentWS,
     float2 uv[UvSetCount],
     float3 localPosition,
     bool isFrontFace)
@@ -76,14 +76,14 @@ PixelGeometryData EvaluatePixelGeometry_Eye(
 
 PixelGeometryData EvaluatePixelGeometry_Eye(VsOutput IN, bool isFrontFace)
 {
-    float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
-    float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
+    real4x4 objectToWorld = real4x4(ObjectSrg::GetWorldMatrix());
+    real3x3 objectToWorldIT = real3x3(ObjectSrg::GetWorldMatrixInverseTranspose());
 
-    float3 normalWS, tangentWS, bitangentWS;
-    ConstructTBN(IN.normal, IN.tangent, objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
+    real3 normalWS, tangentWS, bitangentWS;
+    ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
     // Bitangent is temporarily added back to fix the eye material screenshot test.
-    bitangentWS = normalize(mul(objectToWorld, float4(IN.bitangent, 0.0)).xyz);
+    bitangentWS = normalize(mul(objectToWorld, real4(IN.bitangent, 0.0)).xyz);
 
     return EvaluatePixelGeometry_Eye(
         IN.worldPosition,

+ 39 - 39
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Eye/Eye_SurfaceEval.azsli

@@ -19,9 +19,9 @@
 
 Surface EvaluateSurface_Eye(
     float3 positionWS,
-    float3 vertexNormal,
-    float3 tangents[UvSetCount],
-    float3 bitangents[UvSetCount],
+    real3 vertexNormal,
+    real3 tangents[UvSetCount],
+    real3 bitangents[UvSetCount],
     float2 uvs[UvSetCount],
     float3 localPosition,
     bool isFrontFace)
@@ -31,11 +31,11 @@ Surface EvaluateSurface_Eye(
 
     // ------- Iris/Sclera Layer Setup -------
 
-    float3x3 uvMatrix = CreateIdentity3x3(); // The eye material type doesn't support UV transforms
+    real3x3 uvMatrix = CreateIdentity3x3(); // The eye material type doesn't support UV transforms
 
     // Use a sigmoid to determine the sclera/iris contribution for each point
-    float distFromCenter = length(localPosition.xz);
-    float mask = 1.0/(1.0 + exp(-(distFromCenter - MaterialSrg::m_eyeIrisRadius) / (distFromCenter * MaterialSrg::m_limbusSize)));
+    real distFromCenter = length(real2(localPosition.xz));
+    real mask = 1.0/(1.0 + exp(-(distFromCenter - real(MaterialSrg::m_eyeIrisRadius)) / (distFromCenter * real(MaterialSrg::m_limbusSize))));
 
     // ------- Normal -------
     
@@ -43,50 +43,50 @@ Surface EvaluateSurface_Eye(
     
     // Get surface normal for each layer (iris/sclera) and blend using the mask defined above
     float2 irisNormalUv = uvs[MaterialSrg::m_iris_m_normalMapUvIndex];
-    float3 irisNormal = GetNormalInputWS(MaterialSrg::m_iris_m_normalMap, MaterialSrg::m_sampler, irisNormalUv, MaterialSrg::m_iris_m_flipNormalX, MaterialSrg::m_iris_m_flipNormalY, isFrontFace, surface.vertexNormal,
-                                    tangents[MaterialSrg::m_iris_m_normalMapUvIndex], bitangents[MaterialSrg::m_iris_m_normalMapUvIndex], uvMatrix, o_iris_o_normal_useTexture, MaterialSrg::m_iris_m_normalFactor);
+    real3 irisNormal = GetNormalInputWS(MaterialSrg::m_iris_m_normalMap, MaterialSrg::m_sampler, irisNormalUv, MaterialSrg::m_iris_m_flipNormalX, MaterialSrg::m_iris_m_flipNormalY, isFrontFace, surface.vertexNormal,
+                                    tangents[MaterialSrg::m_iris_m_normalMapUvIndex], bitangents[MaterialSrg::m_iris_m_normalMapUvIndex], uvMatrix, o_iris_o_normal_useTexture, real(MaterialSrg::m_iris_m_normalFactor));
     
     float2 scleraNormalUv = uvs[MaterialSrg::m_sclera_m_normalMapUvIndex];
-    float3 scleraNormal = GetNormalInputWS(MaterialSrg::m_sclera_m_normalMap, MaterialSrg::m_sampler, scleraNormalUv, MaterialSrg::m_sclera_m_flipNormalX, MaterialSrg::m_sclera_m_flipNormalY, isFrontFace, surface.vertexNormal,
-                                    tangents[MaterialSrg::m_sclera_m_normalMapUvIndex], bitangents[MaterialSrg::m_sclera_m_normalMapUvIndex], uvMatrix, o_sclera_o_normal_useTexture, MaterialSrg::m_sclera_m_normalFactor);
+    real3 scleraNormal = GetNormalInputWS(MaterialSrg::m_sclera_m_normalMap, MaterialSrg::m_sampler, scleraNormalUv, MaterialSrg::m_sclera_m_flipNormalX, MaterialSrg::m_sclera_m_flipNormalY, isFrontFace, surface.vertexNormal,
+                                    tangents[MaterialSrg::m_sclera_m_normalMapUvIndex], bitangents[MaterialSrg::m_sclera_m_normalMapUvIndex], uvMatrix, o_sclera_o_normal_useTexture, real(MaterialSrg::m_sclera_m_normalFactor));
     
     surface.normal = normalize(lerp(irisNormal, scleraNormal, mask));
 
     //--------------------- Eye refraction UV offset ----------------------
 
-    float3 viewDir = normalize(surface.position - ViewSrg::m_worldPosition.xyz);
+    real3 viewDir = real3(normalize(surface.position - ViewSrg::m_worldPosition.xyz));
 
     // Get refracted vector
-    const float airIOR = 1.0;
-    float refractionFactor = airIOR/MaterialSrg::m_innerEyeIOR;
-    float3 refractedDir = refract(viewDir, surface.normal, refractionFactor);
+    const real airIOR = 1.0;
+    real refractionFactor = airIOR/real(MaterialSrg::m_innerEyeIOR);
+    real3 refractedDir = refract(viewDir, surface.normal, refractionFactor);
 
     // Get UV offset due to refraction (based on http://www.iryoku.com/stare-into-the-future)
     
     // Gaze direction corresponds to the front vector (in WS)
-    float4x4 worldMatrix = ObjectSrg::GetWorldMatrix(); 
-    float3 gazeDirWS = normalize(mul(worldMatrix, float4(0,1,0,0)).xyz);
+    real4x4 worldMatrix = real4x4(ObjectSrg::GetWorldMatrix()); 
+    real3 gazeDirWS = normalize(mul(worldMatrix, real4(0,1,0,0)).xyz);
 
     // Position direction corresponds to the vector from the object's center to the point in WS (in order to support refraction in all orientations)
-    float3 positionDirWS = mul(worldMatrix, float4(localPosition,0.0)).xyz;
+    real3 positionDirWS = mul(worldMatrix, real4(localPosition,0.0)).xyz;
 
     // Object scale of the front vector (Y) 
-    float scaleY = length(float3(worldMatrix._12, worldMatrix._22, worldMatrix._32));
+    real scaleY = length(real3(worldMatrix._12, worldMatrix._22, worldMatrix._32));
     
     // Compute distance from current point to the iris plane 
     // m_irisDepth corresponds to the distance from the object origin to the local plane (XZ) where the iris lays.
     // By multiplying this parameter by the scale we avoid having to re-tune it everytime we change the object's scale.
-    float height = max(dot(gazeDirWS, positionDirWS) - MaterialSrg::m_irisDepth*scaleY, 0.0); 
+    real height = max(dot(gazeDirWS, positionDirWS) - real(MaterialSrg::m_irisDepth)*scaleY, 0.0); 
 
     // Height encodes the length of the refracted ray projected in (local) Y, but we are interested in the (local) XZ coordinates 
     // of the ray since these will be directly related to the offset to apply in texture space. Hence, we apply basic trigonometry 
     // to get the actual length of the ray
-    float cosAlpha = dot(gazeDirWS, -refractedDir);
-    float refractedRayLength = height / cosAlpha;
-    float3 refractedRay = refractedRayLength * refractedDir;
+    real cosAlpha = dot(gazeDirWS, -refractedDir);
+    real refractedRayLength = height / cosAlpha;
+    real3 refractedRay = refractedRayLength * refractedDir;
 
     // Convert ray to object local space and fetch XZ coordinates (which map to -XY in texture space)
-    float2 refractionUVOffset = -mul(refractedRay, ObjectSrg::GetWorldMatrixInverseTranspose()).xz;
+    real2 refractionUVOffset = -mul(refractedRay, real3x3(ObjectSrg::GetWorldMatrixInverseTranspose())).xz;
 
     // Apply offset to the current UVs
     for (int uvIdx = 0; uvIdx < UvSetCount; uvIdx++)
@@ -98,21 +98,21 @@ Surface EvaluateSurface_Eye(
 
     // Sample iris color map and blend with the base iris color 
     float2 irisBaseColorUv = uvs[MaterialSrg::m_iris_m_baseColorMapUvIndex];
-    float3 irisSampledColor = GetBaseColorInput(MaterialSrg::m_iris_m_baseColorMap, MaterialSrg::m_sampler, irisBaseColorUv, MaterialSrg::m_iris_m_baseColor, o_iris_o_baseColor_useTexture);    
-    float3 irisColor = BlendBaseColor(irisSampledColor, MaterialSrg::m_iris_m_baseColor, MaterialSrg::m_iris_m_baseColorFactor, o_iris_o_baseColorTextureBlendMode, o_iris_o_baseColor_useTexture);
+    real3 irisSampledColor = GetBaseColorInput(MaterialSrg::m_iris_m_baseColorMap, MaterialSrg::m_sampler, irisBaseColorUv, real3(MaterialSrg::m_iris_m_baseColor), o_iris_o_baseColor_useTexture);    
+    real3 irisColor = BlendBaseColor(irisSampledColor, real3(MaterialSrg::m_iris_m_baseColor), real(MaterialSrg::m_iris_m_baseColorFactor), o_iris_o_baseColorTextureBlendMode, o_iris_o_baseColor_useTexture);
     
     // Sample sclera color map and blend with the base sclera color 
     float2 scleraBaseColorUv = uvs[MaterialSrg::m_sclera_m_baseColorMapUvIndex];
-    float3 scleraSampledColor = GetBaseColorInput(MaterialSrg::m_sclera_m_baseColorMap, MaterialSrg::m_sampler, scleraBaseColorUv, MaterialSrg::m_sclera_m_baseColor, o_sclera_o_baseColor_useTexture);    
-    float3 scleraColor = BlendBaseColor(scleraSampledColor, MaterialSrg::m_sclera_m_baseColor, MaterialSrg::m_sclera_m_baseColorFactor, o_sclera_o_baseColorTextureBlendMode, o_sclera_o_baseColor_useTexture);
+    real3 scleraSampledColor = GetBaseColorInput(MaterialSrg::m_sclera_m_baseColorMap, MaterialSrg::m_sampler, scleraBaseColorUv, real3(MaterialSrg::m_sclera_m_baseColor), o_sclera_o_baseColor_useTexture);    
+    real3 scleraColor = BlendBaseColor(scleraSampledColor, real3(MaterialSrg::m_sclera_m_baseColor), real(MaterialSrg::m_sclera_m_baseColorFactor), o_sclera_o_baseColorTextureBlendMode, o_sclera_o_baseColor_useTexture);
     
     // Blend iris and sclera output colors
-    float3 baseColor = lerp(irisColor, scleraColor, mask);
+    real3 baseColor = lerp(irisColor, scleraColor, mask);
 
     // ------- Specular -------
 
     float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture);
+    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture);
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor);
 
@@ -120,12 +120,12 @@ Surface EvaluateSurface_Eye(
 
     // Get surface roughness for each layer (iris/sclera) and blend using the mask defined above
     float2 irisRoughnessUv = uvs[MaterialSrg::m_iris_m_roughnessMapUvIndex];
-    float irisRoughnessLinear = GetRoughnessInput(MaterialSrg::m_iris_m_roughnessMap, MaterialSrg::m_sampler, irisRoughnessUv, MaterialSrg::m_iris_m_roughnessFactor,
-                                        MaterialSrg::m_iris_m_roughnessLowerBound, MaterialSrg::m_iris_m_roughnessUpperBound, o_iris_o_roughness_useTexture);
+    real irisRoughnessLinear = GetRoughnessInput(MaterialSrg::m_iris_m_roughnessMap, MaterialSrg::m_sampler, irisRoughnessUv, real(MaterialSrg::m_iris_m_roughnessFactor),
+                                        real(MaterialSrg::m_iris_m_roughnessLowerBound), real(MaterialSrg::m_iris_m_roughnessUpperBound), o_iris_o_roughness_useTexture);
 
     float2 scleraRoughnessUv = uvs[MaterialSrg::m_sclera_m_roughnessMapUvIndex];
-    float scleraRoughnessLinear = GetRoughnessInput(MaterialSrg::m_sclera_m_roughnessMap, MaterialSrg::m_sampler, scleraRoughnessUv, MaterialSrg::m_sclera_m_roughnessFactor,
-                                        MaterialSrg::m_sclera_m_roughnessLowerBound, MaterialSrg::m_sclera_m_roughnessUpperBound, o_sclera_o_roughness_useTexture);
+    real scleraRoughnessLinear = GetRoughnessInput(MaterialSrg::m_sclera_m_roughnessMap, MaterialSrg::m_sampler, scleraRoughnessUv, real(MaterialSrg::m_sclera_m_roughnessFactor),
+                                        real(MaterialSrg::m_sclera_m_roughnessLowerBound), real(MaterialSrg::m_sclera_m_roughnessUpperBound), o_sclera_o_roughness_useTexture);
 
     surface.roughnessLinear = lerp(irisRoughnessLinear, scleraRoughnessLinear, mask);
     surface.CalculateRoughnessA();
@@ -133,18 +133,18 @@ Surface EvaluateSurface_Eye(
     // ------- Subsurface -------
 
     float2 subsurfaceUv = uvs[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
-    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, MaterialSrg::m_subsurfaceScatteringFactor);
-    surface.subsurfaceScatteringQuality = MaterialSrg::m_subsurfaceScatteringQuality;
-    surface.scatterDistance = MaterialSrg::m_scatterDistance;
+    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, real(MaterialSrg::m_subsurfaceScatteringFactor));
+    surface.subsurfaceScatteringQuality = real(MaterialSrg::m_subsurfaceScatteringQuality);
+    surface.scatterDistance = real3(MaterialSrg::m_scatterDistance);
 
     // ------- Transmission -------
 
     float2 transmissionUv = uvs[MaterialSrg::m_transmissionThicknessMapUvIndex];
-    float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness);
+    real4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, real4(MaterialSrg::m_transmissionTintThickness));
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.thickness = transmissionTintThickness.w;
-    surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams;
-    surface.transmission.scatterDistance = MaterialSrg::m_scatterDistance;
+    surface.transmission.transmissionParams = real4(MaterialSrg::m_transmissionParams);
+    surface.transmission.scatterDistance = real3(MaterialSrg::m_scatterDistance);
 
     return surface;
 }

+ 5 - 5
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/EvaluateTangentFrame.azsli

@@ -11,16 +11,16 @@
 // The built-in tangent frame evaluation forwards the tangent frame interpolated from the vertex
 // data streams for UV-index 0. For UV-index 1, the tangent frame is computed from UV surface gradients.
 void EvaluateTangentFrame(
-    float3 normal,
+    real3 normal,
     float3 worldPosition,
     bool isFrontFace,
     float2 uv,
     int uvIndex,
     // The input tangent and bitangent vectors are optional and used to forward data from interpolants
-    float3 IN_tangent,
-    float3 IN_bitangent,
-    out float3 OUT_tangent,
-    out float3 OUT_bitangent)
+    real3 IN_tangent,
+    real3 IN_bitangent,
+    out real3 OUT_tangent,
+    out real3 OUT_bitangent)
 {
     if (DrawSrg::GetTangentAtUv(uvIndex) == 0)
     {

+ 12 - 12
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/MultilayerParallaxDepth.azsli

@@ -14,38 +14,38 @@
  void MultilayerSetPixelDepth(
      float3 vertexBlendMask,
      inout float3 worldPosition,
-     float3 normal,
-     float3 tangents[UvSetCount],
-     float3 bitangents[UvSetCount],
+     real3 normal,
+     real3 tangents[UvSetCount],
+     real3 bitangents[UvSetCount],
      inout float2 uvs[UvSetCount],
      bool isFrontFace,
      inout float depthNDC,
      inout float depthCS,
      out bool isClipped)
 {
-    float3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3();
-    float3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrixInverse : CreateIdentity3x3();
+    real3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : real3x3(CreateIdentity3x3());
+    real3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrixInverse) : real3x3(CreateIdentity3x3());
 
-    float parallaxOverallOffset = MaterialSrg::m_displacementMax;
-    float parallaxOverallFactor = MaterialSrg::m_displacementMax - MaterialSrg::m_displacementMin;
+    real parallaxOverallOffset = real(MaterialSrg::m_displacementMax);
+    real parallaxOverallFactor = real(MaterialSrg::m_displacementMax) - real(MaterialSrg::m_displacementMin);
     
-    AdjustParallaxShadowCaster(parallaxOverallFactor, parallaxOverallOffset, MaterialSrg::m_parallax_pdo_shadowFactor);
+    AdjustParallaxShadowCaster(parallaxOverallFactor, parallaxOverallOffset, real(MaterialSrg::m_parallax_pdo_shadowFactor));
     
     s_blendMaskFromVertexStream = vertexBlendMask;
     
     GetParallaxInput(
         normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex],
         parallaxOverallFactor, parallaxOverallOffset, 
-        ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse,
+        real4x4(ObjectSrg::GetWorldMatrix()), uvMatrix, uvMatrixInverse,
         uvs[MaterialSrg::m_parallaxUvIndex], worldPosition, depthNDC, depthCS, isClipped);
 }
 
  void MultilayerSetPixelDepth(
      float3 vertexBlendMask,
      inout float3 positionWS,
-     float3 normal,
-     float3 tangents[UvSetCount],
-     float3 bitangents[UvSetCount],
+     real3 normal,
+     real3 tangents[UvSetCount],
+     real3 bitangents[UvSetCount],
      inout float2 uvs[UvSetCount],
      bool isFrontFace,
      inout float depthNDC)

+ 16 - 16
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/ParallaxDepth.azsli

@@ -15,41 +15,41 @@
 
  void SetPixelDepth(
      inout float3 positionWS,
-     float3 normal,
-     float3 tangents[UvSetCount],
-     float3 bitangents[UvSetCount],
+     real3 normal,
+     real3 tangents[UvSetCount],
+     real3 bitangents[UvSetCount],
      inout float2 uvs[UvSetCount],
      bool isFrontFace,
      inout float depthNDC,
      inout float depthCS,
      out bool isClipped)
 {
-    float3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrix : CreateIdentity3x3();
-    float3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? MaterialSrg::m_uvMatrixInverse : CreateIdentity3x3();
+    real3x3 uvMatrix = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrix) : real3x3(CreateIdentity3x3());
+    real3x3 uvMatrixInverse = MaterialSrg::m_parallaxUvIndex == 0 ? real3x3(MaterialSrg::m_uvMatrixInverse) : real3x3(CreateIdentity3x3());
     
-    float heightmapScale = MaterialSrg::m_heightmapScale;
-    float heightmapOffset = MaterialSrg::m_heightmapOffset;
+    real heightmapScale = real(MaterialSrg::m_heightmapScale);
+    real heightmapOffset = real(MaterialSrg::m_heightmapOffset);
     
-    AdjustParallaxShadowCaster(heightmapScale, heightmapOffset, MaterialSrg::m_parallax_pdo_shadowFactor);
+    AdjustParallaxShadowCaster(heightmapScale, heightmapOffset, real(MaterialSrg::m_parallax_pdo_shadowFactor));
 
     GetParallaxInput(
         normal, tangents[MaterialSrg::m_parallaxUvIndex], bitangents[MaterialSrg::m_parallaxUvIndex],
         heightmapScale, heightmapOffset,
-        ObjectSrg::GetWorldMatrix(), uvMatrix, uvMatrixInverse,
+        real4x4(ObjectSrg::GetWorldMatrix()), uvMatrix, uvMatrixInverse,
         uvs[MaterialSrg::m_parallaxUvIndex], positionWS, depthNDC, depthCS, isClipped);
 }
 
  void SetPixelDepth(
      inout float3 positionWS,
-     float3 normal,
-     float3 tangents[UvSetCount],
-     float3 bitangents[UvSetCount],
+     real3 normal,
+     real3 tangents[UvSetCount],
+     real3 bitangents[UvSetCount],
      inout float2 uvs[UvSetCount],
      bool isFrontFace,
      inout float depthNDC)
 {
     // Dummy variables to call the above function
-    float depthCS = 1.0;
+    real depthCS = 1.0;
     bool isClipped;
     
     SetPixelDepth(positionWS, normal, tangents, bitangents, uvs, isFrontFace, depthNDC, depthCS, isClipped);
@@ -57,9 +57,9 @@
 
  void SetPixelDepth(
      inout float3 positionWS,
-     float3 normal,
-     float3 tangents[UvSetCount],
-     float3 bitangents[UvSetCount],
+     real3 normal,
+     real3 tangents[UvSetCount],
+     real3 bitangents[UvSetCount],
      inout float2 uvs[UvSetCount],
      inout float2 detailUv[UvSetCount],
      bool isFrontFace,

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/ParallaxShadowUtil.azsli

@@ -17,11 +17,11 @@
 //! @param heightmapScale inout scale to adjust
 //! @param heightmapOffset inout offset to adjust
 //! @param shadowFactor 0-1 multiplier, where 1 is no-op and 0 squashes the displacement down to its lowest point.
- void AdjustParallaxShadowCaster(inout float heightmapScale, inout float heightmapOffset, float shadowFactor)
+ void AdjustParallaxShadowCaster(inout real heightmapScale, inout real heightmapOffset, real shadowFactor)
  {
 #if SHADOWMAP
-    float newHeightmapScale = heightmapScale * shadowFactor;
-    float newHeightmapOffset = newHeightmapScale - heightmapScale + heightmapOffset;
+    real newHeightmapScale = heightmapScale * shadowFactor;
+    real newHeightmapOffset = newHeightmapScale - heightmapScale + heightmapOffset;
     heightmapScale = newHeightmapScale;
     heightmapOffset = newHeightmapOffset;
 #endif

+ 4 - 4
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialFunctions/StandardGetAlphaAndClip.azsli

@@ -10,12 +10,12 @@
 
 #include "../MaterialInputs/AlphaInput.azsli"
 
-float GetAlphaAndClip(float2 uvs[UvSetCount])
+real GetAlphaAndClip(float2 uvs[UvSetCount])
 {
     // Alpha
     float2 baseColorUV = uvs[MaterialSrg::m_baseColorMapUvIndex];
     float2 opacityUV = uvs[MaterialSrg::m_opacityMapUvIndex];
-    float alpha = SampleAlpha(MaterialSrg::m_baseColorMap, MaterialSrg::m_opacityMap, baseColorUV, opacityUV, MaterialSrg::m_sampler, o_opacity_source);
-    CheckClipping(alpha, MaterialSrg::m_opacityFactor);
-    return MaterialSrg::m_opacityFactor * alpha;
+    real alpha = SampleAlpha(MaterialSrg::m_baseColorMap, MaterialSrg::m_opacityMap, baseColorUV, opacityUV, MaterialSrg::m_sampler, o_opacity_source);
+    CheckClipping(alpha, real(MaterialSrg::m_opacityFactor));
+    return real(MaterialSrg::m_opacityFactor) * alpha;
 }

+ 6 - 6
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/AlphaInput.azsli

@@ -13,19 +13,19 @@
 enum class OpacitySource {Packed, Split, None};
 option OpacitySource o_opacity_source;
 
-float SampleAlpha(Texture2D baseColorMap, Texture2D opacityMap, float2 baseColorUv, float2 opacityUv, sampler mapSampler, OpacitySource opacitySource)
+real SampleAlpha(Texture2D baseColorMap, Texture2D opacityMap, float2 baseColorUv, float2 opacityUv, sampler mapSampler, OpacitySource opacitySource)
 {
-    float alpha = 1.0;
+    real alpha = 1.0;
     switch(opacitySource)
     {
         case OpacitySource::Packed:
         {
-            alpha = baseColorMap.Sample(mapSampler, baseColorUv).a;
+            alpha = real(baseColorMap.Sample(mapSampler, baseColorUv).a);
             break;
         }
         case OpacitySource::Split:  
         {
-            alpha = opacityMap.Sample(mapSampler, opacityUv).r;
+            alpha = real(opacityMap.Sample(mapSampler, opacityUv).r);
             break;
         }
         case OpacitySource::None:
@@ -34,9 +34,9 @@ float SampleAlpha(Texture2D baseColorMap, Texture2D opacityMap, float2 baseColor
     return alpha;
 }
 
-float GetAlphaInputAndClip(Texture2D baseColorMap, Texture2D opacityMap, float2 baseColorUv, float2 opacityUv, sampler mapSampler, float opacityFactor, OpacitySource opacitySource)
+real GetAlphaInputAndClip(Texture2D baseColorMap, Texture2D opacityMap, float2 baseColorUv, float2 opacityUv, sampler mapSampler, real opacityFactor, OpacitySource opacitySource)
 {
-    float alpha = SampleAlpha(baseColorMap, opacityMap, baseColorUv, opacityUv, mapSampler, opacitySource);
+    real alpha = SampleAlpha(baseColorMap, opacityMap, baseColorUv, opacityUv, mapSampler, opacitySource);
     CheckClipping(alpha, opacityFactor);
     return (alpha * opacityFactor);
 }

+ 6 - 4
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/BaseColorInput.azsli

@@ -28,7 +28,7 @@ Texture2D prefix##m_baseColorMap;
 option bool prefix##o_baseColor_useTexture; \
 option TextureBlendMode prefix##o_baseColorTextureBlendMode = TextureBlendMode::Multiply;
 
-float3 GetBaseColorInput(Texture2D map, sampler mapSampler, float2 uv, float3 baseColor, bool useTexture)
+real3 GetBaseColorInput(Texture2D map, sampler mapSampler, float2 uv, real3 baseColor, bool useTexture)
 {
     if(OverrideBaseColorEnabled())
     {
@@ -37,13 +37,15 @@ float3 GetBaseColorInput(Texture2D map, sampler mapSampler, float2 uv, float3 ba
 
     if(useTexture)
     {
-        float3 sampledAbledo = map.Sample(mapSampler, uv).rgb;
-        return TransformColor(sampledAbledo, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
+        real3 sampledAbledo = real3(map.Sample(mapSampler, uv).rgb);
+        //Convert to ACEScg as that is our intermediate working space. 
+        //Todo - We should data drive this color space
+        return LinearSrgb_To_AcesCg(sampledAbledo);
     }
     return baseColor;
 }
 
-float3 BlendBaseColor(float3 sampledBaseColor, float3 baseColor, float factor, TextureBlendMode blendMode, bool useTexture)
+real3 BlendBaseColor(real3 sampledBaseColor, real3 baseColor, real factor, TextureBlendMode blendMode, bool useTexture)
 {
     if(OverrideBaseColorEnabled())
     {

+ 9 - 9
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/ClearCoatInput.azsli

@@ -33,26 +33,26 @@ option bool prefix##o_clearCoat_factor_useTexture;    \
 option bool prefix##o_clearCoat_roughness_useTexture; \
 option bool prefix##o_clearCoat_normal_useTexture;
 
-void GetClearCoatInputs(Texture2D influenceMap, float2 influenceUV, float clearCoatFactor, bool useInfluenceMap,
-                        Texture2D roughnessMap, float2 roughnessUV, float roughness, bool useRoughnessMap,
-                        Texture2D normalMap, float2 normalUV, float3 normal, bool useNormalMap, float normalStrength,
-                        float3x3 uvMatrix, float3 tangent, float3 bitangent,
+void GetClearCoatInputs(Texture2D influenceMap, float2 influenceUV, real clearCoatFactor, bool useInfluenceMap,
+                        Texture2D roughnessMap, float2 roughnessUV, real roughness, bool useRoughnessMap,
+                        Texture2D normalMap, float2 normalUV, real3 normal, bool useNormalMap, real normalStrength,
+                        real3x3 uvMatrix, real3 tangent, real3 bitangent,
                         sampler mapSampler, bool isFrontFace,
-                        inout float finalClearCoatFactor, inout float clearCoatRoughness, inout float3 clearCoatNormal)
+                        inout real finalClearCoatFactor, inout real clearCoatRoughness, inout real3 clearCoatNormal)
 {
     if(useInfluenceMap)
     {
-        clearCoatFactor *= influenceMap.Sample(mapSampler, influenceUV).r;
+        clearCoatFactor *= real(influenceMap.Sample(mapSampler, influenceUV).r);
     }
     
     if(useRoughnessMap)
     {
-        roughness *= roughnessMap.Sample(mapSampler, roughnessUV).r;
+        roughness *= real(roughnessMap.Sample(mapSampler, roughnessUV).r);
     }
     
     if (useNormalMap)
     {  
-        float4 sampledValue = normalMap.Sample(mapSampler, normalUV);
+        real4 sampledValue = real4(normalMap.Sample(mapSampler, normalUV));
         clearCoatNormal = GetWorldSpaceNormal(sampledValue.xy, normal, tangent, bitangent, uvMatrix, normalStrength);
     }
     else
@@ -61,7 +61,7 @@ void GetClearCoatInputs(Texture2D influenceMap, float2 influenceUV, float clearC
     }
     
     // Flip normal if back face is rendered   
-    clearCoatNormal *= mad(isFrontFace, 2.0, -1.0);
+    clearCoatNormal *= real(mad(isFrontFace, 2.0, -1.0));
     finalClearCoatFactor = clearCoatFactor;
     clearCoatRoughness = max(roughness, 1e-3);
 }

+ 24 - 24
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/DetailMapsInput.azsli

@@ -50,11 +50,11 @@ option bool o_detail_baseColor_useTexture;   \
 option bool o_detail_normal_useTexture;
 
 
-float GetDetailLayerBlendFactor(Texture2D detailLayerBlendMask, sampler detailLayerBlendMaskSampler, float2 detailLayerBlendMaskUv, bool useDetailLayerBlendMask, float detailLayerBlendFactor)
+real GetDetailLayerBlendFactor(Texture2D detailLayerBlendMask, sampler detailLayerBlendMaskSampler, float2 detailLayerBlendMaskUv, bool useDetailLayerBlendMask, real detailLayerBlendFactor)
 {
     if (useDetailLayerBlendMask)
     {
-        detailLayerBlendFactor *= detailLayerBlendMask.Sample(detailLayerBlendMaskSampler, detailLayerBlendMaskUv).r;
+        detailLayerBlendFactor *= real(detailLayerBlendMask.Sample(detailLayerBlendMaskSampler, detailLayerBlendMaskUv).r);
     }
 
     return detailLayerBlendFactor;
@@ -62,23 +62,23 @@ float GetDetailLayerBlendFactor(Texture2D detailLayerBlendMask, sampler detailLa
 
 //! Sample a normal map and apply it as an overlay on top of another normal map.
 //! @return a new normal vector in the same tangent space as mainNormalTS.
-float3 ApplyNormalMapOverlayTS(bool applyOverlay, float3 vertexNormalWS, float3 mainNormalTS, float3 mainTangent, float3 mainBitangent, 
-    Texture2D overlayNormalMap, sampler overlayMapSampler, float2 overlayUv, bool flipOverlayNormalX, bool flipOverlayNormalY, float overlayFactor, 
-    float3 overlayTangent, float3 overlayBitangen, float3x3 overlayNormalUvMatrix)
+real3 ApplyNormalMapOverlayTS(bool applyOverlay, real3 vertexNormalWS, real3 mainNormalTS, real3 mainTangent, real3 mainBitangent, 
+    Texture2D overlayNormalMap, sampler overlayMapSampler, float2 overlayUv, bool flipOverlayNormalX, bool flipOverlayNormalY, real overlayFactor, 
+    real3 overlayTangent, real3 overlayBitangent, real3x3 overlayNormalUvMatrix)
 {
     if(applyOverlay && AreDetailNormalMapsEnabled())
     {
         // Get overlay normal in its local tangent space
-        float3 overlayNormalTS = GetNormalInputTS(overlayNormalMap, overlayMapSampler, overlayUv, flipOverlayNormalX, flipOverlayNormalY, overlayNormalUvMatrix, true, overlayFactor);
+        real3 overlayNormalTS = GetNormalInputTS(overlayNormalMap, overlayMapSampler, overlayUv, flipOverlayNormalX, flipOverlayNormalY, overlayNormalUvMatrix, true, overlayFactor);
         
         // [GFX TODO][ATOM-15111]: Find a more efficient way to do this.
 
         // Convert the overlay normal from its local tangent space into the main normal's tangent space.
-        float3 overlayNormalWS = TangentSpaceToWorld(overlayNormalTS, vertexNormalWS, overlayTangent, overlayBitangen);
-        float3 overlayNormalInMainTS = WorldSpaceToTangent(overlayNormalWS, vertexNormalWS, mainTangent, mainBitangent);
+        real3 overlayNormalWS = TangentSpaceToWorld(overlayNormalTS, vertexNormalWS, overlayTangent, overlayBitangent);
+        real3 overlayNormalInMainTS = WorldSpaceToTangent(overlayNormalWS, vertexNormalWS, mainTangent, mainBitangent);
 
         // Combine normals in tangent space
-        float3 normalInMainTS = ReorientTangentSpaceNormal(mainNormalTS, overlayNormalInMainTS);
+        real3 normalInMainTS = ReorientTangentSpaceNormal(mainNormalTS, overlayNormalInMainTS);
 
         return normalInMainTS;
     }
@@ -90,14 +90,14 @@ float3 ApplyNormalMapOverlayTS(bool applyOverlay, float3 vertexNormalWS, float3
 
 //! Sample a normal map and apply it as an overlay on top of another normal map.
 //! @return a new normal vector in world space.
-float3 ApplyNormalMapOverlayWS(bool applyOverlay, float3 vertexNormalWS, float3 mainNormalTS, float3 mainTangent, float3 mainBitangent, 
-    Texture2D overlayNormalMap, sampler overlayMapSampler, float2 overlayUv, bool flipOverlayNormalX, bool flipOverlayNormalY, float overlayFactor, 
-    float3 overlayTangent, float3 overlayBitangen, float3x3 overlayNormalUvMatrix)
+real3 ApplyNormalMapOverlayWS(bool applyOverlay, real3 vertexNormalWS, real3 mainNormalTS, real3 mainTangent, real3 mainBitangent, 
+    Texture2D overlayNormalMap, sampler overlayMapSampler, float2 overlayUv, bool flipOverlayNormalX, bool flipOverlayNormalY, real overlayFactor, 
+    real3 overlayTangent, real3 overlayBitangent, real3x3 overlayNormalUvMatrix)
 {
     if(applyOverlay && AreDetailNormalMapsEnabled())
     {
-        float3 normalTS = ApplyNormalMapOverlayTS(applyOverlay, vertexNormalWS, mainNormalTS, mainTangent, mainBitangent, overlayNormalMap, overlayMapSampler, overlayUv, flipOverlayNormalX, flipOverlayNormalY, overlayFactor, overlayTangent, overlayBitangen, overlayNormalUvMatrix);
-        float3 normalWS = normalize( TangentSpaceToWorld(normalTS, vertexNormalWS, mainTangent, mainBitangent) );
+        real3 normalTS = ApplyNormalMapOverlayTS(applyOverlay, vertexNormalWS, mainNormalTS, mainTangent, mainBitangent, overlayNormalMap, overlayMapSampler, overlayUv, flipOverlayNormalX, flipOverlayNormalY, overlayFactor, overlayTangent, overlayBitangent, overlayNormalUvMatrix);
+        real3 normalWS = normalize( TangentSpaceToWorld(normalTS, vertexNormalWS, mainTangent, mainBitangent) );
         return normalWS;
     }
     else
@@ -106,11 +106,11 @@ float3 ApplyNormalMapOverlayWS(bool applyOverlay, float3 vertexNormalWS, float3
     }
 }
 
-float3 GetDetailedNormalInputWS(bool isFrontFace, float3 vertexNormalWS,
-                                float3 mainTangent,   float3 mainBitangent,   Texture2D mainNormalMap,   sampler mainSampler,   float2 mainUv,   float mainNormalFactor,   bool flipMainNormalX,   bool flipMainNormalY,   float3x3 mainNormalUvMatrix,   bool useMainNormalMap,
-                                float3 detailTangent, float3 detailBitangent, Texture2D detailNormalMap, sampler detailSampler, float2 detailUv, float detailNormalFactor, bool flipDetailNormalX, bool flipDetailNormalY, float3x3 detailNormalUvMatrix, bool useDetailNormalMap)
+real3 GetDetailedNormalInputWS(bool isFrontFace, real3 vertexNormalWS,
+                                real3 mainTangent,   real3 mainBitangent,   Texture2D mainNormalMap,   sampler mainSampler,   float2 mainUv,   real mainNormalFactor,   bool flipMainNormalX,   bool flipMainNormalY,   real3x3 mainNormalUvMatrix,   bool useMainNormalMap,
+                                real3 detailTangent, real3 detailBitangent, Texture2D detailNormalMap, sampler detailSampler, float2 detailUv, real detailNormalFactor, bool flipDetailNormalX, bool flipDetailNormalY, real3x3 detailNormalUvMatrix, bool useDetailNormalMap)
 {
-    float3 normal;
+    real3 normal;
     
     useDetailNormalMap = useDetailNormalMap && AreDetailNormalMapsEnabled();
     useMainNormalMap = useMainNormalMap && AreNormalMapsEnabled();
@@ -118,7 +118,7 @@ float3 GetDetailedNormalInputWS(bool isFrontFace, float3 vertexNormalWS,
     if(useDetailNormalMap)
     {
         // Get normal in tangent space
-        float3 mainNormalTS = GetNormalInputTS(mainNormalMap, mainSampler, mainUv, flipMainNormalX, flipMainNormalY, 
+        real3 mainNormalTS = GetNormalInputTS(mainNormalMap, mainSampler, mainUv, flipMainNormalX, flipMainNormalY, 
                                             mainNormalUvMatrix, useMainNormalMap, mainNormalFactor);
         
         bool applyOverlay = true;
@@ -137,11 +137,11 @@ float3 GetDetailedNormalInputWS(bool isFrontFace, float3 vertexNormalWS,
     return normal;
 }
 
-float3 ApplyTextureOverlay(bool applyOverlay, float3 baseColor, Texture2D map, sampler mapSampler, float2 uv, float factor)
+real3 ApplyTextureOverlay(bool applyOverlay, real3 baseColor, Texture2D map, sampler mapSampler, float2 uv, real factor)
 {
     if (applyOverlay)
     {
-        float3 sampledColor = map.Sample(mapSampler, uv).rgb;
+        real3 sampledColor = real3(map.Sample(mapSampler, uv).rgb);
         sampledColor = TransformColor(sampledColor, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
         return ApplyTextureBlend(baseColor, sampledColor, factor, TextureBlendMode::Overlay);
     }
@@ -151,10 +151,10 @@ float3 ApplyTextureOverlay(bool applyOverlay, float3 baseColor, Texture2D map, s
     }
 }
 
-float3 GetDetailedBaseColorInput(Texture2D mainBaseColorMap,     sampler mainBaseColorMapSampler,     float2 mainBaseColorUv,        bool useMainBaseColorMap,     float3 mainBaseColor, float mainBaseColorFactor, TextureBlendMode mainBaseColorBlendMode,
-                                 Texture2D detailBaseColorMap,   sampler detailBaseColorMapSampler,   float2 detailBaseColorUv,      bool useDetailBaseColorMap,   float detailBaseColorBlendFactor)
+real3 GetDetailedBaseColorInput(Texture2D mainBaseColorMap,     sampler mainBaseColorMapSampler,     float2 mainBaseColorUv,        bool useMainBaseColorMap,     real3 mainBaseColor, real mainBaseColorFactor, TextureBlendMode mainBaseColorBlendMode,
+                                Texture2D detailBaseColorMap,   sampler detailBaseColorMapSampler,   float2 detailBaseColorUv,      bool useDetailBaseColorMap,   real detailBaseColorBlendFactor)
 {
-    float3 color = GetBaseColorInput(mainBaseColorMap, mainBaseColorMapSampler, mainBaseColorUv, mainBaseColor, useMainBaseColorMap);
+    real3 color = GetBaseColorInput(mainBaseColorMap, mainBaseColorMapSampler, mainBaseColorUv, mainBaseColor, useMainBaseColorMap);
     color = BlendBaseColor(color, mainBaseColor, mainBaseColorFactor, mainBaseColorBlendMode, useMainBaseColorMap);
     color = ApplyTextureOverlay(useDetailBaseColorMap, color, detailBaseColorMap, detailBaseColorMapSampler, detailBaseColorUv, detailBaseColorBlendFactor);
     return color;

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/EmissiveInput.azsli

@@ -27,15 +27,15 @@ uint        prefix##m_emissiveMapUvIndex;
 option bool prefix##o_emissiveEnabled; \
 option bool prefix##o_emissive_useTexture; 
 
-float3 GetEmissiveInput(Texture2D map, sampler mapSampler, float2 uv, float factor, float3 emissiveColor, float emissiveAffectedByAlpha, float alpha, bool emissiveEnabled, bool useTexture)
+real3 GetEmissiveInput(Texture2D map, sampler mapSampler, float2 uv, real factor, real3 emissiveColor, real emissiveAffectedByAlpha, real alpha, bool emissiveEnabled, bool useTexture)
 {
-    float3 emissive = float3(0,0,0);
+    real3 emissive = real3(0,0,0);
     if(emissiveEnabled)
     {
         emissive = factor * lerp(1, alpha, emissiveAffectedByAlpha) * emissiveColor;
         if (useTexture)
         {
-            float3 sampledValue = map.Sample(mapSampler, uv).rgb;
+            real3 sampledValue = real3(map.Sample(mapSampler, uv).rgb);
             emissive *= TransformColor(sampledValue, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
         }
     }

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/MetallicInput.azsli

@@ -24,7 +24,7 @@ uint        prefix##m_metallicMapUvIndex;
 #define COMMON_OPTIONS_METALLIC(prefix) \
 option bool prefix##o_metallic_useTexture; 
 
-float GetMetallicInput(Texture2D map, sampler mapSampler, float2 uv, float factor, bool useTexture)
+real GetMetallicInput(Texture2D map, sampler mapSampler, float2 uv, real factor, bool useTexture)
 {
     if(OverrideMetallicEnabled())
     {
@@ -34,7 +34,7 @@ float GetMetallicInput(Texture2D map, sampler mapSampler, float2 uv, float facto
     if (useTexture)
     {
        // [GFX TODO][ATOM-1793]: Figure out how we want our base material to expect channels to be encoded, and apply that to the way we pack metalness.
-       return map.Sample(mapSampler, uv).r;
+       return real(map.Sample(mapSampler, uv).r);
     }
     return factor;
 }

+ 19 - 18
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/NormalInput.azsli

@@ -30,14 +30,14 @@ option bool prefix##o_normal_useTexture;
 //! Samples the normal map and returns the XY values of the normal. 
 //! (Z must be reconstructed assuming length=1; this is handled by the various utility functions that take float2 in TangentSpace.azsli).
 //! The returned XY values will be in the range [-1,1].
-float2 SampleNormalXY(Texture2D map, sampler mapSampler, float2 uv)
+real2 SampleNormalXY(Texture2D map, sampler mapSampler, float2 uv)
 {
     if (!AreNormalMapsEnabled())
     {
-        return float2(0, 0);
+        return real2(0, 0);
     }
 
-    float4 sampledValue = map.Sample(mapSampler, uv);
+    real4 sampledValue = real4(map.Sample(mapSampler, uv));
     
 #if AZ_TRAIT_ASTC_COMPRESSION
     //Astc compression is unorm (0 to 1) so we need to accomodate for that. We are using BC5_SNORM (-1 - +1)for other platforms like pc
@@ -52,9 +52,9 @@ float2 SampleNormalXY(Texture2D map, sampler mapSampler, float2 uv)
 //! (Z must be reconstructed assuming length=1; this is handled by the various utility functions that take float2 in TangentSpace.azsli).
 //! The returned XY values will be in the range [-1,1].
 //! Also flips X and/or Y if requested.
-float2 SampleNormalXY(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY)
+real2 SampleNormalXY(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY)
 {
-    float2 sampledValue = SampleNormalXY(map, mapSampler, uv);
+    real2 sampledValue = real2(SampleNormalXY(map, mapSampler, uv));
 
     // [GFX TODO][ATOM-2404] For some reason, the image build pipeline swaps the R and G channels
     if(flipX)
@@ -69,19 +69,20 @@ float2 SampleNormalXY(Texture2D map, sampler mapSampler, float2 uv, bool flipX,
 }
 
 // Flip normal if back face is rendered
-float3 AdjustBackFaceNormal(float3 normal, bool isFrontFace)
+real3 AdjustBackFaceNormal(real3 normal, bool isFrontFace)
 {
-    normal *= mad(isFrontFace, 2.0, -1.0);
+    real temp = real(mad(isFrontFace, 2.0, -1.0));
+    normal *= temp;
     return normal;
 }
 
 // Get the input normal in world space
-float3 GetNormalInputWS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, bool isFrontFace,
-                        float3 normal, float3 tangent, float3 bitangent, float3x3 uvMatrix, bool useTexture, float normalStrength)
+real3 GetNormalInputWS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, bool isFrontFace,
+                        real3 normal, real3 tangent, real3 bitangent, real3x3 uvMatrix, bool useTexture, real normalStrength)
 {
     if (useTexture && AreNormalMapsEnabled())
     {
-        float2 sampledValue = SampleNormalXY(map, mapSampler, uv, flipX, flipY);
+        real2 sampledValue = SampleNormalXY(map, mapSampler, uv, flipX, flipY);
         normal = GetWorldSpaceNormal(sampledValue, normal, tangent, bitangent, uvMatrix, normalStrength);
     }
     else
@@ -94,30 +95,30 @@ float3 GetNormalInputWS(Texture2D map, sampler mapSampler, float2 uv, bool flipX
 }
 
 // Get the input normal in tangent space
-float3 GetNormalInputTS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, float3x3 uvMatrix, bool useTexture, float normalStrength)
+real3 GetNormalInputTS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, real3x3 uvMatrix, bool useTexture, real normalStrength)
 {
     if (useTexture && AreNormalMapsEnabled())
     {
-        float2 sampledValue = SampleNormalXY(map, mapSampler, uv, flipX, flipY);
+        real2 sampledValue = SampleNormalXY(map, mapSampler, uv, flipX, flipY);
         return GetTangentSpaceNormal(sampledValue, uvMatrix, normalStrength);
     }
     else
     {
-        return float3(0.0f, 0.0f, 1.0f);
+        return real3(0.0f, 0.0f, 1.0f);
     }
 }
 
 // Helper with default normal strength = 1.0f
-float3 GetNormalInputWS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, bool isFrontFace,
-                        float3 normal, float3 tangent, float3 bitangent, float3x3 uvMatrix, bool useTexture)
+real3 GetNormalInputWS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, bool isFrontFace,
+                        real3 normal, real3 tangent, real3 bitangent, real3x3 uvMatrix, bool useTexture)
 {
-    const float normalStrength = 1.0f;
+    const real normalStrength = 1.0f;
     return GetNormalInputWS(map, mapSampler, uv, flipX, flipY, isFrontFace, normal, tangent, bitangent, uvMatrix, useTexture, normalStrength);
 }
 
 // Helper with default normal strength = 1.0f
-float3 GetNormalInputTS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, float3x3 uvMatrix, bool useTexture)
+real3 GetNormalInputTS(Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, real3x3 uvMatrix, bool useTexture)
 {
-    const float normalStrength = 1.0f;
+    const real normalStrength = 1.0f;
     return GetNormalInputTS(map, mapSampler, uv, flipX, flipY, uvMatrix, useTexture, normalStrength);
 }

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/OcclusionInput.azsli

@@ -26,12 +26,12 @@ uint        prefix##m_specularOcclusionMapUvIndex;
 option bool prefix##o_diffuseOcclusion_useTexture; \
 option bool prefix##o_specularOcclusion_useTexture; 
 
-float GetOcclusionInput(Texture2D map, sampler mapSampler, float2 uv, float factor, bool useTexture)
+real GetOcclusionInput(Texture2D map, sampler mapSampler, float2 uv, real factor, bool useTexture)
 {
-    float occlusion = 1.0f;
+    real occlusion = 1.0;
     if(useTexture)
     {
-        float4 sampledValue = map.Sample(mapSampler, uv);
+        real4 sampledValue = real4(map.Sample(mapSampler, uv));
         occlusion = pow(sampledValue.r, factor);
     }
     return occlusion;

+ 14 - 14
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/ParallaxInput.azsli

@@ -25,22 +25,22 @@ float       prefix##m_heightmapOffset;
 #define COMMON_OPTIONS_PARALLAX(prefix) \
 option bool prefix##o_useHeightmap; 
 
-void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
-                      float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
+void GetParallaxInput(real3 normal, real3 tangent, real3 bitangent, real heightmapScale, real heightmapOffset,
+                      real4x4 objectWorldMatrix, real3x3 uvMatrix, real3x3 uvMatrixInverse,
                       inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS, out bool isClipped)
 {
     if(o_parallax_feature_enabled)
     {
-        float3 dirToCamera;
+        real3 dirToCamera;
         if(ViewSrg::m_projectionMatrix[3].w == 1)
         {
             // orthographic projection (directional light)
             // No view position, use light direction
-            dirToCamera = ViewSrg::m_viewMatrix[2].xyz;
+            dirToCamera = real3(ViewSrg::m_viewMatrix[2].xyz);
         }
         else
         {
-            dirToCamera = ViewSrg::m_worldPosition.xyz - worldPosition;
+            dirToCamera = real3(ViewSrg::m_worldPosition.xyz - worldPosition);
         }
     
         ParallaxOffset tangentOffset = GetParallaxOffset( heightmapScale,
@@ -52,20 +52,20 @@ void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float hei
                                                           normal,
                                                           uvMatrix);
 
-        uv += tangentOffset.m_offsetTS.xy;
+        uv += real2(tangentOffset.m_offsetTS.xy);
         isClipped = tangentOffset.m_isClipped;
 
         if(o_parallax_enablePixelDepthOffset)
         {
             PixelDepthOffset pdo = CalcPixelDepthOffset(heightmapScale,
-                                                        tangentOffset.m_offsetTS,
+                                                        real3(tangentOffset.m_offsetTS),
                                                         worldPosition,
                                                         tangent,
                                                         bitangent,
                                                         normal,
                                                         uvMatrixInverse,
                                                         objectWorldMatrix,
-                                                        ViewSrg::m_viewProjectionMatrix);
+                                                        real4x4(ViewSrg::m_viewProjectionMatrix));
 
             depthCS = pdo.m_depthCS;
             depthNDC = pdo.m_depthNDC;
@@ -76,17 +76,17 @@ void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float hei
     }
 }
 
-void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
-                      float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
-                      inout float2 uv, inout float3 worldPosition, inout float depthNDC, inout float depthCS)
+void GetParallaxInput(real3 normal, real3 tangent, real3 bitangent, real heightmapScale, real heightmapOffset,
+                      real4x4 objectWorldMatrix, real3x3 uvMatrix, real3x3 uvMatrixInverse,
+                      inout real2 uv, inout real3 worldPosition, inout float depthNDC, inout float depthCS)
 {
     bool isClipped;
     GetParallaxInput(normal, tangent, bitangent, heightmapScale, heightmapOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS, isClipped);
 }
 
-void GetParallaxInput(float3 normal, float3 tangent, float3 bitangent, float heightmapScale, float heightmapOffset,
-    float4x4 objectWorldMatrix, float3x3 uvMatrix, float3x3 uvMatrixInverse,
-    inout float2 uv, inout float3 worldPosition, inout float depthNDC)
+void GetParallaxInput(real3 normal, real3 tangent, real3 bitangent, real heightmapScale, real heightmapOffset,
+    real4x4 objectWorldMatrix, real3x3 uvMatrix, real3x3 uvMatrixInverse,
+    inout real2 uv, inout real3 worldPosition, inout float depthNDC)
 {
     float depthCS;
     GetParallaxInput(normal, tangent, bitangent, heightmapScale, heightmapOffset, objectWorldMatrix, uvMatrix, uvMatrixInverse, uv, worldPosition, depthNDC, depthCS);

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/RoughnessInput.azsli

@@ -26,7 +26,7 @@ uint        prefix##m_roughnessMapUvIndex;
 #define COMMON_OPTIONS_ROUGHNESS(prefix) \
 option bool prefix##o_roughness_useTexture; 
 
-float GetRoughnessInput(Texture2D map, sampler mapSampler, float2 uv, float factor, float roughnessLowerBound, float roughnessUpperBound, bool useTexture)
+real GetRoughnessInput(Texture2D map, sampler mapSampler, float2 uv, real factor, real roughnessLowerBound, real roughnessUpperBound, bool useTexture)
 {
     if(OverrideRoughnessEnabled())
     {
@@ -36,7 +36,7 @@ float GetRoughnessInput(Texture2D map, sampler mapSampler, float2 uv, float fact
     // [GFX TODO][ATOM-1793]: Figure out how we want our base material to expect channels to be encoded, and apply that to the way we pack roughness.
     if (useTexture)
     {
-        float sampledValue = map.Sample(mapSampler, uv).r;
+        real sampledValue = real(map.Sample(mapSampler, uv).r);
         return lerp(roughnessLowerBound, roughnessUpperBound, sampledValue);
     }
     else

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/SpecularInput.azsli

@@ -22,11 +22,11 @@ uint        prefix##m_specularF0MapUvIndex;
 #define COMMON_OPTIONS_SPECULAR_F0(prefix) \
 option bool prefix##o_specularF0_useTexture; 
 
-float GetSpecularInput(Texture2D map, sampler mapSampler, float2 uv, float specularFactor, bool useTexture)
+real GetSpecularInput(Texture2D map, sampler mapSampler, float2 uv, real specularFactor, bool useTexture)
 {
     if (useTexture)
     {
-        specularFactor *= map.Sample(mapSampler, uv).r;
+        specularFactor *= real(map.Sample(mapSampler, uv).r);
     }
     return specularFactor;
 }

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/SubsurfaceInput.azsli

@@ -10,11 +10,11 @@
 
 option bool o_subsurfaceScattering_useTexture;
 
-float GetSubsurfaceInput(Texture2D map, sampler mapSampler, float2 uv, float surfaceScatteringFactor)
+real GetSubsurfaceInput(Texture2D map, sampler mapSampler, float2 uv, real surfaceScatteringFactor)
 {
     if(o_subsurfaceScattering_useTexture)
     {
-        surfaceScatteringFactor *= map.Sample(mapSampler, uv).r;
+        surfaceScatteringFactor *= real(map.Sample(mapSampler, uv).r);
     }
     return surfaceScatteringFactor;
 }

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/MaterialInputs/TransmissionInput.azsli

@@ -10,11 +10,11 @@
 
 option bool o_transmission_useTexture;
 
-float4 GeTransmissionInput(Texture2D map, sampler mapSampler, float2 uv, float4 transmissionTintThickness)
+real4 GeTransmissionInput(Texture2D map, sampler mapSampler, float2 uv, real4 transmissionTintThickness)
 {
     if(o_transmission_useTexture)
     {
-        transmissionTintThickness.w *= map.Sample(mapSampler, uv).r;
+        transmissionTintThickness.w *= real(map.Sample(mapSampler, uv).r);
     }
     return transmissionTintThickness;
 }

+ 2 - 2
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_LightingBrdf.azsli

@@ -26,9 +26,9 @@
 #endif
 
 // Then define the Diffuse and Specular lighting functions
-float3 GetDiffuseLighting_Skin(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight)
+real3 GetDiffuseLighting_Skin(Surface surface, LightingData lightingData, real3 lightIntensity, real3 dirToLight)
 {
-    float3 diffuse;
+    real3 diffuse;
     if(o_enableSubsurfaceScattering)
     {
         // Use diffuse brdf containing double Fresnel (enter/exit surface) terms if subsurface scattering is enabled

+ 4 - 4
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_PixelGeometryData.azsli

@@ -21,13 +21,13 @@ class PixelGeometryData_Skin
 {
     // BasePBR
     float3 positionWS;
-    float3 vertexNormal;
+    real3 vertexNormal;
     float2 uvs[UvSetCount];
-    float3 tangents[UvSetCount];
-    float3 bitangents[UvSetCount];
+    real3 tangents[UvSetCount];
+    real3 bitangents[UvSetCount];
     bool isFrontFace;    
 
     // Skin
     float2 detailUv;
-    float4 wrinkleBlendFactors;
+    real4 wrinkleBlendFactors;
 };

+ 9 - 9
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_PixelGeometryEval.azsli

@@ -19,12 +19,12 @@
 
 PixelGeometryData EvaluatePixelGeometry_Skin(
     float3 positionWS,
-    float3 normalWS,
-    float3 tangentWS,
-    float3 bitangentWS,
+    real3 normalWS,
+    real3 tangentWS,
+    real3 bitangentWS,
     float2 uvs[UvSetCount],
     float2 detailUv,
-    float4 wrinkleBlendFactors,
+    real4 wrinkleBlendFactors,
     bool isFrontFace)
 {
     // Base PBR Geo Data
@@ -39,11 +39,11 @@ PixelGeometryData EvaluatePixelGeometry_Skin(
 
 PixelGeometryData EvaluatePixelGeometry_Skin(VsOutput IN, bool isFrontFace)
 {
-    float4x4 objectToWorld = ObjectSrg::GetWorldMatrix();
-    float3x3 objectToWorldIT = ObjectSrg::GetWorldMatrixInverseTranspose();
+    real4x4 objectToWorld = real4x4(ObjectSrg::GetWorldMatrix());
+    real3x3 objectToWorldIT = real3x3(ObjectSrg::GetWorldMatrixInverseTranspose());
 
-    float3 normalWS, tangentWS, bitangentWS;
-    ConstructTBN(IN.normal, IN.tangent, objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
+    real3 normalWS, tangentWS, bitangentWS;
+    ConstructTBN(real3(IN.normal), real4(IN.tangent), objectToWorld, objectToWorldIT, normalWS, tangentWS, bitangentWS);
 
     return EvaluatePixelGeometry_Skin(
         IN.worldPosition,
@@ -52,6 +52,6 @@ PixelGeometryData EvaluatePixelGeometry_Skin(VsOutput IN, bool isFrontFace)
         bitangentWS,
         IN.uvs,
         IN.detailUv,
-        IN.wrinkleBlendFactors,
+        real4(IN.wrinkleBlendFactors),
         isFrontFace);
 }

+ 14 - 14
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_SurfaceData.azsli

@@ -27,27 +27,27 @@ class SurfaceData_Skin
     // ------- BasePbrSurfaceData -------
     
     float3 position;            //!< Position in world-space
-    float3 normal;              //!< Normal in world-space
-    float3 vertexNormal;        //!< Vertex 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
+    real3 normal;              //!< Normal in world-space
+    real3 vertexNormal;        //!< Vertex normal in world-space
+    real3 albedo;              //!< Albedo color of the non-metallic material, will be multiplied against the diffuse lighting value
+    real3 specularF0;          //!< Fresnel f0 spectral value of the surface
+    real roughnessLinear;      //!< Perceptually linear roughness value authored by artists. Must be remapped to roughnessA before use
+    real roughnessA;           //!< Actual roughness value ( a.k.a. "alpha roughness") to be used in microfacet calculations
+    real roughnessA2;          //!< Alpha roughness ^ 2 (i.e. roughnessA * roughnessA), used in GGX, cached here for perfromance
 
-    float3 baseColor;
-    float metallic;
+    real3 baseColor;
+    real metallic;
 
     //! Subsurface scattering parameters
-    float subsurfaceScatteringFactor;
-    float subsurfaceScatteringQuality;
-    float3 scatterDistance;
+    real subsurfaceScatteringFactor;
+    real subsurfaceScatteringQuality;
+    real3 scatterDistance;
 
     //! Calculates roughnessA and roughnessA2 after roughness has been set
     void CalculateRoughnessA();
 
     //! Sets albedo and specularF0 (no metallic for skin)
-    void SetAlbedoAndSpecularF0(float3 newBaseColor, float specularF0Factor);
+    void SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor);
 };
 
 void SurfaceData_Skin::CalculateRoughnessA()
@@ -55,7 +55,7 @@ void SurfaceData_Skin::CalculateRoughnessA()
     CalculateRoughnessValues(normal, roughnessLinear, roughnessA, roughnessA2);
 }
 
-void SurfaceData_Skin::SetAlbedoAndSpecularF0(float3 newBaseColor, float specularF0Factor)
+void SurfaceData_Skin::SetAlbedoAndSpecularF0(real3 newBaseColor, real specularF0Factor)
 {
     baseColor = newBaseColor;
     albedo = newBaseColor;

+ 35 - 35
Gems/Atom/Feature/Common/Assets/Shaders/Materials/Skin/Skin_SurfaceEval.azsli

@@ -40,22 +40,22 @@ option bool o_wrinkleLayers_normal_useTexture4;
 option bool o_wrinkleLayers_showBlendMaskValues;
 
 
-float3 ApplyBaseColorWrinkleMap(bool shouldApply, float3 baseColor, Texture2D map, sampler mapSampler, float2 uv, float factor)
+real3 ApplyBaseColorWrinkleMap(bool shouldApply, real3 baseColor, Texture2D map, sampler mapSampler, float2 uv, real factor)
 {
     if (shouldApply)
     {
-        float3 sampledColor = map.Sample(mapSampler, uv).rgb;
+        real3 sampledColor = real3(map.Sample(mapSampler, uv).rgb);
         sampledColor = TransformColor(sampledColor, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
         return lerp(baseColor, sampledColor, factor);
     }
     return baseColor;
 }
 
-float2 ApplyNormalWrinkleMap(bool shouldApply, float2 baseNormalSample, Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, float factor)
+real2 ApplyNormalWrinkleMap(bool shouldApply, real2 baseNormalSample, Texture2D map, sampler mapSampler, float2 uv, bool flipX, bool flipY, real factor)
 {
     if (shouldApply)
     {
-        float2 sampledValue = SampleNormalXY(map, mapSampler, uv, flipX, flipY);
+        real2 sampledValue = SampleNormalXY(map, mapSampler, uv, flipX, flipY);
         return lerp(baseNormalSample, sampledValue, factor);
     }
     return baseNormalSample;
@@ -63,12 +63,12 @@ float2 ApplyNormalWrinkleMap(bool shouldApply, float2 baseNormalSample, Texture2
 
 Surface EvaluateSurface_Skin(
     float3 positionWS,
-    float3 vertexNormal,
-    float3 tangents[UvSetCount],
-    float3 bitangents[UvSetCount],
+    real3 vertexNormal,
+    real3 tangents[UvSetCount],
+    real3 bitangents[UvSetCount],
     float2 uvs[UvSetCount],
     float2 detailUv,
-    float4 wrinkleBlendFactors,
+    real4 wrinkleBlendFactors,
     bool isFrontFace)
 {
     Surface surface;
@@ -80,8 +80,8 @@ Surface EvaluateSurface_Skin(
     const float2 detailBlendMaskUv = (MaterialSrg::m_detail_blendMask_uvIndex == MaterialSrg::m_detail_allMapsUvIndex) ?
                                      detailUv : uvs[MaterialSrg::m_detail_blendMask_uvIndex];
         
-    const float detailLayerBlendFactor = GetDetailLayerBlendFactor( MaterialSrg::m_detail_blendMask_texture, MaterialSrg::m_sampler,
-                                                                    detailBlendMaskUv, o_detail_blendMask_useTexture, MaterialSrg::m_detail_blendFactor);
+    const real detailLayerBlendFactor = GetDetailLayerBlendFactor( MaterialSrg::m_detail_blendMask_texture, MaterialSrg::m_sampler,
+                                                                    detailBlendMaskUv, o_detail_blendMask_useTexture, real(MaterialSrg::m_detail_blendFactor));
   
     // ------- Wrinkle Map Setup -------
 
@@ -89,12 +89,12 @@ Surface EvaluateSurface_Skin(
 
     if(o_wrinkleLayers_enabled)
     {
-        float4 wrinkleMaskBlendFactors = float4(0.0, 0.0, 0.0, 0.0);
+        real4 wrinkleMaskBlendFactors = real4(0.0, 0.0, 0.0, 0.0);
 
         // Combine the optional per-morph target wrinkle masks
         for(uint wrinkleMaskIndex = 0; wrinkleMaskIndex < ObjectSrg::m_wrinkle_mask_count; ++wrinkleMaskIndex)
         {
-            wrinkleMaskBlendFactors += ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].Sample(MaterialSrg::m_sampler, normalUv) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex);
+            wrinkleMaskBlendFactors += real4(ObjectSrg::m_wrinkle_masks[wrinkleMaskIndex].Sample(MaterialSrg::m_sampler, normalUv) * ObjectSrg::GetWrinkleMaskWeight(wrinkleMaskIndex));
         }
 
         // If texture based morph target driven masks are being used, use those values instead of the per-vertex colors
@@ -107,12 +107,12 @@ Surface EvaluateSurface_Skin(
     // ------- Normal -------
 
     surface.vertexNormal = vertexNormal;
-    float detailLayerNormalFactor = MaterialSrg::m_detail_normal_factor * detailLayerBlendFactor;
+    real detailLayerNormalFactor = real(MaterialSrg::m_detail_normal_factor) * detailLayerBlendFactor;
 
     // Since the wrinkle normal maps should all be in the same tangent space as the main normal map, we should be able to blend the raw normal map
     // texture values before doing all the tangent space transforms, so we only have to do the transforms once, for better performance.
     
-    float2 normalMapSample = float2(0.0,0.0);
+    real2 normalMapSample = real2(0.0,0.0);
     
     if(o_normal_useTexture)
     {
@@ -127,29 +127,29 @@ Surface EvaluateSurface_Skin(
         normalMapSample = ApplyNormalWrinkleMap(o_wrinkleLayers_normal_useTexture4, normalMapSample, MaterialSrg::m_wrinkle_normal_texture4, MaterialSrg::m_sampler, normalUv, MaterialSrg::m_flipNormalX, MaterialSrg::m_flipNormalY, wrinkleBlendFactors.a);
     }
 
-    float3x3 uvMatrix = CreateIdentity3x3();
+    real3x3 uvMatrix = real3x3(CreateIdentity3x3());
 
     if(o_detail_normal_useTexture)
     {
-        float3 normalTS = GetTangentSpaceNormal(normalMapSample, uvMatrix, MaterialSrg::m_normalFactor);
+        real3 normalTS = GetTangentSpaceNormal(normalMapSample, uvMatrix, real(MaterialSrg::m_normalFactor));
     
         bool applyOverlay = true;
         surface.normal = ApplyNormalMapOverlayWS(applyOverlay, vertexNormal, normalTS, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], 
                                                  MaterialSrg::m_detail_normal_texture, MaterialSrg::m_sampler, 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);
+                                                 detailLayerNormalFactor, tangents[MaterialSrg::m_detail_allMapsUvIndex], bitangents[MaterialSrg::m_detail_allMapsUvIndex], real3x3(MaterialSrg::m_detailUvMatrix));
     }
     else
     {
-        surface.normal = GetWorldSpaceNormal(normalMapSample, vertexNormal, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, MaterialSrg::m_normalFactor);
+        surface.normal = GetWorldSpaceNormal(normalMapSample, vertexNormal, tangents[MaterialSrg::m_normalMapUvIndex], bitangents[MaterialSrg::m_normalMapUvIndex], uvMatrix, real(MaterialSrg::m_normalFactor));
     }
 
 
     //--------------------- Base Color ----------------------
         
     float2 baseColorUv = uvs[MaterialSrg::m_baseColorMapUvIndex];
-    float detailLayerBaseColorFactor = MaterialSrg::m_detail_baseColor_factor * detailLayerBlendFactor;
+    real detailLayerBaseColorFactor = real(MaterialSrg::m_detail_baseColor_factor) * detailLayerBlendFactor;
     
-    float3 baseColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, MaterialSrg::m_baseColor, o_baseColor_useTexture);
+    real3 baseColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, real3(MaterialSrg::m_baseColor), o_baseColor_useTexture);
     
     bool useSampledBaseColor = o_baseColor_useTexture;
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_baseColor_enabled)
@@ -162,7 +162,7 @@ Surface EvaluateSurface_Skin(
         // we reset the initial baseColor back to white to make sure it will only be applied once.
         if(useSampledBaseColor && !o_baseColor_useTexture)
         {
-            baseColor = float3(1,1,1);
+            baseColor = real3(1,1,1);
         }
 
         baseColor = ApplyBaseColorWrinkleMap(o_wrinkleLayers_baseColor_useTexture1, baseColor, MaterialSrg::m_wrinkle_baseColor_texture1, MaterialSrg::m_sampler, baseColorUv, wrinkleBlendFactors.r);
@@ -172,48 +172,48 @@ Surface EvaluateSurface_Skin(
     
     }
     
-    baseColor = BlendBaseColor(baseColor, MaterialSrg::m_baseColor, MaterialSrg::m_baseColorFactor, o_baseColorTextureBlendMode, useSampledBaseColor);
+    baseColor = BlendBaseColor(baseColor, real3(MaterialSrg::m_baseColor), real(MaterialSrg::m_baseColorFactor), o_baseColorTextureBlendMode, useSampledBaseColor);
     
     baseColor = ApplyTextureOverlay(o_detail_baseColor_useTexture, baseColor, MaterialSrg::m_detail_baseColor_texture, MaterialSrg::m_sampler, detailUv, detailLayerBaseColorFactor);
 
     if(o_wrinkleLayers_enabled && o_wrinkleLayers_showBlendMaskValues)
     {
         // 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), wrinkleBlendFactors.r); }
-        if(o_wrinkleLayers_count > 1) { baseColor = lerp(baseColor, float3(0,1,0), wrinkleBlendFactors.g); }
-        if(o_wrinkleLayers_count > 2) { baseColor = lerp(baseColor, float3(0,0,1), wrinkleBlendFactors.b); }
-        if(o_wrinkleLayers_count > 3) { baseColor = lerp(baseColor, float3(1,1,1), wrinkleBlendFactors.a); }
+        if(o_wrinkleLayers_count > 0) { baseColor = lerp(baseColor, real3(1,0,0), wrinkleBlendFactors.r); }
+        if(o_wrinkleLayers_count > 1) { baseColor = lerp(baseColor, real3(0,1,0), wrinkleBlendFactors.g); }
+        if(o_wrinkleLayers_count > 2) { baseColor = lerp(baseColor, real3(0,0,1), wrinkleBlendFactors.b); }
+        if(o_wrinkleLayers_count > 3) { baseColor = lerp(baseColor, real3(1,1,1), wrinkleBlendFactors.a); }
     }
 
     // ------- Specular -------
 
     float2 specularUv = uvs[MaterialSrg::m_specularF0MapUvIndex];
-    float specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, MaterialSrg::m_specularF0Factor, o_specularF0_useTexture);
+    real specularF0Factor = GetSpecularInput(MaterialSrg::m_specularF0Map, MaterialSrg::m_sampler, specularUv, real(MaterialSrg::m_specularF0Factor), o_specularF0_useTexture);
 
     surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor);
 
     // ------- Roughness -------
 
     float2 roughnessUv = uvs[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.roughnessLinear = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, real(MaterialSrg::m_roughnessFactor),
+                                        real(MaterialSrg::m_roughnessLowerBound), real(MaterialSrg::m_roughnessUpperBound), o_roughness_useTexture);
     surface.CalculateRoughnessA();
 
     // ------- Subsurface -------
 
     float2 subsurfaceUv = uvs[MaterialSrg::m_subsurfaceScatteringInfluenceMapUvIndex];
-    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, MaterialSrg::m_subsurfaceScatteringFactor);
-    surface.subsurfaceScatteringQuality = MaterialSrg::m_subsurfaceScatteringQuality;
-    surface.scatterDistance = MaterialSrg::m_scatterDistance;
+    surface.subsurfaceScatteringFactor = GetSubsurfaceInput(MaterialSrg::m_subsurfaceScatteringInfluenceMap, MaterialSrg::m_sampler, subsurfaceUv, real(MaterialSrg::m_subsurfaceScatteringFactor));
+    surface.subsurfaceScatteringQuality = real(MaterialSrg::m_subsurfaceScatteringQuality);
+    surface.scatterDistance = real3(MaterialSrg::m_scatterDistance);
 
     // ------- Transmission -------
 
     float2 transmissionUv = uvs[MaterialSrg::m_transmissionThicknessMapUvIndex];
-    float4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, MaterialSrg::m_transmissionTintThickness);
+    real4 transmissionTintThickness = GeTransmissionInput(MaterialSrg::m_transmissionThicknessMap, MaterialSrg::m_sampler, transmissionUv, real4(MaterialSrg::m_transmissionTintThickness));
     surface.transmission.tint = transmissionTintThickness.rgb;
     surface.transmission.thickness = transmissionTintThickness.w;
-    surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams;
-    surface.transmission.scatterDistance = MaterialSrg::m_scatterDistance;
+    surface.transmission.transmissionParams = real4(MaterialSrg::m_transmissionParams);
+    surface.transmission.scatterDistance = real3(MaterialSrg::m_scatterDistance);
 
     return surface;
 }

+ 5 - 5
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_LightingBrdf.azsli

@@ -31,15 +31,15 @@
 #endif
 
 // Then define the Diffuse and Specular lighting functions
-float3 GetDiffuseLighting_StandardPBR(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight)
+real3 GetDiffuseLighting_StandardPBR(Surface surface, LightingData lightingData, real3 lightIntensity, real3 dirToLight)
 {
-    float3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight, lightingData.diffuseResponse);
+    real3 diffuse = DiffuseLambertian(surface.albedo, surface.normal, dirToLight, lightingData.diffuseResponse);
 
 #if ENABLE_CLEAR_COAT
     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));
+        real HdotV = saturate(dot(normalize(dirToLight + lightingData.dirToCamera), lightingData.dirToCamera));
         diffuse *= 1.0 - (FresnelSchlick(HdotV, 0.04) * surface.clearCoat.factor);
     }
 #endif
@@ -48,9 +48,9 @@ float3 GetDiffuseLighting_StandardPBR(Surface surface, LightingData lightingData
     return diffuse;
 }
 
-float3 GetSpecularLighting_StandardPBR(Surface surface, LightingData lightingData, const float3 lightIntensity, const float3 dirToLight)
+real3 GetSpecularLighting_StandardPBR(Surface surface, LightingData lightingData, const real3 lightIntensity, const real3 dirToLight)
 {
-    float3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation);
+    real3 specular = SpecularGGX(lightingData.dirToCamera, dirToLight, surface.normal, surface.specularF0, lightingData.NdotV, surface.roughnessA2, lightingData.multiScatterCompensation);
 
 #if ENABLE_CLEAR_COAT
     if(o_clearCoat_feature_enabled)

+ 1 - 1
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_LightingEval.azsli

@@ -32,7 +32,7 @@ void InitializeLightingData_StandardPBR(inout Surface surface, float4 screenPosi
     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);
+        lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, real3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor);
     }
 #endif
 }

+ 3 - 3
Gems/Atom/Feature/Common/Assets/Shaders/Materials/StandardPBR/StandardPBR_PixelGeometryData.azsli

@@ -31,10 +31,10 @@
     class PixelGeometryData_StandardPBR 
     {
         float3 positionWS;
-        float3 vertexNormal;
+        real3 vertexNormal;
         float2 uvs[UvSetCount];
-        float3 tangents[UvSetCount];
-        float3 bitangents[UvSetCount];
+        real3 tangents[UvSetCount];
+        real3 bitangents[UvSetCount];
         bool isFrontFace;
         bool isDisplacementClipped;
     };

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff