From 9825d6aba3ab83d85c93a9e9c6801944fa2d6494 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Mon, 29 Nov 2021 15:49:15 +0100 Subject: [PATCH 01/59] Thin transmission mode fix for directional lights Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/Skin.azsl | 10 +++++ .../Atom/Features/PBR/BackLighting.azsli | 43 +++++++++++-------- .../Features/PBR/Lighting/LightingData.azsli | 3 ++ .../PBR/Lights/DirectionalLight.azsli | 25 ++++++++--- 4 files changed, 56 insertions(+), 25 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index 523353f8fa..091e0a5645 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -92,6 +92,7 @@ struct VSOutput float3 m_bitangent : BITANGENT; float3 m_worldPosition : UV0; float3 m_shadowCoords[ViewSrg::MaxCascadeCount] : UV4; + float3 m_shrinkedShadowCoords[ViewSrg::MaxCascadeCount] : UV9; // Extended fields (only referenced in this azsl file)... float2 m_uv[UvSetCount] : UV1; @@ -137,6 +138,14 @@ VSOutput SkinVS(VSInput IN) VertexHelper(IN, OUT, worldPosition, false); + // Fetch shadow coords for shrinked world position (used in thin transmission materials) + const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; + DirectionalLightShadow::GetShadowCoords( + shadowIndex, + worldPosition - 0.005 * OUT.m_normal, + OUT.m_normal, + OUT.m_shrinkedShadowCoords); + return OUT; } @@ -336,6 +345,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) // Directional light shadow coordinates lightingData.shadowCoords = IN.m_shadowCoords; + lightingData.shrinkedShadowCoords = IN.m_shrinkedShadowCoords; // Diffuse and Specular response (used in IBL calculations) lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index dfd5522f5c..70f49f0a66 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -16,24 +16,26 @@ #include // Analytical integation (approximation) of diffusion profile over radius, could be replaced by other pre integrated kernels -// such as sum of Gaussian +// such as sum of Gaussian (see T(s)) float3 TransmissionKernel(float t, float3 s) { float3 exponent = s * t; return 0.25 * (1.0 / exp(exponent) + 3.0 / exp(exponent / 3.0)); } -float ThinObjectFalloff(const float3 surfaceNormal, const float3 dirToLight) +// Analytical integation (approximation) of diffusion profile over radius, could be precomputed in a LUT +float3 T(float s) { - const float ndl = saturate(dot(-surfaceNormal, dirToLight)); - - // ndl works decently well but it can produce a harsh discontinuity in the area just before - // the shadow starts appearing on objects like cylinder and tubes. - // Smoothing out ndl does a decent enough job of removing this artifact. - return smoothstep(0, 1, ndl * ndl); + // dipoles and multipoles are approximated with sums of a small number of Gaussians with variable weights and variances + return float3(0.233, 0.455, 0.649) * exp(-s*s/0.0064) + + float3(0.1, 0.336, 0.344) * exp(-s*s/0.0484) + + float3(0.118, 0.198, 0.0) * exp(-s*s/0.187) + + float3(0.113, 0.007, 0.007) * exp(-s*s/0.567) + + float3(0.358, 0.004, 0.0) * exp(-s*s/1.99) + + float3(0.078, 0.0, 0.0) * exp(-s*s/7.41); } -float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight, float shadowRatio) +float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight, float transmissionDistance) { float3 result = float3(0.0, 0.0, 0.0); float thickness = 0.0; @@ -49,7 +51,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // https://colinbarrebrisebois.com/2011/03/07/gdc-2011-approximating-translucency-for-a-fast-cheap-and-convincing-subsurface-scattering-look/ { - thickness = max(shadowRatio, surface.transmission.thickness); + thickness = max(transmissionDistance, surface.transmission.thickness); float transmittance = pow( saturate( dot( lightingData.dirToCamera, -normalize( dirToLight + surface.normal * transmissionParams.z ) ) ), transmissionParams.y ) * transmissionParams.w; float lamberAttenuation = exp(-thickness * transmissionParams.x) * saturate(1.0 - thickness); result = transmittance * lamberAttenuation * lightIntensity; @@ -57,18 +59,21 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI break; case TransmissionMode::ThinObject: - // Thin object mode, using thin-film assumption proposed by Jimenez J. et al, 2010, "Real-Time Realistic Skin Translucency" + // Thin object mode, based on Jimenez J. et al, 2010, "Real-Time Realistic Skin Translucency" // http://www.iryoku.com/translucency/downloads/Real-Time-Realistic-Skin-Translucency.pdf - - float litRatio = 1.0 - shadowRatio; - if (litRatio) + { - const float thickness = surface.transmission.thickness * transmissionParams.w; - const float3 invScattering = rcp(transmissionParams.xyz); - const float falloff = ThinObjectFalloff(surface.normal, dirToLight); - result = TransmissionKernel(thickness, invScattering) * falloff * lightIntensity * litRatio; - } + // Irradiance arround surface point. + // Begin the transmittance dot product slightly before it would with the regular dot(N,L) + float E = max(0.30 + dot(-surface.normal, dirToLight), 0.0); + // Transmission distance computed from shadowmaps modulated by editor-exposed parameters + float s = transmissionDistance * surface.transmission.thickness * (20 - transmissionParams.w) * 10; + + // Albedo at front (surface point) is used to approximate irradiance at the back of the object + // See observation 4 in [Jimenez J. et al, 2010] + result = T(s) * lightIntensity * surface.albedo * E; + } break; } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index 878bed02d4..51bd421418 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -28,6 +28,9 @@ class LightingData // Direction light shadow coordinates float3 shadowCoords[ViewSrg::MaxCascadeCount]; + // Direction light shadow coordinates for shrinked positions + float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; + // Normalized direction from surface to camera float3 dirToCamera; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 1eee53a24f..32654e0427 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -18,7 +18,9 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // Shadowed check const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; float litRatio = 1.0f; + float transmissionDistance = 0.0f; float backShadowRatio = 0.0f; + if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount) { litRatio = DirectionalLightShadow::GetVisibility( @@ -30,6 +32,12 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) if (o_transmission_mode == TransmissionMode::ThickObject) { backShadowRatio = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); + } + else if (o_transmission_mode == TransmissionMode::ThinObject) + { + // Use shrinked positions for thin object transmission to ensure they fall onto the object when querying + // the depth from the shadow map + transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shrinkedShadowCoords); } } @@ -50,21 +58,26 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // [GFX TODO][ATOM-2012] care of multiple directional light // Currently shadow check is done only for index == shadowIndex. float currentLitRatio = 1.0f; - float currentBackShadowRatio = 1.0f; + float currentTransmissionParameter = 1.0f; if (o_enableShadows) { - currentLitRatio = (index == shadowIndex) ? litRatio : 1.; - - currentBackShadowRatio = 1.0 - currentLitRatio; + bool activeLight = index == shadowIndex; + currentLitRatio = activeLight ? litRatio : 1.; if (o_transmission_mode == TransmissionMode::ThickObject) { - currentBackShadowRatio = (index == shadowIndex) ? backShadowRatio : 0.; + // Back shadow ratio (add contribution only if current directional light is the active one for shadows) + currentTransmissionParameter = activeLight ? backShadowRatio : 0.; + } + else if (o_transmission_mode == TransmissionMode::ThinObject) + { + // Transmission distance (add contribution only if current directional light is the active one for shadows) + currentTransmissionParameter = activeLight ? transmissionDistance : 9999.f; } } lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentBackShadowRatio); + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionParameter); } // Add debug coloring for directional light shadow From 1417488a2b2939affa14d0494b66c865bef907f9 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Mon, 29 Nov 2021 20:22:31 +0100 Subject: [PATCH 02/59] Increase scale range + expose shrink factor Signed-off-by: Santi Paprika --- .../Feature/Common/Assets/Materials/Types/Skin.azsl | 2 +- .../Common/Assets/Materials/Types/Skin.materialtype | 13 +++++++++++++ .../Common/Assets/Materials/Types/Skin_Common.azsli | 1 + .../ShaderLib/Atom/Features/PBR/BackLighting.azsli | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index 091e0a5645..b672016c00 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -142,7 +142,7 @@ VSOutput SkinVS(VSInput IN) const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; DirectionalLightShadow::GetShadowCoords( shadowIndex, - worldPosition - 0.005 * OUT.m_normal, + worldPosition - MaterialSrg::m_shrinkFactor * OUT.m_normal, OUT.m_normal, OUT.m_shrinkedShadowCoords); diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index e2a05aa916..496d6286cc 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -637,6 +637,19 @@ "min": 0.0, "softMax": 20.0 }, + { + "name": "shrinkFactor", + "displayName": " Shrink Factor", + "description": "Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection", + "type": "float", + "defaultValue": 0.005, + "min": 0.0, + "softMax": 0.05, + "connection": { + "type": "ShaderInput", + "name": "m_shrinkFactor" + } + }, { "name": "transmissionScale", "displayName": " Scale", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index a94f203b23..406da8b70c 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -71,6 +71,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial float4 m_transmissionTintThickness; Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; + float m_shrinkFactor; Texture2D m_wrinkle_baseColor_texture1; Texture2D m_wrinkle_baseColor_texture2; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 70f49f0a66..559b8cac2e 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -68,7 +68,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI float E = max(0.30 + dot(-surface.normal, dirToLight), 0.0); // Transmission distance computed from shadowmaps modulated by editor-exposed parameters - float s = transmissionDistance * surface.transmission.thickness * (20 - transmissionParams.w) * 10; + float s = transmissionDistance * surface.transmission.thickness * (50 - transmissionParams.w) * 10; // Albedo at front (surface point) is used to approximate irradiance at the back of the object // See observation 4 in [Jimenez J. et al, 2010] From 85d206c0c8a86c7bae4df1f818fc3e71aee26ed2 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 30 Nov 2021 18:19:39 +0100 Subject: [PATCH 03/59] Support directional lights with disabled shadows Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/Lights/DirectionalLight.azsli | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 32654e0427..ccaedcd34a 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -58,7 +58,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // [GFX TODO][ATOM-2012] care of multiple directional light // Currently shadow check is done only for index == shadowIndex. float currentLitRatio = 1.0f; - float currentTransmissionParameter = 1.0f; + float currentTransmissionParameter = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { bool activeLight = index == shadowIndex; @@ -66,12 +66,12 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) if (o_transmission_mode == TransmissionMode::ThickObject) { // Back shadow ratio (add contribution only if current directional light is the active one for shadows) - currentTransmissionParameter = activeLight ? backShadowRatio : 0.; + currentTransmissionParameter = activeLight ? backShadowRatio : 0.0f; } else if (o_transmission_mode == TransmissionMode::ThinObject) { // Transmission distance (add contribution only if current directional light is the active one for shadows) - currentTransmissionParameter = activeLight ? transmissionDistance : 9999.f; + currentTransmissionParameter = activeLight ? transmissionDistance : 9999.0f; } } From 9f8994823bd42636cef98e059bf73ea57ace0b79 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 30 Nov 2021 18:41:08 +0100 Subject: [PATCH 04/59] Fix naming for transmission distance parameter Signed-off-by: Santi Paprika --- .../Features/PBR/Lights/DirectionalLight.azsli | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index ccaedcd34a..0b0be82d72 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -19,7 +19,6 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; float litRatio = 1.0f; float transmissionDistance = 0.0f; - float backShadowRatio = 0.0f; if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount) { @@ -31,7 +30,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) if (o_transmission_mode == TransmissionMode::ThickObject) { - backShadowRatio = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); + transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); } else if (o_transmission_mode == TransmissionMode::ThinObject) { @@ -58,26 +57,21 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // [GFX TODO][ATOM-2012] care of multiple directional light // Currently shadow check is done only for index == shadowIndex. float currentLitRatio = 1.0f; - float currentTransmissionParameter = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; + float currentTransmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { bool activeLight = index == shadowIndex; currentLitRatio = activeLight ? litRatio : 1.; - if (o_transmission_mode == TransmissionMode::ThickObject) - { - // Back shadow ratio (add contribution only if current directional light is the active one for shadows) - currentTransmissionParameter = activeLight ? backShadowRatio : 0.0f; - } - else if (o_transmission_mode == TransmissionMode::ThinObject) + if (activeLight) { // Transmission distance (add contribution only if current directional light is the active one for shadows) - currentTransmissionParameter = activeLight ? transmissionDistance : 9999.0f; + currentTransmissionDistance = transmissionDistance; } } lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionParameter); + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance); } // Add debug coloring for directional light shadow From 348c3cc0f62268e74114e27f4cad913b64b2ddfd Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 2 Dec 2021 13:04:16 +0100 Subject: [PATCH 05/59] Expose angle offset below (N.L) Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/Skin.azsl | 3 +++ .../Assets/Materials/Types/Skin.materialtype | 15 ++++++++++++++- .../Assets/Materials/Types/Skin_Common.azsli | 1 + .../Atom/Features/PBR/BackLighting.azsli | 4 ++-- .../Atom/Features/PBR/Lighting/LightingData.azsli | 5 ++++- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index b672016c00..2e861a61bb 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -351,6 +351,9 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); lightingData.diffuseResponse = 1.0 - lightingData.specularResponse; + // Angle offset for subsurface scattering through thin objects + lightingData.angleOffset = MaterialSrg::m_angleOffset; + // ------- Occlusion ------- lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 496d6286cc..39cbe21a18 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -650,6 +650,19 @@ "name": "m_shrinkFactor" } }, + { + "name": "angleOffset", + "displayName": " Angle Offset", + "description": "Angle to accept below (N . L = 0) in scattering through thin objects", + "type": "float", + "defaultValue": 0.1, + "min": -1.0, + "softMax": 1.0, + "connection": { + "type": "ShaderInput", + "name": "m_angleOffset" + } + }, { "name": "transmissionScale", "displayName": " Scale", @@ -657,7 +670,7 @@ "type": "float", "defaultValue": 3.0, "min": 0.0, - "softMax": 20.0 + "softMax": 100.0 } ], "wrinkleLayers": [ diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index 406da8b70c..1fa2039c72 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -72,6 +72,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; float m_shrinkFactor; + float m_angleOffset; Texture2D m_wrinkle_baseColor_texture1; Texture2D m_wrinkle_baseColor_texture2; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 559b8cac2e..0e39739fcb 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -65,10 +65,10 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI { // Irradiance arround surface point. // Begin the transmittance dot product slightly before it would with the regular dot(N,L) - float E = max(0.30 + dot(-surface.normal, dirToLight), 0.0); + float E = saturate(lightingData.angleOffset + dot(-surface.normal, dirToLight)); // Transmission distance computed from shadowmaps modulated by editor-exposed parameters - float s = transmissionDistance * surface.transmission.thickness * (50 - transmissionParams.w) * 10; + float s = transmissionDistance * surface.transmission.thickness * (100 - transmissionParams.w) * 10; // Albedo at front (surface point) is used to approximate irradiance at the back of the object // See observation 4 in [Jimenez J. et al, 2010] diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index 51bd421418..7ca8a797a8 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -28,9 +28,12 @@ class LightingData // Direction light shadow coordinates float3 shadowCoords[ViewSrg::MaxCascadeCount]; - // Direction light shadow coordinates for shrinked positions + // Direction light shadow coordinates for shrinked positions (used in scattering through thin objects) float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; + // Angle to accept below (N . L = 0) in scattering through thin objects + float angleOffset; + // Normalized direction from surface to camera float3 dirToCamera; From 2b99867225fdd21445af244ea6076526ccf6131a Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 2 Dec 2021 13:32:28 +0100 Subject: [PATCH 06/59] Add informative comments for directional light thin scattering Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/Lights/DirectionalLight.azsli | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 0b0be82d72..82bad459cf 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -18,6 +18,8 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // Shadowed check const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; float litRatio = 1.0f; + + // Transmission distance inside object float transmissionDistance = 0.0f; if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount) @@ -57,6 +59,9 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // [GFX TODO][ATOM-2012] care of multiple directional light // Currently shadow check is done only for index == shadowIndex. float currentLitRatio = 1.0f; + + // Transmission distance from current light inside object (default non-influential values) + // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case float currentTransmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { From 97c36a71a26a92b98fa33fe42fa4edacc31cd155 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 2 Dec 2021 17:49:26 +0100 Subject: [PATCH 07/59] Move directional shadow coordinates computation to PS + Fix clamp values Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/Skin.azsl | 15 +++++---------- .../Atom/Features/PBR/BackLighting.azsli | 2 +- .../Atom/Features/PBR/Lighting/LightingData.azsli | 3 +++ .../Features/PBR/Lights/DirectionalLight.azsli | 8 ++++++++ 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index 2e861a61bb..4908e736f4 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -92,7 +92,6 @@ struct VSOutput float3 m_bitangent : BITANGENT; float3 m_worldPosition : UV0; float3 m_shadowCoords[ViewSrg::MaxCascadeCount] : UV4; - float3 m_shrinkedShadowCoords[ViewSrg::MaxCascadeCount] : UV9; // Extended fields (only referenced in this azsl file)... float2 m_uv[UvSetCount] : UV1; @@ -137,14 +136,6 @@ VSOutput SkinVS(VSInput IN) } VertexHelper(IN, OUT, worldPosition, false); - - // Fetch shadow coords for shrinked world position (used in thin transmission materials) - const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; - DirectionalLightShadow::GetShadowCoords( - shadowIndex, - worldPosition - MaterialSrg::m_shrinkFactor * OUT.m_normal, - OUT.m_normal, - OUT.m_shrinkedShadowCoords); return OUT; } @@ -345,15 +336,19 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) // Directional light shadow coordinates lightingData.shadowCoords = IN.m_shadowCoords; - lightingData.shrinkedShadowCoords = IN.m_shrinkedShadowCoords; // Diffuse and Specular response (used in IBL calculations) lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear); lightingData.diffuseResponse = 1.0 - lightingData.specularResponse; + // ------- Thin Object Light Transmission ------- + // Angle offset for subsurface scattering through thin objects lightingData.angleOffset = MaterialSrg::m_angleOffset; + // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection + lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; + // ------- Occlusion ------- lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 0e39739fcb..cd2ce763e4 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -65,7 +65,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI { // Irradiance arround surface point. // Begin the transmittance dot product slightly before it would with the regular dot(N,L) - float E = saturate(lightingData.angleOffset + dot(-surface.normal, dirToLight)); + float E = max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); // Transmission distance computed from shadowmaps modulated by editor-exposed parameters float s = transmissionDistance * surface.transmission.thickness * (100 - transmissionParams.w) * 10; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index 7ca8a797a8..8f3bca703e 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -33,6 +33,9 @@ class LightingData // Angle to accept below (N . L = 0) in scattering through thin objects float angleOffset; + + // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection + float shrinkFactor; // Normalized direction from surface to camera float3 dirToCamera; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 82bad459cf..d7fa77d701 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -29,6 +29,14 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) lightingData.shadowCoords, surface.vertexNormal, debugInfo); + + // Fetch shadow coords for shrinked world position (used in thin transmission materials) + float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; + DirectionalLightShadow::GetShadowCoords( + shadowIndex, + surface.position - lightingData.shrinkFactor * surface.normal, + surface.normal, + lightingData.shrinkedShadowCoords); if (o_transmission_mode == TransmissionMode::ThickObject) { From d1b19a51d5d078eb13f575591d92fdac9cc6b6a3 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 2 Dec 2021 18:36:55 +0100 Subject: [PATCH 08/59] Add point light thin transmission support Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/Lights/PointLight.azsli | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index 92f4065931..7f4cd46749 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -84,8 +84,9 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD // shadow float litRatio = 1.0; - // How much is back face shadowed, it's set to the reverse of litRatio to share the same default value with thickness, which should be 0 if no shadow map available - float backShadowRatio = 0.0; + // Transmission distance from current light inside object (default non-influential values) + // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case + float transmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { const float3 lightDir = normalize(light.m_position - surface.position); @@ -97,13 +98,13 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD lightDir, surface.vertexNormal); - // Use backShadowRatio to carry thickness from shadow map for thick mode - backShadowRatio = 1.0 - litRatio; if (o_transmission_mode == TransmissionMode::ThickObject) { - backShadowRatio = ProjectedShadow::GetThickness( - shadowIndex, - surface.position); + transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position); + } + else if (o_transmission_mode == TransmissionMode::ThinObject) + { + transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position - lightingData.shrinkFactor * surface.normal); } } @@ -111,7 +112,7 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, normalize(posToLight)) * litRatio; // Transmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), backShadowRatio); + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); // Adjust the light direcion for specular based on bulb size From 1178bc142091a84687ba59e5a9489d82cdb32edf Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Fri, 3 Dec 2021 17:02:02 +0100 Subject: [PATCH 09/59] Add disk light support for thin object translucency Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/Lights/DiskLight.azsli | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index 63f671f021..7cc5a34453 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -77,8 +77,9 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat // shadow float litRatio = 1.0; - // How much is back face shadowed, it's set to the reverse of litRatio to share the same default value with thickness, which should be 0 if no shadow map available - float backShadowRatio = 0.0; + // Transmission distance from current light inside object (default non-influential values) + // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case + float transmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { litRatio = ProjectedShadow::GetVisibility( @@ -88,14 +89,14 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat -dirToConeTip, surface.vertexNormal); - // Use backShadowRatio to carry thickness from shadow map for thick mode - backShadowRatio = 1.0 - litRatio; if (o_transmission_mode == TransmissionMode::ThickObject) { - backShadowRatio = ProjectedShadow::GetThickness( - light.m_shadowIndex, - surface.position); + transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position); } + else if (o_transmission_mode == TransmissionMode::ThinObject) + { + transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.normal); + } } if (useConeAngle && dotWithDirection < light.m_cosInnerConeAngle) // in penumbra @@ -113,7 +114,7 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, posToLightDir) * litRatio; // Transmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, backShadowRatio); + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); // Adjust the light direction for specular based on disk size From d951cd332f80de55d18824e9a82b2efe90a4266a Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Fri, 3 Dec 2021 22:06:29 +0100 Subject: [PATCH 10/59] Consider default thickness value for quadlight fast approx mode Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/Lights/QuadLight.azsli | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli index 63515339d8..a4ef25572d 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli @@ -148,13 +148,14 @@ void ApplyQuadLight(ViewSrg::QuadLight light, Surface surface, inout LightingDat GetDiffuseLighting(surface, lightingData, intensity, dirToLightCenter) ); + float nullTransmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; lightingData.translucentBackLighting += ( - GetBackLighting(surface, lightingData, intensity, p0, 0.0) + - GetBackLighting(surface, lightingData, intensity, p1, 0.0) + - GetBackLighting(surface, lightingData, intensity, p2, 0.0) + - GetBackLighting(surface, lightingData, intensity, p3, 0.0) + - GetBackLighting(surface, lightingData, intensity, dirToLightCenter, 0.0) + GetBackLighting(surface, lightingData, intensity, p0, nullTransmissionDistance) + + GetBackLighting(surface, lightingData, intensity, p1, nullTransmissionDistance) + + GetBackLighting(surface, lightingData, intensity, p2, nullTransmissionDistance) + + GetBackLighting(surface, lightingData, intensity, p3, nullTransmissionDistance) + + GetBackLighting(surface, lightingData, intensity, dirToLightCenter, nullTransmissionDistance) ); // Calculate specular by choosing a single representative point on the light's surface based on the reflection ray From 6172bb003442ffb85b446a698d96f290669055b0 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Sat, 4 Dec 2021 09:59:16 +0100 Subject: [PATCH 11/59] Add EnhancedPBR support for thin object transmission Signed-off-by: Santi Paprika --- .../Materials/Types/EnhancedPBR.materialtype | 28 ++++++++++++++++++- .../Materials/Types/EnhancedPBR_Common.azsli | 2 ++ .../Types/EnhancedPBR_ForwardPass.azsl | 8 ++++++ 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index 5de756067a..a83721f0b1 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1223,6 +1223,32 @@ "min": 0.0, "softMax": 20.0 }, + { + "name": "shrinkFactor", + "displayName": " Shrink Factor", + "description": "Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection", + "type": "float", + "defaultValue": 0.005, + "min": 0.0, + "softMax": 0.05, + "connection": { + "type": "ShaderInput", + "name": "m_shrinkFactor" + } + }, + { + "name": "angleOffset", + "displayName": " Angle Offset", + "description": "Angle to accept below (N . L = 0) in scattering through thin objects", + "type": "float", + "defaultValue": 0.1, + "min": -1.0, + "softMax": 1.0, + "connection": { + "type": "ShaderInput", + "name": "m_angleOffset" + } + }, { "name": "transmissionScale", "displayName": " Scale", @@ -1230,7 +1256,7 @@ "type": "float", "defaultValue": 3.0, "min": 0.0, - "softMax": 20.0 + "softMax": 100.0 } ], "detailLayerGroup": [ diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli index 3c35ca65be..98f091cb12 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli @@ -100,6 +100,8 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial float4 m_transmissionTintThickness; Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; + float m_shrinkFactor; + float m_angleOffset; } // Callback function for ParallaxMapping.azsli diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index 0f9771e480..bc660979f6 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -275,6 +275,14 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture); + // ------- Thin Object Light Transmission ------- + + // Angle offset for subsurface scattering through thin objects + lightingData.angleOffset = MaterialSrg::m_angleOffset; + + // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection + lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; + // ------- Clearcoat ------- // [GFX TODO][ATOM-14603]: Clean up the double uses of these clear coat flags From 7e78c260c1d80103764de83433df5e9c7a467da4 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Mon, 6 Dec 2021 12:38:30 +0100 Subject: [PATCH 12/59] Use generic diffusion profiles instead of skin-specific Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/BackLighting.azsli | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index cd2ce763e4..79a5041cf1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -23,6 +23,7 @@ float3 TransmissionKernel(float t, float3 s) return 0.25 * (1.0 / exp(exponent) + 3.0 / exp(exponent / 3.0)); } +// [specific profile for SKIN (not used ATM)] // Analytical integation (approximation) of diffusion profile over radius, could be precomputed in a LUT float3 T(float s) { @@ -68,11 +69,15 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI float E = max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); // Transmission distance computed from shadowmaps modulated by editor-exposed parameters - float s = transmissionDistance * surface.transmission.thickness * (100 - transmissionParams.w) * 10; + float s = transmissionDistance * surface.transmission.thickness * (100 - transmissionParams.w); + + // Use scattering color to weight thin object transmission color + const float3 invScattering = rcp(transmissionParams.xyz); // Albedo at front (surface point) is used to approximate irradiance at the back of the object // See observation 4 in [Jimenez J. et al, 2010] - result = T(s) * lightIntensity * surface.albedo * E; + result = TransmissionKernel(s, invScattering) * lightIntensity * surface.albedo * E; + // result = T(s) * lightIntensity * surface.albedo * E; } break; } From 4a10b5ac62b999d385b99c755032863223b3cdf4 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Mon, 6 Dec 2021 17:17:17 +0100 Subject: [PATCH 13/59] Update T(s) function explanation (comment) Signed-off-by: Santi Paprika --- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 79a5041cf1..7c5e4732cd 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -23,7 +23,7 @@ float3 TransmissionKernel(float t, float3 s) return 0.25 * (1.0 / exp(exponent) + 3.0 / exp(exponent / 3.0)); } -// [specific profile for SKIN (not used ATM)] +// [specific profile for SKIN (not used ATM, replaced by TransmissionKernel)] // Analytical integation (approximation) of diffusion profile over radius, could be precomputed in a LUT float3 T(float s) { From 2e5df3f0181425f5eae7bd43d3cb80eadc69b8f6 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Wed, 8 Dec 2021 16:12:02 +0100 Subject: [PATCH 14/59] Avoid negative thickness values Signed-off-by: Santi Paprika --- .../Atom/Features/Shadow/DirectionalLightShadow.azsli | 5 ++++- .../ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli index 59817af701..5405d2e914 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli @@ -154,7 +154,10 @@ float DirectionalLightShadow::GetThickness(uint lightIndex, float3 shadowCoords[ shadowCoord.y >= 0. && shadowCoord.y * size < size - PixelMargin && shadowCoord.z < (1. - DepthMargin)) { const float depthBufferValue = shadowmap.Sample(PassSrg::LinearSampler, float3(shadowCoord.xy, indexOfCascade)).r; - const float deltaDepth = abs(shadowCoord.z - depthBufferValue); + + // Normalized thickness (avoid negative values given by to precission or shrinking offsets) + const float deltaDepth = max(shadowCoord.z - depthBufferValue,0.0); + const float viewSpaceThickness = ViewSrg::m_directionalLightShadows[lightIndex].m_far_minus_near * deltaDepth; return viewSpaceThickness; } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli index 98ec9ea8bc..5baacf4756 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli @@ -274,8 +274,9 @@ float ProjectedShadow::GetThickness() float3(atlasPosition.xy * invAtlasSize, atlasPosition.z), /*LOD=*/0 ).r; - - const float viewSpaceThickness = abs(UnprojectDepth(m_shadowIndex, m_shadowPosition.z) - UnprojectDepth(m_shadowIndex, depthValue)); + + // Denormalized thickness (avoid negative values given by to precission or shrinking offsets) + const float viewSpaceThickness = max(UnprojectDepth(m_shadowIndex, depthValue) - UnprojectDepth(m_shadowIndex, m_shadowPosition.z), 0.0); return viewSpaceThickness; } From 8de5f8b9383b17483b1a0ce88678f6486c1ac5c7 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 9 Dec 2021 11:51:47 +0100 Subject: [PATCH 15/59] Use geometry normals instead of altered-by-maps normals Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli | 2 +- .../Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli | 2 +- .../Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index d7fa77d701..0b48094bbf 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -34,7 +34,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; DirectionalLightShadow::GetShadowCoords( shadowIndex, - surface.position - lightingData.shrinkFactor * surface.normal, + surface.position - lightingData.shrinkFactor * surface.vertexNormal, surface.normal, lightingData.shrinkedShadowCoords); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index 7cc5a34453..fbef38595d 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -95,7 +95,7 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat } else if (o_transmission_mode == TransmissionMode::ThinObject) { - transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.normal); + transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); } } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index 7f4cd46749..a7b6b822c9 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -104,7 +104,7 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD } else if (o_transmission_mode == TransmissionMode::ThinObject) { - transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position - lightingData.shrinkFactor * surface.normal); + transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); } } From 78aa73e3fd6540ebcb90366dc2c181f757d5c07f Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 9 Dec 2021 18:44:02 +0100 Subject: [PATCH 16/59] Remove thickness + refactor scale parameter influence Signed-off-by: Santi Paprika --- .../Assets/Materials/Types/EnhancedPBR.materialtype | 4 ++-- .../Common/Assets/Materials/Types/Skin.materialtype | 4 ++-- .../ShaderLib/Atom/Features/PBR/BackLighting.azsli | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index a83721f0b1..ef1d2539f6 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1254,9 +1254,9 @@ "displayName": " Scale", "description": "Strength of transmission", "type": "float", - "defaultValue": 3.0, + "defaultValue": 0.01, "min": 0.0, - "softMax": 100.0 + "softMax": 1.0 } ], "detailLayerGroup": [ diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 39cbe21a18..33b07bb86b 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -668,9 +668,9 @@ "displayName": " Scale", "description": "Strength of transmission", "type": "float", - "defaultValue": 3.0, + "defaultValue": 0.01, "min": 0.0, - "softMax": 100.0 + "softMax": 1.0 } ], "wrinkleLayers": [ diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 7c5e4732cd..a550180f9c 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -65,18 +65,18 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI { // Irradiance arround surface point. - // Begin the transmittance dot product slightly before it would with the regular dot(N,L) - float E = max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); + // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(angleOffset)) to smoothen transition regions + float3 E = surface.albedo * max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); - // Transmission distance computed from shadowmaps modulated by editor-exposed parameters - float s = transmissionDistance * surface.transmission.thickness * (100 - transmissionParams.w); + // Transmission distance modulated by editor-exposed scale parameter + float s = transmissionDistance / (transmissionParams.w * transmissionParams.w); // Use scattering color to weight thin object transmission color const float3 invScattering = rcp(transmissionParams.xyz); // Albedo at front (surface point) is used to approximate irradiance at the back of the object // See observation 4 in [Jimenez J. et al, 2010] - result = TransmissionKernel(s, invScattering) * lightIntensity * surface.albedo * E; + result = TransmissionKernel(s, invScattering) * lightIntensity * E; // result = T(s) * lightIntensity * surface.albedo * E; } break; From 90bf2520be0a0c23d34590593e94f0907349b88c Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Fri, 10 Dec 2021 13:57:04 +0100 Subject: [PATCH 17/59] Add and expose distance attenuation to compensate low-res shadow maps Signed-off-by: Santi Paprika --- .../Materials/Types/EnhancedPBR.materialtype | 15 ++++++++++++++- .../Materials/Types/EnhancedPBR_Common.azsli | 1 + .../Materials/Types/EnhancedPBR_ForwardPass.azsl | 3 +++ .../Common/Assets/Materials/Types/Skin.azsl | 3 +++ .../Assets/Materials/Types/Skin.materialtype | 15 ++++++++++++++- .../Assets/Materials/Types/Skin_Common.azsli | 1 + .../Atom/Features/PBR/Lighting/LightingData.azsli | 3 +++ .../Features/PBR/Lights/DirectionalLight.azsli | 10 ++++++++-- .../Atom/Features/PBR/Lights/DiskLight.azsli | 7 ++++++- .../Atom/Features/PBR/Lights/PointLight.azsli | 8 +++++++- 10 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index ef1d2539f6..31f8bd3c32 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1239,7 +1239,7 @@ { "name": "angleOffset", "displayName": " Angle Offset", - "description": "Angle to accept below (N . L = 0) in scattering through thin objects", + "description": "cosine of angle to extend below (N . L = 0) in scattering through thin objects", "type": "float", "defaultValue": 0.1, "min": -1.0, @@ -1249,6 +1249,19 @@ "name": "m_angleOffset" } }, + { + "name": "distanceAttenuation", + "displayName": " Distance Attenuation", + "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", + "type": "float", + "defaultValue": 4.0, + "min": 0.0, + "softMax": 10.0, + "connection": { + "type": "ShaderInput", + "name": "m_distanceAttenuation" + } + }, { "name": "transmissionScale", "displayName": " Scale", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli index 98f091cb12..7c791e1cd0 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli @@ -102,6 +102,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial uint m_transmissionThicknessMapUvIndex; float m_shrinkFactor; float m_angleOffset; + float m_distanceAttenuation; } // Callback function for ParallaxMapping.azsli diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index bc660979f6..e35941c623 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -283,6 +283,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; + // Attenuation applied to hide artifacts due to low-res shadow maps + lightingData.distanceAttenuation = MaterialSrg::m_distanceAttenuation; + // ------- Clearcoat ------- // [GFX TODO][ATOM-14603]: Clean up the double uses of these clear coat flags diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index 4908e736f4..ca02d496c5 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -349,6 +349,9 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; + // Attenuation applied to hide artifacts due to low-res shadow maps + lightingData.distanceAttenuation = MaterialSrg::m_distanceAttenuation; + // ------- Occlusion ------- lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture); diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 33b07bb86b..fa190657c0 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -653,7 +653,7 @@ { "name": "angleOffset", "displayName": " Angle Offset", - "description": "Angle to accept below (N . L = 0) in scattering through thin objects", + "description": "cosine of angle to extend below (N . L = 0) in scattering through thin objects", "type": "float", "defaultValue": 0.1, "min": -1.0, @@ -663,6 +663,19 @@ "name": "m_angleOffset" } }, + { + "name": "distanceAttenuation", + "displayName": " Distance Attenuation", + "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", + "type": "float", + "defaultValue": 4.0, + "min": 0.0, + "softMax": 10.0, + "connection": { + "type": "ShaderInput", + "name": "m_distanceAttenuation" + } + }, { "name": "transmissionScale", "displayName": " Scale", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index 1fa2039c72..2ec1e6e8dc 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -73,6 +73,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial uint m_transmissionThicknessMapUvIndex; float m_shrinkFactor; float m_angleOffset; + float m_distanceAttenuation; Texture2D m_wrinkle_baseColor_texture1; Texture2D m_wrinkle_baseColor_texture2; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index 8f3bca703e..cc55c4796e 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -37,6 +37,9 @@ class LightingData // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection float shrinkFactor; + // Attenuation applied to hide artifacts due to low-res shadow maps + float distanceAttenuation; + // Normalized direction from surface to camera float3 dirToCamera; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 0b48094bbf..ffac82232f 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -18,7 +18,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // Shadowed check const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; float litRatio = 1.0f; - + float camToSurfDist = distance(ViewSrg::m_worldPosition, surface.position); // Transmission distance inside object float transmissionDistance = 0.0f; @@ -84,7 +84,13 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance); + + float3 backLighting = GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance); + + // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float attenuation = 1.0 / pow(max(1.0, camToSurfDist/2.0), lightingData.distanceAttenuation + 1.0); + + lightingData.translucentBackLighting += backLighting * attenuation; } // Add debug coloring for directional light shadow diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index fbef38595d..209a6af823 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -114,8 +114,13 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, posToLightDir) * litRatio; // Transmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); + float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); + // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float attenuation = 1.0 / pow(max(1.0, sqrt(distanceToLight2)), lightingData.distanceAttenuation + 1.0); + + lightingData.translucentBackLighting += backLighting * attenuation; + // Adjust the light direction for specular based on disk size // Calculate the reflection off the normal from the view direction diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index a7b6b822c9..2eb815410d 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -67,6 +67,7 @@ uint ComputeShadowIndex(const ViewSrg::PointLight light, const Surface surface) void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingData lightingData) { float3 posToLight = light.m_position - surface.position; + float posToLightDist = length(posToLight); float d2 = dot(posToLight, posToLight); // light distance squared float falloff = d2 * light.m_invAttenuationRadiusSquared; @@ -112,7 +113,12 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, normalize(posToLight)) * litRatio; // Transmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); + float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); + + // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float attenuation = 1.0 / pow(max(1.0, posToLightDist), lightingData.distanceAttenuation + 1.0); + + lightingData.translucentBackLighting += backLighting * attenuation; // Adjust the light direcion for specular based on bulb size From 84829dd8eed1322cb6cc2570709af1e7d1b140b6 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Mon, 13 Dec 2021 10:47:03 +0100 Subject: [PATCH 18/59] Make scale parameter influence output instead of transmission distance Signed-off-by: Santi Paprika --- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index a550180f9c..e729fcb363 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -69,15 +69,17 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI float3 E = surface.albedo * max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); // Transmission distance modulated by editor-exposed scale parameter - float s = transmissionDistance / (transmissionParams.w * transmissionParams.w); + float s = transmissionDistance * 100.0; // Use scattering color to weight thin object transmission color const float3 invScattering = rcp(transmissionParams.xyz); // Albedo at front (surface point) is used to approximate irradiance at the back of the object // See observation 4 in [Jimenez J. et al, 2010] - result = TransmissionKernel(s, invScattering) * lightIntensity * E; - // result = T(s) * lightIntensity * surface.albedo * E; + result = TransmissionKernel(s, invScattering) * lightIntensity * E * transmissionParams.w; + + // Alternative specific to skin translucency + // result = T(s) * lightIntensity * surface.albedo * E * transmissionParams.w; } break; } From 2d45ecb616a504d1fa4135dea04e5adfa19775b4 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 11:33:36 +0100 Subject: [PATCH 19/59] Fix nits (https://github.com/o3de/o3de/pull/6428#discussion_r774251316 , https://github.com/o3de/o3de/pull/6428#discussion_r774252019) Signed-off-by: Santi Paprika --- Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl | 2 +- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index ca02d496c5..8a041a93f1 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -136,7 +136,7 @@ VSOutput SkinVS(VSInput IN) } VertexHelper(IN, OUT, worldPosition, false); - + return OUT; } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index e729fcb363..b35e17b160 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -65,7 +65,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI { // Irradiance arround surface point. - // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(angleOffset)) to smoothen transition regions + // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(angleOffset)) to smooth transition regions float3 E = surface.albedo * max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); // Transmission distance modulated by editor-exposed scale parameter From c700b95c8d4aed5605b28c901a49a7287725e9cb Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 15:33:00 +0100 Subject: [PATCH 20/59] Avoid mode-specific transmission distance initialization (potential fix for https://github.com/o3de/o3de/pull/6428#discussion_r774259781) Signed-off-by: Santi Paprika --- .../PBR/Lights/DirectionalLight.azsli | 20 +++--- .../Atom/Features/PBR/Lights/DiskLight.azsli | 61 ++++++++++--------- .../Atom/Features/PBR/Lights/PointLight.azsli | 25 ++++---- 3 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index ffac82232f..d2aeb4b5f8 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -19,7 +19,8 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) const uint shadowIndex = ViewSrg::m_shadowIndexDirectionalLight; float litRatio = 1.0f; float camToSurfDist = distance(ViewSrg::m_worldPosition, surface.position); - // Transmission distance inside object + + // Distance travelled by the light inside the object float transmissionDistance = 0.0f; if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount) @@ -69,28 +70,25 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) float currentLitRatio = 1.0f; // Transmission distance from current light inside object (default non-influential values) - // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case - float currentTransmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { bool activeLight = index == shadowIndex; + + // Add contribution only if current directional light is the active one for shadows currentLitRatio = activeLight ? litRatio : 1.; if (activeLight) { - // Transmission distance (add contribution only if current directional light is the active one for shadows) - currentTransmissionDistance = transmissionDistance; + float3 backLighting = GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, transmissionDistance); + + // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float attenuation = 1.0 / pow(max(1.0, camToSurfDist/2.0), lightingData.distanceAttenuation + 1.0); + lightingData.translucentBackLighting += backLighting * attenuation; } } lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; - float3 backLighting = GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance); - - // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float attenuation = 1.0 / pow(max(1.0, camToSurfDist/2.0), lightingData.distanceAttenuation + 1.0); - - lightingData.translucentBackLighting += backLighting * attenuation; } // Add debug coloring for directional light shadow diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index 209a6af823..9d4e503df6 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -76,28 +76,6 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat // shadow float litRatio = 1.0; - - // Transmission distance from current light inside object (default non-influential values) - // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case - float transmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; - if (o_enableShadows) - { - litRatio = ProjectedShadow::GetVisibility( - light.m_shadowIndex, - light.m_position, - surface.position, - -dirToConeTip, - surface.vertexNormal); - - if (o_transmission_mode == TransmissionMode::ThickObject) - { - transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position); - } - else if (o_transmission_mode == TransmissionMode::ThinObject) - { - transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); - } - } if (useConeAngle && dotWithDirection < light.m_cosInnerConeAngle) // in penumbra { @@ -110,17 +88,40 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat lightIntensity *= penumbraMask; } + if (o_enableShadows) + { + litRatio = ProjectedShadow::GetVisibility( + light.m_shadowIndex, + light.m_position, + surface.position, + -dirToConeTip, + surface.vertexNormal); + + // Distance travelled by the light inside the object + float transmissionDistance = 0.0f; + + // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case + if (o_transmission_mode == TransmissionMode::ThickObject) + { + transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position); + } + else if (o_transmission_mode == TransmissionMode::ThinObject) + { + transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); + } + + // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float attenuation = 1.0 / pow(max(1.0, sqrt(distanceToLight2)), lightingData.distanceAttenuation + 1.0); + + // Transmission contribution + float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); + + lightingData.translucentBackLighting += backLighting * attenuation; + } + // Diffuse contribution lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, posToLightDir) * litRatio; - // Transmission contribution - float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); - - // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float attenuation = 1.0 / pow(max(1.0, sqrt(distanceToLight2)), lightingData.distanceAttenuation + 1.0); - - lightingData.translucentBackLighting += backLighting * attenuation; - // Adjust the light direction for specular based on disk size // Calculate the reflection off the normal from the view direction diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index 2eb815410d..e2297fd3d3 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -85,9 +85,6 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD // shadow float litRatio = 1.0; - // Transmission distance from current light inside object (default non-influential values) - // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case - float transmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; if (o_enableShadows) { const float3 lightDir = normalize(light.m_position - surface.position); @@ -99,6 +96,10 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD lightDir, surface.vertexNormal); + // Distance travelled by the light inside the object + float transmissionDistance = 0.0f; + + // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case if (o_transmission_mode == TransmissionMode::ThickObject) { transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position); @@ -106,20 +107,20 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD else if (o_transmission_mode == TransmissionMode::ThinObject) { transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); - } + } + + // Transmission contribution + float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); + + // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float attenuation = 1.0 / pow(max(1.0, posToLightDist), lightingData.distanceAttenuation + 1.0); + + lightingData.translucentBackLighting += backLighting * attenuation; } // Diffuse contribution lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, normalize(posToLight)) * litRatio; - // Transmission contribution - float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); - - // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float attenuation = 1.0 / pow(max(1.0, posToLightDist), lightingData.distanceAttenuation + 1.0); - - lightingData.translucentBackLighting += backLighting * attenuation; - // Adjust the light direcion for specular based on bulb size // Calculate the reflection off the normal from the view direction From 14683bf3eff17aa5c4eeed09fa5237c616cf45db Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 15:47:00 +0100 Subject: [PATCH 21/59] Fix nits (remove residual comment) Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli | 2 -- 1 file changed, 2 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index d2aeb4b5f8..da4901cf8e 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -69,7 +69,6 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // Currently shadow check is done only for index == shadowIndex. float currentLitRatio = 1.0f; - // Transmission distance from current light inside object (default non-influential values) if (o_enableShadows) { bool activeLight = index == shadowIndex; @@ -88,7 +87,6 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; - } // Add debug coloring for directional light shadow From 038c71a660bedf0c3ddde707e913dbcc4d09db19 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 17:55:27 +0100 Subject: [PATCH 22/59] Move mode-specific behavior into GetBackLighting (improvement on https://github.com/o3de/o3de/pull/6428#discussion_r774259781 and https://github.com/o3de/o3de/pull/6428/commits/c700b95c8d4aed5605b28c901a49a7287725e9cb) Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/BackLighting.azsli | 8 +++++- .../PBR/Lights/DirectionalLight.azsli | 25 ++++++++----------- .../Atom/Features/PBR/Lights/DiskLight.azsli | 17 ++++++------- .../Atom/Features/PBR/Lights/PointLight.azsli | 19 ++++++-------- .../Atom/Features/PBR/Lights/QuadLight.azsli | 11 ++++---- 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index b35e17b160..2f4680bc9d 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -64,11 +64,17 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // http://www.iryoku.com/translucency/downloads/Real-Time-Realistic-Skin-Translucency.pdf { + // transmissionDistance < 0.0f means shadows are not enabled --> avoid unnecessary computation + if (transmissionDistance < 0.0f) + { + break; + } + // Irradiance arround surface point. // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(angleOffset)) to smooth transition regions float3 E = surface.albedo * max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); - // Transmission distance modulated by editor-exposed scale parameter + // Transmission distance modulated by hardcoded constant (could be exposed as a weight of scattering distance for transmission) float s = transmissionDistance * 100.0; // Use scattering color to weight thin object transmission color diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index da4901cf8e..a34411c332 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -20,8 +20,8 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) float litRatio = 1.0f; float camToSurfDist = distance(ViewSrg::m_worldPosition, surface.position); - // Distance travelled by the light inside the object - float transmissionDistance = 0.0f; + // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) + float transmissionDistance = -1.0f; if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount) { @@ -68,22 +68,19 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) // [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; - if (o_enableShadows) + if (o_enableShadows && index == shadowIndex) { - bool activeLight = index == shadowIndex; - // Add contribution only if current directional light is the active one for shadows - currentLitRatio = activeLight ? litRatio : 1.; - if (activeLight) - { - float3 backLighting = GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, transmissionDistance); - - // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float attenuation = 1.0 / pow(max(1.0, camToSurfDist/2.0), lightingData.distanceAttenuation + 1.0); - lightingData.translucentBackLighting += backLighting * attenuation; - } + currentLitRatio = litRatio; + currentTransmissionDistance = transmissionDistance; } + + // Transmission contribution with attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float3 backLighting = GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance); + float attenuation = 1.0 / pow(max(1.0, camToSurfDist/2.0), lightingData.distanceAttenuation + 1.0); + lightingData.translucentBackLighting += backLighting * attenuation; lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index 9d4e503df6..cc0e33ff5b 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -88,6 +88,9 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat lightIntensity *= penumbraMask; } + // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) + float transmissionDistance = -1.0f; + if (o_enableShadows) { litRatio = ProjectedShadow::GetVisibility( @@ -97,8 +100,6 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat -dirToConeTip, surface.vertexNormal); - // Distance travelled by the light inside the object - float transmissionDistance = 0.0f; // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case if (o_transmission_mode == TransmissionMode::ThickObject) @@ -110,18 +111,16 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); } - // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float attenuation = 1.0 / pow(max(1.0, sqrt(distanceToLight2)), lightingData.distanceAttenuation + 1.0); - - // Transmission contribution - float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); - - lightingData.translucentBackLighting += backLighting * attenuation; } // Diffuse contribution lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, posToLightDir) * litRatio; + // Transmission contribution with attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); + float attenuation = 1.0 / pow(max(1.0, sqrt(distanceToLight2)), lightingData.distanceAttenuation + 1.0); + lightingData.translucentBackLighting += backLighting * attenuation; + // Adjust the light direction for specular based on disk size // Calculate the reflection off the normal from the view direction diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index e2297fd3d3..664c3693fb 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -85,6 +85,9 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD // shadow float litRatio = 1.0; + // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) + float transmissionDistance = -1.0f; + if (o_enableShadows) { const float3 lightDir = normalize(light.m_position - surface.position); @@ -95,9 +98,6 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD surface.position, lightDir, surface.vertexNormal); - - // Distance travelled by the light inside the object - float transmissionDistance = 0.0f; // o_transmission_mode == NONE is not taken into account because GetBackLighting already ignores this case if (o_transmission_mode == TransmissionMode::ThickObject) @@ -108,19 +108,16 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD { transmissionDistance = ProjectedShadow::GetThickness(shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); } - - // Transmission contribution - float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); - - // Attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float attenuation = 1.0 / pow(max(1.0, posToLightDist), lightingData.distanceAttenuation + 1.0); - - lightingData.translucentBackLighting += backLighting * attenuation; } // Diffuse contribution lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, normalize(posToLight)) * litRatio; + // Transmission contribution with attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) + float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); + float attenuation = 1.0 / pow(max(1.0, posToLightDist), lightingData.distanceAttenuation + 1.0); + lightingData.translucentBackLighting += backLighting * attenuation; + // Adjust the light direcion for specular based on bulb size // Calculate the reflection off the normal from the view direction diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli index a4ef25572d..b4cdbeb847 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli @@ -148,14 +148,13 @@ void ApplyQuadLight(ViewSrg::QuadLight light, Surface surface, inout LightingDat GetDiffuseLighting(surface, lightingData, intensity, dirToLightCenter) ); - float nullTransmissionDistance = (o_transmission_mode == TransmissionMode::ThickObject) ? 0.0f : 9999.0f; lightingData.translucentBackLighting += ( - GetBackLighting(surface, lightingData, intensity, p0, nullTransmissionDistance) + - GetBackLighting(surface, lightingData, intensity, p1, nullTransmissionDistance) + - GetBackLighting(surface, lightingData, intensity, p2, nullTransmissionDistance) + - GetBackLighting(surface, lightingData, intensity, p3, nullTransmissionDistance) + - GetBackLighting(surface, lightingData, intensity, dirToLightCenter, nullTransmissionDistance) + GetBackLighting(surface, lightingData, intensity, p0, -1.0f) + + GetBackLighting(surface, lightingData, intensity, p1, -1.0f) + + GetBackLighting(surface, lightingData, intensity, p2, -1.0f) + + GetBackLighting(surface, lightingData, intensity, p3, -1.0f) + + GetBackLighting(surface, lightingData, intensity, dirToLightCenter, -1.0f) ); // Calculate specular by choosing a single representative point on the light's surface based on the reflection ray From 6e3ada487e14ab43dae08161b1099ccb099c338b Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 18:21:18 +0100 Subject: [PATCH 23/59] Move penumbra computation back to original place. Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/Lights/DiskLight.azsli | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index cc0e33ff5b..3acd74ab03 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -77,16 +77,6 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat // shadow float litRatio = 1.0; - if (useConeAngle && dotWithDirection < light.m_cosInnerConeAngle) // in penumbra - { - // Normalize into 0.0 - 1.0 space. - float penumbraMask = (dotWithDirection - light.m_cosOuterConeAngle) / (light.m_cosInnerConeAngle - light.m_cosOuterConeAngle); - - // Apply smoothstep - penumbraMask = penumbraMask * penumbraMask * (3.0 - 2.0 * penumbraMask); - - lightIntensity *= penumbraMask; - } // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) float transmissionDistance = -1.0f; @@ -110,7 +100,17 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat { transmissionDistance = ProjectedShadow::GetThickness(light.m_shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal); } + } + if (useConeAngle && dotWithDirection < light.m_cosInnerConeAngle) // in penumbra + { + // Normalize into 0.0 - 1.0 space. + float penumbraMask = (dotWithDirection - light.m_cosOuterConeAngle) / (light.m_cosInnerConeAngle - light.m_cosOuterConeAngle); + + // Apply smoothstep + penumbraMask = penumbraMask * penumbraMask * (3.0 - 2.0 * penumbraMask); + + lightIntensity *= penumbraMask; } // Diffuse contribution From eda405f5f1d3ca785f61ea9ae1f4b9fb3ea54c0a Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 19:49:47 +0100 Subject: [PATCH 24/59] Move attenuation computation into GetBackLighting (https://github.com/o3de/o3de/pull/6428#discussion_r774259148) Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/BackLighting.azsli | 5 ++++- .../Atom/Features/PBR/Lights/CapsuleLight.azsli | 2 +- .../Atom/Features/PBR/Lights/DirectionalLight.azsli | 6 ++---- .../ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli | 6 ++---- .../Atom/Features/PBR/Lights/LightTypesCommon.azsli | 2 +- .../Atom/Features/PBR/Lights/PointLight.azsli | 6 ++---- .../ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli | 10 +++++----- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 2f4680bc9d..adb2dea927 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -36,7 +36,7 @@ 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) +float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightIntensity, float3 dirToLight, float transmissionDistance, float attenuationDistance) { float3 result = float3(0.0, 0.0, 0.0); float thickness = 0.0; @@ -86,6 +86,9 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // Alternative specific to skin translucency // result = T(s) * lightIntensity * surface.albedo * E * transmissionParams.w; + + // Distance attenuation applied to hide artifacts due to low-res projected areas onto shadowmaps (might need some work in the future) + result *= 1.0 / pow(max(1.0, sqrt(attenuationDistance)), lightingData.distanceAttenuation + 1.0); } break; } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli index e6b18df9b5..bb4be45e5a 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli @@ -136,7 +136,7 @@ void ApplyCapsuleLight(ViewSrg::CapsuleLight light, Surface surface, inout Light float3 posToLight = closestIntersectionPoint - surface.position; // Tranmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), 0.0); + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), -1.0f, 0.0f); // Calculate the offset from the nearest point on the reflection vector to the nearest point on the capsule light float3 posToClosestPointAlongReflection = dot(posToLight, reflectionDir) * reflectionDir; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index a34411c332..e3f3f1135a 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -77,10 +77,8 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) currentTransmissionDistance = transmissionDistance; } - // Transmission contribution with attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float3 backLighting = GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance); - float attenuation = 1.0 / pow(max(1.0, camToSurfDist/2.0), lightingData.distanceAttenuation + 1.0); - lightingData.translucentBackLighting += backLighting * attenuation; + // Transmission contribution + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance, camToSurfDist/2.0); lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index 3acd74ab03..a98b99452b 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -116,10 +116,8 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat // Diffuse contribution lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, posToLightDir) * litRatio; - // Transmission contribution with attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance); - float attenuation = 1.0 / pow(max(1.0, sqrt(distanceToLight2)), lightingData.distanceAttenuation + 1.0); - lightingData.translucentBackLighting += backLighting * attenuation; + // Transmission contribution + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, posToLightDir, transmissionDistance, distanceToLight2); // Adjust the light direction for specular based on disk size diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli index f0169e29b8..dee0d63c79 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli @@ -49,6 +49,6 @@ void AddSampleContribution( float3 intensityRgb = float3(intensity, intensity, intensity); diffuseAcc += GetDiffuseLighting(surface, lightingData, intensityRgb, posToLightSampleDir); - translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, 0.0); + translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, -1.0f, 0.0f); specularAcc += GetSpecularLighting(surface, lightingData, intensityRgb, posToLightSampleDir); } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index 664c3693fb..ecec0af004 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -113,10 +113,8 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD // Diffuse contribution lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, lightIntensity, normalize(posToLight)) * litRatio; - // Transmission contribution with attenuation applied to hide artifacts due to low-res shadow maps (might need some work in the future) - float3 backLighting = GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance); - float attenuation = 1.0 / pow(max(1.0, posToLightDist), lightingData.distanceAttenuation + 1.0); - lightingData.translucentBackLighting += backLighting * attenuation; + // Transmission contribution + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance, posToLightDist); // Adjust the light direcion for specular based on bulb size diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli index b4cdbeb847..f5e148f771 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli @@ -150,11 +150,11 @@ void ApplyQuadLight(ViewSrg::QuadLight light, Surface surface, inout LightingDat lightingData.translucentBackLighting += ( - GetBackLighting(surface, lightingData, intensity, p0, -1.0f) + - GetBackLighting(surface, lightingData, intensity, p1, -1.0f) + - GetBackLighting(surface, lightingData, intensity, p2, -1.0f) + - GetBackLighting(surface, lightingData, intensity, p3, -1.0f) + - GetBackLighting(surface, lightingData, intensity, dirToLightCenter, -1.0f) + GetBackLighting(surface, lightingData, intensity, p0, -1.0f, 0.0f) + + GetBackLighting(surface, lightingData, intensity, p1, -1.0f, 0.0f) + + GetBackLighting(surface, lightingData, intensity, p2, -1.0f, 0.0f) + + GetBackLighting(surface, lightingData, intensity, p3, -1.0f, 0.0f) + + GetBackLighting(surface, lightingData, intensity, dirToLightCenter, -1.0f, 0.0f) ); // Calculate specular by choosing a single representative point on the light's surface based on the reflection ray From 46abff309336e54ff19507ef8f32c3a883f2df28 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 20:29:42 +0100 Subject: [PATCH 25/59] Rename 'angleOffset' to 'transmissionNdLBias' (https://github.com/o3de/o3de/pull/6428#discussion_r774253626) Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/EnhancedPBR.materialtype | 6 +++--- .../Common/Assets/Materials/Types/EnhancedPBR_Common.azsli | 2 +- .../Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl | 2 +- Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl | 2 +- .../Feature/Common/Assets/Materials/Types/Skin.materialtype | 6 +++--- .../Feature/Common/Assets/Materials/Types/Skin_Common.azsli | 2 +- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 4 ++-- .../ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index 31f8bd3c32..77caf42834 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1237,8 +1237,8 @@ } }, { - "name": "angleOffset", - "displayName": " Angle Offset", + "name": "transmissionAngleBias", + "displayName": " Angle Bias", "description": "cosine of angle to extend below (N . L = 0) in scattering through thin objects", "type": "float", "defaultValue": 0.1, @@ -1246,7 +1246,7 @@ "softMax": 1.0, "connection": { "type": "ShaderInput", - "name": "m_angleOffset" + "name": "m_transmissionNdLBias" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli index 7c791e1cd0..c15b49dc7d 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli @@ -101,7 +101,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; float m_shrinkFactor; - float m_angleOffset; + float m_transmissionNdLBias; float m_distanceAttenuation; } diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index e35941c623..5e02da679e 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -278,7 +278,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Thin Object Light Transmission ------- // Angle offset for subsurface scattering through thin objects - lightingData.angleOffset = MaterialSrg::m_angleOffset; + lightingData.transmissionNdLBias = MaterialSrg::m_transmissionNdLBias; // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index 8a041a93f1..faa16b205a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -344,7 +344,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) // ------- Thin Object Light Transmission ------- // Angle offset for subsurface scattering through thin objects - lightingData.angleOffset = MaterialSrg::m_angleOffset; + lightingData.transmissionNdLBias = MaterialSrg::m_transmissionNdLBias; // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index fa190657c0..d42f62d0ac 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -651,8 +651,8 @@ } }, { - "name": "angleOffset", - "displayName": " Angle Offset", + "name": "transmissionAngleBias", + "displayName": " Angle Bias", "description": "cosine of angle to extend below (N . L = 0) in scattering through thin objects", "type": "float", "defaultValue": 0.1, @@ -660,7 +660,7 @@ "softMax": 1.0, "connection": { "type": "ShaderInput", - "name": "m_angleOffset" + "name": "m_transmissionNdLBias" } }, { diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index 2ec1e6e8dc..630291c260 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -72,7 +72,7 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; float m_shrinkFactor; - float m_angleOffset; + float m_transmissionNdLBias; float m_distanceAttenuation; Texture2D m_wrinkle_baseColor_texture1; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index adb2dea927..0506f08db1 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -71,8 +71,8 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI } // Irradiance arround surface point. - // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(angleOffset)) to smooth transition regions - float3 E = surface.albedo * max(lightingData.angleOffset + dot(-surface.normal, dirToLight),0.0); + // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions + float3 E = surface.albedo * max(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight),0.0); // Transmission distance modulated by hardcoded constant (could be exposed as a weight of scattering distance for transmission) float s = transmissionDistance * 100.0; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index cc55c4796e..7e7af6be96 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -31,8 +31,8 @@ class LightingData // Direction light shadow coordinates for shrinked positions (used in scattering through thin objects) float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; - // Angle to accept below (N . L = 0) in scattering through thin objects - float angleOffset; + // (N . L) to accept below (N . L = 0) in scattering through thin objects + float transmissionNdLBias; // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection float shrinkFactor; From 6dbb8e1794f763302226dce41ff91e99b3b7e875 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 21:02:02 +0100 Subject: [PATCH 26/59] Use local shrinked shadow coords (https://github.com/o3de/o3de/pull/6428#discussion_r774255818) Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli | 3 --- .../ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli | 4 ++-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli index 7e7af6be96..a1278b8126 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli @@ -28,9 +28,6 @@ class LightingData // Direction light shadow coordinates float3 shadowCoords[ViewSrg::MaxCascadeCount]; - // Direction light shadow coordinates for shrinked positions (used in scattering through thin objects) - float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; - // (N . L) to accept below (N . L = 0) in scattering through thin objects float transmissionNdLBias; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index e3f3f1135a..e6de9e57c3 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -37,7 +37,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) shadowIndex, surface.position - lightingData.shrinkFactor * surface.vertexNormal, surface.normal, - lightingData.shrinkedShadowCoords); + shrinkedShadowCoords); if (o_transmission_mode == TransmissionMode::ThickObject) { @@ -47,7 +47,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) { // Use shrinked positions for thin object transmission to ensure they fall onto the object when querying // the depth from the shadow map - transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shrinkedShadowCoords); + transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, shrinkedShadowCoords); } } From 60ec8c3cfb5d9a1110a96977bdc3318739b3f1e0 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Thu, 23 Dec 2021 21:17:17 +0100 Subject: [PATCH 27/59] Alias shadowCoords memory instead of using local variable (https://github.com/o3de/o3de/pull/6428#discussion_r774255818 cont'd) Signed-off-by: Santi Paprika --- .../Features/PBR/Lights/DirectionalLight.azsli | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index e6de9e57c3..507b226682 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -31,23 +31,21 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) surface.vertexNormal, debugInfo); - // Fetch shadow coords for shrinked world position (used in thin transmission materials) - float3 shrinkedShadowCoords[ViewSrg::MaxCascadeCount]; - DirectionalLightShadow::GetShadowCoords( - shadowIndex, - surface.position - lightingData.shrinkFactor * surface.vertexNormal, - surface.normal, - shrinkedShadowCoords); - if (o_transmission_mode == TransmissionMode::ThickObject) { transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); } else if (o_transmission_mode == TransmissionMode::ThinObject) { - // Use shrinked positions for thin object transmission to ensure they fall onto the object when querying + // Fetch and use shrinked positions for thin object transmission to ensure they fall onto the object when querying + DirectionalLightShadow::GetShadowCoords( + shadowIndex, + surface.position - lightingData.shrinkFactor * surface.vertexNormal, + surface.normal, + lightingData.shadowCoords); + // the depth from the shadow map - transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, shrinkedShadowCoords); + transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); } } From 7052b99671027ceb36174d95e275d935eeb5be42 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 4 Jan 2022 09:49:15 +0100 Subject: [PATCH 28/59] Add reference for skin-specific profiles (https://github.com/o3de/o3de/pull/6428/files#r776068153) Signed-off-by: Santi Paprika --- .../Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 0506f08db1..eec90a1da9 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -25,6 +25,7 @@ float3 TransmissionKernel(float t, float3 s) // [specific profile for SKIN (not used ATM, replaced by TransmissionKernel)] // Analytical integation (approximation) of diffusion profile over radius, could be precomputed in a LUT +// From d'Eon and Luebke (https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin, section 14.4.7) float3 T(float s) { // dipoles and multipoles are approximated with sums of a small number of Gaussians with variable weights and variances From c814be22fd65eacf47ea11d969acc8994780c2eb Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 4 Jan 2022 10:34:05 +0100 Subject: [PATCH 29/59] Saturate (NdL + bias) to preserve energy (https://github.com/o3de/o3de/pull/6428#discussion_r774253478, https://github.com/o3de/o3de/pull/6428#discussion_r776069110) Signed-off-by: Santi Paprika --- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index eec90a1da9..dd40b94414 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -73,7 +73,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // Irradiance arround surface point. // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions - float3 E = surface.albedo * max(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight),0.0); + float3 E = surface.albedo * saturate(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight)); // Transmission distance modulated by hardcoded constant (could be exposed as a weight of scattering distance for transmission) float s = transmissionDistance * 100.0; From 69df812941fedec065e23e1965fc646f66a50624 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 4 Jan 2022 12:23:02 +0100 Subject: [PATCH 30/59] Add explanations for default constant parameters + define as separate const variables (https://github.com/o3de/o3de/pull/6428#discussion_r776073076, https://github.com/o3de/o3de/pull/6428#discussion_r776072881, https://github.com/o3de/o3de/pull/6428#discussion_r776069391) Signed-off-by: Santi Paprika --- .../Atom/Features/PBR/BackLighting.azsli | 5 +++-- .../Features/PBR/Lights/CapsuleLight.azsli | 11 +++++++++-- .../Features/PBR/Lights/DirectionalLight.azsli | 4 +++- .../Atom/Features/PBR/Lights/DiskLight.azsli | 5 +++-- .../Features/PBR/Lights/LightTypesCommon.azsli | 12 +++++++++++- .../Atom/Features/PBR/Lights/PointLight.azsli | 4 +++- .../Atom/Features/PBR/Lights/QuadLight.azsli | 18 +++++++++++++----- 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index dd40b94414..87dd42fd28 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -75,8 +75,9 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions float3 E = surface.albedo * saturate(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight)); - // Transmission distance modulated by hardcoded constant (could be exposed as a weight of scattering distance for transmission) - float s = transmissionDistance * 100.0; + // Transmission distance modulated by hardcoded constant C (could be exposed as a weight of scattering distance for transmission) + const float C = 100.0f; + float s = transmissionDistance * C; // Use scattering color to weight thin object transmission color const float3 invScattering = rcp(transmissionParams.xyz); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli index bb4be45e5a..1921159c03 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli @@ -135,8 +135,15 @@ void ApplyCapsuleLight(ViewSrg::CapsuleLight light, Surface surface, inout Light float3 closestIntersectionPoint = startPoint + closestT * startToEnd; float3 posToLight = closestIntersectionPoint - surface.position; - // Tranmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), -1.0f, 0.0f); + // Transmission contribution + // We cannot compute the actual transmission distance so we want to: + // - 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; + // If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence + const float attenuationDistance = 0.0f; + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance, attenuationDistance); // Calculate the offset from the nearest point on the reflection vector to the nearest point on the capsule light float3 posToClosestPointAlongReflection = dot(posToLight, reflectionDir) * reflectionDir; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 507b226682..92b90b16ea 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -20,7 +20,9 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) float litRatio = 1.0f; float camToSurfDist = distance(ViewSrg::m_worldPosition, surface.position); - // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) + // 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; if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli index a98b99452b..4f05caa912 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DiskLight.azsli @@ -77,8 +77,9 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat // shadow float litRatio = 1.0; - - // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) + // 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; if (o_enableShadows) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli index dee0d63c79..6718c6f385 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/LightTypesCommon.azsli @@ -49,6 +49,16 @@ void AddSampleContribution( float3 intensityRgb = float3(intensity, intensity, intensity); diffuseAcc += GetDiffuseLighting(surface, lightingData, intensityRgb, posToLightSampleDir); - translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, -1.0f, 0.0f); + + // Transmission contribution + // We cannot compute the actual transmission distance so we want to: + // - 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; + // If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence + const float attenuationDistance = 0.0f; + translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, transmissionDistance, attenuationDistance); + specularAcc += GetSpecularLighting(surface, lightingData, intensityRgb, posToLightSampleDir); } diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli index ecec0af004..02ae82d0f9 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli @@ -85,7 +85,9 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD // shadow float litRatio = 1.0; - // Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting()) + // 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; if (o_enableShadows) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli index f5e148f771..e6ac886fb6 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli @@ -148,13 +148,21 @@ void ApplyQuadLight(ViewSrg::QuadLight light, Surface surface, inout LightingDat GetDiffuseLighting(surface, lightingData, intensity, dirToLightCenter) ); + // Transmission contribution + // We cannot compute the actual transmission distance so we want to: + // - 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; + // If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence + const float attenuationDistance = 0.0f; lightingData.translucentBackLighting += ( - GetBackLighting(surface, lightingData, intensity, p0, -1.0f, 0.0f) + - GetBackLighting(surface, lightingData, intensity, p1, -1.0f, 0.0f) + - GetBackLighting(surface, lightingData, intensity, p2, -1.0f, 0.0f) + - GetBackLighting(surface, lightingData, intensity, p3, -1.0f, 0.0f) + - GetBackLighting(surface, lightingData, intensity, dirToLightCenter, -1.0f, 0.0f) + GetBackLighting(surface, lightingData, intensity, p0, transmissionDistance, attenuationDistance) + + GetBackLighting(surface, lightingData, intensity, p1, transmissionDistance, attenuationDistance) + + GetBackLighting(surface, lightingData, intensity, p2, transmissionDistance, attenuationDistance) + + GetBackLighting(surface, lightingData, intensity, p3, transmissionDistance, attenuationDistance) + + GetBackLighting(surface, lightingData, intensity, dirToLightCenter, transmissionDistance, attenuationDistance) ); // Calculate specular by choosing a single representative point on the light's surface based on the reflection ray From 41e8e5dc89ccf7ce6ca710e07653074c6c64d39b Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 4 Jan 2022 12:37:20 +0100 Subject: [PATCH 31/59] Add nit empty space Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 92b90b16ea..81fd8deb74 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -32,7 +32,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) lightingData.shadowCoords, surface.vertexNormal, debugInfo); - + if (o_transmission_mode == TransmissionMode::ThickObject) { transmissionDistance = DirectionalLightShadow::GetThickness(shadowIndex, lightingData.shadowCoords); From 0bae6d062fe65390d371d059e843ed9ec47caa99 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Tue, 4 Jan 2022 14:58:49 +0100 Subject: [PATCH 32/59] Remove pows and sqrts from attenuation computation + readjust attenuation parameter bounds (https://github.com/o3de/o3de/pull/6428#discussion_r776071926, https://github.com/o3de/o3de/pull/6428#discussion_r776066792) Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/EnhancedPBR.materialtype | 4 ++-- .../Feature/Common/Assets/Materials/Types/Skin.materialtype | 4 ++-- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index 77caf42834..f1d8952bb2 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1254,9 +1254,9 @@ "displayName": " Distance Attenuation", "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", "type": "float", - "defaultValue": 4.0, + "defaultValue": 0.5, "min": 0.0, - "softMax": 10.0, + "softMax": 4.0, "connection": { "type": "ShaderInput", "name": "m_distanceAttenuation" diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index d42f62d0ac..59d8be914e 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -668,9 +668,9 @@ "displayName": " Distance Attenuation", "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", "type": "float", - "defaultValue": 4.0, + "defaultValue": 0.5, "min": 0.0, - "softMax": 10.0, + "softMax": 4.0, "connection": { "type": "ShaderInput", "name": "m_distanceAttenuation" diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 87dd42fd28..47ec914815 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -90,7 +90,7 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // result = T(s) * lightIntensity * surface.albedo * E * transmissionParams.w; // Distance attenuation applied to hide artifacts due to low-res projected areas onto shadowmaps (might need some work in the future) - result *= 1.0 / pow(max(1.0, sqrt(attenuationDistance)), lightingData.distanceAttenuation + 1.0); + result /= max(1.0, attenuationDistance * attenuationDistance * lightingData.distanceAttenuation); } break; } From c580499b6fd5e4a7e5c91390677fe9e656adbe17 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Wed, 5 Jan 2022 09:03:35 +0100 Subject: [PATCH 33/59] Fix nit typo in comment Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli index 5405d2e914..d6fdc012b4 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli @@ -155,7 +155,7 @@ float DirectionalLightShadow::GetThickness(uint lightIndex, float3 shadowCoords[ { const float depthBufferValue = shadowmap.Sample(PassSrg::LinearSampler, float3(shadowCoord.xy, indexOfCascade)).r; - // Normalized thickness (avoid negative values given by to precission or shrinking offsets) + // Normalized thickness (avoid negative values given by precission errors or shrinking offsets) const float deltaDepth = max(shadowCoord.z - depthBufferValue,0.0); const float viewSpaceThickness = ViewSrg::m_directionalLightShadows[lightIndex].m_far_minus_near * deltaDepth; From 8770118b904f73ad27d0a5ceb71c067e4f5ecb9b Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Wed, 5 Jan 2022 09:06:06 +0100 Subject: [PATCH 34/59] Fix nit typo in comment v2 Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli index d6fdc012b4..f59b3cf5c8 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli @@ -155,7 +155,7 @@ float DirectionalLightShadow::GetThickness(uint lightIndex, float3 shadowCoords[ { const float depthBufferValue = shadowmap.Sample(PassSrg::LinearSampler, float3(shadowCoord.xy, indexOfCascade)).r; - // Normalized thickness (avoid negative values given by precission errors or shrinking offsets) + // Normalized thickness (avoid negative values given by precision errors or shrinking offsets) const float deltaDepth = max(shadowCoord.z - depthBufferValue,0.0); const float viewSpaceThickness = ViewSrg::m_directionalLightShadows[lightIndex].m_far_minus_near * deltaDepth; From d0bb222ce6115f308f920089e31b15fbcca4df8d Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Mon, 10 Jan 2022 18:19:39 +0100 Subject: [PATCH 35/59] Refactor thin transmission factor variable packing and visibility + use thickness to modulate transmission distance Signed-off-by: Santi Paprika --- .../Materials/Types/EnhancedPBR.materialtype | 29 ++++++----------- .../Materials/Types/EnhancedPBR_Common.azsli | 5 +-- .../Types/EnhancedPBR_ForwardPass.azsl | 11 ++++--- .../Types/EnhancedPBR_SubsurfaceState.lua | 31 +++++++++++++------ .../Common/Assets/Materials/Types/Skin.azsl | 11 ++++--- .../Assets/Materials/Types/Skin.materialtype | 29 ++++++----------- .../Assets/Materials/Types/Skin_Common.azsli | 5 +-- .../Atom/Features/PBR/BackLighting.azsli | 10 +++--- .../Surfaces/TransmissionSurfaceData.azsli | 4 ++- ...SubsurfaceTransmissionParameterFunctor.cpp | 10 +++++- .../SubsurfaceTransmissionParameterFunctor.h | 3 ++ ...TransmissionParameterFunctorSourceData.cpp | 12 ++++++- ...ceTransmissionParameterFunctorSourceData.h | 3 ++ 13 files changed, 89 insertions(+), 74 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index 3fe3569a50..9186efd385 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1154,7 +1154,7 @@ { "name": "thickness", "displayName": " Thickness", - "description": "Normalized global thickness, the maxima between this value (multiplied by thickness map if enabled) and thickness from shadow map (if applicable) will be used as final thickness of pixel", + "description": "In thick transmission mode: Normalized global thickness, the maxima between this value (multiplied by thickness map if enabled) and thickness from shadow map (if applicable) will be used as final thickness of pixel\n\nIn thin transmission mode: This value modulates the distance traversed by light inside an object.", "type": "float", "defaultValue": 0.5, "min": 0.0, @@ -1230,24 +1230,16 @@ "type": "float", "defaultValue": 0.005, "min": 0.0, - "softMax": 0.05, - "connection": { - "type": "ShaderInput", - "name": "m_shrinkFactor" - } + "softMax": 0.05 }, { - "name": "transmissionAngleBias", + "name": "transmissionNdLBias", "displayName": " Angle Bias", "description": "cosine of angle to extend below (N . L = 0) in scattering through thin objects", "type": "float", "defaultValue": 0.1, "min": -1.0, - "softMax": 1.0, - "connection": { - "type": "ShaderInput", - "name": "m_transmissionNdLBias" - } + "softMax": 1.0 }, { "name": "distanceAttenuation", @@ -1256,20 +1248,16 @@ "type": "float", "defaultValue": 0.5, "min": 0.0, - "softMax": 4.0, - "connection": { - "type": "ShaderInput", - "name": "m_distanceAttenuation" - } + "softMax": 4.0 }, { "name": "transmissionScale", "displayName": " Scale", "description": "Strength of transmission", "type": "float", - "defaultValue": 0.01, + "defaultValue": 1.0, "min": 0.0, - "softMax": 1.0 + "softMax": 5.0 } ], "detailLayerGroup": [ @@ -1594,6 +1582,9 @@ "power": "subsurfaceScattering.transmissionPower", "distortion": "subsurfaceScattering.transmissionDistortion", "attenuation": "subsurfaceScattering.transmissionAttenuation", + "shrinkFactor": "subsurfaceScattering.shrinkFactor", + "transmissionNdLBias": "subsurfaceScattering.transmissionNdLBias", + "distanceAttenuation": "subsurfaceScattering.distanceAttenuation", "tintColor": "subsurfaceScattering.transmissionTint", "thickness": "subsurfaceScattering.thickness", "enabled": "subsurfaceScattering.enableSubsurfaceScattering", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli index c15b49dc7d..786b0db4d7 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_Common.azsli @@ -93,16 +93,13 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial // Elements of m_transmissionParams: // Thick object mode: (attenuation coefficient, power, distortion, scale) - // Thin object mode: (float3 scatter distance, scale) + // Thin object mode: (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale) float4 m_transmissionParams; // (float3 TintColor, thickness) float4 m_transmissionTintThickness; Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; - float m_shrinkFactor; - float m_transmissionNdLBias; - float m_distanceAttenuation; } // Callback function for ParallaxMapping.azsli diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl index 5e02da679e..600617aa6f 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_ForwardPass.azsl @@ -243,6 +243,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float surface.transmission.tint = transmissionTintThickness.rgb; surface.transmission.thickness = transmissionTintThickness.w; surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams; + surface.transmission.scatterDistance = MaterialSrg::m_scatterDistance; // ------- Anisotropy ------- @@ -277,14 +278,14 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float // ------- Thin Object Light Transmission ------- - // Angle offset for subsurface scattering through thin objects - lightingData.transmissionNdLBias = MaterialSrg::m_transmissionNdLBias; - // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection - lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; + lightingData.shrinkFactor = surface.transmission.transmissionParams.x; + + // Angle offset for subsurface scattering through thin objects + lightingData.transmissionNdLBias = surface.transmission.transmissionParams.y; // Attenuation applied to hide artifacts due to low-res shadow maps - lightingData.distanceAttenuation = MaterialSrg::m_distanceAttenuation; + lightingData.distanceAttenuation = surface.transmission.transmissionParams.z; // ------- Clearcoat ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_SubsurfaceState.lua b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_SubsurfaceState.lua index e705d7867a..1f1979e3a9 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_SubsurfaceState.lua +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR_SubsurfaceState.lua @@ -92,23 +92,34 @@ function ProcessEditor(context) -- Update visibility for transmission... - local transmissionEnabled = TransmissionMode_None ~= context:GetMaterialPropertyValue_enum("subsurfaceScattering.transmissionMode") - - local commonTrasmissionVisibility - if(transmissionEnabled) then + local thickTransmissionEnabled = TransmissionMode_ThickObject == context:GetMaterialPropertyValue_enum("subsurfaceScattering.transmissionMode") + local thinTransmissionEnabled = TransmissionMode_ThinObject == context:GetMaterialPropertyValue_enum("subsurfaceScattering.transmissionMode") + + local commonTrasmissionVisibility = MaterialPropertyVisibility_Hidden + local thickTransmissionVisibility = MaterialPropertyVisibility_Hidden + local thinTransmissionVisibility = MaterialPropertyVisibility_Hidden + if (thickTransmissionEnabled or thinTransmissionEnabled) then commonTrasmissionVisibility = MaterialPropertyVisibility_Enabled - else - commonTrasmissionVisibility = MaterialPropertyVisibility_Hidden + + if(thickTransmissionEnabled) then + thickTransmissionVisibility = MaterialPropertyVisibility_Enabled + else -- thin transmission enabled + thinTransmissionVisibility = MaterialPropertyVisibility_Enabled + end end context:SetMaterialPropertyVisibility("subsurfaceScattering.thickness", commonTrasmissionVisibility) context:SetMaterialPropertyVisibility("subsurfaceScattering.thicknessMap", commonTrasmissionVisibility) context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionTint", commonTrasmissionVisibility) - context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionPower", commonTrasmissionVisibility) - context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionDistortion", commonTrasmissionVisibility) - context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionAttenuation", commonTrasmissionVisibility) + context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionPower", thickTransmissionVisibility) + context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionDistortion", thickTransmissionVisibility) + context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionAttenuation", thickTransmissionVisibility) + context:SetMaterialPropertyVisibility("subsurfaceScattering.shrinkFactor", thinTransmissionVisibility) + context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionNdLBias", thinTransmissionVisibility) + context:SetMaterialPropertyVisibility("subsurfaceScattering.distanceAttenuation", thinTransmissionVisibility) context:SetMaterialPropertyVisibility("subsurfaceScattering.transmissionScale", commonTrasmissionVisibility) - UpdateTextureDependentPropertyVisibility(context, transmissionEnabled, "subsurfaceScattering.thicknessMap", "subsurfaceScattering.useThicknessMap", "subsurfaceScattering.thicknessMapUv") + + UpdateTextureDependentPropertyVisibility(context, thickTransmissionEnabled or thinTransmissionEnabled, "subsurfaceScattering.thicknessMap", "subsurfaceScattering.useThicknessMap", "subsurfaceScattering.thicknessMapUv") end diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl index faa16b205a..7ec26d8342 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.azsl @@ -325,6 +325,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) surface.transmission.tint = transmissionTintThickness.rgb; surface.transmission.thickness = transmissionTintThickness.w; surface.transmission.transmissionParams = MaterialSrg::m_transmissionParams; + surface.transmission.scatterDistance = MaterialSrg::m_scatterDistance; // ------- Lighting Data ------- @@ -343,14 +344,14 @@ PbrLightingOutput SkinPS_Common(VSOutput IN) // ------- Thin Object Light Transmission ------- - // Angle offset for subsurface scattering through thin objects - lightingData.transmissionNdLBias = MaterialSrg::m_transmissionNdLBias; - // Shrink (absolute) offset towards the normal opposite direction to ensure correct shadow map projection - lightingData.shrinkFactor = MaterialSrg::m_shrinkFactor; + lightingData.shrinkFactor = surface.transmission.transmissionParams.x; + + // Angle offset for subsurface scattering through thin objects + lightingData.transmissionNdLBias = surface.transmission.transmissionParams.y; // Attenuation applied to hide artifacts due to low-res shadow maps - lightingData.distanceAttenuation = MaterialSrg::m_distanceAttenuation; + lightingData.distanceAttenuation = surface.transmission.transmissionParams.z; // ------- Occlusion ------- diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index baa48a5c44..13d2a09a2f 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -568,7 +568,7 @@ { "name": "thickness", "displayName": " Thickness", - "description": "Normalized global thickness, the maxima between this value (multiplied by thickness map if enabled) and thickness from shadow map (if applicable) will be used as final thickness of pixel", + "description": "In thick transmission mode: Normalized global thickness, the maxima between this value (multiplied by thickness map if enabled) and thickness from shadow map (if applicable) will be used as final thickness of pixel\n\nIn thin transmission mode: This value modulates the distance traversed by light inside an object.", "type": "float", "defaultValue": 0.5, "min": 0.0, @@ -644,24 +644,16 @@ "type": "float", "defaultValue": 0.005, "min": 0.0, - "softMax": 0.05, - "connection": { - "type": "ShaderInput", - "name": "m_shrinkFactor" - } + "softMax": 0.05 }, { - "name": "transmissionAngleBias", + "name": "transmissionNdLBias", "displayName": " Angle Bias", "description": "cosine of angle to extend below (N . L = 0) in scattering through thin objects", "type": "float", "defaultValue": 0.1, "min": -1.0, - "softMax": 1.0, - "connection": { - "type": "ShaderInput", - "name": "m_transmissionNdLBias" - } + "softMax": 1.0 }, { "name": "distanceAttenuation", @@ -670,20 +662,16 @@ "type": "float", "defaultValue": 0.5, "min": 0.0, - "softMax": 4.0, - "connection": { - "type": "ShaderInput", - "name": "m_distanceAttenuation" - } + "softMax": 4.0 }, { "name": "transmissionScale", "displayName": " Scale", "description": "Strength of transmission", "type": "float", - "defaultValue": 0.01, + "defaultValue": 1.0, "min": 0.0, - "softMax": 1.0 + "softMax": 5.0 } ], "wrinkleLayers": [ @@ -1050,6 +1038,9 @@ "power": "subsurfaceScattering.transmissionPower", "distortion": "subsurfaceScattering.transmissionDistortion", "attenuation": "subsurfaceScattering.transmissionAttenuation", + "shrinkFactor": "subsurfaceScattering.shrinkFactor", + "transmissionNdLBias": "subsurfaceScattering.transmissionNdLBias", + "distanceAttenuation": "subsurfaceScattering.distanceAttenuation", "tintColor": "subsurfaceScattering.transmissionTint", "thickness": "subsurfaceScattering.thickness", "enabled": "subsurfaceScattering.enableSubsurfaceScattering", diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index 630291c260..cf3bd14d8a 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -64,16 +64,13 @@ ShaderResourceGroup MaterialSrg : SRG_PerMaterial // Elements of m_transmissionParams: // Thick object mode: (attenuation coefficient, power, distortion, scale) - // Thin object mode: (float3 scatter distance, scale) + // Thin object mode: (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale) float4 m_transmissionParams; // (float3 TintColor, thickness) float4 m_transmissionTintThickness; Texture2D m_transmissionThicknessMap; uint m_transmissionThicknessMapUvIndex; - float m_shrinkFactor; - float m_transmissionNdLBias; - float m_distanceAttenuation; Texture2D m_wrinkle_baseColor_texture1; Texture2D m_wrinkle_baseColor_texture2; diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 47ec914815..863315c28c 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -75,19 +75,19 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions float3 E = surface.albedo * saturate(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight)); - // Transmission distance modulated by hardcoded constant C (could be exposed as a weight of scattering distance for transmission) - const float C = 100.0f; - float s = transmissionDistance * C; + // 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 * surface.transmission.thickness; // Use scattering color to weight thin object transmission color - const float3 invScattering = rcp(transmissionParams.xyz); + const float3 invScattering = rcp(max(surface.transmission.scatterDistance, float(0.00001))); // Albedo at front (surface point) is used to approximate irradiance at the back of the object // See observation 4 in [Jimenez J. et al, 2010] result = TransmissionKernel(s, invScattering) * lightIntensity * E * transmissionParams.w; // Alternative specific to skin translucency - // result = T(s) * lightIntensity * surface.albedo * E * transmissionParams.w; + // result = T(s) * lightIntensity * E * transmissionParams.w; // Distance attenuation applied to hide artifacts due to low-res projected areas onto shadowmaps (might need some work in the future) result /= max(1.0, attenuationDistance * attenuationDistance * lightingData.distanceAttenuation); diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli index 9b575de3ec..38916199b9 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli @@ -12,7 +12,8 @@ class TransmissionSurfaceData { float3 tint; float thickness; //!< pre baked local thickness, used for transmission - float4 transmissionParams; //!< parameters: thick mode->(attenuation coefficient, power, distortion, scale), thin mode: (float3 scatter distance, scale) + float4 transmissionParams; //!< parameters: thick mode->(attenuation coefficient, power, distortion, scale), thin mode: (shrinkFactor, transmissionNdLBias, distanceAttenuation, scale) + float3 scatterDistance; //!< scatter distance (same as in MaterialSrg) > void InitializeToZero(); }; @@ -22,4 +23,5 @@ void TransmissionSurfaceData::InitializeToZero() tint = float3(0.0f, 0.0f, 0.0f); thickness = 0.0f; transmissionParams = float4(0.0f, 0.0f, 0.0f, 0.0f); + scatterDistance = float3(0.0f, 0.0f, 0.0f); } diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.cpp b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.cpp index 8c42160fff..b5d38e25fc 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.cpp @@ -26,6 +26,9 @@ namespace AZ ->Field("m_power", &SubsurfaceTransmissionParameterFunctor::m_power) ->Field("m_distortion", &SubsurfaceTransmissionParameterFunctor::m_distortion) ->Field("m_attenuation", &SubsurfaceTransmissionParameterFunctor::m_attenuation) + ->Field("m_shrinkFactor", &SubsurfaceTransmissionParameterFunctor::m_shrinkFactor) + ->Field("m_transmissionNdLBias", &SubsurfaceTransmissionParameterFunctor::m_transmissionNdLBias) + ->Field("m_distanceAttenuation", &SubsurfaceTransmissionParameterFunctor::m_distanceAttenuation) ->Field("m_tintColor", &SubsurfaceTransmissionParameterFunctor::m_tintColor) ->Field("m_thickness", &SubsurfaceTransmissionParameterFunctor::m_thickness) ->Field("m_enabled", &SubsurfaceTransmissionParameterFunctor::m_enabled) @@ -50,6 +53,9 @@ namespace AZ auto power = context.GetMaterialPropertyValue(m_power); auto distortion = context.GetMaterialPropertyValue(m_distortion); auto attenuation = context.GetMaterialPropertyValue(m_attenuation); + auto shrinkFactor = context.GetMaterialPropertyValue(m_shrinkFactor); + auto transmissionNdLBias = context.GetMaterialPropertyValue(m_transmissionNdLBias); + auto distanceAttenuation = context.GetMaterialPropertyValue(m_distanceAttenuation); auto tintColor = context.GetMaterialPropertyValue(m_tintColor); auto thickness = context.GetMaterialPropertyValue(m_thickness); auto scatterDistanceColor = context.GetMaterialPropertyValue(m_scatterDistanceColor); @@ -67,7 +73,9 @@ namespace AZ } else { - transmissionParams.Set(scatterDistance); + transmissionParams.SetX(shrinkFactor); + transmissionParams.SetY(transmissionNdLBias); + transmissionParams.SetZ(distanceAttenuation); transmissionParams.SetW(scale); } diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.h b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.h index e412687947..17096e71a5 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.h +++ b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctor.h @@ -37,6 +37,9 @@ namespace AZ RPI::MaterialPropertyIndex m_power; RPI::MaterialPropertyIndex m_distortion; RPI::MaterialPropertyIndex m_attenuation; + RPI::MaterialPropertyIndex m_shrinkFactor; + RPI::MaterialPropertyIndex m_transmissionNdLBias; + RPI::MaterialPropertyIndex m_distanceAttenuation; RPI::MaterialPropertyIndex m_tintColor; RPI::MaterialPropertyIndex m_thickness; RPI::MaterialPropertyIndex m_enabled; diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp index a8ba40fb7f..140dfe8c6b 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp @@ -25,6 +25,9 @@ namespace AZ ->Field("power", &SubsurfaceTransmissionParameterFunctorSourceData::m_power) ->Field("distortion", &SubsurfaceTransmissionParameterFunctorSourceData::m_distortion) ->Field("attenuation", &SubsurfaceTransmissionParameterFunctorSourceData::m_attenuation) + ->Field("shrinkFactor", &SubsurfaceTransmissionParameterFunctorSourceData::m_shrinkFactor) + ->Field("transmissionNdLBias", &SubsurfaceTransmissionParameterFunctorSourceData::m_transmissionNdLBias) + ->Field("distanceAttenuation", &SubsurfaceTransmissionParameterFunctorSourceData::m_distanceAttenuation) ->Field("tintColor", &SubsurfaceTransmissionParameterFunctorSourceData::m_tintColor) ->Field("thickness", &SubsurfaceTransmissionParameterFunctorSourceData::m_thickness) ->Field("enabled", &SubsurfaceTransmissionParameterFunctorSourceData::m_enabled) @@ -48,6 +51,9 @@ namespace AZ functor->m_power = context.FindMaterialPropertyIndex(Name{ m_power }); functor->m_distortion = context.FindMaterialPropertyIndex(Name{ m_distortion }); functor->m_attenuation = context.FindMaterialPropertyIndex(Name{ m_attenuation }); + functor->m_shrinkFactor = context.FindMaterialPropertyIndex(Name{ m_shrinkFactor }); + functor->m_transmissionNdLBias = context.FindMaterialPropertyIndex(Name{ m_transmissionNdLBias }); + functor->m_distanceAttenuation = context.FindMaterialPropertyIndex(Name{ m_distanceAttenuation }); functor->m_tintColor = context.FindMaterialPropertyIndex(Name{ m_tintColor }); functor->m_thickness = context.FindMaterialPropertyIndex(Name{ m_thickness }); functor->m_enabled = context.FindMaterialPropertyIndex(Name{ m_enabled }); @@ -56,7 +62,8 @@ namespace AZ if (functor->m_mode.IsNull() || functor->m_scale.IsNull() || functor->m_power.IsNull() || functor->m_distortion.IsNull() || functor->m_tintColor.IsNull() || functor->m_thickness.IsNull() || functor->m_enabled.IsNull() || functor->m_attenuation.IsNull() || functor->m_scatterDistanceColor.IsNull() || - functor->m_scatterDistanceIntensity.IsNull()) + functor->m_scatterDistanceIntensity.IsNull() || functor->m_shrinkFactor.IsNull() || functor->m_transmissionNdLBias.IsNull() || + functor->m_distanceAttenuation.IsNull()) { return Failure(); } @@ -66,6 +73,9 @@ namespace AZ AddMaterialPropertyDependency(functor, functor->m_power); AddMaterialPropertyDependency(functor, functor->m_distortion); AddMaterialPropertyDependency(functor, functor->m_attenuation); + AddMaterialPropertyDependency(functor, functor->m_shrinkFactor); + AddMaterialPropertyDependency(functor, functor->m_transmissionNdLBias); + AddMaterialPropertyDependency(functor, functor->m_distanceAttenuation); AddMaterialPropertyDependency(functor, functor->m_tintColor); AddMaterialPropertyDependency(functor, functor->m_thickness); AddMaterialPropertyDependency(functor, functor->m_enabled); diff --git a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.h b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.h index 9d074551c3..8d058243fa 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.h +++ b/Gems/Atom/Feature/Common/Code/Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.h @@ -36,6 +36,9 @@ namespace AZ AZStd::string m_power; //!< material property for thick transmission power AZStd::string m_distortion; //!< material property for thick transmission distortion towards surface normal AZStd::string m_attenuation; //!< material property for thick transmission volume absorption + AZStd::string m_shrinkFactor; //!< material property for thin transmission position shrink factor towards surface normal + AZStd::string m_transmissionNdLBias; //!< material property for thin transmission bias of the NdL value + AZStd::string m_distanceAttenuation; //!< material property for thin transmission attenuation with distance AZStd::string m_tintColor; //!< material property for transmission tint AZStd::string m_thickness; //!< material property for normalized object thickness AZStd::string m_enabled; //!< material property for subsurface scattering feature switch (enabled or disabled) From 1087e45ce3f8cb13669fd049957c6b52c9d653e9 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Wed, 2 Feb 2022 18:42:29 +0100 Subject: [PATCH 36/59] Fix typo (https://github.com/o3de/o3de/pull/6428#discussion_r797667772) Signed-off-by: Santi Paprika --- .../Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli index 5baacf4756..e6bdc13293 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli @@ -275,7 +275,7 @@ float ProjectedShadow::GetThickness() /*LOD=*/0 ).r; - // Denormalized thickness (avoid negative values given by to precission or shrinking offsets) + // Denormalized thickness (avoid negative values given by precision errors or shrinking offsets) const float viewSpaceThickness = max(UnprojectDepth(m_shadowIndex, depthValue) - UnprojectDepth(m_shadowIndex, m_shadowPosition.z), 0.0); return viewSpaceThickness; } From 9c60bd008cbda990a237a54eaf71244cca141638 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Wed, 2 Feb 2022 18:47:11 +0100 Subject: [PATCH 37/59] Enable human skin profile via preprocessor define (https://github.com/o3de/o3de/pull/6428#discussion_r797699927) Signed-off-by: Santi Paprika --- .../Assets/Materials/Types/Skin_Common.azsli | 4 ++++ .../Atom/Features/PBR/BackLighting.azsli | 17 ++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli index cf3bd14d8a..9b3c29e96d 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin_Common.azsli @@ -22,6 +22,10 @@ #include "MaterialInputs/UvSetCount.azsli" #include "MaterialInputs/DetailMapsInput.azsli" +// Use human skin profile for thin object transmission (if enabled) +// Remove this line to use a custom profile based on the scatter color +#define USE_HUMAN_SKIN_PROFILE + ShaderResourceGroup MaterialSrg : SRG_PerMaterial { // Auto-generate material SRG fields for common inputs diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 863315c28c..82a3038054 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -23,7 +23,7 @@ float3 TransmissionKernel(float t, float3 s) return 0.25 * (1.0 / exp(exponent) + 3.0 / exp(exponent / 3.0)); } -// [specific profile for SKIN (not used ATM, replaced by TransmissionKernel)] +// [specific profile for human skin] // Analytical integation (approximation) of diffusion profile over radius, could be precomputed in a LUT // From d'Eon and Luebke (https://developer.nvidia.com/gpugems/gpugems3/part-iii-rendering/chapter-14-advanced-techniques-realistic-real-time-skin, section 14.4.7) float3 T(float s) @@ -72,6 +72,8 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI } // Irradiance arround surface point. + // Albedo at front (surface point) is used to approximate irradiance at the back of the object + // See observation 4 in [Jimenez J. et al, 2010] // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions float3 E = surface.albedo * saturate(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight)); @@ -82,13 +84,14 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI // Use scattering color to weight thin object transmission color const float3 invScattering = rcp(max(surface.transmission.scatterDistance, float(0.00001))); - // Albedo at front (surface point) is used to approximate irradiance at the back of the object - // See observation 4 in [Jimenez J. et al, 2010] +#ifndef USE_HUMAN_SKIN_PROFILE + // Generic profile based on scatter color result = TransmissionKernel(s, invScattering) * lightIntensity * E * transmissionParams.w; - - // Alternative specific to skin translucency - // result = T(s) * lightIntensity * E * transmissionParams.w; - +#else // USE_HUMAN_SKIN_PROFILE + // Profile specific to human skin + result = T(s) * lightIntensity * E * transmissionParams.w; +#endif + // Distance attenuation applied to hide artifacts due to low-res projected areas onto shadowmaps (might need some work in the future) result /= max(1.0, attenuationDistance * attenuationDistance * lightingData.distanceAttenuation); } From 024933d4a177997467dc97271610dcb5f450363b Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Fri, 4 Feb 2022 12:15:45 +0100 Subject: [PATCH 38/59] Improve descriptions and comments (https://github.com/o3de/o3de/pull/6428#discussion_r799207891, https://github.com/o3de/o3de/pull/6428#discussion_r799213620) Signed-off-by: Santi Paprika --- .../Common/Assets/Materials/Types/EnhancedPBR.materialtype | 2 +- .../Feature/Common/Assets/Materials/Types/Skin.materialtype | 2 +- .../Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli | 5 ++--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype index 9186efd385..846c3d0f34 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/EnhancedPBR.materialtype @@ -1244,7 +1244,7 @@ { "name": "distanceAttenuation", "displayName": " Distance Attenuation", - "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", + "description": "Attenuation of the transmission effect, used to hide artifacts due to low-res shadow maps\nFor directional lights: attenuation proportional to the distance from the object to the camera.\nFor other light sources: attenuation proportional to the distance from the object to the light source.", "type": "float", "defaultValue": 0.5, "min": 0.0, diff --git a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype index 13d2a09a2f..1edbd7e505 100644 --- a/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype +++ b/Gems/Atom/Feature/Common/Assets/Materials/Types/Skin.materialtype @@ -658,7 +658,7 @@ { "name": "distanceAttenuation", "displayName": " Distance Attenuation", - "description": "Attenuation applied to hide artifacts due to low-res shadow maps (e.g. objects far to the camera when using directional lights or objects far to the light when using sphere/disk lights", + "description": "Attenuation of the transmission effect, used to hide artifacts due to low-res shadow maps\nFor directional lights: attenuation proportional to the distance from the object to the camera.\nFor other light sources: attenuation proportional to the distance from the object to the light source.", "type": "float", "defaultValue": 0.5, "min": 0.0, diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli index 82a3038054..e43f2729b7 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/BackLighting.azsli @@ -72,9 +72,8 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI } // Irradiance arround surface point. - // Albedo at front (surface point) is used to approximate irradiance at the back of the object - // See observation 4 in [Jimenez J. et al, 2010] - // Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions + // 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 smooth transition regions float3 E = surface.albedo * saturate(lightingData.transmissionNdLBias + 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) From c173fd9357dfa3d8ef22dd3efd81f505773727d5 Mon Sep 17 00:00:00 2001 From: Santi Paprika Date: Fri, 4 Feb 2022 17:34:39 +0100 Subject: [PATCH 39/59] Remove division by constant in distance attenuation for DirectionalLight (https://github.com/o3de/o3de/pull/6428#discussion_r799216516) Signed-off-by: Santi Paprika --- .../ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli index 25f0545037..03c48b6232 100644 --- a/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli +++ b/Gems/Atom/Feature/Common/Assets/ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli @@ -80,7 +80,7 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData) } // Transmission contribution - lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance, camToSurfDist/2.0); + lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight, currentTransmissionDistance, camToSurfDist); lightingData.diffuseLighting += GetDiffuseLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; lightingData.specularLighting += GetSpecularLighting(surface, lightingData, light.m_rgbIntensityLux, dirToLight) * currentLitRatio; From 36bcf0ca9e5ce158331b31278ced57e6f395fb21 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Fri, 4 Feb 2022 17:44:28 -0600 Subject: [PATCH 40/59] Atom Tools: fix gem autoload settings registry files Signed-off-by: Guthrie Adams --- Registry/gem_autoload.materialeditor.setreg | 2 +- Registry/gem_autoload.shadermanagementconsole.setreg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Registry/gem_autoload.materialeditor.setreg b/Registry/gem_autoload.materialeditor.setreg index 653cc80056..293fcab1b1 100644 --- a/Registry/gem_autoload.materialeditor.setreg +++ b/Registry/gem_autoload.materialeditor.setreg @@ -28,7 +28,7 @@ "ScriptCanvas.Editor": { "AutoLoad": false }, - "ScriptCanvasDeveloper": { + "ScriptCanvasDeveloper.Editor": { "AutoLoad": false }, "ScriptCanvasPhysics": { diff --git a/Registry/gem_autoload.shadermanagementconsole.setreg b/Registry/gem_autoload.shadermanagementconsole.setreg index 653cc80056..293fcab1b1 100644 --- a/Registry/gem_autoload.shadermanagementconsole.setreg +++ b/Registry/gem_autoload.shadermanagementconsole.setreg @@ -28,7 +28,7 @@ "ScriptCanvas.Editor": { "AutoLoad": false }, - "ScriptCanvasDeveloper": { + "ScriptCanvasDeveloper.Editor": { "AutoLoad": false }, "ScriptCanvasPhysics": { From 1497250ff599f4b9add70d823b6e6fbd68dc60d3 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Sun, 6 Feb 2022 05:49:11 -0600 Subject: [PATCH 41/59] Atom Tools: Move common asset browser interactions to shared class in ATF Moved the class for common asset browser interactions for source files, folders, and source control to atom tools framework. Added a function to register custom actions Deleted unnecessary document settings class in favor of settings registry Signed-off-by: Guthrie Adams --- .../AtomToolsAssetBrowserInteractions.h | 65 +++++ .../AtomToolsAssetBrowserInteractions.cpp} | 222 ++++---------- .../Code/atomtoolsframework_files.cmake | 2 + .../Document/MaterialDocumentSettings.cpp | 47 --- .../Document/MaterialDocumentSettings.h | 30 -- .../Code/Source/MaterialEditorApplication.cpp | 85 +++++- .../Code/Source/MaterialEditorApplication.h | 4 +- .../CreateMaterialDialog.cpp | 8 +- .../MaterialEditorBrowserInteractions.h | 58 ---- .../Source/Window/MaterialEditorWindow.cpp | 2 +- .../Window/SettingsDialog/SettingsWidget.cpp | 33 +-- .../Window/SettingsDialog/SettingsWidget.h | 13 - .../Code/materialeditor_files.cmake | 4 - .../ShaderManagementConsoleApplication.cpp | 51 +++- .../ShaderManagementConsoleApplication.h | 4 +- ...erManagementConsoleBrowserInteractions.cpp | 273 ------------------ ...aderManagementConsoleBrowserInteractions.h | 58 ---- .../Code/shadermanagementconsole_files.cmake | 2 - 18 files changed, 269 insertions(+), 692 deletions(-) create mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/AssetBrowser/AtomToolsAssetBrowserInteractions.h rename Gems/Atom/Tools/{MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp => AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowserInteractions.cpp} (52%) delete mode 100644 Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.cpp delete mode 100644 Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.h delete mode 100644 Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h delete mode 100644 Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp delete mode 100644 Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.h diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/AssetBrowser/AtomToolsAssetBrowserInteractions.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/AssetBrowser/AtomToolsAssetBrowserInteractions.h new file mode 100644 index 0000000000..1892b1ca0c --- /dev/null +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/AssetBrowser/AtomToolsAssetBrowserInteractions.h @@ -0,0 +1,65 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include +#include + +class QWidget; +class QMenu; +class QAction; + +namespace AzToolsFramework +{ + namespace AssetBrowser + { + class AssetBrowserEntry; + } // namespace AssetBrowser +} // namespace AzToolsFramework + +namespace AtomToolsFramework +{ + //! Provides common asset browser interactions, source control integration, and functionality to add custom menu actions + class AtomToolsAssetBrowserInteractions : public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler + { + public: + AZ_CLASS_ALLOCATOR(AtomToolsAssetBrowserInteractions, AZ::SystemAllocator, 0); + + AtomToolsAssetBrowserInteractions(); + ~AtomToolsAssetBrowserInteractions(); + + using AssetBrowserEntryVector = AZStd::vector; + using FilterCallback = AZStd::function; + using ActionCallback = AZStd::function; + + //! Add a filter and handler for custom context menu entries that will be added to the top of the context menu + void RegisterContextMenuActions(const FilterCallback& filterCallback, const ActionCallback& actionCallback); + + private: + //! AssetBrowserInteractionNotificationBus::Handler overrides... + void AddContextMenuActions(QWidget* caller, QMenu* menu, const AssetBrowserEntryVector& entries) override; + + void AddContextMenuActionsForSourceEntries( + QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); + void AddContextMenuActionsForFolderEntries( + QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); + void AddContextMenuActionsForAllEntries( + QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); + void AddContextMenuActionsForSourceControl( + QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); + void UpdateContextMenuActionsForSourceControl(bool success, AzToolsFramework::SourceControlFileInfo info); + + QWidget* m_caller = {}; + QAction* m_addAction = {}; + QAction* m_checkOutAction = {}; + QAction* m_undoCheckOutAction = {}; + QAction* m_getLatestAction = {}; + AZStd::vector> m_contextMenuCallbacks; + }; +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowserInteractions.cpp similarity index 52% rename from Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp rename to Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowserInteractions.cpp index 435d1f6f12..5b65356aab 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowserInteractions.cpp @@ -7,44 +7,47 @@ */ #include -#include -#include -#include -#include +#include #include #include #include #include +#include #include #include #include #include -#include -#include #include #include #include +#include #include +#include #include #include #include -namespace MaterialEditor +namespace AtomToolsFramework { - MaterialEditorBrowserInteractions::MaterialEditorBrowserInteractions() + AtomToolsAssetBrowserInteractions::AtomToolsAssetBrowserInteractions() { - using namespace AzToolsFramework::AssetBrowser; - AssetBrowserInteractionNotificationBus::Handler::BusConnect(); } - MaterialEditorBrowserInteractions::~MaterialEditorBrowserInteractions() + AtomToolsAssetBrowserInteractions::~AtomToolsAssetBrowserInteractions() { AssetBrowserInteractionNotificationBus::Handler::BusDisconnect(); } - void MaterialEditorBrowserInteractions::AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector& entries) + void AtomToolsAssetBrowserInteractions::RegisterContextMenuActions( + const FilterCallback& filterCallback, const ActionCallback& actionCallback) + { + m_contextMenuCallbacks.emplace_back(filterCallback, actionCallback); + } + + void AtomToolsAssetBrowserInteractions::AddContextMenuActions( + QWidget* caller, QMenu* menu, const AssetBrowserEntryVector& entries) { AssetBrowserEntry* entry = entries.empty() ? nullptr : entries.front(); if (!entry) @@ -53,79 +56,33 @@ namespace MaterialEditor } m_caller = caller; - QObject::connect(m_caller, &QObject::destroyed, [this]() - { - m_caller = nullptr; - }); + QObject::connect(m_caller, &QObject::destroyed, [this]() { m_caller = nullptr; }); - AddGenericContextMenuActions(caller, menu, entry); + // Add all of the custom context menu entries first + for (const auto& contextMenuCallbackPair : m_contextMenuCallbacks) + { + if (contextMenuCallbackPair.first(entries)) + { + contextMenuCallbackPair.second(caller, menu, entries); + } + } if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source) { - const auto source = azalias_cast(entry); - if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), AZ::RPI::MaterialSourceData::Extension)) - { - AddContextMenuActionsForMaterialSource(caller, menu, source); - } - else if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), AZ::RPI::MaterialTypeSourceData::Extension)) - { - AddContextMenuActionsForMaterialTypeSource(caller, menu, source); - } - else - { - AddContextMenuActionsForOtherSource(caller, menu, source); - } + AddContextMenuActionsForSourceEntries(caller, menu, entry); } else if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Folder) { - const auto folder = azalias_cast(entry); - AddContextMenuActionsForFolder(caller, menu, folder); + AddContextMenuActionsForFolderEntries(caller, menu, entry); } - } - - void MaterialEditorBrowserInteractions::AddGenericContextMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) - { - menu->addAction(QObject::tr("Copy Name To Clipboard"), [=]() - { - QApplication::clipboard()->setText(entry->GetName().c_str()); - }); - menu->addAction(QObject::tr("Copy Path To Clipboard"), [=]() - { - QApplication::clipboard()->setText(entry->GetFullPath().c_str()); - }); + + AddContextMenuActionsForAllEntries(caller, menu, entry); + AddContextMenuActionsForSourceControl(caller, menu, entry); } - void MaterialEditorBrowserInteractions::AddContextMenuActionsForMaterialTypeSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) + void AtomToolsAssetBrowserInteractions::AddContextMenuActionsForSourceEntries( + [[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) { - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - menu->addSeparator(); - - menu->addAction("Create Material...", [entry]() - { - const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::Utils::GetProjectPath().c_str()) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + - AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); - - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, - entry->GetFullPath(), AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); - }); - - AddPerforceMenuActions(caller, menu, entry); - } - - void MaterialEditorBrowserInteractions::AddContextMenuActionsForOtherSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) - { - menu->addAction("Open", [entry]() - { - QDesktopServices::openUrl(QUrl::fromLocalFile(entry->GetFullPath().c_str())); - }); - menu->addAction("Duplicate...", [entry]() { const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); @@ -142,79 +99,26 @@ namespace MaterialEditor } }); - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - AddPerforceMenuActions(caller, menu, entry); - } - - void MaterialEditorBrowserInteractions::AddContextMenuActionsForMaterialSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) - { - menu->addAction("Open", [entry]() - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, entry->GetFullPath()); - }); - - menu->addAction("Duplicate...", [entry]() - { - const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); - if (!duplicateFileInfo.absoluteFilePath().isEmpty()) + menu->addAction("Run Python on File...", [caller, entry]() + { + const QString script = QFileDialog::getOpenFileName( + caller, QObject::tr("Run Script"), QString(AZ::Utils::GetProjectPath().c_str()), QString("*.py")); + if (!script.isEmpty()) { - if (QFile::copy(entry->GetFullPath().c_str(), duplicateFileInfo.absoluteFilePath())) - { - QFile::setPermissions(duplicateFileInfo.absoluteFilePath(), QFile::ReadOther | QFile::WriteOther); - - // Auto add file to source control - AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, - duplicateFileInfo.absoluteFilePath().toUtf8().constData(), true, [](bool, const AzToolsFramework::SourceControlFileInfo&) {}); - } + AZStd::vector pythonArgs{ entry->GetFullPath() }; + AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast( + &AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs, script.toUtf8().constData(), + pythonArgs); } }); - - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - menu->addSeparator(); - - menu->addAction("Create Child Material...", [entry]() - { - const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( - QString(AZ::Utils::GetProjectPath().c_str()) + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + - AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + - AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); - - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, - entry->GetFullPath(), AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); - }); - - menu->addSeparator(); - - QAction* openParentAction = menu->addAction("Open Parent Material", [entry]() - { - AZ_UNUSED(entry); - // ToDo - }); - openParentAction->setEnabled(false); - - AddPerforceMenuActions(caller, menu, entry); } - void MaterialEditorBrowserInteractions::AddContextMenuActionsForFolder(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::FolderAssetBrowserEntry* entry) + void AtomToolsAssetBrowserInteractions::AddContextMenuActionsForFolderEntries( + QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) { - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() + menu->addAction(QObject::tr("Create new sub folder..."), [caller, entry]() { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - QAction* createFolderAction = menu->addAction(QObject::tr("Create new sub folder...")); - QObject::connect(createFolderAction, &QAction::triggered, caller, [caller, entry]() - { - bool ok; + bool ok = false; QString newFolderName = QInputDialog::getText(caller, "Enter new folder name", "name:", QLineEdit::Normal, "NewFolder", &ok); if (ok) { @@ -242,27 +146,29 @@ namespace MaterialEditor } } }); + } + + void AtomToolsAssetBrowserInteractions::AddContextMenuActionsForAllEntries( + [[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) + { + menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() + { + AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); + }); menu->addSeparator(); - - QAction* createMaterialAction = menu->addAction(QObject::tr("Create Material...")); - QObject::connect(createMaterialAction, &QAction::triggered, caller, [caller, entry]() + menu->addAction(QObject::tr("Copy Name To Clipboard"), [=]() { - CreateMaterialDialog createDialog(entry->GetFullPath().c_str(), caller); - createDialog.adjustSize(); - - if (createDialog.exec() == QDialog::Accepted && - !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && - !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, - createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), - createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); - } + QApplication::clipboard()->setText(entry->GetName().c_str()); + }); + menu->addAction(QObject::tr("Copy Path To Clipboard"), [=]() + { + QApplication::clipboard()->setText(entry->GetFullPath().c_str()); }); } - void MaterialEditorBrowserInteractions::AddPerforceMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) + void AtomToolsAssetBrowserInteractions::AddContextMenuActionsForSourceControl( + [[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) { using namespace AzToolsFramework; @@ -282,7 +188,7 @@ namespace MaterialEditor QMenu::connect(sourceControlMenu, &QMenu::aboutToShow, [this, path]() { SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::GetFileInfo, path.c_str(), - [this](bool success, const SourceControlFileInfo& info) { UpdateSourceControlActions(success, info); }); + [this](bool success, const SourceControlFileInfo& info) { UpdateContextMenuActionsForSourceControl(success, info); }); }); // add get latest action @@ -344,7 +250,7 @@ namespace MaterialEditor } } - void MaterialEditorBrowserInteractions::UpdateSourceControlActions(bool success, AzToolsFramework::SourceControlFileInfo info) + void AtomToolsAssetBrowserInteractions::UpdateContextMenuActionsForSourceControl(bool success, AzToolsFramework::SourceControlFileInfo info) { if (!success && m_caller) { @@ -367,4 +273,4 @@ namespace MaterialEditor m_undoCheckOutAction->setEnabled(info.IsManaged() && !info.IsReadOnly()); } } -} // namespace MaterialEditor +} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake index 1dbfb7b686..b7f9882e92 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake @@ -9,6 +9,7 @@ set(FILES Include/AtomToolsFramework/Application/AtomToolsApplication.h Include/AtomToolsFramework/AssetBrowser/AtomToolsAssetBrowser.h + Include/AtomToolsFramework/AssetBrowser/AtomToolsAssetBrowserInteractions.h Include/AtomToolsFramework/AssetGridDialog/AssetGridDialog.h Include/AtomToolsFramework/Communication/LocalServer.h Include/AtomToolsFramework/Communication/LocalSocket.h @@ -44,6 +45,7 @@ set(FILES Source/AssetBrowser/AtomToolsAssetBrowser.cpp Source/AssetBrowser/AtomToolsAssetBrowser.qrc Source/AssetBrowser/AtomToolsAssetBrowser.ui + Source/AssetBrowser/AtomToolsAssetBrowserInteractions.cpp Source/AssetGridDialog/AssetGridDialog.cpp Source/AssetGridDialog/AssetGridDialog.ui Source/Communication/LocalServer.cpp diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.cpp deleted file mode 100644 index 256497de54..0000000000 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include - -namespace MaterialEditor -{ - void MaterialDocumentSettings::Reflect(AZ::ReflectContext* context) - { - if (auto serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ->Field("defaultMaterialTypeName", &MaterialDocumentSettings::m_defaultMaterialTypeName) - ; - - if (auto editContext = serializeContext->GetEditContext()) - { - editContext->Class( - "MaterialDocumentSettings", "") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->DataElement(AZ::Edit::UIHandlers::Default, &MaterialDocumentSettings::m_defaultMaterialTypeName, "Default Material Type Name", "") - ; - } - } - - if (auto behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class("MaterialDocumentSettings") - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ->Attribute(AZ::Script::Attributes::Category, "Editor") - ->Attribute(AZ::Script::Attributes::Module, "materialeditor") - ->Constructor() - ->Constructor() - ->Property("defaultMaterialTypeName", BehaviorValueProperty(&MaterialDocumentSettings::m_defaultMaterialTypeName)) - ; - } - } -} // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.h deleted file mode 100644 index 5f39c50717..0000000000 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Document/MaterialDocumentSettings.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#endif - -namespace MaterialEditor -{ - struct MaterialDocumentSettings - : public AZ::UserSettings - { - AZ_RTTI(MaterialDocumentSettings, "{12E8461F-65AD-4AD2-8A1D-82C3B1183522}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(MaterialDocumentSettings, AZ::SystemAllocator, 0); - - static void Reflect(AZ::ReflectContext* context); - - AZStd::string m_defaultMaterialTypeName = "StandardPBR"; - }; -} // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp index 686715017c..17453bf7af 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.cpp @@ -6,21 +6,32 @@ * */ +#include +#include +#include #include +#include #include #include #include #include +#include #include +#include #include #include -#include #include #include #include +#include #include #include +#include +#include +#include +#include + void InitMaterialEditorResources() { // Must register qt resources from other modules @@ -56,7 +67,6 @@ namespace MaterialEditor void MaterialEditorApplication::Reflect(AZ::ReflectContext* context) { Base::Reflect(context); - MaterialDocumentSettings::Reflect(context); MaterialEditorWindowSettings::Reflect(context); if (AZ::BehaviorContext* behaviorContext = azrtti_cast(context)) @@ -112,8 +122,77 @@ namespace MaterialEditor void MaterialEditorApplication::CreateMainWindow() { - m_materialEditorBrowserInteractions.reset(aznew MaterialEditorBrowserInteractions); m_window.reset(aznew MaterialEditorWindow); + m_assetBrowserInteractions.reset(aznew AtomToolsFramework::AtomToolsAssetBrowserInteractions); + m_assetBrowserInteractions->RegisterContextMenuActions( + [](const AtomToolsFramework::AtomToolsAssetBrowserInteractions::AssetBrowserEntryVector& entries) + { + return entries.front()->GetEntryType() == AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntryType::Source; + }, + []([[maybe_unused]] QWidget* caller, QMenu* menu, const AtomToolsFramework::AtomToolsAssetBrowserInteractions::AssetBrowserEntryVector& entries) + { + const bool isMaterial = AzFramework::StringFunc::Path::IsExtension( + entries.front()->GetFullPath().c_str(), AZ::RPI::MaterialSourceData::Extension); + const bool isMaterialType = AzFramework::StringFunc::Path::IsExtension( + entries.front()->GetFullPath().c_str(), AZ::RPI::MaterialTypeSourceData::Extension); + if (isMaterial || isMaterialType) + { + menu->addAction(QObject::tr("Open"), [entries]() + { + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast( + &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, + entries.front()->GetFullPath()); + }); + + const QString createActionName = + isMaterialType ? QObject::tr("Create Material...") : QObject::tr("Create Child Material..."); + + menu->addAction(createActionName, [entries]() + { + const QString defaultPath = AtomToolsFramework::GetUniqueFileInfo( + QString(AZ::Utils::GetProjectPath().c_str()) + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "Assets" + + AZ_CORRECT_FILESYSTEM_SEPARATOR + "untitled." + + AZ::RPI::MaterialSourceData::Extension).absoluteFilePath(); + + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast( + &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, + entries.front()->GetFullPath(), + AtomToolsFramework::GetSaveFileInfo(defaultPath).absoluteFilePath().toUtf8().constData()); + }); + } + else + { + menu->addAction(QObject::tr("Open"), [entries]() + { + QDesktopServices::openUrl(QUrl::fromLocalFile(entries.front()->GetFullPath().c_str())); + }); + } + }); + + m_assetBrowserInteractions->RegisterContextMenuActions( + [](const AtomToolsFramework::AtomToolsAssetBrowserInteractions::AssetBrowserEntryVector& entries) + { + return entries.front()->GetEntryType() == AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntryType::Folder; + }, + [](QWidget* caller, QMenu* menu, const AtomToolsFramework::AtomToolsAssetBrowserInteractions::AssetBrowserEntryVector& entries) + { + menu->addAction(QObject::tr("Create Material..."), [caller, entries]() + { + CreateMaterialDialog createDialog(entries.front()->GetFullPath().c_str(), caller); + createDialog.adjustSize(); + + if (createDialog.exec() == QDialog::Accepted && + !createDialog.m_materialFileInfo.absoluteFilePath().isEmpty() && + !createDialog.m_materialTypeFileInfo.absoluteFilePath().isEmpty()) + { + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast( + &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::CreateDocumentFromFile, + createDialog.m_materialTypeFileInfo.absoluteFilePath().toUtf8().constData(), + createDialog.m_materialFileInfo.absoluteFilePath().toUtf8().constData()); + } + }); + }); } void MaterialEditorApplication::DestroyMainWindow() diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h index 060353e396..0cf4354f6c 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/MaterialEditorApplication.h @@ -8,10 +8,10 @@ #pragma once +#include #include #include #include -#include #include namespace MaterialEditor @@ -49,6 +49,6 @@ namespace MaterialEditor QWidget* GetAppMainWindow() override; AZStd::unique_ptr m_window; - AZStd::unique_ptr m_materialEditorBrowserInteractions; + AZStd::unique_ptr m_assetBrowserInteractions; }; } // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp index 0e6cf565e3..dead08dde9 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/CreateMaterialDialog/CreateMaterialDialog.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include namespace MaterialEditor @@ -65,11 +64,10 @@ namespace MaterialEditor m_ui->m_materialTypeComboBox->model()->sort(0, Qt::AscendingOrder); - // Select the default material type from settings - auto settings = - AZ::UserSettings::CreateFind(AZ::Crc32("MaterialDocumentSettings"), AZ::UserSettings::CT_GLOBAL); + const AZStd::string defaultMaterialType = AtomToolsFramework::GetSettingOrDefault( + "/O3DE/Atom/MaterialEditor/CreateMaterialDialog/DefaultMaterialType", "StandardPBR"); - const int index = m_ui->m_materialTypeComboBox->findText(settings->m_defaultMaterialTypeName.c_str()); + const int index = m_ui->m_materialTypeComboBox->findText(defaultMaterialType.c_str()); if (index >= 0) { m_ui->m_materialTypeComboBox->setCurrentIndex(index); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h deleted file mode 100644 index 31043ef0a9..0000000000 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorBrowserInteractions.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include -#include - -class QWidget; -class QMenu; -class QAction; - -namespace AzToolsFramework -{ - namespace AssetBrowser - { - class AssetBrowserEntry; - class SourceAssetBrowserEntry; - class FolderAssetBrowserEntry; - } -} - -namespace MaterialEditor -{ - class MaterialEditorBrowserInteractions - : public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler - { - public: - AZ_CLASS_ALLOCATOR(MaterialEditorBrowserInteractions, AZ::SystemAllocator, 0); - - MaterialEditorBrowserInteractions(); - ~MaterialEditorBrowserInteractions(); - - private: - //! AssetBrowserInteractionNotificationBus::Handler overrides... - void AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector& entries) override; - - void AddGenericContextMenuActions(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); - void AddContextMenuActionsForOtherSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry); - void AddContextMenuActionsForMaterialSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry); - void AddContextMenuActionsForMaterialTypeSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry); - void AddContextMenuActionsForFolder(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::FolderAssetBrowserEntry* entry); - void AddPerforceMenuActions(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); - - void UpdateSourceControlActions(bool success, AzToolsFramework::SourceControlFileInfo info); - - QWidget* m_caller = nullptr; - QAction* m_addAction = nullptr; - QAction* m_checkOutAction = nullptr; - QAction* m_undoCheckOutAction = nullptr; - QAction* m_getLatestAction = nullptr; - }; -} // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp index bed28d146c..da742d498d 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/MaterialEditorWindow.cpp @@ -146,7 +146,7 @@ namespace MaterialEditor bool MaterialEditorWindow::GetCreateDocumentParams(AZStd::string& openPath, AZStd::string& savePath) { - CreateMaterialDialog createDialog(this); + CreateMaterialDialog createDialog(openPath.c_str(), this); createDialog.adjustSize(); if (createDialog.exec() == QDialog::Accepted && diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp index 2a061a2ed6..357dfc37e0 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp @@ -14,8 +14,6 @@ namespace MaterialEditor SettingsWidget::SettingsWidget(QWidget* parent) : AtomToolsFramework::InspectorWidget(parent) { - m_documentSettings = - AZ::UserSettings::CreateFind(AZ_CRC_CE("MaterialDocumentSettings"), AZ::UserSettings::CT_GLOBAL); m_documentSystemSettings = AZ::UserSettings::CreateFind( AZ_CRC_CE("AtomToolsDocumentSystemSettings"), AZ::UserSettings::CT_GLOBAL); } @@ -29,23 +27,9 @@ namespace MaterialEditor { AddGroupsBegin(); AddDocumentSystemSettingsGroup(); - AddDocumentSettingsGroup(); AddGroupsEnd(); } - void SettingsWidget::AddDocumentSettingsGroup() - { - const AZStd::string groupName = "documentSettings"; - const AZStd::string groupDisplayName = "Document Settings"; - const AZStd::string groupDescription = "Document Settings"; - - const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentSettingsGroup")); - AddGroup( - groupName, groupDisplayName, groupDescription, - new AtomToolsFramework::InspectorPropertyGroupWidget( - m_documentSettings.get(), nullptr, m_documentSettings->TYPEINFO_Uuid(), this, this, saveStateKey)); - } - void SettingsWidget::AddDocumentSystemSettingsGroup() { const AZStd::string groupName = "documentSystemSettings"; @@ -56,7 +40,7 @@ namespace MaterialEditor AddGroup( groupName, groupDisplayName, groupDescription, new AtomToolsFramework::InspectorPropertyGroupWidget( - m_documentSystemSettings.get(), nullptr, m_documentSystemSettings->TYPEINFO_Uuid(), this, this, saveStateKey)); + m_documentSystemSettings.get(), nullptr, m_documentSystemSettings->TYPEINFO_Uuid(), nullptr, this, saveStateKey)); } void SettingsWidget::Reset() @@ -64,21 +48,6 @@ namespace MaterialEditor AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect(); AtomToolsFramework::InspectorWidget::Reset(); } - - void SettingsWidget::BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) - { - AZ_UNUSED(pNode); - } - - void SettingsWidget::AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) - { - AZ_UNUSED(pNode); - } - - void SettingsWidget::SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) - { - AZ_UNUSED(pNode); - } } // namespace MaterialEditor //#include diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h index e7c655ee21..2642d9d55e 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h @@ -12,7 +12,6 @@ #include #include #include -#include #endif namespace MaterialEditor @@ -20,7 +19,6 @@ namespace MaterialEditor //! Provides controls for viewing and editing settings. class SettingsWidget : public AtomToolsFramework::InspectorWidget - , private AzToolsFramework::IPropertyEditorNotify { Q_OBJECT public: @@ -32,22 +30,11 @@ namespace MaterialEditor void Populate(); private: - void AddDocumentSettingsGroup(); void AddDocumentSystemSettingsGroup(); // AtomToolsFramework::InspectorRequestBus::Handler overrides... void Reset() override; - // AzToolsFramework::IPropertyEditorNotify overrides... - void BeforePropertyModified(AzToolsFramework::InstanceDataNode* pNode) override; - void AfterPropertyModified(AzToolsFramework::InstanceDataNode* pNode) override; - void SetPropertyEditingActive([[maybe_unused]] AzToolsFramework::InstanceDataNode* pNode) override {} - void SetPropertyEditingComplete(AzToolsFramework::InstanceDataNode* pNode) override; - void SealUndoStack() override {} - void RequestPropertyContextMenu(AzToolsFramework::InstanceDataNode*, const QPoint&) override {} - void PropertySelectionChanged(AzToolsFramework::InstanceDataNode*, bool) override {} - - AZStd::intrusive_ptr m_documentSettings; AZStd::intrusive_ptr m_documentSystemSettings; }; } // namespace MaterialEditor diff --git a/Gems/Atom/Tools/MaterialEditor/Code/materialeditor_files.cmake b/Gems/Atom/Tools/MaterialEditor/Code/materialeditor_files.cmake index 4e270460a6..d68e013c59 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/materialeditor_files.cmake +++ b/Gems/Atom/Tools/MaterialEditor/Code/materialeditor_files.cmake @@ -12,10 +12,8 @@ set(FILES Source/MaterialEditorApplication.h Source/Document/MaterialDocumentRequestBus.h - Source/Document/MaterialDocumentSettings.h Source/Document/MaterialDocument.cpp Source/Document/MaterialDocument.h - Source/Document/MaterialDocumentSettings.cpp Source/Viewport/MaterialViewportModule.h Source/Viewport/MaterialViewportModule.cpp @@ -49,8 +47,6 @@ set(FILES Source/Viewport/MaterialViewportWidget.ui Source/Window/MaterialEditorWindowSettings.h - Source/Window/MaterialEditorBrowserInteractions.h - Source/Window/MaterialEditorBrowserInteractions.cpp Source/Window/MaterialEditorWindow.h Source/Window/MaterialEditorWindow.cpp Source/Window/MaterialEditorWindowSettings.cpp diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp index aa0c378ff0..2d61730c4d 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.cpp @@ -12,12 +12,16 @@ #include #include #include +#include #include #include #include #include +#include #include +#include #include +#include #include #include #include @@ -25,11 +29,13 @@ #include #include -AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT +#include +#include #include #include +#include #include -AZ_POP_DISABLE_WARNING +#include void InitShaderManagementConsoleResources() { @@ -135,9 +141,46 @@ namespace ShaderManagementConsole void ShaderManagementConsoleApplication::CreateMainWindow() { - m_assetBrowserInteractions.reset(aznew ShaderManagementConsoleBrowserInteractions); m_window.reset(aznew ShaderManagementConsoleWindow); - m_window->show(); + m_assetBrowserInteractions.reset(aznew AtomToolsFramework::AtomToolsAssetBrowserInteractions); + m_assetBrowserInteractions->RegisterContextMenuActions( + [](const AtomToolsFramework::AtomToolsAssetBrowserInteractions::AssetBrowserEntryVector& entries) + { + return entries.front()->GetEntryType() == AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntryType::Source; + }, + []([[maybe_unused]] QWidget* caller, QMenu* menu, const AtomToolsFramework::AtomToolsAssetBrowserInteractions::AssetBrowserEntryVector& entries) + { + if (AzFramework::StringFunc::Path::IsExtension( + entries.front()->GetFullPath().c_str(), AZ::RPI::ShaderSourceData::Extension)) + { + menu->addAction("Generate Shader Variant List", [entries]() + { + const QString script = + "@engroot@/Gems/Atom/Tools/ShaderManagementConsole/Scripts/GenerateShaderVariantListForMaterials.py"; + AZStd::vector pythonArgs{ entries.front()->GetFullPath() }; + AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast( + &AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs, script.toUtf8().constData(), + pythonArgs); + }); + } + else if (AzFramework::StringFunc::Path::IsExtension( + entries.front()->GetFullPath().c_str(), AZ::RPI::ShaderVariantListSourceData::Extension)) + { + menu->addAction(QObject::tr("Open"), [entries]() + { + AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast( + &AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, + entries.front()->GetFullPath()); + }); + } + else + { + menu->addAction(QObject::tr("Open"), [entries]() + { + QDesktopServices::openUrl(QUrl::fromLocalFile(entries.front()->GetFullPath().c_str())); + }); + } + }); } void ShaderManagementConsoleApplication::DestroyMainWindow() diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h index 3bb62d0756..232f204790 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/ShaderManagementConsoleApplication.h @@ -9,11 +9,11 @@ #pragma once #include +#include #include #include #include #include -#include #include namespace ShaderManagementConsole @@ -55,6 +55,6 @@ namespace ShaderManagementConsole private: AZStd::unique_ptr m_window; - AZStd::unique_ptr m_assetBrowserInteractions; + AZStd::unique_ptr m_assetBrowserInteractions; }; } // namespace ShaderManagementConsole diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp deleted file mode 100644 index ca836b1b8d..0000000000 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -namespace ShaderManagementConsole -{ - ShaderManagementConsoleBrowserInteractions::ShaderManagementConsoleBrowserInteractions() - { - using namespace AzToolsFramework::AssetBrowser; - - AssetBrowserInteractionNotificationBus::Handler::BusConnect(); - } - - ShaderManagementConsoleBrowserInteractions::~ShaderManagementConsoleBrowserInteractions() - { - AssetBrowserInteractionNotificationBus::Handler::BusDisconnect(); - } - - AzToolsFramework::AssetBrowser::SourceFileDetails ShaderManagementConsoleBrowserInteractions::GetSourceFileDetails([[maybe_unused]] const char* fullSourceFileName) - { - return AzToolsFramework::AssetBrowser::SourceFileDetails(); - } - - void ShaderManagementConsoleBrowserInteractions::AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector& entries) - { - AssetBrowserEntry* entry = entries.empty() ? nullptr : entries.front(); - if (!entry) - { - return; - } - - m_caller = caller; - QObject::connect(m_caller, &QObject::destroyed, [this]() - { - m_caller = nullptr; - }); - - if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Source) - { - const auto source = azalias_cast(entry); - AddContextMenuActionsForOtherSource(caller, menu, source); - } - else if (entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Folder) - { - const auto folder = azalias_cast(entry); - AddContextMenuActionsForFolder(caller, menu, folder); - } - } - - void ShaderManagementConsoleBrowserInteractions::AddContextMenuActionsForOtherSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry) - { - menu->addAction("Open", [entry]() - { - if (AzFramework::StringFunc::Path::IsExtension(entry->GetFullPath().c_str(), AZ::RPI::ShaderVariantListSourceData::Extension)) - { - AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Broadcast(&AtomToolsFramework::AtomToolsDocumentSystemRequestBus::Events::OpenDocument, entry->GetFullPath().c_str()); - } - else - { - QDesktopServices::openUrl(QUrl::fromLocalFile(entry->GetFullPath().c_str())); - } - }); - - menu->addAction("Duplicate...", [entry]() - { - const QFileInfo duplicateFileInfo(AtomToolsFramework::GetDuplicationFileInfo(entry->GetFullPath().c_str())); - if (!duplicateFileInfo.absoluteFilePath().isEmpty()) - { - if (QFile::copy(entry->GetFullPath().c_str(), duplicateFileInfo.absoluteFilePath())) - { - QFile::setPermissions(duplicateFileInfo.absoluteFilePath(), QFile::ReadOther | QFile::WriteOther); - - // Auto add file to source control - AzToolsFramework::SourceControlCommandBus::Broadcast(&AzToolsFramework::SourceControlCommandBus::Events::RequestEdit, - duplicateFileInfo.absoluteFilePath().toUtf8().constData(), true, [](bool, const AzToolsFramework::SourceControlFileInfo&) {}); - } - } - }); - - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - menu->addSeparator(); - menu->addAction("Generate Shader Variant List", [entry]() { - const QString script = "@engroot@/Gems/Atom/Tools/ShaderManagementConsole/Scripts/GenerateShaderVariantListForMaterials.py"; - AZStd::vector pythonArgs{ entry->GetFullPath() }; - AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs, script.toUtf8().constData(), pythonArgs); - }); - - menu->addAction("Run Python on Asset...", [entry]() - { - const QString script = QFileDialog::getOpenFileName(nullptr, "Run Script", QString(), QString("*.py")); - if (!script.isEmpty()) - { - AZStd::vector pythonArgs { entry->GetFullPath() }; - AzToolsFramework::EditorPythonRunnerRequestBus::Broadcast(&AzToolsFramework::EditorPythonRunnerRequestBus::Events::ExecuteByFilenameWithArgs, script.toUtf8().constData(), pythonArgs); - } - }); - - AddPerforceMenuActions(caller, menu, entry); - } - - void ShaderManagementConsoleBrowserInteractions::AddContextMenuActionsForFolder(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::FolderAssetBrowserEntry* entry) - { - menu->addAction(AzQtComponents::fileBrowserActionName(), [entry]() - { - AzQtComponents::ShowFileOnDesktop(entry->GetFullPath().c_str()); - }); - - QAction* createFolderAction = menu->addAction(QObject::tr("Create new sub folder...")); - QObject::connect(createFolderAction, &QAction::triggered, caller, [caller, entry]() - { - bool ok; - QString newFolderName = QInputDialog::getText(caller, "Enter new folder name", "name:", QLineEdit::Normal, "NewFolder", &ok); - if (ok) - { - if (newFolderName.isEmpty()) - { - QMessageBox msgBox(QMessageBox::Icon::Critical, "Error", "Folder name can't be empty", QMessageBox::Ok, caller); - msgBox.exec(); - } - else - { - AZStd::string newFolderPath; - AzFramework::StringFunc::Path::Join(entry->GetFullPath().c_str(), newFolderName.toUtf8().constData(), newFolderPath); - QDir dir(newFolderPath.c_str()); - if (dir.exists()) - { - QMessageBox::critical(caller, "Error", "Folder with this name already exists"); - return; - } - auto result = dir.mkdir(newFolderPath.c_str()); - if (!result) - { - AZ_Error("ShaderManagementConsoleBrowser", false, "Failed to make new folder"); - return; - } - } - } - }); - } - - void ShaderManagementConsoleBrowserInteractions::AddPerforceMenuActions([[maybe_unused]] QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry) - { - using namespace AzToolsFramework; - - bool isActive = false; - SourceControlConnectionRequestBus::BroadcastResult(isActive, &SourceControlConnectionRequests::IsActive); - - if (isActive) - { - menu->addSeparator(); - - AZStd::string path = entry->GetFullPath(); - AzFramework::StringFunc::Path::Normalize(path); - - QMenu* sourceControlMenu = menu->addMenu("Source Control"); - - // Update the enabled state of source control menu actions only if menu is shown - QMenu::connect(sourceControlMenu, &QMenu::aboutToShow, [this, path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::GetFileInfo, path.c_str(), - [this](bool success, const SourceControlFileInfo& info) { UpdateSourceControlActions(success, info); }); - }); - - // add get latest action - m_getLatestAction = sourceControlMenu->addAction("Get Latest", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestLatest, path.c_str(), - [](bool, const SourceControlFileInfo&) {}); - }); - QObject::connect(m_getLatestAction, &QObject::destroyed, [this]() - { - m_getLatestAction = nullptr; - }); - m_getLatestAction->setEnabled(false); - - // add add action - m_addAction = sourceControlMenu->addAction("Add", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestEdit, path.c_str(), true, - [path](bool, const SourceControlFileInfo&) - { - SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); - }); - }); - QObject::connect(m_addAction, &QObject::destroyed, [this]() - { - m_addAction = nullptr; - }); - m_addAction->setEnabled(false); - - // add checkout action - m_checkOutAction = sourceControlMenu->addAction("Check Out", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestEdit, path.c_str(), true, - [path](bool, const SourceControlFileInfo&) - { - SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); - }); - }); - QObject::connect(m_checkOutAction, &QObject::destroyed, [this]() - { - m_checkOutAction = nullptr; - }); - m_checkOutAction->setEnabled(false); - - // add undo checkout action - m_undoCheckOutAction = sourceControlMenu->addAction("Undo Check Out", [path]() - { - SourceControlCommandBus::Broadcast(&SourceControlCommandBus::Events::RequestRevert, path.c_str(), - [path](bool, const SourceControlFileInfo&) - { - SourceControlThumbnailRequestBus::Broadcast(&SourceControlThumbnailRequests::FileStatusChanged, path.c_str()); - }); - }); - QObject::connect(m_undoCheckOutAction, &QObject::destroyed, [this]() - { - m_undoCheckOutAction = nullptr; - }); - m_undoCheckOutAction->setEnabled(false); - } - } - - void ShaderManagementConsoleBrowserInteractions::UpdateSourceControlActions(bool success, AzToolsFramework::SourceControlFileInfo info) - { - if (!success && m_caller) - { - QMessageBox::critical(m_caller, "Error", "Source control operation failed."); - } - if (m_getLatestAction) - { - m_getLatestAction->setEnabled(info.IsManaged() && info.HasFlag(AzToolsFramework::SCF_OutOfDate)); - } - if (m_addAction) - { - m_addAction->setEnabled(!info.IsManaged()); - } - if (m_checkOutAction) - { - m_checkOutAction->setEnabled(info.IsManaged() && info.IsReadOnly() && !info.IsLockedByOther()); - } - if (m_undoCheckOutAction) - { - m_undoCheckOutAction->setEnabled(info.IsManaged() && !info.IsReadOnly()); - } - } -} // namespace ShaderManagementConsole diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.h b/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.h deleted file mode 100644 index 996e755640..0000000000 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/Source/Window/ShaderManagementConsoleBrowserInteractions.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include -#include - -class QWidget; -class QMenu; -class QAction; - -namespace AzToolsFramework -{ - namespace AssetBrowser - { - class AssetBrowserEntry; - class SourceAssetBrowserEntry; - class FolderAssetBrowserEntry; - } -} - -namespace ShaderManagementConsole -{ - class ShaderManagementConsoleBrowserInteractions - : public AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler - { - public: - AZ_CLASS_ALLOCATOR(ShaderManagementConsoleBrowserInteractions, AZ::SystemAllocator, 0); - - ShaderManagementConsoleBrowserInteractions(); - ~ShaderManagementConsoleBrowserInteractions(); - - private: - //////////////////////////////////////////////////////////////////////// - // AssetBrowserInteractionNotificationBus::Handler implementation - AzToolsFramework::AssetBrowser::SourceFileDetails GetSourceFileDetails(const char* fullSourceFileName) override; - void AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector& entries) override; - //////////////////////////////////////////////////////////////////////// - - void AddContextMenuActionsForOtherSource(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::SourceAssetBrowserEntry* entry); - void AddContextMenuActionsForFolder(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::FolderAssetBrowserEntry* entry); - void AddPerforceMenuActions(QWidget* caller, QMenu* menu, const AzToolsFramework::AssetBrowser::AssetBrowserEntry* entry); - - void UpdateSourceControlActions(bool success, AzToolsFramework::SourceControlFileInfo info); - - QWidget* m_caller = nullptr; - QAction* m_addAction = nullptr; - QAction* m_checkOutAction = nullptr; - QAction* m_undoCheckOutAction = nullptr; - QAction* m_getLatestAction = nullptr; - }; -} // namespace ShaderManagementConsole diff --git a/Gems/Atom/Tools/ShaderManagementConsole/Code/shadermanagementconsole_files.cmake b/Gems/Atom/Tools/ShaderManagementConsole/Code/shadermanagementconsole_files.cmake index dac14b7f16..332cd73b40 100644 --- a/Gems/Atom/Tools/ShaderManagementConsole/Code/shadermanagementconsole_files.cmake +++ b/Gems/Atom/Tools/ShaderManagementConsole/Code/shadermanagementconsole_files.cmake @@ -11,8 +11,6 @@ set(FILES Source/Document/ShaderManagementConsoleDocument.cpp Source/Document/ShaderManagementConsoleDocument.h - Source/Window/ShaderManagementConsoleBrowserInteractions.h - Source/Window/ShaderManagementConsoleBrowserInteractions.cpp Source/Window/ShaderManagementConsoleWindow.h Source/Window/ShaderManagementConsoleWindow.cpp Source/Window/ShaderManagementConsole.qrc From 2d8b4d8285241125715dc19c519aa515a4d0a89c Mon Sep 17 00:00:00 2001 From: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> Date: Mon, 7 Feb 2022 09:20:55 -0800 Subject: [PATCH 42/59] Fix for github issue https://github.com/o3de/o3de/issues/6380 (#7386) The texture was treated as in linear space which leads to the color change when renders. Change to sRGB fixes the issue. Signed-off-by: Qing Tao <55564570+VickyAtAZ@users.noreply.github.com> --- .../Config/UserInterface_Compressed.preset | 20 +++++++++++++------ .../Config/UserInterface_Lossless.preset | 20 +++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset index cd1b00b2fb..c89fae1136 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Compressed.preset @@ -8,33 +8,41 @@ "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, "PixelFormat": "R8G8B8A8", - "SourceColor": "Linear", - "DestColor": "Linear" + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "PlatformsPresets": { "android": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "ASTC_4x4" + "PixelFormat": "ASTC_4x4", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "ios": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "ASTC_6x6" + "PixelFormat": "ASTC_6x6", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "mac": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "BC1" + "PixelFormat": "BC1", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "provo": { "UUID": "{2828FBFE-BDF9-45A7-9370-F93822719CCF}", "Name": "UserInterface_Compressed", "SuppressEngineReduce": true, - "PixelFormat": "BC1" + "PixelFormat": "BC1", + "SourceColor": "sRGB", + "DestColor": "sRGB" } } } diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset index bec6a604ef..e68ea9edc3 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset +++ b/Gems/Atom/Asset/ImageProcessingAtom/Assets/Config/UserInterface_Lossless.preset @@ -8,33 +8,41 @@ "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, "PixelFormat": "R8G8B8A8", - "SourceColor": "Linear", - "DestColor": "Linear" + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "PlatformsPresets": { "android": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "ios": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "mac": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" }, "provo": { "UUID": "{83003128-F63E-422B-AEC2-68F0A947225F}", "Name": "UserInterface_Lossless", "SuppressEngineReduce": true, - "PixelFormat": "R8G8B8A8" + "PixelFormat": "R8G8B8A8", + "SourceColor": "sRGB", + "DestColor": "sRGB" } } } From be242f9c7138455129371c2bda825bde3fab6f2c Mon Sep 17 00:00:00 2001 From: Roman <69218254+amzn-rhhong@users.noreply.github.com> Date: Mon, 7 Feb 2022 09:50:31 -0800 Subject: [PATCH 43/59] Fix a problem about rotation and scale manipulator (#7451) * Load workspace should activate the graph by default. Signed-off-by: rhhong * Fixed the bug with rotation and scale manipulator Signed-off-by: rhhong --- .../Code/Tools/EMStudio/AtomRenderPlugin.cpp | 51 ++++++++----------- .../Code/Tools/EMStudio/AtomRenderPlugin.h | 3 +- 2 files changed, 23 insertions(+), 31 deletions(-) diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp index 131cbd7053..5b3f305cd0 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.cpp @@ -177,10 +177,19 @@ namespace EMStudio m_rotateManipulators.ConfigureView( AzToolsFramework::RotationManipulatorRadius(), AzFramework::ViewportColors::XAxisColor, AzFramework::ViewportColors::YAxisColor, AzFramework::ViewportColors::ZAxisColor); + m_rotateManipulators.InstallLeftMouseDownCallback( + [this]([[maybe_unused]]const AzToolsFramework::AngularManipulator::Action& action) + { + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::EventResult(m_mouseDownStartTransform, entityId, &AZ::TransformBus::Events::GetLocalTM); + }); + m_rotateManipulators.InstallMouseMoveCallback( [this](const AzToolsFramework::AngularManipulator::Action& action) { - OnManipulatorRotated(action.LocalOrientation()); + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalRotationQuaternion, + m_mouseDownStartTransform.GetRotation() * action.m_current.m_delta); }); // Setup the scale manipulator @@ -189,10 +198,21 @@ namespace EMStudio m_scaleManipulators.ConfigureView( AzToolsFramework::LinearManipulatorAxisLength(), AzFramework::ViewportColors::XAxisColor, AzFramework::ViewportColors::YAxisColor, AzFramework::ViewportColors::ZAxisColor); + m_scaleManipulators.InstallAxisLeftMouseDownCallback( + [this]([[maybe_unused]] const AzToolsFramework::LinearManipulator::Action& action) + { + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::EventResult(m_mouseDownStartTransform, entityId, &AZ::TransformBus::Events::GetLocalTM); + }); m_scaleManipulators.InstallAxisMouseMoveCallback( [this](const AzToolsFramework::LinearManipulator::Action& action) { - OnManipulatorScaled(action.LocalScale(), action.LocalScaleOffset()); + // Since we are compulting a uniform scale, the delta scale should be the none-zero value from one of the three axis. + const float deltaScale = action.m_current.m_localPositionOffset.GetMaxElement() + + action.m_current.m_localPositionOffset.GetMinElement(); + const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); + AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalUniformScale, + m_mouseDownStartTransform.GetUniformScale() + deltaScale); }); } @@ -259,33 +279,6 @@ namespace EMStudio AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalTranslation, position); } - void AtomRenderPlugin::OnManipulatorRotated(const AZ::Quaternion& rotation) - { - const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); - AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalRotationQuaternion, rotation); - } - - void AtomRenderPlugin::OnManipulatorScaled( - const AZ::Vector3& scale, const AZ::Vector3& scaleOffset) - { - // Use the scaleOffset to determine which axis to use on the uniform scale. - float localScale = 1.0f; - if (scaleOffset.GetX() != 0.0f) - { - localScale = scale.GetX(); - } - else if (scaleOffset.GetY() != 0.0f) - { - localScale = scale.GetY(); - } - else if (scaleOffset.GetZ() != 0.0f) - { - localScale = scale.GetZ(); - } - const AZ::EntityId entityId = m_animViewportWidget->GetAnimViewportRenderer()->GetEntityId(); - AZ::TransformBus::Event(entityId, &AZ::TransformBus::Events::SetLocalUniformScale, localScale); - } - void AtomRenderPlugin::LoadRenderOptions() { AZStd::string renderOptionsFilename(GetManager()->GetAppDataFolder()); diff --git a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h index 23980ddc0d..2207690628 100644 --- a/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h +++ b/Gems/AtomLyIntegration/EMotionFXAtom/Code/Tools/EMStudio/AtomRenderPlugin.h @@ -70,8 +70,6 @@ namespace EMStudio void SetupManipulators(); void OnManipulatorMoved(const AZ::Vector3& position); - void OnManipulatorRotated(const AZ::Quaternion& rotation); - void OnManipulatorScaled(const AZ::Vector3& scale, const AZ::Vector3& scaleOffset); QWidget* m_innerWidget = nullptr; AnimViewportWidget* m_animViewportWidget = nullptr; @@ -82,6 +80,7 @@ namespace EMStudio AzToolsFramework::RotationManipulators m_rotateManipulators; AzToolsFramework::ScaleManipulators m_scaleManipulators; AZStd::shared_ptr m_manipulatorManager; + AZ::Transform m_mouseDownStartTransform; MCORE_DEFINECOMMANDCALLBACK(ImportActorCallback); MCORE_DEFINECOMMANDCALLBACK(RemoveActorCallback); From 38a34d811d98a0a417b5edda07c20c3838559102 Mon Sep 17 00:00:00 2001 From: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> Date: Mon, 7 Feb 2022 11:29:13 -0800 Subject: [PATCH 44/59] Update default bundle size limit to fit slightly larger content. Longer term we'll want to refactor these tests so they don't start failing to seemingly unrelated upstream changes, but for now this buys us time to work on other, more important things. (#7414) What happened to cause this: The test_WindowsAndMac_BundlesAndBundleSettings_EquivalentOutput test bundles the same content in two different ways, with the final intention to compare and verify the results are the same. It's bundling up the level levels\testdependencieslevel\testdependencieslevel.spawnable Along the way, it verifies the bundles it gets are what it expects. One of the bundle settings it uses is a relatively small maximum bundle size of 5 mib. Note that when we use a maximum bundle size, it's not a hard limit, it's just when we go to create a new bundle, if the current bundle size + next file would make the bundle too big, it starts a new bundle. This means you can have bundles go over the bundle size in the case where one file is larger than the bundle size limit. Somehow, one of the files referenced from this bundle ( goegap_4k_skyboxcm.exr.streamingimage ) is now 24 MB, which is larger than the default bundle size originally used, which is why the test fails, it goes to examine the contents of the second pak file of the first bundle, and it's larger than the maximum bundle size. That's why the test is failing. Changing this to 30 mib causes this test to continue to pass. Signed-off-by: AMZN-stankowi <4838196+AMZN-stankowi@users.noreply.github.com> --- .../ap_fixtures/bundler_batch_setup_fixture.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/AutomatedTesting/Gem/PythonTests/assetpipeline/ap_fixtures/bundler_batch_setup_fixture.py b/AutomatedTesting/Gem/PythonTests/assetpipeline/ap_fixtures/bundler_batch_setup_fixture.py index 9281d5947e..069b333346 100755 --- a/AutomatedTesting/Gem/PythonTests/assetpipeline/ap_fixtures/bundler_batch_setup_fixture.py +++ b/AutomatedTesting/Gem/PythonTests/assetpipeline/ap_fixtures/bundler_batch_setup_fixture.py @@ -79,7 +79,7 @@ def bundler_batch_setup_fixture(request, workspace, asset_processor, timeout) -> workspace.asset_processor_platform) ) # Useful sizes - self.max_bundle_size_in_mib = 5 + self.max_bundle_size_in_mib = 35 self.number_of_bytes_in_mib = 1024 * 1024 self.workspace = workspace self.platforms = platforms @@ -271,11 +271,13 @@ def bundler_batch_setup_fixture(request, workspace, asset_processor, timeout) -> for rel_path in self.get_asset_relative_paths(self.asset_info_file_result): assets_from_file.append(os.path.normpath(rel_path)) + expected_size = self.max_bundle_size_in_mib * self.number_of_bytes_in_mib # extract all files from the bundles for bundle in dependent_bundle_name: file_info = os.stat(bundle) # Verify that the size of all bundles is less than the max size specified - assert file_info.st_size <= (self.max_bundle_size_in_mib * self.number_of_bytes_in_mib) + assert file_info.st_size <= expected_size, \ + f"file_info.st_size {file_info.st_size} for bundle {bundle} was expected to be smaller than {expected_size}" with zipfile.ZipFile(bundle) as bundle_zip: bundle_zip.extractall(extract_dir) From 7c6c01d5a1bb83924c27d4782f36cf0c25c7282f Mon Sep 17 00:00:00 2001 From: chiyenteng <82238204+chiyenteng@users.noreply.github.com> Date: Mon, 7 Feb 2022 12:11:01 -0800 Subject: [PATCH 45/59] Convert automated tests related to content and unused levels (#7416) * Convert automated tests related to content/WaterSample level/Physics's Base level Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Fix nits Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Add missing .prefab level file Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Fix nits Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Convert Blast tests Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Convert scripting tests Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Remove useless comments Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> * Revert Collider_AddColliderComponent change until prefab error message bug fixed Signed-off-by: chiyenteng <82238204+chiyenteng@users.noreply.github.com> --- .../Gem/PythonTests/Blast/TestSuite_Main.py | 16 +- .../ComponentAssetCommands_test_case.py | 2 +- .../ComponentCommands_test.py | 1 + .../ComponentCommands_test_case.py | 4 +- .../ComponentPropertyCommands_test_case.py | 2 +- .../EntityCRUDCommands_test_case.py | 2 +- .../EntityCommands_test_case.py | 2 +- .../ObjectManagerCommands_test.py | 2 +- .../ObjectManagerCommands_test_case.py | 8 +- .../PySide_Example_test_case.py | 3 +- .../ViewPaneCommands_test_case.py | 2 +- .../ViewportTitleDlgCommands_test_case.py | 2 +- .../hydra_editor_utils.py | 2 +- .../hydra_test_utils.py | 2 +- .../pyside_component_utils.py | 3 +- .../editor_python_test_tools/utils.py | 8 +- .../Gem/PythonTests/Physics/TestSuite_Main.py | 6 +- .../Physics/TestSuite_Main_Optimized.py | 87 ++- .../PythonTests/Physics/TestSuite_Periodic.py | 24 +- .../CharacterController_SwitchLevels.py | 4 +- ...llider_CheckDefaultShapeSettingIsPxMesh.py | 5 +- .../collider/Collider_MultipleSurfaceSlots.py | 5 +- ...toAssignedWhenAddingRenderMeshComponent.py | 5 +- ...ssignedWhenModifyingRenderMeshComponent.py | 5 +- .../Collider_PxMeshConvexMeshCollides.py | 5 +- ...r_PxMeshNotAutoAssignedWhenNoPhysicsFbx.py | 5 +- ...rceRegion_WithNonTriggerColliderWarning.py | 6 +- .../Material_LibraryClearingAssignsDefault.py | 5 +- .../Ragdoll_AddPhysxRagdollComponentWorks.py | 5 +- .../ShapeCollider_CanBeAddedWitNoWarnings.py | 5 +- ...peCollider_InactiveWhenNoShapeComponent.py | 5 +- ...geNumberOfShapeCollidersWontCrashEditor.py | 5 +- .../PythonTests/WhiteBox/TestSuite_Main.py | 6 +- .../tests/WhiteBox_AddComponentToEntity.py | 2 +- .../tests/WhiteBox_SetDefaultShape.py | 2 +- .../WhiteBox/tests/WhiteBox_SetInvisible.py | 2 +- .../scripting/TestSuite_Periodic.py | 61 +- .../scripting/TestSuite_Sandbox.py | 2 +- .../Blast_ActorSplitsAfterCollision.prefab | 255 ++++++ .../Blast_ActorSplitsAfterDamage.prefab | 148 ++++ .../CharacterController_SwitchLevels.prefab | 217 ++++++ .../WhiteBox/EmptyLevel/EmptyLevel.prefab | 118 +++ .../Levels/auto_test/auto_test.prefab | 214 +++++ .../ocean_component/ocean_component.prefab | 348 +++++++++ .../ocean_trackview/ocean_trackview.prefab | 736 ++++++++++++++++++ 45 files changed, 2204 insertions(+), 150 deletions(-) create mode 100644 AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterCollision/Blast_ActorSplitsAfterCollision.prefab create mode 100644 AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterDamage/Blast_ActorSplitsAfterDamage.prefab create mode 100644 AutomatedTesting/Levels/Physics/CharacterController_SwitchLevels/CharacterController_SwitchLevels.prefab create mode 100644 AutomatedTesting/Levels/WhiteBox/EmptyLevel/EmptyLevel.prefab create mode 100644 AutomatedTesting/Levels/auto_test/auto_test.prefab create mode 100644 AutomatedTesting/Levels/ocean_component/ocean_component.prefab create mode 100644 AutomatedTesting/Levels/ocean_trackview/ocean_trackview.prefab diff --git a/AutomatedTesting/Gem/PythonTests/Blast/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/Blast/TestSuite_Main.py index a047d09d29..86a3df8271 100644 --- a/AutomatedTesting/Gem/PythonTests/Blast/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/Blast/TestSuite_Main.py @@ -17,34 +17,34 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)) + '/../automatedtesti from base import TestAutomationBase -@pytest.mark.SUITE_periodic +@pytest.mark.SUITE_main @pytest.mark.parametrize("launcher_platform", ['windows_editor']) @pytest.mark.parametrize("project", ["AutomatedTesting"]) class TestAutomation(TestAutomationBase): def test_ActorSplitsAfterCollision(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterCollision as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ActorSplitsAfterRadialDamage(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterRadialDamage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ActorSplitsAfterCapsuleDamage(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterCapsuleDamage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ActorSplitsAfterImpactSpreadDamage(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterImpactSpreadDamage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ActorSplitsAfterShearDamage(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterShearDamage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ActorSplitsAfterTriangleDamage(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterTriangleDamage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ActorSplitsAfterStressDamage(self, request, workspace, editor, launcher_platform): from .tests import Blast_ActorSplitsAfterStressDamage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentAssetCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentAssetCommands_test_case.py index d661615d02..c694ff2ebb 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentAssetCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentAssetCommands_test_case.py @@ -14,7 +14,7 @@ import azlmbr.math as math import azlmbr.asset as asset # Open a level (any level should work) -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') def GetSetCompareTest(component, path, assetId): # Test Get/Set (get old value, set new value, check that new value was set correctly) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test.py index 086de87c08..5e5fd31397 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test.py @@ -24,6 +24,7 @@ from hydra_utils import launch_test_case @pytest.mark.parametrize('level', ['Simple']) class TestComponentCommands(object): + # It needs a new test level in prefab format to make it testable again. def test_MeshComponentBasics(self, request, editor, level, launcher_platform): unexpected_lines=[] diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test_case.py index 8723d97fc9..682d804721 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentCommands_test_case.py @@ -5,6 +5,8 @@ For complete copyright and license terms please see the LICENSE at the root of t SPDX-License-Identifier: Apache-2.0 OR MIT """ +# It needs a new test level in prefab format to make it testable again. + # Tests a portion of the Component CRUD Python API while the Editor is running import azlmbr.bus as bus @@ -18,7 +20,7 @@ def CompareComponentEntityIdPairs(component1, component2): return component1.Equal(component2) # Open a level (any level should work) -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') # Get Component Types for Mesh and Comment typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', ["Mesh", "Comment", "Mesh Collider"], entity.EntityType().Game) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentPropertyCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentPropertyCommands_test_case.py index face62cf6b..1f692b90ea 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentPropertyCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ComponentPropertyCommands_test_case.py @@ -13,7 +13,7 @@ import azlmbr.entity as entity import azlmbr.math as math # Open a level (any level should work) -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') def GetSetCompareTest(component, path, value): oldObj = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentProperty', component, path) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCRUDCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCRUDCommands_test_case.py index 7d72d8893e..490b84791c 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCRUDCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCRUDCommands_test_case.py @@ -12,7 +12,7 @@ import azlmbr.editor as editor from azlmbr.entity import EntityId # Open a level (any level should work) -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') parentEntityId = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', EntityId()) childEntityId = editor.ToolsApplicationRequestBus(bus.Broadcast, 'CreateNewEntity', EntityId()) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCommands_test_case.py index 8aa34a5723..b7827d12e2 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/EntityCommands_test_case.py @@ -32,7 +32,7 @@ def onEditorEntityDeleted(parameters): # Open a level (any level should work) -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') # Listen for notifications when entities are created/deleted handler = bus.NotificationHandler('EditorEntityContextNotificationBus') diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test.py index b7acfe7e05..1b147d65a9 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test.py @@ -16,13 +16,13 @@ import os sys.path.append(os.path.dirname(__file__)) from hydra_utils import launch_test_case - @pytest.mark.SUITE_sandbox @pytest.mark.parametrize('launcher_platform', ['windows_editor']) @pytest.mark.parametrize('project', ['AutomatedTesting']) @pytest.mark.parametrize('level', ['Simple']) class TestObjectManagerAutomation(object): + # It needs a new test level in prefab format to make it testable again. def test_ViewPane(self, request, editor, level, launcher_platform): unexpected_lines=[] diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test_case.py index 28b49bb4cb..2d2e7a9dda 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ObjectManagerCommands_test_case.py @@ -20,12 +20,10 @@ def fetch_vector3_parts(vec3): general.idle_enable(True) -# Try to open the WaterSample level. If not, fail the test. -# We need to rely on an existing level since the API does not provide -# a way to create entities, but only lets us manipulate them. -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +# It needs a new test level in prefab format to make it testable again. +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') -if (editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'GetCurrentLevelName') == 'WaterSample'): +if (editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'GetCurrentLevelName') == 'Base'): objs_list = general.get_all_objects() diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py index 8ec9dd1fb3..7f111cae9d 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/PySide_Example_test_case.py @@ -21,8 +21,7 @@ import azlmbr.bus as bus import azlmbr.entity as entity import azlmbr.editor as editor import azlmbr.legacy.general as general -import editor_python_test_tools.pyside_component_utils as pysde_component_utils - +import editor_python_test_tools.pyside_component_utils as pyside_component_utils def PySide_Example_test_case(): # Open level, any level should work diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewPaneCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewPaneCommands_test_case.py index 562e3c733c..64b5417f92 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewPaneCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewPaneCommands_test_case.py @@ -13,7 +13,7 @@ import azlmbr.math import azlmbr.legacy.general as general # Open a level (any level should work) -editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'WaterSample') +editor.EditorToolsApplicationRequestBus(bus.Broadcast, 'OpenLevelNoPrompt', 'Base') general.idle_wait(0.5) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewportTitleDlgCommands_test_case.py b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewportTitleDlgCommands_test_case.py index 1eb0f45a7c..2652df386c 100755 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewportTitleDlgCommands_test_case.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonBindings/ViewportTitleDlgCommands_test_case.py @@ -11,7 +11,7 @@ import azlmbr.math import azlmbr.legacy.general as general # Open a level (any level should work) -general.open_level_no_prompt('WaterSample') +general.open_level_no_prompt('Base') general.idle_wait(0.5) test_success = True diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_editor_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_editor_utils.py index ac74c611a2..93f1dbb229 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_editor_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_editor_utils.py @@ -20,7 +20,7 @@ from editor_python_test_tools.utils import TestHelper as helper def open_base_level(): helper.init_idle() - helper.open_level("Prefab", "Base") + helper.open_level("", "Base") def find_entity_by_name(entity_name): diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py index 5580499526..c34361150c 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/hydra_test_utils.py @@ -61,7 +61,7 @@ def launch_and_validate_results(request, test_directory, editor, editor_script, from os import path editor.args.extend([ "--regset=/Amazon/Preferences/EnablePrefabSystem=true", - f"--regset-file={os.path.join(workspace.paths.engine_root(), 'Registry', 'prefab.test.setreg')}"]) + f"--regset-file={os.path.join(editor.workspace.paths.engine_root(), 'Registry', 'prefab.test.setreg')}"]) else: editor.args.extend(["--regset=/Amazon/Preferences/EnablePrefabSystem=false"]) diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py index 50007374d2..76e75fb20d 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/pyside_component_utils.py @@ -7,8 +7,7 @@ SPDX-License-Identifier: Apache-2.0 OR MIT import PySide2 -import editor_python_test_tools.pyside_utils - +import editor_python_test_tools.pyside_utils as pyside_utils def get_component_combobox_values(component_name, property_name, log_fn=None): """ diff --git a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py index 35a50b6090..0994e5942a 100644 --- a/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py +++ b/AutomatedTesting/Gem/PythonTests/EditorPythonTestTools/editor_python_test_tools/utils.py @@ -67,7 +67,7 @@ class TestHelper: return result == 0 @staticmethod - def open_level(directory : str, level : str): + def open_level(directory : str, level : str, no_prompt: bool = True): # type: (str, str) -> None """ :param level: the name of the level folder in AutomatedTesting\\Physics\\ @@ -75,7 +75,11 @@ class TestHelper: :return: None """ Report.info("Open level {}/{}".format(directory, level)) - success = general.open_level_no_prompt(os.path.join(directory, level)) + if no_prompt: + success = general.open_level_no_prompt(os.path.join(directory, level)) + else: + success = general.open_level(os.path.join(directory, level)) + if not success: open_level_name = general.get_current_level_name() if open_level_name == level: diff --git a/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main.py index 07ae5f6ca0..0cdeaa8a67 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main.py @@ -52,11 +52,11 @@ class TestAutomation(TestAutomationBase): @revert_physics_config def test_CharacterController_SwitchLevels(self, request, workspace, editor, launcher_platform): from .tests.character_controller import CharacterController_SwitchLevels as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Ragdoll_AddPhysxRagdollComponentWorks(self, request, workspace, editor, launcher_platform): from .tests.ragdoll import Ragdoll_AddPhysxRagdollComponentWorks as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @revert_physics_config def test_ScriptCanvas_MultipleRaycastNode(self, request, workspace, editor, launcher_platform): @@ -81,7 +81,7 @@ class TestAutomation(TestAutomationBase): @revert_physics_config def test_Collider_PxMeshConvexMeshCollides(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_PxMeshConvexMeshCollides as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @revert_physics_config def test_ShapeCollider_CylinderShapeCollides(self, request, workspace, editor, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main_Optimized.py b/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main_Optimized.py index b25b4340e8..a40b9065d6 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main_Optimized.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Main_Optimized.py @@ -53,7 +53,8 @@ class EditorSingleTest_WithFileOverrides(EditorSingleTest): for f in original_file_list: fm._restore_file(f, file_list[f]) -@pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.") + +# @pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.") @pytest.mark.SUITE_main @pytest.mark.parametrize("launcher_platform", ['windows_editor']) @pytest.mark.parametrize("project", ["AutomatedTesting"]) @@ -72,6 +73,48 @@ class TestAutomationWithPrefabSystemEnabled(EditorTestSuite): class C4982802_PhysXColliderShape_CanBeSelected(EditorSharedTest): from .tests.collider import Collider_CapsuleShapeEditing as test_module + class C14654881_CharacterController_SwitchLevels(EditorSharedTest): + from .tests.character_controller import CharacterController_SwitchLevels as test_module + + class C14861500_DefaultSetting_ColliderShape(EditorSharedTest): + from .tests.collider import Collider_CheckDefaultShapeSettingIsPxMesh as test_module + + class C4044695_PhysXCollider_AddMultipleSurfaceFbx(EditorSharedTest): + from .tests.collider import Collider_MultipleSurfaceSlots as test_module + + class C14861501_PhysXCollider_RenderMeshAutoAssigned(EditorSharedTest): + from .tests.collider import Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent as test_module + + @pytest.mark.xfail(reason="This will fail due to this issue ATOM-15487.") + class C14861502_PhysXCollider_AssetAutoAssigned(EditorSharedTest): + from .tests.collider import Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent as test_module + + class C4982803_Enable_PxMesh_Option(EditorSharedTest): + from .tests.collider import Collider_PxMeshConvexMeshCollides as test_module + + class C15096740_Material_LibraryUpdatedCorrectly(EditorSharedTest): + from .tests.material import Material_LibraryClearingAssignsDefault as test_module + + class C17411467_AddPhysxRagdollComponent(EditorSharedTest): + from .tests.ragdoll import Ragdoll_AddPhysxRagdollComponentWorks as test_module + + class C19578021_ShapeCollider_CanBeAdded(EditorSharedTest): + from .tests.shape_collider import ShapeCollider_CanBeAddedWitNoWarnings as test_module + + class C19578018_ShapeColliderWithNoShapeComponent(EditorSharedTest): + from .tests.shape_collider import ShapeCollider_InactiveWhenNoShapeComponent as test_module + + class C19723164_ShapeCollider_WontCrashEditor(EditorSharedTest): + from .tests.shape_collider import ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor as test_module + + class C12905528_ForceRegion_WithNonTriggerCollider(EditorSharedTest): + from .tests.force_region import ForceRegion_WithNonTriggerColliderWarning as test_module + # Fixme: expected_lines = ["[Warning] (PhysX Force Region) - Please ensure collider component marked as trigger exists in entity"] + + class C14861504_RenderMeshAsset_WithNoPxAsset(EditorSharedTest): + from .tests.collider import Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx as test_module + + @pytest.mark.xfail(reason="Optimized tests are experimental, we will enable xfail and monitor them temporarily.") @pytest.mark.SUITE_main @pytest.mark.parametrize("launcher_platform", ['windows_editor']) @@ -115,19 +158,13 @@ class TestAutomation(EditorTestSuite): class C14654881_CharacterController_SwitchLevels(EditorSharedTest): from .tests.character_controller import CharacterController_SwitchLevels as test_module - - class C17411467_AddPhysxRagdollComponent(EditorSharedTest): - from .tests.ragdoll import Ragdoll_AddPhysxRagdollComponentWorks as test_module - + class C12712453_ScriptCanvas_MultipleRaycastNode(EditorSharedTest): from .tests.script_canvas import ScriptCanvas_MultipleRaycastNode as test_module class C18243586_Joints_HingeLeadFollowerCollide(EditorSharedTest): from .tests.joints import Joints_HingeLeadFollowerCollide as test_module - class C4982803_Enable_PxMesh_Option(EditorSharedTest): - from .tests.collider import Collider_PxMeshConvexMeshCollides as test_module - class C24308873_CylinderShapeCollider_CollidesWithPhysXTerrain(EditorSharedTest): from .tests.shape_collider import ShapeCollider_CylinderShapeCollides as test_module @@ -297,19 +334,6 @@ class TestAutomation(EditorTestSuite): class C18243591_Joints_BallLeadFollowerCollide(EditorSharedTest): from .tests.joints import Joints_BallLeadFollowerCollide as test_module - class C19578018_ShapeColliderWithNoShapeComponent(EditorSharedTest): - from .tests.shape_collider import ShapeCollider_InactiveWhenNoShapeComponent as test_module - - class C14861500_DefaultSetting_ColliderShape(EditorSharedTest): - from .tests.collider import Collider_CheckDefaultShapeSettingIsPxMesh as test_module - - class C19723164_ShapeCollider_WontCrashEditor(EditorSharedTest): - from .tests.shape_collider import ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor as test_module - - class C12905528_ForceRegion_WithNonTriggerCollider(EditorSharedTest): - from .tests.force_region import ForceRegion_WithNonTriggerColliderWarning as test_module - # Fixme: expected_lines = ["[Warning] (PhysX Force Region) - Please ensure collider component marked as trigger exists in entity"] - class C5932040_ForceRegion_CubeExertsWorldForce(EditorSharedTest): from .tests.force_region import ForceRegion_WorldSpaceForceOnRigidBodies as test_module @@ -321,26 +345,10 @@ class TestAutomation(EditorTestSuite): class C5959809_ForceRegion_RotationalOffset(EditorSharedTest): from .tests.force_region import ForceRegion_RotationalOffset as test_module - - class C15096740_Material_LibraryUpdatedCorrectly(EditorSharedTest): - from .tests.material import Material_LibraryClearingAssignsDefault as test_module - + class C4976236_AddPhysxColliderComponent(EditorSharedTest): from .tests.collider import Collider_AddColliderComponent as test_module - @pytest.mark.xfail(reason="This will fail due to this issue ATOM-15487.") - class C14861502_PhysXCollider_AssetAutoAssigned(EditorSharedTest): - from .tests.collider import Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent as test_module - - class C14861501_PhysXCollider_RenderMeshAutoAssigned(EditorSharedTest): - from .tests.collider import Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent as test_module - - class C4044695_PhysXCollider_AddMultipleSurfaceFbx(EditorSharedTest): - from .tests.collider import Collider_MultipleSurfaceSlots as test_module - - class C14861504_RenderMeshAsset_WithNoPxAsset(EditorSharedTest): - from .tests.collider import Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx as test_module - class C100000_RigidBody_EnablingGravityWorksPoC(EditorSharedTest): from .tests.rigid_body import RigidBody_EnablingGravityWorksPoC as test_module @@ -350,8 +358,5 @@ class TestAutomation(EditorTestSuite): class C6090547_ForceRegion_ParentChildForceRegions(EditorSharedTest): from .tests.force_region import ForceRegion_ParentChildForcesCombineForces as test_module - class C19578021_ShapeCollider_CanBeAdded(EditorSharedTest): - from .tests.shape_collider import ShapeCollider_CanBeAddedWitNoWarnings as test_module - class C15425929_Undo_Redo(EditorSharedTest): from .tests import Physics_UndoRedoWorksOnEntityWithPhysComponents as test_module diff --git a/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Periodic.py index 6daf852708..d75328d8f7 100755 --- a/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Periodic.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/TestSuite_Periodic.py @@ -388,17 +388,17 @@ class TestAutomation(TestAutomationBase): @revert_physics_config def test_ShapeCollider_InactiveWhenNoShapeComponent(self, request, workspace, editor, launcher_platform): from .tests.shape_collider import ShapeCollider_InactiveWhenNoShapeComponent as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @revert_physics_config def test_Collider_CheckDefaultShapeSettingIsPxMesh(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_CheckDefaultShapeSettingIsPxMesh as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @revert_physics_config def test_ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor(self, request, workspace, editor, launcher_platform): from .tests.shape_collider import ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @revert_physics_config def test_Collider_SphereShapeEditing(self, request, workspace, editor, launcher_platform): @@ -418,7 +418,7 @@ class TestAutomation(TestAutomationBase): def test_ForceRegion_WithNonTriggerColliderWarning(self, request, workspace, editor, launcher_platform): from .tests.force_region import ForceRegion_WithNonTriggerColliderWarning as test_module # Fixme: expected_lines = ["[Warning] (PhysX Force Region) - Please ensure collider component marked as trigger exists in entity"] - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ForceRegion_WorldSpaceForceOnRigidBodies(self, request, workspace, editor, launcher_platform): from .tests.force_region import ForceRegion_WorldSpaceForceOnRigidBodies as test_module @@ -438,8 +438,12 @@ class TestAutomation(TestAutomationBase): def test_Material_LibraryClearingAssignsDefault(self, request, workspace, editor, launcher_platform): from .tests.material import Material_LibraryClearingAssignsDefault as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) + @pytest.mark.xfail(reason= + "Test failed due to an error message shown while in game mode: " + "'(Prefab) - Invalid asset found referenced in scene while entering game mode. " + "The asset was stored in an instance of Asset.'") def test_Collider_AddColliderComponent(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_AddColliderComponent as test_module self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) @@ -448,19 +452,19 @@ class TestAutomation(TestAutomationBase): reason="This will fail due to this issue ATOM-15487.") def test_Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Collider_MultipleSurfaceSlots(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_MultipleSurfaceSlots as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx(self, request, workspace, editor, launcher_platform): from .tests.collider import Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_RigidBody_EnablingGravityWorksPoC(self, request, workspace, editor, launcher_platform): from .tests.rigid_body import RigidBody_EnablingGravityWorksPoC as test_module @@ -486,7 +490,7 @@ class TestAutomation(TestAutomationBase): @revert_physics_config def test_ShapeCollider_CanBeAddedWitNoWarnings(self, request, workspace, editor, launcher_platform): from .tests.shape_collider import ShapeCollider_CanBeAddedWitNoWarnings as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @revert_physics_config def test_Physics_UndoRedoWorksOnEntityWithPhysComponents(self, request, workspace, editor, launcher_platform): diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/character_controller/CharacterController_SwitchLevels.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/character_controller/CharacterController_SwitchLevels.py index 564a2a1020..d14daefc7b 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/character_controller/CharacterController_SwitchLevels.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/character_controller/CharacterController_SwitchLevels.py @@ -53,10 +53,12 @@ def CharacterController_SwitchLevels(): import os import sys + from editor_python_test_tools.utils import Report from editor_python_test_tools.utils import TestHelper as helper import azlmbr.legacy.general as general import azlmbr.bus + import editor_python_test_tools.hydra_editor_utils as hydra # Constants WAIT_FOR_ERRORS = 3.0 @@ -77,7 +79,7 @@ def CharacterController_SwitchLevels(): helper.exit_game_mode(Tests.level1_exit_game_mode) # 2.1) Load level 2 (empty level) - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2.2) Enter game mode helper.enter_game_mode(Tests.level2_enter_game_mode) diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_CheckDefaultShapeSettingIsPxMesh.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_CheckDefaultShapeSettingIsPxMesh.py index cf8bd740c9..4208de9c1d 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_CheckDefaultShapeSettingIsPxMesh.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_CheckDefaultShapeSettingIsPxMesh.py @@ -45,14 +45,15 @@ def Collider_CheckDefaultShapeSettingIsPxMesh(): from editor_python_test_tools.utils import Report from editor_python_test_tools.utils import TestHelper as helper + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.legacy.general as general PHYSICS_ASSET_INDEX = 7 # Hardcoded enum index value for Shape property - helper.init_idle() # 1) Load empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create an entity to hold the PhysX Shape Collider component collider_entity = Entity.create_editor_entity("Collider") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_MultipleSurfaceSlots.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_MultipleSurfaceSlots.py index 2eabc6ab09..832766aa24 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_MultipleSurfaceSlots.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_MultipleSurfaceSlots.py @@ -54,6 +54,8 @@ def Collider_MultipleSurfaceSlots(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.asset_utils import Asset + import editor_python_test_tools.hydra_editor_utils as hydra + # Constants PHYSICS_ASSET_INDEX = 7 # Hardcoded enum index value for Shape property SURFACE_TAG_COUNT = 4 # Number of surface tags included in used asset @@ -62,9 +64,8 @@ def Collider_MultipleSurfaceSlots(): STATIC_MESH = os.path.join("assets", "Physics", "Collider_MultipleSurfaceSlots", "test.azmodel") PHYSX_MESH = os.path.join("assets", "Physics","Collider_MultipleSurfaceSlots", "test.pxmesh") - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create an entity test_entity = Entity.create_editor_entity("test_entity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent.py index f229842d2f..a73c69c788 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent.py @@ -54,15 +54,16 @@ def Collider_PxMeshAutoAssignedWhenAddingRenderMeshComponent(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.asset_utils import Asset + import editor_python_test_tools.hydra_editor_utils as hydra + # Asset paths STATIC_MESH = os.path.join("assets", "Physics", "Collider_PxMeshAutoAssigned", "spherebot", "r0-b_body.azmodel") PHYSX_MESH = os.path.join( "assets", "Physics", "Collider_PxMeshAutoAssigned", "spherebot", "r0-b_body.pxmesh" ) - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create an entity test_entity = Entity.create_editor_entity("test_entity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent.py index 8b08aae49d..b42ee69b80 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent.py @@ -53,6 +53,8 @@ def Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.asset_utils import Asset + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.legacy.general as general @@ -60,9 +62,8 @@ def Collider_PxMeshAutoAssignedWhenModifyingRenderMeshComponent(): MESH_PROPERTY_PATH = "Controller|Configuration|Mesh Asset" TESTED_PROPERTY_PATH = "Shape Configuration|Asset|PhysX Mesh" - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create an entity test_entity = Entity.create_editor_entity("test_entity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshConvexMeshCollides.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshConvexMeshCollides.py index 7d8f421d6b..36a79953d6 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshConvexMeshCollides.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshConvexMeshCollides.py @@ -62,7 +62,9 @@ def Collider_PxMeshConvexMeshCollides(): from editor_python_test_tools.utils import Report from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.asset_utils import Asset + import azlmbr.math as math + import editor_python_test_tools.hydra_editor_utils as hydra # Open 3D Engine Imports import azlmbr @@ -73,9 +75,8 @@ def Collider_PxMeshConvexMeshCollides(): MESH_ASSET_PATH = os.path.join("assets", "Physics", "Collider_PxMeshConvexMeshCollides", "spherebot", "r0-b_body.pxmesh") TIMEOUT = 2.0 - helper.init_idle() # 1) Load the level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create test entity collider = EditorEntity.create_editor_entity_at([512.0, 512.0, 33.0], "Collider") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx.py index 780c5439dd..bd0ef91903 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/collider/Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx.py @@ -59,15 +59,16 @@ def Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx(): from editor_python_test_tools.utils import Tracer from editor_python_test_tools.asset_utils import Asset + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.asset as azasset # Asset paths STATIC_MESH = os.path.join("assets", "Physics", "Collider_PxMeshNotAutoAssignedWhenNoPhysicsFbx", "test_asset.azmodel") - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create an entity test_entity = Entity.create_editor_entity("test_entity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/force_region/ForceRegion_WithNonTriggerColliderWarning.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/force_region/ForceRegion_WithNonTriggerColliderWarning.py index 2814fe01f8..11e2b2ae63 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/force_region/ForceRegion_WithNonTriggerColliderWarning.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/force_region/ForceRegion_WithNonTriggerColliderWarning.py @@ -44,15 +44,15 @@ def ForceRegion_WithNonTriggerColliderWarning(): :return: None """ import azlmbr.legacy.general as general + import editor_python_test_tools.hydra_editor_utils as hydra + from editor_python_test_tools.editor_entity_utils import EditorEntity from editor_python_test_tools.utils import Report - from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.utils import Tracer - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create test entity test_entity = EditorEntity.create_editor_entity("TestEntity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/material/Material_LibraryClearingAssignsDefault.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/material/Material_LibraryClearingAssignsDefault.py index 66bca8bfda..df991c5b5a 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/material/Material_LibraryClearingAssignsDefault.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/material/Material_LibraryClearingAssignsDefault.py @@ -57,6 +57,8 @@ def Material_LibraryClearingAssignsDefault(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.asset_utils import Asset + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.asset as azasset @@ -66,9 +68,8 @@ def Material_LibraryClearingAssignsDefault(): default_material_path = os.path.join("assets", "physics", "surfacetypemateriallibrary.physmaterial") new_material_path = os.path.join("physicssurfaces", "default_phys_materials.physmaterial") - helper.init_idle() # 1) Load the level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create new Entity with PhysX Character Controller test_entity = EditorEntity.create_editor_entity("TestEntity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/ragdoll/Ragdoll_AddPhysxRagdollComponentWorks.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/ragdoll/Ragdoll_AddPhysxRagdollComponentWorks.py index 9791d385fc..d8cd59e225 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/ragdoll/Ragdoll_AddPhysxRagdollComponentWorks.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/ragdoll/Ragdoll_AddPhysxRagdollComponentWorks.py @@ -49,9 +49,10 @@ def Ragdoll_AddPhysxRagdollComponentWorks(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.utils import Tracer - helper.init_idle() + import editor_python_test_tools.hydra_editor_utils as hydra + # 1) Load the level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create test entity test_entity = EditorEntity.create_editor_entity("TestEntity") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_CanBeAddedWitNoWarnings.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_CanBeAddedWitNoWarnings.py index 8c581e105c..e6f57b48d8 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_CanBeAddedWitNoWarnings.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_CanBeAddedWitNoWarnings.py @@ -50,12 +50,13 @@ def ShapeCollider_CanBeAddedWitNoWarnings(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.utils import Tracer + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.legacy.general as general - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create an entity collider_entity = Entity.create_editor_entity("Collider") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_InactiveWhenNoShapeComponent.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_InactiveWhenNoShapeComponent.py index d057e83398..3802b40ba6 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_InactiveWhenNoShapeComponent.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_InactiveWhenNoShapeComponent.py @@ -54,6 +54,8 @@ def ShapeCollider_InactiveWhenNoShapeComponent(): from editor_python_test_tools.editor_entity_utils import EditorEntity from editor_python_test_tools.utils import TestHelper as helper + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.bus as bus import azlmbr.editor as editor @@ -65,9 +67,8 @@ def ShapeCollider_InactiveWhenNoShapeComponent(): """ return editor.EditorComponentAPIBus(bus.Broadcast, "IsComponentEnabled", component_id) - helper.init_idle() # 1) Load the level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Add an entity with a PhysX Shape Collider component. collider = EditorEntity.create_editor_entity("Collider") diff --git a/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor.py b/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor.py index ba8b598987..e6bf7f88c7 100644 --- a/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor.py +++ b/AutomatedTesting/Gem/PythonTests/Physics/tests/shape_collider/ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor.py @@ -45,6 +45,8 @@ def ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor(): from editor_python_test_tools.utils import TestHelper as helper from editor_python_test_tools.editor_entity_utils import EditorEntity as Entity + import editor_python_test_tools.hydra_editor_utils as hydra + # Open 3D Engine Imports import azlmbr.legacy.general as general @@ -61,9 +63,8 @@ def ShapeCollider_LargeNumberOfShapeCollidersWontCrashEditor(): # Wait 60 frames more general.idle_wait_frames(60) - helper.init_idle() # 1) Load the empty level - helper.open_level("Physics", "Base") + hydra.open_base_level() # 2) Create 512 entities with PhysX Shape Collider and Sphere Shape components entity_failure = False diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/TestSuite_Main.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/TestSuite_Main.py index 2fc717e256..fa6c81c98a 100644 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/TestSuite_Main.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/TestSuite_Main.py @@ -24,12 +24,12 @@ from base import TestAutomationBase class TestAutomation(TestAutomationBase): def test_WhiteBox_AddComponentToEntity(self, request, workspace, editor, launcher_platform): from .tests import WhiteBox_AddComponentToEntity as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_WhiteBox_SetDefaultShape(self, request, workspace, editor, launcher_platform): from .tests import WhiteBox_SetDefaultShape as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_WhiteBox_SetInvisible(self, request, workspace, editor, launcher_platform): from .tests import WhiteBox_SetInvisible as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_AddComponentToEntity.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_AddComponentToEntity.py index 7e250e304f..b93a845a25 100644 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_AddComponentToEntity.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_AddComponentToEntity.py @@ -32,7 +32,7 @@ def C28798177_WhiteBox_AddComponentToEntity(): # open level helper.init_idle() - general.open_level("EmptyLevel") + helper.open_level("WhiteBox", "EmptyLevel", no_prompt=False) # create white box entity and attach component white_box_entity = init.create_white_box_entity() diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetDefaultShape.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetDefaultShape.py index 417561a3bd..c44929e5f2 100644 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetDefaultShape.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetDefaultShape.py @@ -54,7 +54,7 @@ def C29279329_WhiteBox_SetDefaultShape(): # open level helper.init_idle() - general.open_level("EmptyLevel") + helper.open_level("WhiteBox", "EmptyLevel", no_prompt=False) # create white box entity and attach component white_box_entity = init.create_white_box_entity() diff --git a/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetInvisible.py b/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetInvisible.py index 9642835e8f..3dd6ed2fc4 100644 --- a/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetInvisible.py +++ b/AutomatedTesting/Gem/PythonTests/WhiteBox/tests/WhiteBox_SetInvisible.py @@ -39,7 +39,7 @@ def C28798205_WhiteBox_SetInvisible(): # open level helper.init_idle() - general.open_level("EmptyLevel") + helper.open_level("WhiteBox", "EmptyLevel", no_prompt=False) white_box_entity_name = 'WhiteBox-Visibility' white_box_visibility_path = 'White Box Material|Visible' diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py index 27af63ddbc..887bfe2426 100755 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Periodic.py @@ -27,15 +27,15 @@ TEST_DIRECTORY = os.path.dirname(__file__) class TestAutomation(TestAutomationBase): def test_Pane_HappyPath_OpenCloseSuccessfully(self, request, workspace, editor, launcher_platform): from . import Pane_HappyPath_OpenCloseSuccessfully as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Pane_HappyPath_DocksProperly(self, request, workspace, editor, launcher_platform): from . import Pane_HappyPath_DocksProperly as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Pane_HappyPath_ResizesProperly(self, request, workspace, editor, launcher_platform): from . import Pane_HappyPath_ResizesProperly as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -45,7 +45,7 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptCanvas_TwoComponents_InteractSuccessfully as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -55,15 +55,15 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptCanvas_ChangingAssets_ComponentStable as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Graph_HappyPath_ZoomInZoomOut(self, request, workspace, editor, launcher_platform): from . import Graph_HappyPath_ZoomInZoomOut as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_NodePalette_HappyPath_CanSelectNode(self, request, workspace, editor, launcher_platform): from . import NodePalette_HappyPath_CanSelectNode as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -73,11 +73,11 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptCanvasComponent_OnEntityActivatedDeactivated_PrintMessage as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_NodePalette_HappyPath_ClearSelection(self, request, workspace, editor, launcher_platform, project): from . import NodePalette_HappyPath_ClearSelection as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -87,7 +87,7 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptCanvas_TwoEntities_UseSimultaneously as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ScriptEvent_HappyPath_CreatedWithoutError(self, request, workspace, editor, launcher_platform, project): def teardown(): @@ -99,19 +99,19 @@ class TestAutomation(TestAutomationBase): [os.path.join(workspace.paths.project(), "ScriptCanvas", "test_file.scriptevent")], True, True ) from . import ScriptEvent_HappyPath_CreatedWithoutError as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ScriptCanvasTools_Toggle_OpenCloseSuccess(self, request, workspace, editor, launcher_platform): from . import ScriptCanvasTools_Toggle_OpenCloseSuccess as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_NodeInspector_HappyPath_VariableRenames(self, request, workspace, editor, launcher_platform, project): from . import NodeInspector_HappyPath_VariableRenames as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Debugger_HappyPath_TargetMultipleGraphs(self, request, workspace, editor, launcher_platform, project): from . import Debugger_HappyPath_TargetMultipleGraphs as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.parametrize("level", ["tmp_level"]) def test_Debugger_HappyPath_TargetMultipleEntities(self, request, workspace, editor, launcher_platform, project, level): @@ -120,16 +120,16 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import Debugger_HappyPath_TargetMultipleEntities as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") def test_EditMenu_Default_UndoRedo(self, request, workspace, editor, launcher_platform, project): from . import EditMenu_Default_UndoRedo as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Pane_Undocked_ClosesSuccessfully(self, request, workspace, editor, launcher_platform): from . import Pane_Undocked_ClosesSuccessfully as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.parametrize("level", ["tmp_level"]) def test_Entity_HappyPath_AddScriptCanvasComponent(self, request, workspace, editor, launcher_platform, project, level): @@ -138,11 +138,11 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import Entity_HappyPath_AddScriptCanvasComponent as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Pane_Default_RetainOnSCRestart(self, request, workspace, editor, launcher_platform): from . import Pane_Default_RetainOnSCRestart as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -152,7 +152,7 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptEvents_HappyPath_SendReceiveAcrossMultiple as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -162,7 +162,7 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptEvents_Default_SendReceiveSuccessfully as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @pytest.mark.parametrize("level", ["tmp_level"]) @@ -172,24 +172,24 @@ class TestAutomation(TestAutomationBase): request.addfinalizer(teardown) file_system.delete([os.path.join(workspace.paths.project(), "Levels", level)], True, True) from . import ScriptEvents_ReturnSetType_Successfully as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_NodeCategory_ExpandOnClick(self, request, workspace, editor, launcher_platform): from . import NodeCategory_ExpandOnClick as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_NodePalette_SearchText_Deletion(self, request, workspace, editor, launcher_platform): from . import NodePalette_SearchText_Deletion as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") def test_VariableManager_UnpinVariableType_Works(self, request, workspace, editor, launcher_platform): from . import VariableManager_UnpinVariableType_Works as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_Node_HappyPath_DuplicateNode(self, request, workspace, editor, launcher_platform): from . import Node_HappyPath_DuplicateNode as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) def test_ScriptEvent_AddRemoveParameter_ActionsSuccessful(self, request, workspace, editor, launcher_platform): def teardown(): @@ -201,7 +201,7 @@ class TestAutomation(TestAutomationBase): [os.path.join(workspace.paths.project(), "ScriptCanvas", "test_file.scriptevent")], True, True ) from . import ScriptEvent_AddRemoveParameter_ActionsSuccessful as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) # NOTE: We had to use hydra_test_utils.py, as TestAutomationBase run_test method # fails because of pyside_utils import @@ -227,7 +227,6 @@ class TestScriptCanvasTests(object): expected_lines, auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @@ -246,7 +245,6 @@ class TestScriptCanvasTests(object): expected_lines, auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) def test_GraphClose_Default_SavePrompt(self, request, editor, launcher_platform): @@ -263,7 +261,6 @@ class TestScriptCanvasTests(object): expected_lines, auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) def test_VariableManager_Default_CreateDeleteVars(self, request, editor, launcher_platform): @@ -278,7 +275,6 @@ class TestScriptCanvasTests(object): expected_lines, auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) @pytest.mark.parametrize( @@ -314,7 +310,6 @@ class TestScriptCanvasTests(object): cfg_args=[config.get('cfg_args')], auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @@ -343,7 +338,6 @@ class TestScriptCanvasTests(object): expected_lines, auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) @pytest.mark.xfail(reason="Test fails to find expected lines, it needs to be fixed.") @@ -371,6 +365,5 @@ class TestScriptCanvasTests(object): expected_lines, auto_test_mode=False, timeout=60, - enable_prefab_system=False, ) \ No newline at end of file diff --git a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Sandbox.py b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Sandbox.py index 071ae2286c..91b01d8d08 100644 --- a/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Sandbox.py +++ b/AutomatedTesting/Gem/PythonTests/scripting/TestSuite_Sandbox.py @@ -23,4 +23,4 @@ class TestAutomation(TestAutomationBase): def test_Opening_Closing_Pane(self, request, workspace, editor, launcher_platform): from . import Opening_Closing_Pane as test_module - self._run_test(request, workspace, editor, test_module, enable_prefab_system=False) + self._run_test(request, workspace, editor, test_module) diff --git a/AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterCollision/Blast_ActorSplitsAfterCollision.prefab b/AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterCollision/Blast_ActorSplitsAfterCollision.prefab new file mode 100644 index 0000000000..df1a632788 --- /dev/null +++ b/AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterCollision/Blast_ActorSplitsAfterCollision.prefab @@ -0,0 +1,255 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "Blast_ActorSplitsAfterCollision", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[678057008134]": { + "Id": "Entity_[678057008134]", + "Name": "Sphere_Moving", + "Components": { + "Component_[158491845118288574]": { + "$type": "EditorColliderComponent", + "Id": 158491845118288574, + "ColliderConfiguration": { + "CollisionGroupId": { + "GroupId": "{45EBDE87-10BA-405B-9118-1FE9C750E5A3}" + }, + "MaterialSelection": { + "MaterialIds": [ + {} + ] + } + }, + "ShapeConfiguration": { + "ShapeType": 0 + } + }, + "Component_[15882836540317052831]": { + "$type": "EditorOnlyEntityComponent", + "Id": 15882836540317052831 + }, + "Component_[15988538924200810686]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 15988538924200810686 + }, + "Component_[17332118306686659923]": { + "$type": "SelectionComponent", + "Id": 17332118306686659923 + }, + "Component_[18013098363541384892]": { + "$type": "EditorPendingCompositionComponent", + "Id": 18013098363541384892 + }, + "Component_[3299242856338866058]": { + "$type": "EditorVisibilityComponent", + "Id": 3299242856338866058 + }, + "Component_[3368757662560547573]": { + "$type": "EditorInspectorComponent", + "Id": 3368757662560547573, + "ComponentOrderEntryArray": [ + { + "ComponentId": 9646670826592538370 + }, + { + "ComponentId": 158491845118288574, + "SortIndex": 1 + }, + { + "ComponentId": 7177752238184232813, + "SortIndex": 2 + }, + { + "ComponentId": 3538399061071907667, + "SortIndex": 3 + } + ] + }, + "Component_[3538399061071907667]": { + "$type": "EditorSphereShapeComponent", + "Id": 3538399061071907667, + "GameView": true + }, + "Component_[3584595476595239676]": { + "$type": "EditorLockComponent", + "Id": 3584595476595239676 + }, + "Component_[4539775501292735153]": { + "$type": "EditorEntityIconComponent", + "Id": 4539775501292735153 + }, + "Component_[5885911623396957736]": { + "$type": "EditorEntitySortComponent", + "Id": 5885911623396957736 + }, + "Component_[7177752238184232813]": { + "$type": "EditorRigidBodyComponent", + "Id": 7177752238184232813, + "Configuration": { + "entityId": "", + "Compute Mass": false, + "Mass": 100.0, + "Inertia tensor": { + "roll": 0.0, + "pitch": 0.0, + "yaw": 0.0, + "scale": 0.10000000149011612 + } + } + }, + "Component_[9646670826592538370]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 9646670826592538370, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 511.9999694824219, + 532.0, + 43.0 + ] + } + } + } + }, + "Entity_[682351975430]": { + "Id": "Entity_[682351975430]", + "Name": "Destructable_Box", + "Components": { + "Component_[14428979635353087750]": { + "$type": "EditorEntitySortComponent", + "Id": 14428979635353087750 + }, + "Component_[14459069801260260996]": { + "$type": "EditorPendingCompositionComponent", + "Id": 14459069801260260996 + }, + "Component_[16353277599917996564]": { + "$type": "SelectionComponent", + "Id": 16353277599917996564 + }, + "Component_[16528484535459302978]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 16528484535459302978 + }, + "Component_[17689177494335411023]": { + "$type": "EditorVisibilityComponent", + "Id": 17689177494335411023 + }, + "Component_[18116908665747450198]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18116908665747450198 + }, + "Component_[3544855145233062627]": { + "$type": "EditorInspectorComponent", + "Id": 3544855145233062627, + "ComponentOrderEntryArray": [ + { + "ComponentId": 3826825320808092990 + }, + { + "ComponentId": 5627868831214978789, + "SortIndex": 1 + }, + { + "ComponentId": 7875098433529363009, + "SortIndex": 2 + } + ] + }, + "Component_[3569626399556956817]": { + "$type": "EditorLockComponent", + "Id": 3569626399556956817 + }, + "Component_[3826825320808092990]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 3826825320808092990, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 511.9991455078125, + 532.031982421875, + 39.52538299560547 + ], + "Scale": [ + 1.0000001192092896, + 0.9999998807907104, + 1.0 + ] + } + }, + "Component_[5627868831214978789]": { + "$type": "EditorBlastFamilyComponent", + "Id": 5627868831214978789, + "BlastAsset": { + "assetId": { + "guid": "{BAB71D97-F136-5C11-8AB6-6E9F768CA83B}" + }, + "assetHint": "assets/destruction/box_2_chunks.blast" + }, + "BlastMaterial": { + "BlastMaterialId": "{2F200947-553F-487F-B4EA-57F0EF5AE024}" + }, + "PhysicsMaterial": { + "MaterialId": "{34AD1046-240B-448C-A694-AE80F595C431}" + } + }, + "Component_[7159608037522336146]": { + "$type": "EditorEntityIconComponent", + "Id": 7159608037522336146 + }, + "Component_[7875098433529363009]": { + "$type": "EditorBlastMeshDataComponent", + "Id": 7875098433529363009 + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterDamage/Blast_ActorSplitsAfterDamage.prefab b/AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterDamage/Blast_ActorSplitsAfterDamage.prefab new file mode 100644 index 0000000000..79445eea4e --- /dev/null +++ b/AutomatedTesting/Levels/Blast/Blast_ActorSplitsAfterDamage/Blast_ActorSplitsAfterDamage.prefab @@ -0,0 +1,148 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "Blast_ActorSplitsAfterDamage", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[682351975430]": { + "Id": "Entity_[682351975430]", + "Name": "Destructable_Box", + "Components": { + "Component_[14428979635353087750]": { + "$type": "EditorEntitySortComponent", + "Id": 14428979635353087750 + }, + "Component_[14459069801260260996]": { + "$type": "EditorPendingCompositionComponent", + "Id": 14459069801260260996 + }, + "Component_[16353277599917996564]": { + "$type": "SelectionComponent", + "Id": 16353277599917996564 + }, + "Component_[16528484535459302978]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 16528484535459302978 + }, + "Component_[17689177494335411023]": { + "$type": "EditorVisibilityComponent", + "Id": 17689177494335411023 + }, + "Component_[18116908665747450198]": { + "$type": "EditorOnlyEntityComponent", + "Id": 18116908665747450198 + }, + "Component_[3544855145233062627]": { + "$type": "EditorInspectorComponent", + "Id": 3544855145233062627, + "ComponentOrderEntryArray": [ + { + "ComponentId": 3826825320808092990 + }, + { + "ComponentId": 5627868831214978789, + "SortIndex": 1 + }, + { + "ComponentId": 7875098433529363009, + "SortIndex": 2 + } + ] + }, + "Component_[3569626399556956817]": { + "$type": "EditorLockComponent", + "Id": 3569626399556956817 + }, + "Component_[3826825320808092990]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 3826825320808092990, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 511.9991455078125, + 532.031982421875, + 39.52538299560547 + ], + "Scale": [ + 1.0000001192092896, + 0.9999998807907104, + 1.0 + ] + } + }, + "Component_[5627868831214978789]": { + "$type": "EditorBlastFamilyComponent", + "Id": 5627868831214978789, + "BlastAsset": { + "assetId": { + "guid": "{BAB71D97-F136-5C11-8AB6-6E9F768CA83B}" + }, + "assetHint": "assets/destruction/box_2_chunks.blast" + }, + "BlastMaterial": { + "BlastMaterialId": "{2F200947-553F-487F-B4EA-57F0EF5AE024}" + }, + "PhysicsMaterial": { + "MaterialId": "{34AD1046-240B-448C-A694-AE80F595C431}" + } + }, + "Component_[7159608037522336146]": { + "$type": "EditorEntityIconComponent", + "Id": 7159608037522336146 + }, + "Component_[7875098433529363009]": { + "$type": "EditorBlastMeshDataComponent", + "Id": 7875098433529363009, + "Show Mesh Assets": true + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/Physics/CharacterController_SwitchLevels/CharacterController_SwitchLevels.prefab b/AutomatedTesting/Levels/Physics/CharacterController_SwitchLevels/CharacterController_SwitchLevels.prefab new file mode 100644 index 0000000000..aa0167dfb4 --- /dev/null +++ b/AutomatedTesting/Levels/Physics/CharacterController_SwitchLevels/CharacterController_SwitchLevels.prefab @@ -0,0 +1,217 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "CharacterController_SwitchLevels", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[271494215500]": { + "Id": "Entity_[271494215500]", + "Name": "DefaultLevelSetup", + "Components": { + "Component_[10017568850356726118]": { + "$type": "EditorEntitySortComponent", + "Id": 10017568850356726118 + }, + "Component_[13730791873699866292]": { + "$type": "EditorVisibilityComponent", + "Id": 13730791873699866292 + }, + "Component_[14036484285432839222]": { + "$type": "EditorInspectorComponent", + "Id": 14036484285432839222, + "ComponentOrderEntryArray": [ + { + "ComponentId": 9432950532896492451 + }, + { + "ComponentId": 16094906495473882735, + "SortIndex": 1 + } + ] + }, + "Component_[15490606709331567745]": { + "$type": "EditorOnlyEntityComponent", + "Id": 15490606709331567745 + }, + "Component_[17819059404707659501]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 17819059404707659501 + }, + "Component_[2317367007807622931]": { + "$type": "EditorLockComponent", + "Id": 2317367007807622931 + }, + "Component_[2676812743453687109]": { + "$type": "EditorPendingCompositionComponent", + "Id": 2676812743453687109 + }, + "Component_[3047355939801335922]": { + "$type": "EditorEntityIconComponent", + "Id": 3047355939801335922 + }, + "Component_[3687396159953003426]": { + "$type": "SelectionComponent", + "Id": 3687396159953003426 + }, + "Component_[9432950532896492451]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 9432950532896492451, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 512.0, + 512.0, + 100.0 + ] + } + } + } + }, + "Entity_[348803626828]": { + "Id": "Entity_[348803626828]", + "Name": "CharacterController", + "Components": { + "Component_[10957270521451904134]": { + "$type": "EditorOnlyEntityComponent", + "Id": 10957270521451904134 + }, + "Component_[12992548330649678626]": { + "$type": "EditorLockComponent", + "Id": 12992548330649678626 + }, + "Component_[15540557783782258382]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 15540557783782258382 + }, + "Component_[16081734969125733179]": { + "$type": "EditorEntitySortComponent", + "Id": 16081734969125733179 + }, + "Component_[1999380243426028380]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 1999380243426028380, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 511.9999694824219, + 512.0, + 34.0 + ] + } + }, + "Component_[2476703453858708137]": { + "$type": "EditorEntityIconComponent", + "Id": 2476703453858708137 + }, + "Component_[259360796349614835]": { + "$type": "EditorVisibilityComponent", + "Id": 259360796349614835 + }, + "Component_[5309782390278392323]": { + "$type": "EditorCapsuleShapeComponent", + "Id": 5309782390278392323, + "GameView": true, + "ShapeColor": [ + 0.6666666865348816, + 0.0, + 0.0 + ], + "CapsuleShape": { + "Configuration": { + "DrawColor": [ + 0.6666666865348816, + 0.0, + 0.0 + ], + "Height": 2.0 + } + } + }, + "Component_[5810440768491728833]": { + "$type": "EditorInspectorComponent", + "Id": 5810440768491728833, + "ComponentOrderEntryArray": [ + { + "ComponentId": 1999380243426028380 + }, + { + "ComponentId": 6864662272767840579, + "SortIndex": 1 + }, + { + "ComponentId": 5309782390278392323, + "SortIndex": 2 + } + ] + }, + "Component_[6654367643820201613]": { + "$type": "EditorPendingCompositionComponent", + "Id": 6654367643820201613 + }, + "Component_[6864662272767840579]": { + "$type": "EditorCharacterControllerComponent", + "Id": 6864662272767840579, + "Configuration": { + "entityId": "", + "Material": { + "MaterialIds": [ + {} + ] + } + } + }, + "Component_[9211907343705413938]": { + "$type": "SelectionComponent", + "Id": 9211907343705413938 + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/WhiteBox/EmptyLevel/EmptyLevel.prefab b/AutomatedTesting/Levels/WhiteBox/EmptyLevel/EmptyLevel.prefab new file mode 100644 index 0000000000..d03a63b2c0 --- /dev/null +++ b/AutomatedTesting/Levels/WhiteBox/EmptyLevel/EmptyLevel.prefab @@ -0,0 +1,118 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "EmptyLevel", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[273050554979]": { + "Id": "Entity_[273050554979]", + "Name": "DefaultLevelSetup", + "Components": { + "Component_[10017568850356726118]": { + "$type": "EditorEntitySortComponent", + "Id": 10017568850356726118 + }, + "Component_[13730791873699866292]": { + "$type": "EditorVisibilityComponent", + "Id": 13730791873699866292 + }, + "Component_[14036484285432839222]": { + "$type": "EditorInspectorComponent", + "Id": 14036484285432839222, + "ComponentOrderEntryArray": [ + { + "ComponentId": 9432950532896492451 + }, + { + "ComponentId": 16094906495473882735, + "SortIndex": 1 + } + ] + }, + "Component_[16744953497953161231]": { + "$type": "EditorOnlyEntityComponent", + "Id": 16744953497953161231 + }, + "Component_[17819059404707659501]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 17819059404707659501 + }, + "Component_[2317367007807622931]": { + "$type": "EditorLockComponent", + "Id": 2317367007807622931 + }, + "Component_[2676812743453687109]": { + "$type": "EditorPendingCompositionComponent", + "Id": 2676812743453687109 + }, + "Component_[3047355939801335922]": { + "$type": "EditorEntityIconComponent", + "Id": 3047355939801335922 + }, + "Component_[3687396159953003426]": { + "$type": "SelectionComponent", + "Id": 3687396159953003426 + }, + "Component_[9432950532896492451]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 9432950532896492451, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 512.0, + 512.0, + 100.0 + ] + } + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/auto_test/auto_test.prefab b/AutomatedTesting/Levels/auto_test/auto_test.prefab new file mode 100644 index 0000000000..1ac6b45cb6 --- /dev/null +++ b/AutomatedTesting/Levels/auto_test/auto_test.prefab @@ -0,0 +1,214 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "auto_test", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[212522713927]": { + "Id": "Entity_[212522713927]", + "Name": "Entity1", + "Components": { + "Component_[13533719491703491179]": { + "$type": "EditorLockComponent", + "Id": 13533719491703491179 + }, + "Component_[14279778360325346613]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 14279778360325346613, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 512.0, + 512.0, + 32.0 + ] + } + }, + "Component_[16516432490694776069]": { + "$type": "EditorPendingCompositionComponent", + "Id": 16516432490694776069 + }, + "Component_[16894842505954369943]": { + "$type": "ScriptEditorComponent", + "Id": 16894842505954369943, + "ScriptComponent": { + "Script": { + "assetId": { + "guid": "{AEB649BE-6E63-5D08-B6A6-323EE80125D9}", + "subId": 1 + }, + "assetHint": "scripts/auto_director.luac" + } + }, + "ScriptAsset": { + "assetId": { + "guid": "{AEB649BE-6E63-5D08-B6A6-323EE80125D9}", + "subId": 1 + }, + "assetHint": "scripts/auto_director.luac" + } + }, + "Component_[17917865139404413371]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 17917865139404413371 + }, + "Component_[300870010798916271]": { + "$type": "EditorOnlyEntityComponent", + "Id": 300870010798916271 + }, + "Component_[3542492159899223622]": { + "$type": "EditorEntitySortComponent", + "Id": 3542492159899223622 + }, + "Component_[5861133001616453159]": { + "$type": "SelectionComponent", + "Id": 5861133001616453159 + }, + "Component_[5861394204754691870]": { + "$type": "EditorVisibilityComponent", + "Id": 5861394204754691870 + }, + "Component_[6534723243071167847]": { + "$type": "EditorEntityIconComponent", + "Id": 6534723243071167847 + }, + "Component_[8192412641288145942]": { + "$type": "EditorInspectorComponent", + "Id": 8192412641288145942, + "ComponentOrderEntryArray": [ + { + "ComponentId": 14279778360325346613 + }, + { + "ComponentId": 16894842505954369943, + "SortIndex": 1 + } + ] + } + } + }, + "Entity_[264062321479]": { + "Id": "Entity_[264062321479]", + "Name": "Camera1", + "Components": { + "Component_[0]": { + "$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent" + }, + "Component_[10250997976046839424]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 10250997976046839424, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 512.0531005859375, + 505.3736877441406, + 36.008216857910156 + ], + "Rotate": [ + 343.8316345214844, + 359.8723449707031, + 0.44026151299476624 + ], + "Scale": [ + 1.0, + 1.0, + 0.9999998807907104 + ] + } + }, + "Component_[14117951654550186353]": { + "$type": "EditorOnlyEntityComponent", + "Id": 14117951654550186353 + }, + "Component_[15441561693121796704]": { + "$type": "EditorEntitySortComponent", + "Id": 15441561693121796704 + }, + "Component_[16579888413894171159]": { + "$type": "EditorEntityIconComponent", + "Id": 16579888413894171159 + }, + "Component_[2015490294161116421]": { + "$type": "EditorVisibilityComponent", + "Id": 2015490294161116421 + }, + "Component_[2585309221365912267]": { + "$type": "EditorInspectorComponent", + "Id": 2585309221365912267, + "ComponentOrderEntryArray": [ + { + "ComponentId": 10250997976046839424 + }, + { + "ComponentId": 17989353981643488311, + "SortIndex": 1 + } + ] + }, + "Component_[4907915728143987395]": { + "$type": "SelectionComponent", + "Id": 4907915728143987395 + }, + "Component_[5911437040663285596]": { + "$type": "EditorPendingCompositionComponent", + "Id": 5911437040663285596 + }, + "Component_[8717969720874629567]": { + "$type": "EditorLockComponent", + "Id": 8717969720874629567 + }, + "Component_[992024776394048323]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 992024776394048323 + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/ocean_component/ocean_component.prefab b/AutomatedTesting/Levels/ocean_component/ocean_component.prefab new file mode 100644 index 0000000000..f2d740b77e --- /dev/null +++ b/AutomatedTesting/Levels/ocean_component/ocean_component.prefab @@ -0,0 +1,348 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "ocean_component", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[113557230075]": { + "Id": "Entity_[113557230075]", + "Name": "the_ocean", + "Components": { + "Component_[10578707299131614649]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 10578707299131614649, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 55.0, + 81.0, + 20.0 + ] + } + }, + "Component_[11046344975288527044]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 11046344975288527044 + }, + "Component_[13465592091248295601]": { + "$type": "EditorInspectorComponent", + "Id": 13465592091248295601, + "ComponentOrderEntryArray": [ + { + "ComponentId": 10578707299131614649 + }, + { + "ComponentId": 2840515548992536974, + "SortIndex": 1 + } + ] + }, + "Component_[13984822296855598165]": { + "$type": "EditorLockComponent", + "Id": 13984822296855598165 + }, + "Component_[14230937071328458692]": { + "$type": "EditorEntitySortComponent", + "Id": 14230937071328458692 + }, + "Component_[1515275142160994114]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1515275142160994114 + }, + "Component_[16187876448121091850]": { + "$type": "EditorEntityIconComponent", + "Id": 16187876448121091850 + }, + "Component_[16861233641669829560]": { + "$type": "EditorOnlyEntityComponent", + "Id": 16861233641669829560 + }, + "Component_[9086259058015300489]": { + "$type": "SelectionComponent", + "Id": 9086259058015300489 + }, + "Component_[9741974704446379447]": { + "$type": "EditorVisibilityComponent", + "Id": 9741974704446379447 + } + } + }, + "Entity_[127885714554]": { + "Id": "Entity_[127885714554]", + "Name": "the_camera", + "Components": { + "Component_[0]": { + "$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent" + }, + "Component_[12093754677865520350]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 12093754677865520350 + }, + "Component_[12730323471937880555]": { + "$type": "EditorEntityIconComponent", + "Id": 12730323471937880555 + }, + "Component_[13204709256342535717]": { + "$type": "EditorPendingCompositionComponent", + "Id": 13204709256342535717 + }, + "Component_[14559512685789945421]": { + "$type": "EditorLockComponent", + "Id": 14559512685789945421 + }, + "Component_[15770539414692920876]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 15770539414692920876, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 23.118545532226563, + 128.9333038330078, + 41.236572265625 + ], + "Rotate": [ + 0.12950840592384338, + 35.17909240722656, + 269.7752685546875 + ], + "Scale": [ + 1.0, + 0.9999998807907104, + 1.0 + ] + } + }, + "Component_[17658049626755079421]": { + "$type": "EditorVisibilityComponent", + "Id": 17658049626755079421 + }, + "Component_[3194947345798045730]": { + "$type": "EditorInspectorComponent", + "Id": 3194947345798045730, + "ComponentOrderEntryArray": [ + { + "ComponentId": 15770539414692920876 + }, + { + "ComponentId": 7411461277430009852, + "SortIndex": 1 + } + ] + }, + "Component_[4514043637061174274]": { + "$type": "SelectionComponent", + "Id": 4514043637061174274 + }, + "Component_[6690157295583364107]": { + "$type": "EditorEntitySortComponent", + "Id": 6690157295583364107 + }, + "Component_[8418547677002847981]": { + "$type": "EditorOnlyEntityComponent", + "Id": 8418547677002847981 + } + } + }, + "Entity_[132180681850]": { + "Id": "Entity_[132180681850]", + "Name": "the_thing", + "Components": { + "Component_[10221686237776167339]": { + "$type": "EditorOnlyEntityComponent", + "Id": 10221686237776167339 + }, + "Component_[10230254870444799387]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 10230254870444799387 + }, + "Component_[10910683815551719249]": { + "$type": "EditorEntityIconComponent", + "Id": 10910683815551719249 + }, + "Component_[1551781018072505537]": { + "$type": "EditorInspectorComponent", + "Id": 1551781018072505537, + "ComponentOrderEntryArray": [ + { + "ComponentId": 750431367071390348 + }, + { + "ComponentId": 10543707305560077725, + "SortIndex": 1 + }, + { + "ComponentId": 16828474708198673661, + "SortIndex": 2 + }, + { + "ComponentId": 6413469258372364445, + "SortIndex": 3 + } + ] + }, + "Component_[1610584700060024614]": { + "$type": "EditorEntitySortComponent", + "Id": 1610584700060024614 + }, + "Component_[1702498396513087308]": { + "$type": "EditorLockComponent", + "Id": 1702498396513087308 + }, + "Component_[191898962635170167]": { + "$type": "SelectionComponent", + "Id": 191898962635170167 + }, + "Component_[5524024140510561095]": { + "$type": "EditorVisibilityComponent", + "Id": 5524024140510561095 + }, + "Component_[7126349013266909622]": { + "$type": "EditorPendingCompositionComponent", + "Id": 7126349013266909622 + }, + "Component_[750431367071390348]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 750431367071390348, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 56.0, + 128.0, + 37.0 + ], + "Scale": [ + 2.0, + 2.0, + 2.0 + ], + "UniformScale": 2.0 + } + } + } + }, + "Entity_[285018505936]": { + "Id": "Entity_[285018505936]", + "Name": "the_comments", + "Components": { + "Component_[12254043508887231201]": { + "$type": "EditorCommentComponent", + "Id": 12254043508887231201, + "Configuration": "This level is meant to show the most basic ocean scene.\n" + }, + "Component_[13365140461414494550]": { + "$type": "EditorLockComponent", + "Id": 13365140461414494550 + }, + "Component_[15049990108511425568]": { + "$type": "EditorOnlyEntityComponent", + "Id": 15049990108511425568 + }, + "Component_[16058263010361769158]": { + "$type": "EditorCommentComponent", + "Id": 16058263010361769158, + "Configuration": "The physical object of \"the_thing\" requires the PhysicsEntities gem" + }, + "Component_[3610853239595723287]": { + "$type": "EditorInspectorComponent", + "Id": 3610853239595723287, + "ComponentOrderEntryArray": [ + { + "ComponentId": 6600498728445617807 + }, + { + "ComponentId": 12254043508887231201, + "SortIndex": 1 + }, + { + "ComponentId": 16058263010361769158, + "SortIndex": 2 + } + ] + }, + "Component_[4646570851596337987]": { + "$type": "EditorEntitySortComponent", + "Id": 4646570851596337987 + }, + "Component_[6425461812824751097]": { + "$type": "EditorEntityIconComponent", + "Id": 6425461812824751097 + }, + "Component_[6600498728445617807]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 6600498728445617807, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 19.0, + 114.0, + 32.0 + ] + } + }, + "Component_[748169014486201159]": { + "$type": "EditorVisibilityComponent", + "Id": 748169014486201159 + }, + "Component_[7489457744445094173]": { + "$type": "SelectionComponent", + "Id": 7489457744445094173 + }, + "Component_[8625778444077768294]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 8625778444077768294 + }, + "Component_[8776561997810927609]": { + "$type": "EditorPendingCompositionComponent", + "Id": 8776561997810927609 + } + } + } + } +} \ No newline at end of file diff --git a/AutomatedTesting/Levels/ocean_trackview/ocean_trackview.prefab b/AutomatedTesting/Levels/ocean_trackview/ocean_trackview.prefab new file mode 100644 index 0000000000..648487d815 --- /dev/null +++ b/AutomatedTesting/Levels/ocean_trackview/ocean_trackview.prefab @@ -0,0 +1,736 @@ +{ + "ContainerEntity": { + "Id": "ContainerEntity", + "Name": "ocean_trackview", + "Components": { + "Component_[10182366347512475253]": { + "$type": "EditorPrefabComponent", + "Id": 10182366347512475253 + }, + "Component_[12917798267488243668]": { + "$type": "EditorPendingCompositionComponent", + "Id": 12917798267488243668 + }, + "Component_[3261249813163778338]": { + "$type": "EditorOnlyEntityComponent", + "Id": 3261249813163778338 + }, + "Component_[3837204912784440039]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 3837204912784440039 + }, + "Component_[4272963378099646759]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4272963378099646759, + "Parent Entity": "" + }, + "Component_[4848458548047175816]": { + "$type": "EditorVisibilityComponent", + "Id": 4848458548047175816 + }, + "Component_[5787060997243919943]": { + "$type": "EditorInspectorComponent", + "Id": 5787060997243919943 + }, + "Component_[7804170251266531779]": { + "$type": "EditorLockComponent", + "Id": 7804170251266531779 + }, + "Component_[7874177159288365422]": { + "$type": "EditorEntitySortComponent", + "Id": 7874177159288365422 + }, + "Component_[8018146290632383969]": { + "$type": "EditorEntityIconComponent", + "Id": 8018146290632383969 + }, + "Component_[8452360690590857075]": { + "$type": "SelectionComponent", + "Id": 8452360690590857075 + } + } + }, + "Entities": { + "Entity_[113557230075]": { + "Id": "Entity_[113557230075]", + "Name": "the_ocean", + "Components": { + "Component_[10578707299131614649]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 10578707299131614649, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 55.0, + 81.0, + 16.0 + ] + } + }, + "Component_[11046344975288527044]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 11046344975288527044 + }, + "Component_[13465592091248295601]": { + "$type": "EditorInspectorComponent", + "Id": 13465592091248295601, + "ComponentOrderEntryArray": [ + { + "ComponentId": 10578707299131614649 + }, + { + "ComponentId": 8504984791098638268, + "SortIndex": 1 + }, + { + "ComponentId": 2840515548992536974, + "SortIndex": 2 + } + ] + }, + "Component_[13984822296855598165]": { + "$type": "EditorLockComponent", + "Id": 13984822296855598165 + }, + "Component_[14230937071328458692]": { + "$type": "EditorEntitySortComponent", + "Id": 14230937071328458692 + }, + "Component_[1515275142160994114]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1515275142160994114 + }, + "Component_[16187876448121091850]": { + "$type": "EditorEntityIconComponent", + "Id": 16187876448121091850 + }, + "Component_[8504984791098638268]": { + "$type": "EditorSequenceAgentComponent", + "Id": 8504984791098638268, + "SequenceComponentEntityIds": [ + "Entity_[117514781392]" + ] + }, + "Component_[9060135739962621874]": { + "$type": "EditorOnlyEntityComponent", + "Id": 9060135739962621874 + }, + "Component_[9086259058015300489]": { + "$type": "SelectionComponent", + "Id": 9086259058015300489 + }, + "Component_[9741974704446379447]": { + "$type": "EditorVisibilityComponent", + "Id": 9741974704446379447 + } + } + }, + "Entity_[117514781392]": { + "Id": "Entity_[117514781392]", + "Name": "the_seq", + "Components": { + "Component_[10651628595557926239]": { + "$type": "EditorPendingCompositionComponent", + "Id": 10651628595557926239 + }, + "Component_[11623691525514612151]": { + "$type": "EditorInspectorComponent", + "Id": 11623691525514612151, + "ComponentOrderEntryArray": [ + { + "ComponentId": 4273477098584349604 + }, + { + "ComponentId": 5882335637425824535, + "SortIndex": 1 + } + ] + }, + "Component_[12470939899970032484]": { + "$type": "EditorEntityIconComponent", + "Id": 12470939899970032484 + }, + "Component_[14478010456841775378]": { + "$type": "EditorOnlyEntityComponent", + "Id": 14478010456841775378 + }, + "Component_[18243888196443202779]": { + "$type": "EditorLockComponent", + "Id": 18243888196443202779 + }, + "Component_[1910120971488156322]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 1910120971488156322 + }, + "Component_[2096039468306613876]": { + "$type": "EditorVisibilityComponent", + "Id": 2096039468306613876 + }, + "Component_[4273477098584349604]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 4273477098584349604, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 61.15132141113281, + 82.34228515625, + 56.032203674316406 + ] + } + }, + "Component_[4856824333512618654]": { + "$type": "SelectionComponent", + "Id": 4856824333512618654 + }, + "Component_[5882335637425824535]": { + "$type": "EditorSequenceComponent", + "Id": 5882335637425824535, + "Sequence": { + "$type": "CAnimSequence", + "Name": "the_seq", + "SequenceEntityId": "Entity_[117514781392]", + "Flags": 1, + "ID": 1, + "Nodes": [ + { + "$type": "CAnimAzEntityNode", + "ID": 1, + "Name": "the_ocean", + "Flags": 6, + "Entity": "Entity_[113557230075]" + }, + { + "$type": "CAnimComponentNode", + "ID": 2, + "Name": "Infinite Ocean", + "Tracks": [ + { + "$type": "CCompoundSplineTrack", + "ParamType": { + "Type": 8, + "Name": "FogColor" + }, + "NumSubTracks": 3, + "SubTracks": [ + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "y": 0.01568629965186119 + }, + "ParamType": { + "Type": 82 + }, + "Spline": { + "Keys": [ + { + "flags": 73, + "ds": { + "x": 1.0 + }, + "dd": { + "x": 1.0 + } + }, + { + "time": 3.0, + "flags": 73, + "value": { + "x": 3.0, + "y": 255.0 + }, + "ds": { + "x": 1.0 + }, + "dd": { + "x": 1.0 + } + }, + { + "time": 5.0, + "flags": 73, + "value": { + "x": 5.0, + "y": 255.0 + }, + "ds": { + "x": 0.6666666865348816 + }, + "dd": { + "x": 0.6666666865348816 + } + }, + { + "time": 7.699999809265137, + "flags": 73, + "value": { + "x": 7.699999809265137 + }, + "ds": { + "x": 0.8999999761581421 + }, + "dd": { + "x": 0.8999999761581421 + } + }, + { + "time": 10.0, + "flags": 73, + "value": { + "x": 10.0 + }, + "ds": { + "x": 0.766666829586029 + }, + "dd": { + "x": 0.766666829586029 + } + } + ] + }, + "Id": 2 + }, + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "y": 0.09411770105361938 + }, + "ParamType": { + "Type": 83 + }, + "Spline": { + "Keys": [ + { + "flags": 73, + "ds": { + "x": 1.0 + }, + "dd": { + "x": 1.0 + } + }, + { + "time": 3.0, + "flags": 73, + "value": { + "x": 3.0, + "y": 255.0 + }, + "ds": { + "x": 1.0 + }, + "dd": { + "x": 1.0 + } + }, + { + "time": 5.0, + "flags": 73, + "value": { + "x": 5.0, + "y": 102.50434112548828 + }, + "ds": { + "x": 0.6666666865348816 + }, + "dd": { + "x": 0.6666666865348816 + } + }, + { + "time": 7.699999809265137, + "flags": 73, + "value": { + "x": 7.699999809265137 + }, + "ds": { + "x": 0.8999999761581421 + }, + "dd": { + "x": 0.8999999761581421 + } + }, + { + "time": 10.0, + "flags": 73, + "value": { + "x": 10.0, + "y": 23.16463851928711 + }, + "ds": { + "x": 0.766666829586029 + }, + "dd": { + "x": 0.766666829586029 + } + } + ] + }, + "Id": 3 + }, + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "y": 0.1411765068769455 + }, + "ParamType": { + "Type": 84 + }, + "Spline": { + "Keys": [ + { + "flags": 73, + "ds": { + "x": 1.0 + }, + "dd": { + "x": 1.0 + } + }, + { + "time": 3.0, + "flags": 73, + "value": { + "x": 3.0, + "y": 255.0 + }, + "ds": { + "x": 1.0 + }, + "dd": { + "x": 1.0 + } + }, + { + "time": 5.0, + "flags": 73, + "value": { + "x": 5.0, + "y": 255.0 + }, + "ds": { + "x": 0.6666666865348816 + }, + "dd": { + "x": 0.6666666865348816 + } + }, + { + "time": 7.699999809265137, + "flags": 73, + "value": { + "x": 7.699999809265137, + "y": 54.11885070800781 + }, + "ds": { + "x": 0.8999999761581421 + }, + "dd": { + "x": 0.8999999761581421 + } + }, + { + "time": 10.0, + "flags": 73, + "value": { + "x": 10.0 + }, + "ds": { + "x": 0.766666829586029 + }, + "dd": { + "x": 0.766666829586029 + } + } + ] + }, + "Id": 4 + }, + null + ], + "SubTrackNames": [ + "Red", + "Green", + "Blue", + "W" + ], + "ValueType": 20, + "Id": 1 + } + ], + "Parent": 1, + "ComponentID": 2840515548992536974, + "ComponentTypeID": "{961C77CC-CB98-49B8-83C4-CB7FD6D9AB5B}" + }, + { + "$type": "CAnimComponentNode", + "ID": 3, + "Name": "Transform", + "Tracks": [ + { + "$type": "CCompoundSplineTrack", + "ParamType": { + "Type": 1, + "Name": "Position" + }, + "NumSubTracks": 3, + "SubTracks": [ + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "x": -8029758706415567000.0, + "y": 55.0 + }, + "ParamType": { + "Type": 51 + }, + "Id": 6 + }, + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "x": -8029758706415567000.0, + "y": 81.0 + }, + "ParamType": { + "Type": 52 + }, + "Id": 7 + }, + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "x": -8029758706415567000.0, + "y": 57.0 + }, + "ParamType": { + "Type": 53 + }, + "Id": 8 + }, + null + ], + "SubTrackNames": [ + "X", + "Y", + "Z", + "W" + ], + "ValueType": 1, + "Id": 5 + }, + { + "$type": "CCompoundSplineTrack", + "ParamType": { + "Type": 2, + "Name": "Rotation" + }, + "NumSubTracks": 3, + "SubTracks": [ + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "x": -8029758706415567000.0 + }, + "ParamType": { + "Type": 54 + }, + "Id": 10 + }, + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "x": -8029758706415567000.0 + }, + "ParamType": { + "Type": 55 + }, + "Id": 11 + }, + { + "$type": "TAnimSplineTrack", + "DefaultValue": { + "x": -8029758706415567000.0 + }, + "ParamType": { + "Type": 56 + }, + "Id": 12 + }, + null + ], + "SubTrackNames": [ + "X", + "Y", + "Z", + "W" + ], + "ValueType": 2, + "Id": 9 + } + ], + "Parent": 1, + "ComponentID": 10578707299131614649, + "ComponentTypeID": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0}" + } + ], + "Events": [ + "start" + ] + } + }, + "Component_[8277927932072884141]": { + "$type": "EditorEntitySortComponent", + "Id": 8277927932072884141 + } + } + }, + "Entity_[310788309712]": { + "Id": "Entity_[310788309712]", + "Name": "the_comments", + "Components": { + "Component_[10820736773970990934]": { + "$type": "SelectionComponent", + "Id": 10820736773970990934 + }, + "Component_[16460362337690040728]": { + "$type": "EditorVisibilityComponent", + "Id": 16460362337690040728 + }, + "Component_[1711788818167604478]": { + "$type": "EditorInspectorComponent", + "Id": 1711788818167604478, + "ComponentOrderEntryArray": [ + { + "ComponentId": 17162444099898225645 + }, + { + "ComponentId": 4524863805502269700, + "SortIndex": 1 + } + ] + }, + "Component_[17162444099898225645]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 17162444099898225645, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 61.0, + 82.0, + 56.0 + ] + } + }, + "Component_[17783575382365366340]": { + "$type": "EditorOnlyEntityComponent", + "Id": 17783575382365366340 + }, + "Component_[2087049458930367042]": { + "$type": "EditorLockComponent", + "Id": 2087049458930367042 + }, + "Component_[2711019276572888356]": { + "$type": "EditorEntitySortComponent", + "Id": 2711019276572888356 + }, + "Component_[4524863805502269700]": { + "$type": "EditorCommentComponent", + "Id": 4524863805502269700, + "Configuration": "This level is meant to test track view with the ocean component." + }, + "Component_[6476444408609098475]": { + "$type": "EditorPendingCompositionComponent", + "Id": 6476444408609098475 + }, + "Component_[7805954804953628853]": { + "$type": "EditorEntityIconComponent", + "Id": 7805954804953628853 + }, + "Component_[8159544250366547808]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 8159544250366547808 + } + } + }, + "Entity_[315083277008]": { + "Id": "Entity_[315083277008]", + "Name": "the_camera", + "Components": { + "Component_[0]": { + "$type": "{CA11DA46-29FF-4083-B5F6-E02C3A8C3A3D} EditorCameraComponent" + }, + "Component_[11755705402873798069]": { + "$type": "EditorVisibilityComponent", + "Id": 11755705402873798069 + }, + "Component_[11939241802298470223]": { + "$type": "EditorInspectorComponent", + "Id": 11939241802298470223, + "ComponentOrderEntryArray": [ + { + "ComponentId": 13678215694230152557 + }, + { + "ComponentId": 7780955726439597543, + "SortIndex": 1 + }, + { + "ComponentId": 14118047423140175065, + "SortIndex": 2 + } + ] + }, + "Component_[1263945907594972096]": { + "$type": "EditorPendingCompositionComponent", + "Id": 1263945907594972096 + }, + "Component_[13678215694230152557]": { + "$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent", + "Id": 13678215694230152557, + "Parent Entity": "ContainerEntity", + "Transform Data": { + "Translate": [ + 5.279235363006592, + 89.93304443359375, + 41.92418670654297 + ], + "Rotate": [ + 8.572165489196777, + 351.0418701171875, + 134.06057739257813 + ], + "Scale": [ + 0.9999998807907104, + 0.9999998807907104, + 1.0 + ] + } + }, + "Component_[16694969224252903921]": { + "$type": "SelectionComponent", + "Id": 16694969224252903921 + }, + "Component_[16770043767194988305]": { + "$type": "EditorLockComponent", + "Id": 16770043767194988305 + }, + "Component_[17615022962377688621]": { + "$type": "EditorEntityIconComponent", + "Id": 17615022962377688621 + }, + "Component_[4781886688900343222]": { + "$type": "EditorEntitySortComponent", + "Id": 4781886688900343222 + }, + "Component_[8790131188175752902]": { + "$type": "EditorDisabledCompositionComponent", + "Id": 8790131188175752902 + }, + "Component_[9731263833327927165]": { + "$type": "EditorOnlyEntityComponent", + "Id": 9731263833327927165 + } + } + } + } +} \ No newline at end of file From 0f07f581f8ca6eaa8c4645af58578afea40aa972 Mon Sep 17 00:00:00 2001 From: Guthrie Adams Date: Mon, 7 Feb 2022 15:11:03 -0600 Subject: [PATCH 46/59] Atom Tools: replaced document settings with settings registry Signed-off-by: Guthrie Adams --- .../AtomToolsDocumentSystemSettings.h | 30 ------------ .../Application/AtomToolsApplication.cpp | 3 +- .../AssetBrowser/AtomToolsAssetBrowser.cpp | 9 +++- .../AtomToolsDocumentSystemComponent.cpp | 19 +++++--- .../AtomToolsDocumentSystemComponent.h | 2 - .../AtomToolsDocumentSystemSettings.cpp | 47 ------------------- .../Code/atomtoolsframework_files.cmake | 2 - .../Window/SettingsDialog/SettingsWidget.cpp | 16 ------- .../Window/SettingsDialog/SettingsWidget.h | 5 -- 9 files changed, 22 insertions(+), 111 deletions(-) delete mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h delete mode 100644 Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemSettings.cpp diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h deleted file mode 100644 index 9b4c1d77fe..0000000000 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#endif - -namespace AtomToolsFramework -{ - struct AtomToolsDocumentSystemSettings - : public AZ::UserSettings - { - AZ_RTTI(AtomToolsDocumentSystemSettings, "{9E576D4F-A74A-4326-9135-C07284D0A3B9}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(AtomToolsDocumentSystemSettings, AZ::SystemAllocator, 0); - - static void Reflect(AZ::ReflectContext* context); - - bool m_showReloadDocumentPrompt = true; - }; -} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp index 150b06cabd..4ba1d04b71 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Application/AtomToolsApplication.cpp @@ -189,8 +189,9 @@ namespace AtomToolsFramework AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotificationBus::Broadcast( &AzToolsFramework::AssetBrowser::AssetDatabaseLocationNotifications::OnDatabaseInitialized); + const bool enableSourceControl = GetSettingOrDefault("/O3DE/AtomToolsFramework/Application/EnableSourceControl", true); AzToolsFramework::SourceControlConnectionRequestBus::Broadcast( - &AzToolsFramework::SourceControlConnectionRequests::EnableSourceControl, true); + &AzToolsFramework::SourceControlConnectionRequests::EnableSourceControl, enableSourceControl); if (!AZ::RPI::RPISystemInterface::Get()->IsInitialized()) { diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowser.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowser.cpp index 4270cb87fe..8394efa46f 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowser.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/AssetBrowser/AtomToolsAssetBrowser.cpp @@ -8,6 +8,7 @@ #include #include +#include #include #include #include @@ -103,8 +104,12 @@ namespace AtomToolsFramework { const AZStd::vector entries = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); - const int multiSelectPromptThreshold = 10; - if (entries.size() >= multiSelectPromptThreshold) + const bool promptToOpenMultipleFiles = + GetSettingOrDefault("/O3DE/AtomToolsFramework/AssetBrowser/PromptToOpenMultipleFiles", true); + const AZ::u64 promptToOpenMultipleFilesThreshold = + GetSettingOrDefault("/O3DE/AtomToolsFramework/AssetBrowser/PromptToOpenMultipleFilesThreshold", 10); + + if (promptToOpenMultipleFiles && promptToOpenMultipleFilesThreshold <= entries.size()) { QMessageBox::StandardButton result = QMessageBox::question( QApplication::activeWindow(), diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp index c05bb56391..329bc1b1b3 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -35,8 +34,6 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::Reflect(AZ::ReflectContext* context) { - AtomToolsDocumentSystemSettings::Reflect(context); - if (AZ::SerializeContext* serialize = azrtti_cast(context)) { serialize->Class() @@ -113,7 +110,6 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::Activate() { m_documentMap.clear(); - m_settings = AZ::UserSettings::CreateFind(AZ_CRC_CE("AtomToolsDocumentSystemSettings"), AZ::UserSettings::CT_GLOBAL); AtomToolsDocumentSystemRequestBus::Handler::BusConnect(); AtomToolsDocumentNotificationBus::Handler::BusConnect(); } @@ -178,6 +174,17 @@ namespace AtomToolsFramework void AtomToolsDocumentSystemComponent::ReopenDocuments() { + const bool enableHotReload = GetSettingOrDefault("/O3DE/AtomToolsFramework/DocumentSystem/EnableHotReload", true); + if (!enableHotReload) + { + m_documentIdsWithDependencyChanges.clear(); + m_documentIdsWithExternalChanges.clear(); + m_queueReopenDocuments = false; + } + + const bool enableHotReloadPrompts = + GetSettingOrDefault("/O3DE/AtomToolsFramework/DocumentSystem/EnableHotReloadPrompts", true); + for (const AZ::Uuid& documentId : m_documentIdsWithExternalChanges) { m_documentIdsWithDependencyChanges.erase(documentId); @@ -185,7 +192,7 @@ namespace AtomToolsFramework AZStd::string documentPath; AtomToolsDocumentRequestBus::EventResult(documentPath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - if (m_settings->m_showReloadDocumentPrompt && + if (enableHotReloadPrompts && (QMessageBox::question(QApplication::activeWindow(), QString("Document was externally modified"), QString("Would you like to reopen the document:\n%1?").arg(documentPath.c_str()), @@ -212,7 +219,7 @@ namespace AtomToolsFramework AZStd::string documentPath; AtomToolsDocumentRequestBus::EventResult(documentPath, documentId, &AtomToolsDocumentRequestBus::Events::GetAbsolutePath); - if (m_settings->m_showReloadDocumentPrompt && + if (enableHotReloadPrompts && (QMessageBox::question(QApplication::activeWindow(), QString("Document dependencies have changed"), QString("Would you like to update the document with these changes:\n%1?").arg(documentPath.c_str()), diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h index 5c7454e5c7..5eb531ef25 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemComponent.h @@ -15,7 +15,6 @@ #include #include #include -#include AZ_PUSH_DISABLE_WARNING(4251 4800, "-Wunknown-warning-option") // disable warnings spawned by QT #include @@ -79,7 +78,6 @@ namespace AtomToolsFramework AZ::Uuid OpenDocumentImpl(AZStd::string_view sourcePath, bool checkIfAlreadyOpen); - AZStd::intrusive_ptr m_settings; AZStd::function m_documentCreator; AZStd::unordered_map> m_documentMap; AZStd::unordered_set m_documentIdsWithExternalChanges; diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemSettings.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemSettings.cpp deleted file mode 100644 index 94af43e524..0000000000 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Document/AtomToolsDocumentSystemSettings.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include - -namespace AtomToolsFramework -{ - void AtomToolsDocumentSystemSettings::Reflect(AZ::ReflectContext* context) - { - if (auto serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ->Field("showReloadDocumentPrompt", &AtomToolsDocumentSystemSettings::m_showReloadDocumentPrompt) - ; - - if (auto editContext = serializeContext->GetEditContext()) - { - editContext->Class( - "AtomToolsDocumentSystemSettings", "") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::AutoExpand, true) - ->DataElement(AZ::Edit::UIHandlers::Default, &AtomToolsDocumentSystemSettings::m_showReloadDocumentPrompt, "Show Reload Document Prompt", "") - ; - } - } - - if (auto behaviorContext = azrtti_cast(context)) - { - behaviorContext->Class("AtomToolsDocumentSystemSettings") - ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) - ->Attribute(AZ::Script::Attributes::Category, "Editor") - ->Attribute(AZ::Script::Attributes::Module, "atomtools") - ->Constructor() - ->Constructor() - ->Property("showReloadDocumentPrompt", BehaviorValueProperty(&AtomToolsDocumentSystemSettings::m_showReloadDocumentPrompt)) - ; - } - } -} // namespace AtomToolsFramework diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake index b7f9882e92..041e6e1807 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/atomtoolsframework_files.cmake @@ -17,7 +17,6 @@ set(FILES Include/AtomToolsFramework/Document/AtomToolsDocument.h Include/AtomToolsFramework/Document/AtomToolsDocumentApplication.h Include/AtomToolsFramework/Document/AtomToolsDocumentMainWindow.h - Include/AtomToolsFramework/Document/AtomToolsDocumentSystemSettings.h Include/AtomToolsFramework/Document/AtomToolsDocumentSystemRequestBus.h Include/AtomToolsFramework/Document/AtomToolsDocumentNotificationBus.h Include/AtomToolsFramework/Document/AtomToolsDocumentRequestBus.h @@ -54,7 +53,6 @@ set(FILES Source/Document/AtomToolsDocument.cpp Source/Document/AtomToolsDocumentApplication.cpp Source/Document/AtomToolsDocumentMainWindow.cpp - Source/Document/AtomToolsDocumentSystemSettings.cpp Source/Document/AtomToolsDocumentSystemComponent.cpp Source/Document/AtomToolsDocumentSystemComponent.h Source/DynamicProperty/DynamicProperty.cpp diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp index 357dfc37e0..8bf4191432 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.cpp @@ -14,8 +14,6 @@ namespace MaterialEditor SettingsWidget::SettingsWidget(QWidget* parent) : AtomToolsFramework::InspectorWidget(parent) { - m_documentSystemSettings = AZ::UserSettings::CreateFind( - AZ_CRC_CE("AtomToolsDocumentSystemSettings"), AZ::UserSettings::CT_GLOBAL); } SettingsWidget::~SettingsWidget() @@ -26,23 +24,9 @@ namespace MaterialEditor void SettingsWidget::Populate() { AddGroupsBegin(); - AddDocumentSystemSettingsGroup(); AddGroupsEnd(); } - void SettingsWidget::AddDocumentSystemSettingsGroup() - { - const AZStd::string groupName = "documentSystemSettings"; - const AZStd::string groupDisplayName = "Document System Settings"; - const AZStd::string groupDescription = "Document System Settings"; - - const AZ::Crc32 saveStateKey(AZStd::string::format("SettingsWidget::DocumentSystemSettingsGroup")); - AddGroup( - groupName, groupDisplayName, groupDescription, - new AtomToolsFramework::InspectorPropertyGroupWidget( - m_documentSystemSettings.get(), nullptr, m_documentSystemSettings->TYPEINFO_Uuid(), nullptr, this, saveStateKey)); - } - void SettingsWidget::Reset() { AtomToolsFramework::InspectorRequestBus::Handler::BusDisconnect(); diff --git a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h index 2642d9d55e..9a222b39c1 100644 --- a/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h +++ b/Gems/Atom/Tools/MaterialEditor/Code/Source/Window/SettingsDialog/SettingsWidget.h @@ -9,7 +9,6 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include #include #endif @@ -30,11 +29,7 @@ namespace MaterialEditor void Populate(); private: - void AddDocumentSystemSettingsGroup(); - // AtomToolsFramework::InspectorRequestBus::Handler overrides... void Reset() override; - - AZStd::intrusive_ptr m_documentSystemSettings; }; } // namespace MaterialEditor From e7857120b0896774f082898842e7e5e984f184c6 Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Mon, 7 Feb 2022 13:35:48 -0800 Subject: [PATCH 47/59] Fix issue with clearing the parent entityId in the transform would result in prefab reparenting. (#7464) Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../ToolsComponents/TransformComponent.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp index 55961aa703..014bade347 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/ToolsComponents/TransformComponent.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -963,18 +963,22 @@ namespace AzToolsFramework if (!m_parentEntityId.IsValid()) { - // If Prefabs are enabled, reroute the invalid id to the level root + // If Prefabs are enabled, reroute the invalid id to the focused prefab container entity id bool isPrefabSystemEnabled = false; AzFramework::ApplicationRequests::Bus::BroadcastResult( isPrefabSystemEnabled, &AzFramework::ApplicationRequests::IsPrefabSystemEnabled); if (isPrefabSystemEnabled) { - auto prefabPublicInterface = AZ::Interface::Get(); + auto prefabFocusPublicInterface = AZ::Interface::Get(); - if (prefabPublicInterface) + if (prefabFocusPublicInterface) { - m_parentEntityId = prefabPublicInterface->GetLevelInstanceContainerEntityId(); + auto editorEntityContextId = AzFramework::EntityContextId::CreateNull(); + EditorEntityContextRequestBus::BroadcastResult( + editorEntityContextId, &EditorEntityContextRequests::GetEditorEntityContextId); + + m_parentEntityId = prefabFocusPublicInterface->GetFocusedPrefabContainerEntityId(editorEntityContextId); refreshLevel = AZ::Edit::PropertyRefreshLevels::ValuesOnly; } } From 45e347315fefecc094bf49b3d6a87edf81318eaf Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Mon, 7 Feb 2022 13:49:25 -0800 Subject: [PATCH 48/59] Remove -Wno-unused-value suppression for GCC (#7387) - Remove '-Wno-unused-value' flag from GCC - Fixes for resulting errors - Ignore GCC error on FIR-Filter.cpp Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- Code/Legacy/CryCommon/ISystem.h | 54 +++++++++++++------ Code/Legacy/CryCommon/Linux64Specific.h | 2 +- .../Code/Source/Converters/FIR-Filter.cpp | 4 ++ .../Common/GCC/Configurations_gcc.cmake | 1 - 4 files changed, 44 insertions(+), 17 deletions(-) diff --git a/Code/Legacy/CryCommon/ISystem.h b/Code/Legacy/CryCommon/ISystem.h index b68dd2041c..b0974818dc 100644 --- a/Code/Legacy/CryCommon/ISystem.h +++ b/Code/Legacy/CryCommon/ISystem.h @@ -1280,48 +1280,72 @@ namespace Detail #endif -#define ASSERT_CONSOLE_EXISTS 0 - // the following macros allow the help text to be easily stripped out // Summary: // Preferred way to register a CVar -#define REGISTER_CVAR(_var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment))) +#define REGISTER_CVAR(_var, _def_val, _flags, _comment) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment))) + // Summary: // Preferred way to register a CVar with a callback -#define REGISTER_CVAR_CB(_var, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) +#define REGISTER_CVAR_CB(_var, _def_val, _flags, _comment, _onchangefunction) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register((#_var), &(_var), (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) + // Summary: // Preferred way to register a string CVar -#define REGISTER_STRING(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment))) +#define REGISTER_STRING(_name, _def_val, _flags, _comment) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment))) + // Summary: // Preferred way to register a string CVar with a callback -#define REGISTER_STRING_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) +#define REGISTER_STRING_CB(_name, _def_val, _flags, _comment, _onchangefunction) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterString(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) + // Summary: // Preferred way to register an int CVar -#define REGISTER_INT(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment))) +#define REGISTER_INT(_name, _def_val, _flags, _comment) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment))) + // Summary: // Preferred way to register an int CVar with a callback -#define REGISTER_INT_CB(_name, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) +#define REGISTER_INT_CB(_name, _def_val, _flags, _comment, _onchangefunction) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterInt(_name, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) + // Summary: // Preferred way to register a float CVar -#define REGISTER_FLOAT(_name, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment))) +#define REGISTER_FLOAT(_name, _def_val, _flags, _comment) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->RegisterFloat(_name, (_def_val), (_flags), CVARHELP(_comment))) + // Summary: // Offers more flexibility but more code is required -#define REGISTER_CVAR2(_name, _var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment))) +#define REGISTER_CVAR2(_name, _var, _def_val, _flags, _comment) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment))) + // Summary: // Offers more flexibility but more code is required -#define REGISTER_CVAR2_CB(_name, _var, _def_val, _flags, _comment, _onchangefunction) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) +#define REGISTER_CVAR2_CB(_name, _var, _def_val, _flags, _comment, _onchangefunction) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, _var, (_def_val), (_flags), CVARHELP(_comment), _onchangefunction)) + // Summary: // Offers more flexibility but more code is required, explicit address taking of destination variable -#define REGISTER_CVAR3(_name, _var, _def_val, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment))) +#define REGISTER_CVAR3(_name, _var, _def_val, _flags, _comment) \ + (gEnv->pConsole == 0 ? 0 : gEnv->pConsole->Register(_name, &(_var), (_def_val), (_flags), CVARHELP(_comment))) + // Summary: // Preferred way to register a console command -#define REGISTER_COMMAND(_name, _func, _flags, _comment) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? false : gEnv->pConsole->AddCommand(_name, _func, (_flags), CVARHELP(_comment))) +#define REGISTER_COMMAND(_name, _func, _flags, _comment) \ + (gEnv->pConsole == 0 ? false : gEnv->pConsole->AddCommand(_name, _func, (_flags), CVARHELP(_comment))) + // Summary: // Preferred way to unregister a CVar -#define UNREGISTER_CVAR(_name) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->UnregisterVariable(_name)) +#define UNREGISTER_CVAR(_name) \ + (gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->UnregisterVariable(_name)) + +// Summary: // Preferred way to unregister a console command -#define UNREGISTER_COMMAND(_name) (ASSERT_CONSOLE_EXISTS, gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->RemoveCommand(_name)) +#define UNREGISTER_COMMAND(_name) \ + (gEnv->pConsole == 0 ? (void)0 : gEnv->pConsole->RemoveCommand(_name)) //////////////////////////////////////////////////////////////////////////////// // diff --git a/Code/Legacy/CryCommon/Linux64Specific.h b/Code/Legacy/CryCommon/Linux64Specific.h index 07cb92f207..7783e48495 100644 --- a/Code/Legacy/CryCommon/Linux64Specific.h +++ b/Code/Legacy/CryCommon/Linux64Specific.h @@ -106,7 +106,7 @@ typedef uint8 byte; #ifdef _RELEASE #define __debugbreak() #else - #define __debugbreak() "_asm int 3" + #define __debugbreak() asm("int3") #endif #define __assume(x) diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp index 2b1e822db4..68e6138b23 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Source/Converters/FIR-Filter.cpp @@ -21,6 +21,8 @@ #define mallocAligned(sze) _aligned_malloc(sze, 16) #define freeAligned(ptr) _aligned_free(ptr) +AZ_PUSH_DISABLE_WARNING_GCC("-Wunused-value") + /* #################################################################################################################### */ @@ -1279,3 +1281,5 @@ namespace ImageProcessingAtom FilterImage(filterIndex, filterOp, blurH, blurV, srcImg, srcMip, dstImg, dstMip, srcRect, dstRect); } } + +AZ_POP_DISABLE_WARNING_GCC diff --git a/cmake/Platform/Common/GCC/Configurations_gcc.cmake b/cmake/Platform/Common/GCC/Configurations_gcc.cmake index 9ce6d2b405..d2d6059b69 100644 --- a/cmake/Platform/Common/GCC/Configurations_gcc.cmake +++ b/cmake/Platform/Common/GCC/Configurations_gcc.cmake @@ -72,7 +72,6 @@ ly_append_configurations_options( -Wno-uninitialized -Wno-unused-but-set-variable -Wno-unused-result - -Wno-unused-value -Wno-unused-variable COMPILATION_DEBUG From d209bf783c48397fed85a77167b114763ddf9dbf Mon Sep 17 00:00:00 2001 From: LesaelR <89800757+LesaelR@users.noreply.github.com> Date: Mon, 7 Feb 2022 14:01:58 -0800 Subject: [PATCH 49/59] Moving test_CLITool_AssetBuilder_Works to sandbox. (#7438) Signed-off-by: Rosario Cox --- AutomatedTesting/Gem/PythonTests/smoke/CMakeLists.txt | 10 ++++++++++ .../smoke/test_CLITool_AssetBuilder_Works.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/AutomatedTesting/Gem/PythonTests/smoke/CMakeLists.txt b/AutomatedTesting/Gem/PythonTests/smoke/CMakeLists.txt index 69d411536f..226d1970d8 100644 --- a/AutomatedTesting/Gem/PythonTests/smoke/CMakeLists.txt +++ b/AutomatedTesting/Gem/PythonTests/smoke/CMakeLists.txt @@ -45,4 +45,14 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) AutomatedTesting.Assets ) + ly_add_pytest( + NAME AutomatedTesting::SmokeTest_Sandbox + TEST_SUITE sandbox + TEST_SERIAL + PATH ${CMAKE_CURRENT_LIST_DIR} + PYTEST_MARKS "SUITE_sandbox" + RUNTIME_DEPENDENCIES + AZ::AssetProcessor + ) + endif() diff --git a/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py b/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py index 4c716a5be3..161614e1fe 100644 --- a/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py +++ b/AutomatedTesting/Gem/PythonTests/smoke/test_CLITool_AssetBuilder_Works.py @@ -14,7 +14,7 @@ import pytest import subprocess -@pytest.mark.SUITE_smoke +@pytest.mark.SUITE_sandbox class TestCLIToolAssetBuilderWorks(object): def test_CLITool_AssetBuilder_Works(self, build_directory): file_path = os.path.join(build_directory, "AssetBuilder") From 7ddfb5d6a09a3dee45df37b5f4b40ad42cb23c14 Mon Sep 17 00:00:00 2001 From: Steve Pham <82231385+spham-amzn@users.noreply.github.com> Date: Mon, 7 Feb 2022 15:58:29 -0800 Subject: [PATCH 50/59] Remove AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS and disabled tests from it (#7325) Signed-off-by: Steve Pham <82231385+spham-amzn@users.noreply.github.com> --- .../AzFramework/Tests/ProcessLaunchParseTests.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Code/Framework/AzFramework/Tests/ProcessLaunchParseTests.cpp b/Code/Framework/AzFramework/Tests/ProcessLaunchParseTests.cpp index 0a7eb24df4..875051b358 100644 --- a/Code/Framework/AzFramework/Tests/ProcessLaunchParseTests.cpp +++ b/Code/Framework/AzFramework/Tests/ProcessLaunchParseTests.cpp @@ -117,11 +117,7 @@ namespace UnitTest EXPECT_EQ(param2[0], "param2val"); } -#if AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS - TEST_F(ProcessLaunchParseTests, DISABLED_ProcessLauncher_StringsWithCommas_Success) -#else TEST_F(ProcessLaunchParseTests, ProcessLauncher_WithCommas_Success) -#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS { ProcessLaunchParseTests::ParsedArgMap argMap; AzFramework::ProcessOutput processOutput; @@ -155,11 +151,7 @@ namespace UnitTest EXPECT_EQ(param2[1], "al"); } -#if AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS - TEST_F(ProcessLaunchParseTests, DISABLED_ProcessLauncher_StringsWithSpaces_Success) -#else TEST_F(ProcessLaunchParseTests, ProcessLauncher_WithSpaces_Success) -#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS { ProcessLaunchParseTests::ParsedArgMap argMap; AzFramework::ProcessOutput processOutput; @@ -191,11 +183,7 @@ namespace UnitTest EXPECT_EQ(param2[0], "param2v al"); } -#if AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS - TEST_F(ProcessLaunchParseTests, DISABLED_ProcessLauncher_StringsWithSpacesAndComma_Success) -#else TEST_F(ProcessLaunchParseTests, ProcessLauncher_WithSpacesAndComma_Success) -#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS { ProcessLaunchParseTests::ParsedArgMap argMap; AzFramework::ProcessOutput processOutput; From a33529e86039421b12e5aa37db30a4b6b573bf4f Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Mon, 7 Feb 2022 16:19:24 -0800 Subject: [PATCH 51/59] Fixed group and bookmark display on graph load Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> A --- Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp | 4 ++++ Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp b/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp index e821ea9be2..d121ed49b0 100644 --- a/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp @@ -1286,6 +1286,10 @@ namespace GraphCanvas { GRAPH_CANVAS_PROFILE_FUNCTION(); const SceneComponentSaveData* saveData = saveDataContainer.FindSaveDataAs(); + if (!saveData) + { + return; + } for (const GraphCanvasConstructSaveData* currentConstruct : saveData->m_constructs) { diff --git a/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp b/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp index 3127a99ef6..7024a01570 100644 --- a/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Components/EditorGraph.cpp @@ -3543,11 +3543,9 @@ namespace ScriptCanvasEditor GraphCanvas::SceneRequestBus::Event(graphCanvasGraphId, &GraphCanvas::SceneRequests::SignalLoadStart); - auto saveDataIter = m_graphCanvasSaveData.find(GetEntityId()); - - if (saveDataIter != m_graphCanvasSaveData.end()) + for (auto& saveDataIter : m_graphCanvasSaveData) { - GraphCanvas::EntitySaveDataRequestBus::Event(graphCanvasGraphId, &GraphCanvas::EntitySaveDataRequests::ReadSaveData, (*saveDataIter->second)); + GraphCanvas::EntitySaveDataRequestBus::Event(graphCanvasGraphId, &GraphCanvas::EntitySaveDataRequests::ReadSaveData, (*saveDataIter.second)); } ScriptCanvas::NodeIdList nodeList = GetNodes(); From 1b52339b6be010c1d5b797525bc30a5a5ec10135 Mon Sep 17 00:00:00 2001 From: lsemp3d <58790905+lsemp3d@users.noreply.github.com> Date: Mon, 7 Feb 2022 16:48:23 -0800 Subject: [PATCH 52/59] PR feedback Signed-off-by: lsemp3d <58790905+lsemp3d@users.noreply.github.com> --- .../Code/Source/Components/SceneComponent.cpp | 61 +++++++++---------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp b/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp index d121ed49b0..425334293a 100644 --- a/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp +++ b/Gems/GraphCanvas/Code/Source/Components/SceneComponent.cpp @@ -1285,43 +1285,40 @@ namespace GraphCanvas void SceneComponent::ReadSaveData(const EntitySaveDataContainer& saveDataContainer) { GRAPH_CANVAS_PROFILE_FUNCTION(); - const SceneComponentSaveData* saveData = saveDataContainer.FindSaveDataAs(); - if (!saveData) + if (const SceneComponentSaveData* saveData = saveDataContainer.FindSaveDataAs()) { - return; - } - - for (const GraphCanvasConstructSaveData* currentConstruct : saveData->m_constructs) - { - AZ::Entity* constructEntity = nullptr; - switch (currentConstruct->m_constructType) + for (const GraphCanvasConstructSaveData* currentConstruct : saveData->m_constructs) { - case ConstructType::CommentNode: - GraphCanvasRequestBus::BroadcastResult(constructEntity, &GraphCanvasRequests::CreateCommentNode); - break; - case ConstructType::NodeGroup: - GraphCanvasRequestBus::BroadcastResult(constructEntity, &GraphCanvasRequests::CreateNodeGroup); - break; - case ConstructType::BookmarkAnchor: - GraphCanvasRequestBus::BroadcastResult(constructEntity, &GraphCanvasRequests::CreateBookmarkAnchor); - break; - default: - break; + AZ::Entity* constructEntity = nullptr; + switch (currentConstruct->m_constructType) + { + case ConstructType::CommentNode: + GraphCanvasRequestBus::BroadcastResult(constructEntity, &GraphCanvasRequests::CreateCommentNode); + break; + case ConstructType::NodeGroup: + GraphCanvasRequestBus::BroadcastResult(constructEntity, &GraphCanvasRequests::CreateNodeGroup); + break; + case ConstructType::BookmarkAnchor: + GraphCanvasRequestBus::BroadcastResult(constructEntity, &GraphCanvasRequests::CreateBookmarkAnchor); + break; + default: + break; + } + + if (constructEntity) + { + constructEntity->Init(); + constructEntity->Activate(); + + EntitySaveDataRequestBus::Event(constructEntity->GetId(), &EntitySaveDataRequests::ReadSaveData, currentConstruct->m_saveDataContainer); + + Add(constructEntity->GetId()); + } } - if (constructEntity) - { - constructEntity->Init(); - constructEntity->Activate(); - - EntitySaveDataRequestBus::Event(constructEntity->GetId(), &EntitySaveDataRequests::ReadSaveData, currentConstruct->m_saveDataContainer); - - Add(constructEntity->GetId()); - } + m_viewParams = saveData->m_viewParams; + m_bookmarkCounter = saveData->m_bookmarkCounter; } - - m_viewParams = saveData->m_viewParams; - m_bookmarkCounter = saveData->m_bookmarkCounter; } AZStd::any* SceneComponent::GetUserData() From 1db12ca46370fbb982c9e7306c741806d1fb6987 Mon Sep 17 00:00:00 2001 From: srikappa-amzn <82230713+srikappa-amzn@users.noreply.github.com> Date: Mon, 7 Feb 2022 17:59:13 -0800 Subject: [PATCH 53/59] Always store LinkIds during prefab instance serialization except when saving to disk (#7444) * Always store prefab instance linkIds to DOM except for saving to disk Signed-off-by: srikappa-amzn <82230713+srikappa-amzn@users.noreply.github.com> * Added more checks to remove linkIds from templates Signed-off-by: srikappa-amzn <82230713+srikappa-amzn@users.noreply.github.com> * Remove additional check to remove LinkId during template update Signed-off-by: srikappa-amzn <82230713+srikappa-amzn@users.noreply.github.com> --- .../Prefab/PrefabDomUtils.cpp | 2 +- .../AzToolsFramework/Prefab/PrefabDomUtils.h | 2 +- .../AzToolsFramework/Prefab/PrefabLoader.cpp | 4 ++-- .../Prefab/PrefabPublicHandler.cpp | 2 +- .../Prefab/PrefabSystemComponent.cpp | 22 +++++++++++-------- .../AzToolsFramework/Prefab/PrefabUndo.cpp | 14 +++++------- 6 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.cpp index d6faed4b0a..d1d3491156 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.cpp @@ -73,7 +73,7 @@ namespace AzToolsFramework settings.m_keepDefaults = true; } - if ((flags & StoreFlags::StoreLinkIds) != StoreFlags::None) + if ((flags & StoreFlags::StripLinkIds) != StoreFlags::StripLinkIds) { settings.m_metadata.Create(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.h index e336cf0fca..d2234f423b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabDomUtils.h @@ -52,7 +52,7 @@ namespace AzToolsFramework //! We do not save linkIds to file. However when loading a level we want to temporarily save //! linkIds to instance dom so any nested prefabs will have linkIds correctly set. - StoreLinkIds = 1 << 1 + StripLinkIds = 1 << 1 }; AZ_DEFINE_ENUM_BITWISE_OPERATORS(StoreFlags); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp index d0b057d45b..3b082fe9ff 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabLoader.cpp @@ -331,7 +331,7 @@ namespace AzToolsFramework } PrefabDom storedPrefabDom(&loadedTemplateDom->get().GetAllocator()); - if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom, PrefabDomUtils::StoreFlags::StoreLinkIds)) + if (!PrefabDomUtils::StoreInstanceInPrefabDom(loadedPrefabInstance, storedPrefabDom)) { return false; } @@ -359,7 +359,7 @@ namespace AzToolsFramework PrefabDom storedPrefabDom(&savingTemplateDom->get().GetAllocator()); if (!PrefabDomUtils::StoreInstanceInPrefabDom(savingPrefabInstance, storedPrefabDom, - PrefabDomUtils::StoreFlags::StripDefaultValues)) + PrefabDomUtils::StoreFlags::StripDefaultValues | PrefabDomUtils::StoreFlags::StripLinkIds)) { return false; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp index 62003cd846..4101357d65 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabPublicHandler.cpp @@ -197,7 +197,7 @@ namespace AzToolsFramework // Update the template of the instance since the entities are modified since the template creation. Prefab::PrefabDom serializedInstance; - if (Prefab::PrefabDomUtils::StoreInstanceInPrefabDom(instanceToCreate->get(), serializedInstance)) + if (m_instanceToTemplateInterface->GenerateDomForInstance(serializedInstance, instanceToCreate->get())) { m_prefabSystemComponentInterface->UpdatePrefabTemplate(instanceToCreate->get().GetTemplateId(), serializedInstance); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp index 38ffb98fcb..3234aa8b2d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabSystemComponent.cpp @@ -163,17 +163,21 @@ namespace AzToolsFramework void PrefabSystemComponent::PropagateTemplateChanges(TemplateId templateId, InstanceOptionalConstReference instanceToExclude) { - auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId); - if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end()) + TemplateReference findTemplateResult = FindTemplate(templateId); + if (findTemplateResult.has_value()) { - // We need to initialize a queue here because once all linked instances of a template are updated, - // we will find all the linkIds corresponding to the updated template and add them to this queue again. - AZStd::queue linkIdsToUpdateQueue; - linkIdsToUpdateQueue.push(LinkIds(templateIdToLinkIdsIterator->second.begin(), - templateIdToLinkIdsIterator->second.end())); - UpdateLinkedInstances(linkIdsToUpdateQueue); + auto templateIdToLinkIdsIterator = m_templateToLinkIdsMap.find(templateId); + if (templateIdToLinkIdsIterator != m_templateToLinkIdsMap.end()) + { + // We need to initialize a queue here because once all linked instances of a template are updated, + // we will find all the linkIds corresponding to the updated template and add them to this queue again. + AZStd::queue linkIdsToUpdateQueue; + linkIdsToUpdateQueue.push( + LinkIds(templateIdToLinkIdsIterator->second.begin(), templateIdToLinkIdsIterator->second.end())); + UpdateLinkedInstances(linkIdsToUpdateQueue); + } + UpdatePrefabInstances(templateId, instanceToExclude); } - UpdatePrefabInstances(templateId, instanceToExclude); } void PrefabSystemComponent::UpdatePrefabTemplate(TemplateId templateId, const PrefabDom& updatedDom) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp index dc799c235a..25879be23d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabUndo.cpp @@ -256,7 +256,7 @@ namespace AzToolsFramework return; } - PrefabDomReference sourceDom = sourceTemplate->get().GetPrefabDom(); + PrefabDom& sourceDom = sourceTemplate->get().GetPrefabDom(); //use instance pointer to reach position PrefabDomValueReference instanceDomRef = link->get().GetLinkedInstanceDom(); @@ -274,16 +274,14 @@ namespace AzToolsFramework (result.GetOutcome() != AZ::JsonSerializationResult::Outcomes::PartialSkip), "Some of the patches are not successfully applied."); - //remove the link id placed into the instance - auto linkIdIter = instanceDom.FindMember(PrefabDomUtils::LinkIdName); - if (linkIdIter != instanceDom.MemberEnd()) - { - instanceDom.RemoveMember(PrefabDomUtils::LinkIdName); - } + // Remove the link ids if present in the doms. We don't want any overrides to be created on top of linkIds because + // linkIds are not persistent and will be created dynamically when prefabs are loaded into the editor. + instanceDom.RemoveMember(PrefabDomUtils::LinkIdName); + sourceDom.RemoveMember(PrefabDomUtils::LinkIdName); //we use this to diff our copy against the vanilla template (source template) PrefabDom patchLink; - m_instanceToTemplateInterface->GeneratePatch(patchLink, sourceDom->get(), instanceDom); + m_instanceToTemplateInterface->GeneratePatch(patchLink, sourceDom, instanceDom); // Create a copy of patchLink by providing the allocator of m_linkDomNext so that the patch doesn't become invalid when // the patch goes out of scope in this function. From 01cac7871ba926f1da620f424ff3530d498d0661 Mon Sep 17 00:00:00 2001 From: Sergey Pereslavtsev Date: Tue, 8 Feb 2022 13:11:27 +0000 Subject: [PATCH 54/59] PipelineState build fix for non-unity builds Signed-off-by: Sergey Pereslavtsev --- Gems/Atom/RHI/Code/Tests/PipelineState.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/Atom/RHI/Code/Tests/PipelineState.h b/Gems/Atom/RHI/Code/Tests/PipelineState.h index 7f7303d0b9..29e2099097 100644 --- a/Gems/Atom/RHI/Code/Tests/PipelineState.h +++ b/Gems/Atom/RHI/Code/Tests/PipelineState.h @@ -23,7 +23,7 @@ namespace UnitTest AZStd::unordered_map m_pipelineStates; private: - AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const RHI::PipelineLibraryDescriptor&) override { return AZ::RHI::ResultCode::Success; } + AZ::RHI::ResultCode InitInternal(AZ::RHI::Device&, const AZ::RHI::PipelineLibraryDescriptor&) override { return AZ::RHI::ResultCode::Success; } void ShutdownInternal() override; AZ::RHI::ResultCode MergeIntoInternal(AZStd::span) override; AZ::RHI::ConstPtr GetSerializedDataInternal() const override { return nullptr; } From 46a435b8774ad8c02a4f3a9489a3068f414f0745 Mon Sep 17 00:00:00 2001 From: Allen Jackson <23512001+jackalbe@users.noreply.github.com> Date: Tue, 8 Feb 2022 09:11:25 -0600 Subject: [PATCH 55/59] {ghi7403} cleaning up file handles and warnings for PYI files (#7461) * {ghi7403} cleaning up file handles and warnings for PYI files Cleaning up file handles and warnings for PYI files while writing how to the python_symbols folder. The warnings are clogging up the Jenkins logs making it hard to find real errors. Signed-off-by: Allen Jackson <23512001+jackalbe@users.noreply.github.com> * fixing empty shared pointer failures during tests that do not set up the logging PYI logging Signed-off-by: Allen Jackson <23512001+jackalbe@users.noreply.github.com> --- .../Code/Source/PythonLogSymbolsComponent.cpp | 72 +++++++++---------- .../Code/Source/PythonLogSymbolsComponent.h | 11 ++- 2 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.cpp b/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.cpp index 0be51909f4..dc1f7d11cc 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.cpp +++ b/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -219,15 +220,15 @@ namespace EditorPythonBindings void PythonLogSymbolsComponent::LogClassWithName(const AZStd::string moduleName, const AZ::BehaviorClass* behaviorClass, const AZStd::string className) { - Internal::FileHandle fileHandle(OpenModuleAt(moduleName)); - if (fileHandle.IsValid()) + auto fileHandle = OpenModuleAt(moduleName); + if (fileHandle->IsValid()) { // Behavior Class types with member methods and properties AZStd::string buffer; AzFramework::StringFunc::Append(buffer, "class "); AzFramework::StringFunc::Append(buffer, className.data()); AzFramework::StringFunc::Append(buffer, ":\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, buffer.c_str(), buffer.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, buffer.c_str(), buffer.size()); buffer.clear(); if (behaviorClass->m_methods.empty() && behaviorClass->m_properties.empty()) @@ -235,7 +236,7 @@ namespace EditorPythonBindings AZStd::string body{ " # behavior class type with no methods or properties \n" }; Internal::Indent(1, body); AzFramework::StringFunc::Append(body, "pass\n\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, body.c_str(), body.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, body.c_str(), body.size()); } else { @@ -244,7 +245,7 @@ namespace EditorPythonBindings AZ::BehaviorProperty* property = properyEntry.second; AZStd::string propertyName{ properyEntry.first }; Scope::FetchScriptName(property->m_attributes, propertyName); - WriteProperty(fileHandle, 1, propertyName, *property, behaviorClass); + WriteProperty(*fileHandle, 1, propertyName, *property, behaviorClass); } for (const auto& methodEntry : behaviorClass->m_methods) @@ -254,7 +255,7 @@ namespace EditorPythonBindings { AZStd::string baseMethodName{ methodEntry.first }; Scope::FetchScriptName(method->m_attributes, baseMethodName); - WriteMethod(fileHandle, baseMethodName, *method, behaviorClass); + WriteMethod(*fileHandle, baseMethodName, *method, behaviorClass); } } } @@ -264,14 +265,13 @@ namespace EditorPythonBindings void PythonLogSymbolsComponent::LogClassMethod( const AZStd::string moduleName, const AZStd::string globalMethodName, - const AZ::BehaviorClass* behaviorClass, + [[maybe_unused]] const AZ::BehaviorClass* behaviorClass, const AZ::BehaviorMethod* behaviorMethod) { - AZ_UNUSED(behaviorClass); - Internal::FileHandle fileHandle(OpenModuleAt(moduleName)); - if (fileHandle.IsValid()) + auto fileHandle = OpenModuleAt(moduleName); + if (fileHandle->IsValid()) { - WriteMethod(fileHandle, globalMethodName, *behaviorMethod, nullptr); + WriteMethod(*fileHandle, globalMethodName, *behaviorMethod, nullptr); } } @@ -282,8 +282,8 @@ namespace EditorPythonBindings return; } - Internal::FileHandle fileHandle(OpenModuleAt(moduleName)); - if (fileHandle.IsValid()) + auto fileHandle = OpenModuleAt(moduleName); + if (fileHandle->IsValid()) { AZStd::string buffer; @@ -314,7 +314,7 @@ namespace EditorPythonBindings } AzFramework::StringFunc::Append(buffer, " -> Any:\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, buffer.c_str(), buffer.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, buffer.c_str(), buffer.size()); buffer.clear(); auto eventInfoBuilder = [this](const AZ::BehaviorMethod* behaviorMethod, AZStd::string& inOutStrBuffer, [[maybe_unused]] TypeMap& typeCache) @@ -398,7 +398,7 @@ namespace EditorPythonBindings Internal::Indent(1, buffer); AzFramework::StringFunc::Append(buffer, "pass\n\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, buffer.c_str(), buffer.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, buffer.c_str(), buffer.size()); // can the EBus create & destroy a handler? if (behaviorEBus->m_createHandler && behaviorEBus->m_destroyHandler) @@ -409,17 +409,17 @@ namespace EditorPythonBindings AzFramework::StringFunc::Append(buffer, "Handler() -> None:\n"); Internal::Indent(1, buffer); AzFramework::StringFunc::Append(buffer, "pass\n\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, buffer.c_str(), buffer.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, buffer.c_str(), buffer.size()); } } } void PythonLogSymbolsComponent::LogGlobalMethod(const AZStd::string moduleName, const AZStd::string methodName, const AZ::BehaviorMethod* behaviorMethod) { - Internal::FileHandle fileHandle(OpenModuleAt(moduleName)); - if (fileHandle.IsValid()) + auto fileHandle = OpenModuleAt(moduleName); + if (fileHandle->IsValid()) { - WriteMethod(fileHandle, methodName, *behaviorMethod, nullptr); + WriteMethod(*fileHandle, methodName, *behaviorMethod, nullptr); } auto functionMapIt = m_globalFunctionMap.find(moduleName); @@ -448,14 +448,14 @@ namespace EditorPythonBindings return; } - Internal::FileHandle fileHandle(OpenModuleAt(moduleName)); - if (fileHandle.IsValid()) + auto fileHandle = OpenModuleAt(moduleName); + if (fileHandle->IsValid()) { AZStd::string buffer; // add header AZ::u64 filesize = 0; - AZ::IO::FileIOBase::GetInstance()->Size(fileHandle, filesize); + AZ::IO::FileIOBase::GetInstance()->Size(fileHandle->m_handle, filesize); if (filesize == 0) { AzFramework::StringFunc::Append(buffer, "class property():\n"); @@ -483,14 +483,14 @@ namespace EditorPythonBindings } AzFramework::StringFunc::Append(buffer, "\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, buffer.c_str(), buffer.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, buffer.c_str(), buffer.size()); } } void PythonLogSymbolsComponent::Finalize() { - Internal::FileHandle fileHandle(OpenInitFileAt("azlmbr.bus")); - if (fileHandle) + auto fileHandle = OpenInitFileAt("azlmbr.bus"); + if (fileHandle->IsValid()) { AZStd::string buffer; AzFramework::StringFunc::Append(buffer, "# Bus dispatch types:\n"); @@ -499,9 +499,9 @@ namespace EditorPythonBindings AzFramework::StringFunc::Append(buffer, "Event: Final[int] = 1\n"); AzFramework::StringFunc::Append(buffer, "QueueBroadcast: Final[int] = 2\n"); AzFramework::StringFunc::Append(buffer, "QueueEvent: Final[int] = 3\n"); - AZ::IO::FileIOBase::GetInstance()->Write(fileHandle, buffer.c_str(), buffer.size()); + AZ::IO::FileIOBase::GetInstance()->Write(*fileHandle, buffer.c_str(), buffer.size()); } - fileHandle.Close(); + fileHandle->Close(); } void PythonLogSymbolsComponent::GetModuleList(AZStd::vector& moduleList) const @@ -689,11 +689,11 @@ namespace EditorPythonBindings return pythonType; } - AZ::IO::HandleType PythonLogSymbolsComponent::OpenInitFileAt(AZStd::string_view moduleName) + PythonLogSymbolsComponent::FileHandlePtr PythonLogSymbolsComponent::OpenInitFileAt(AZStd::string_view moduleName) { if (m_basePath.empty()) { - return AZ::IO::InvalidHandle; + return AZStd::make_shared(AZ::IO::InvalidHandle); } // creates the __init__.py file in this path @@ -708,20 +708,19 @@ namespace EditorPythonBindings AZ::IO::OpenMode openMode = AZ::IO::OpenMode::ModeText | AZ::IO::OpenMode::ModeWrite; AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle; AZ::IO::Result result = AZ::IO::FileIOBase::GetInstance()->Open(initFile.c_str(), openMode, fileHandle); - AZ_Warning("python", result, "Could not open %s to write Python symbols.", initFile.c_str()); if (result) { - return fileHandle; + return AZStd::make_shared(fileHandle); } - return AZ::IO::InvalidHandle; + return AZStd::make_shared(AZ::IO::InvalidHandle); } - AZ::IO::HandleType PythonLogSymbolsComponent::OpenModuleAt(AZStd::string_view moduleName) + PythonLogSymbolsComponent::FileHandlePtr PythonLogSymbolsComponent::OpenModuleAt(AZStd::string_view moduleName) { if (m_basePath.empty()) { - return AZ::IO::InvalidHandle; + return AZStd::make_shared(AZ::IO::InvalidHandle); } bool resetFile = false; @@ -769,12 +768,11 @@ namespace EditorPythonBindings AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle; AZ::IO::Result result = AZ::IO::FileIOBase::GetInstance()->Open(modulePath.c_str(), openMode, fileHandle); - AZ_Warning("python", result, "Could not open %s to write Python module symbols.", modulePath.c_str()); if (result) { - return fileHandle; + return AZStd::make_shared(fileHandle); } - return AZ::IO::InvalidHandle; + return AZStd::make_shared(AZ::IO::InvalidHandle); } } diff --git a/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.h b/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.h index 5fbd1c3f37..7e89a41cd5 100644 --- a/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.h +++ b/Gems/EditorPythonBindings/Code/Source/PythonLogSymbolsComponent.h @@ -27,6 +27,11 @@ namespace AZ namespace EditorPythonBindings { + namespace Internal + { + struct FileHandle; + } + //! Exports Python symbols to the log folder for Python script developers to include into their local projects class PythonLogSymbolsComponent : public AZ::Component @@ -77,11 +82,13 @@ namespace EditorPythonBindings AZStd::string_view FetchPythonTypeAndTraits(const AZ::TypeId& typeId, AZ::u32 traits); private: + using ModuleSet = AZStd::unordered_set; using GlobalFunctionEntry = AZStd::pair; using GlobalFunctionList = AZStd::vector; using GlobalFunctionMap = AZStd::unordered_map; using TypeMap = AZStd::unordered_map; + using FileHandlePtr = AZStd::shared_ptr; AZStd::string m_basePath; ModuleSet m_moduleSet; @@ -92,8 +99,8 @@ namespace EditorPythonBindings AZStd::string FetchMapType(const AZ::TypeId& typeId); AZStd::string FetchOutcomeType(const AZ::TypeId& typeId); AZStd::string TypeNameFallback(const AZ::TypeId& typeId); - AZ::IO::HandleType OpenInitFileAt(AZStd::string_view moduleName); - AZ::IO::HandleType OpenModuleAt(AZStd::string_view moduleName); + FileHandlePtr OpenInitFileAt(AZStd::string_view moduleName); + FileHandlePtr OpenModuleAt(AZStd::string_view moduleName); void WriteMethod(AZ::IO::HandleType handle, AZStd::string_view methodName, const AZ::BehaviorMethod& behaviorMethod, const AZ::BehaviorClass* behaviorClass); void WriteProperty(AZ::IO::HandleType handle, int level, AZStd::string_view propertyName, const AZ::BehaviorProperty& property, const AZ::BehaviorClass* behaviorClass); }; From 3337bdd05d7f769bed058a7048a5927e1ed6c5f0 Mon Sep 17 00:00:00 2001 From: Nicholas Lawson <70027408+lawsonamzn@users.noreply.github.com> Date: Tue, 8 Feb 2022 08:00:34 -0800 Subject: [PATCH 56/59] Update Lua to 5.4.4 (#7460) * Update lua to 5.4.4 (fixes #7267) Signed-off-by: lawsonamzn <70027408+lawsonamzn@users.noreply.github.com> --- .../AzCore/AzCore/Script/ScriptContext.cpp | 12 +++++- .../AzCore/AzCore/Script/ScriptContext.h | 4 ++ Code/Framework/AzCore/AzCore/Script/lua/lua.h | 39 ++++--------------- .../LuaBuilder/LuaBuilderComponent.cpp | 2 +- .../Builders/LuaBuilder/LuaBuilderWorker.cpp | 16 +++++++- .../Builders/LuaBuilder/LuaBuilderWorker.h | 2 + .../Android/BuiltInPackages_android.cmake | 2 +- .../Linux/BuiltInPackages_linux.cmake | 2 +- .../Platform/Mac/BuiltInPackages_mac.cmake | 2 +- .../Windows/BuiltInPackages_windows.cmake | 2 +- .../Platform/iOS/BuiltInPackages_ios.cmake | 2 +- 11 files changed, 44 insertions(+), 41 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptContext.cpp b/Code/Framework/AzCore/AzCore/Script/ScriptContext.cpp index 6b927b7010..13852ba354 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptContext.cpp +++ b/Code/Framework/AzCore/AzCore/Script/ScriptContext.cpp @@ -25,6 +25,11 @@ extern "C" { # include # include # include + + // versions of LUA before 5.3.x used to define a union that contained a double, a pointer, and a long + // as L_Umaxalign. Newer versions define those inner types in the macro LUAI_MAXALIGN instead but + // no longer actually declare a union around it. For backward compatibility we define the same one here + union L_Umaxalign { LUAI_MAXALIGN; }; } #include @@ -1687,6 +1692,11 @@ LUA_API const Node* lua_getDummyNode() ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// + const char* ScriptDataContext::GetInterpreterVersion() + { + return LUA_VERSION; + } + ////////////////////////////////////////////////////////////////////////// ScriptContext* ScriptDataContext::GetScriptContext() const @@ -4367,7 +4377,7 @@ LUA_API const Node* lua_getDummyNode() lua_pushlightuserdata(m_lua, m_owner); int tableRef = luaL_ref(m_lua, LUA_REGISTRYINDEX); (void)tableRef; - AZ_Assert(tableRef == AZ_LUA_SCRIPT_CONTEXT_REF, "Table referece should match %d !", AZ_LUA_SCRIPT_CONTEXT_REF); + AZ_Assert(tableRef == AZ_LUA_SCRIPT_CONTEXT_REF, "Table reference should match %d but is instead %d!", AZ_LUA_SCRIPT_CONTEXT_REF, tableRef); // create a AZGlobals table, we can use internal unodered_map if it's faster (TODO: test which is faster, or if there is a benefit keeping in la) lua_createtable(m_lua, 0, 1024); // pre allocate some values in the hash diff --git a/Code/Framework/AzCore/AzCore/Script/ScriptContext.h b/Code/Framework/AzCore/AzCore/Script/ScriptContext.h index 9a7b6681f9..c8f08a7772 100644 --- a/Code/Framework/AzCore/AzCore/Script/ScriptContext.h +++ b/Code/Framework/AzCore/AzCore/Script/ScriptContext.h @@ -212,6 +212,10 @@ namespace AZ ~ScriptDataContext() { Reset(); } + //! Retrieve a string representing the current version of the interpreter. + //! Example of use: To signal incompatibility with previously emitted bytecode, to invalidate + static const char* GetInterpreterVersion(); + ScriptContext* GetScriptContext() const; lua_State* GetNativeContext() const { return m_nativeContext; } diff --git a/Code/Framework/AzCore/AzCore/Script/lua/lua.h b/Code/Framework/AzCore/AzCore/Script/lua/lua.h index 7ec14a5b3d..2f69cc5db1 100644 --- a/Code/Framework/AzCore/AzCore/Script/lua/lua.h +++ b/Code/Framework/AzCore/AzCore/Script/lua/lua.h @@ -14,38 +14,13 @@ extern "C" { # include } -// Currently we support Lua 5.1 and later (we have tested with 5.2) - -#if LUA_VERSION_NUM <= 502 - -inline void lua_pushunsigned(lua_State* l, unsigned int v) -{ - lua_pushnumber(l, static_cast(v)); -} - -inline unsigned int lua_tounsigned(lua_State* l, int idx) -{ - return static_cast(lua_tonumber(l, idx)); -} - -#define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) - -inline LUA_API int lua_load(lua_State* L, lua_Reader reader, void* data, const char* chunkname, const char* mode) -{ - (void)mode; - return lua_load(L, reader, data, chunkname); -} - -#define LUA_RIDX_LAST 0 -#define LUA_NUMTAGS 9 - -#endif - -#define AZ_LUA_SCRIPT_CONTEXT_REF LUA_RIDX_LAST + 1 -#define AZ_LUA_GLOBALS_TABLE_REF LUA_RIDX_LAST + 2 -#define AZ_LUA_CLASS_TABLE_REF LUA_RIDX_LAST + 3 -#define AZ_LUA_WEAK_CACHE_TABLE_REF LUA_RIDX_LAST + 4 -#define AZ_LUA_ERROR_HANDLER_FUN_REF LUA_RIDX_LAST + 5 +// Currently we support Lua 5.4.4 and later +// note that Lua 5.x defines LUA_RID_LAST + 1 to be an index of a free-list. +#define AZ_LUA_SCRIPT_CONTEXT_REF LUA_RIDX_LAST + 2 +#define AZ_LUA_GLOBALS_TABLE_REF LUA_RIDX_LAST + 3 +#define AZ_LUA_CLASS_TABLE_REF LUA_RIDX_LAST + 4 +#define AZ_LUA_WEAK_CACHE_TABLE_REF LUA_RIDX_LAST + 5 +#define AZ_LUA_ERROR_HANDLER_FUN_REF LUA_RIDX_LAST + 6 #define AZ_LUA_CLASS_METATABLE_NAME_INDEX 1 // can we always read the name from the behavior class??? #define AZ_LUA_CLASS_METATABLE_BEHAVIOR_CLASS 2 diff --git a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderComponent.cpp b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderComponent.cpp index 0ef02837da..89e2968639 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderComponent.cpp +++ b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderComponent.cpp @@ -26,7 +26,7 @@ void LuaBuilder::BuilderPluginComponent::Activate() AssetBuilderSDK::AssetBuilderDesc builderDescriptor; builderDescriptor.m_name = "Lua Worker Builder"; builderDescriptor.m_version = 7; - builderDescriptor.m_analysisFingerprint = AZStd::string::format("%d", static_cast(AZ::ScriptAsset::AssetVersion)); + builderDescriptor.m_analysisFingerprint = AZStd::string::format("%s-%d", LuaBuilderWorker::GetAnalysisFingerprint().c_str(), static_cast(AZ::ScriptAsset::AssetVersion)); builderDescriptor.m_patterns.push_back(AssetBuilderSDK::AssetBuilderPattern("*.lua", AssetBuilderSDK::AssetBuilderPattern::PatternType::Wildcard)); builderDescriptor.m_busId = azrtti_typeid(); builderDescriptor.m_createJobFunction = AZStd::bind(&LuaBuilderWorker::CreateJobs, &m_luaBuilder, AZStd::placeholders::_1, AZStd::placeholders::_2); diff --git a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.cpp b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.cpp index b3ba419321..69ba5e0ea1 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.cpp +++ b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.cpp @@ -14,13 +14,13 @@ #include #include #include -#include #include #include #include #include +#include // for lua_tostring namespace LuaBuilder { @@ -36,8 +36,15 @@ namespace LuaBuilder static const AZ::u32 s_BuildTypeKey = AZ_CRC("BuildType", 0xd01cbdd7); static const char* s_BuildTypeCompiled = "Compiled"; - static const char* s_BuildTypeText = "Text"; } + static const char* s_BuildTypeText = "Text"; + } + AZStd::string LuaBuilderWorker::GetAnalysisFingerprint() + { + // mutating the Analysis Fingerprint will cause the CreateJobs function to run even + // on files which have not changed. + return AZ::ScriptDataContext::GetInterpreterVersion(); + } ////////////////////////////////////////////////////////////////////////// // CreateJobs void LuaBuilderWorker::CreateJobs(const AssetBuilderSDK::CreateJobsRequest& request, AssetBuilderSDK::CreateJobsResponse& response) @@ -57,6 +64,11 @@ namespace LuaBuilder descriptor.m_jobKey = "Lua Compile"; descriptor.SetPlatformIdentifier(info.m_identifier.c_str()); descriptor.m_critical = true; + // mutating the AdditionalFingerprintInfo will cause the job to run even if + // nothing else has changed (ie, files are the same, version of this builder didnt change) + // by doing this, changing the version of the interpreter is enough to cause the files to rebuild + // automatically. + descriptor.m_additionalFingerprintInfo = GetAnalysisFingerprint(); descriptor.m_jobParameters[s_BuildTypeKey] = info.HasTag("android") ? s_BuildTypeText : s_BuildTypeCompiled; response.m_createJobOutputs.push_back(descriptor); } diff --git a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h index 6f2aeecb8f..3371329846 100644 --- a/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h +++ b/Gems/LmbrCentral/Code/Source/Builders/LuaBuilder/LuaBuilderWorker.h @@ -34,6 +34,8 @@ namespace LuaBuilder void ShutDown() override; ////////////////////////////////////////////////////////////////////////// + static AZStd::string GetAnalysisFingerprint(); + void ParseDependencies(const AZStd::string& file, AssetBuilderSDK::ProductPathDependencySet& outDependencies); private: diff --git a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake index d231954c49..2ffbe75084 100644 --- a/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake +++ b/cmake/3rdParty/Platform/Android/BuiltInPackages_android.cmake @@ -19,7 +19,7 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS gla ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev4-android TARGETS TIFF PACKAGE_HASH 2c62cdf34a8ee6c7eb091d05d98f60b4da7634c74054d4dbb8736886182f4589) ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-android TARGETS freetype PACKAGE_HASH df9e4d559ea0f03b0666b48c79813b1cd4d9624429148a249865de9f5c2c11cd) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.9.50-rev1-android TARGETS AWSNativeSDK PACKAGE_HASH 33771499f9080cbaab613459927e52911e68f94fa356397885e85005efbd1490) -ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-android TARGETS Lua PACKAGE_HASH 1f638e94a17a87fe9e588ea456d5893876094b4db191234380e4c4eb9e06c300) +ly_associate_package(PACKAGE_NAME Lua-5.4.4-rev1-android TARGETS Lua PACKAGE_HASH 2adda1831577336454090f249baf09519f41bb73160cd1d5b5b33564729af4a2) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev5-android TARGETS PhysX PACKAGE_HASH b346e8f9bc55f367a97d781d94c8a5c3bff8059478b8a7007e5fd17708dc1d07) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-android TARGETS mikkelsen PACKAGE_HASH 075e8e4940884971063b5a9963014e2e517246fa269c07c7dc55b8cf2cd99705) ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-android TARGETS googletest PACKAGE_HASH 95671be75287a61c9533452835c3647e9c1b30f81b34b43bcb0ec1997cc23894) diff --git a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake index 5d30abfb4d..de36760ea4 100644 --- a/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake +++ b/cmake/3rdParty/Platform/Linux/BuiltInPackages_linux.cmake @@ -24,7 +24,7 @@ ly_associate_package(PACKAGE_NAME AWSGameLiftServerSDK-3.4.1-rev1-linux ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-linux TARGETS TIFF PACKAGE_HASH 2377f48b2ebc2d1628d9f65186c881544c92891312abe478a20d10b85877409a) ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-linux TARGETS freetype PACKAGE_HASH 3f10c703d9001ecd2bb51a3bd003d3237c02d8f947ad0161c0252fdc54cbcf97) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.9.50-rev1-linux TARGETS AWSNativeSDK PACKAGE_HASH f30b6969c6732a7c1a23a59d205a150633a7f219dcb60d837b543888d2c63ea1) -ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev7-linux TARGETS Lua PACKAGE_HASH 81a6ce4965c63e264f923d3ca04ddc40c27074b3e607073c6ad90eca32b9c260) +ly_associate_package(PACKAGE_NAME Lua-5.4.4-rev1-linux TARGETS Lua PACKAGE_HASH d582362c3ef90e1ef175a874abda2265839ffc2e40778fa293f10b443b4697ac) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev5-linux TARGETS PhysX PACKAGE_HASH fa72365df409376aef02d1763194dc91d255bdfcb4e8febcfbb64d23a3e50b96) ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-linux TARGETS mcpp PACKAGE_HASH df7a998d0bc3fedf44b5bdebaf69ddad6033355b71a590e8642445ec77bc6c41) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-linux TARGETS mikkelsen PACKAGE_HASH 5973b1e71a64633588eecdb5b5c06ca0081f7be97230f6ef64365cbda315b9c8) diff --git a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake index 082cefee5d..ae51076857 100644 --- a/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake +++ b/cmake/3rdParty/Platform/Mac/BuiltInPackages_mac.cmake @@ -25,7 +25,7 @@ ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-mac ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-mac TARGETS TIFF PACKAGE_HASH c2615ccdadcc0e1d6c5ed61e5965c4d3a82193d206591b79b805c3b3ff35a4bf) ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-mac TARGETS freetype PACKAGE_HASH f159b346ac3251fb29cb8dd5f805c99b0015ed7fdb3887f656945ca701a61d0d) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.9.50-rev1-mac TARGETS AWSNativeSDK PACKAGE_HASH 6c27a49376870c606144e4639e15867f9db7e4a1ee5f1a726f152d3bd8459966) -ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev6-mac TARGETS Lua PACKAGE_HASH b9079fd35634774c9269028447562c6b712dbc83b9c64975c095fd423ff04c08) +ly_associate_package(PACKAGE_NAME Lua-5.4.4-rev1-mac TARGETS Lua PACKAGE_HASH b44daae6bfdf092c7935e4aebafded6772853250c6f0a209866a1ac599857d58) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev5-mac TARGETS PhysX PACKAGE_HASH 83940b3876115db82cd8ffcb9e902278e75846d6ad94a41e135b155cee1ee186) ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-mac TARGETS mcpp PACKAGE_HASH be9558905c9c49179ef3d7d84f0a5472415acdf7fe2d76eb060d9431723ddf2e) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-mac TARGETS mikkelsen PACKAGE_HASH 83af99ca8bee123684ad254263add556f0cf49486c0b3e32e6d303535714e505) diff --git a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake index dd4d158d1c..3ce5730f2a 100644 --- a/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake +++ b/cmake/3rdParty/Platform/Windows/BuiltInPackages_windows.cmake @@ -26,7 +26,7 @@ ly_associate_package(PACKAGE_NAME SPIRVCross-2021.04.29-rev1-windows ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-windows TARGETS TIFF PACKAGE_HASH c6000a906e6d2a0816b652e93dfbeab41c9ed73cdd5a613acd53e553d0510b60) ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-windows TARGETS freetype PACKAGE_HASH 9809255f1c59b07875097aa8d8c6c21c97c47a31fb35e30f2bb93188e99a85ff) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.9.50-rev2-windows TARGETS AWSNativeSDK PACKAGE_HASH 047de23fa57d33196666c22f45afc9c628bae354a6c39d774cbeee8054b2eb53) -ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-windows TARGETS Lua PACKAGE_HASH 136faccf1f73891e3fa3b95f908523187792e56f5b92c63c6a6d7e72d1158d40) +ly_associate_package(PACKAGE_NAME Lua-5.4.4-rev1-windows TARGETS Lua PACKAGE_HASH 8ac853288712267ec9763be152a9274ce87b54728b8add97e2ba73c0fd5a0345) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev5-windows TARGETS PhysX PACKAGE_HASH 4e31a3e1f5bf3952d8af8e28d1a29f04167995a6362fc3a7c20c25f74bf01e23) ly_associate_package(PACKAGE_NAME mcpp-2.7.2_az.2-rev1-windows TARGETS mcpp PACKAGE_HASH 794789aba639bfe2f4e8fcb4424d679933dd6290e523084aa0a4e287ac44acb2) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-windows TARGETS mikkelsen PACKAGE_HASH 872c4d245a1c86139aa929f2b465b63ea4ea55b04ced50309135dd4597457a4e) diff --git a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake index 3f1bb204f7..5854738338 100644 --- a/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake +++ b/cmake/3rdParty/Platform/iOS/BuiltInPackages_ios.cmake @@ -19,7 +19,7 @@ ly_associate_package(PACKAGE_NAME glad-2.0.0-beta-rev2-multiplatform TARGETS gla ly_associate_package(PACKAGE_NAME tiff-4.2.0.15-rev3-ios TARGETS TIFF PACKAGE_HASH e9067e88649fb6e93a926d9ed38621a9fae360a2e6f6eb24ebca63c1bc7761ea) ly_associate_package(PACKAGE_NAME freetype-2.10.4.16-ios TARGETS freetype PACKAGE_HASH 3ac3c35e056ae4baec2e40caa023d76a7a3320895ef172b6655e9261b0dc2e29) ly_associate_package(PACKAGE_NAME AWSNativeSDK-1.9.50-rev1-ios TARGETS AWSNativeSDK PACKAGE_HASH c3c9478c259ecb569fb2ce6fcfa733647adc3b6bd2854e8eff9de64bcd18c745) -ly_associate_package(PACKAGE_NAME Lua-5.3.5-rev5-ios TARGETS Lua PACKAGE_HASH c2d3c4e67046c293049292317a7d60fdb8f23effeea7136aefaef667163e5ffe) +ly_associate_package(PACKAGE_NAME Lua-5.4.4-rev1-ios TARGETS Lua PACKAGE_HASH 82f27bf6c745c98395dcea7ec72f82cb5254fd19fca9f5ac7a6246527a30bacb) ly_associate_package(PACKAGE_NAME PhysX-4.1.2.29882248-rev5-ios TARGETS PhysX PACKAGE_HASH 4a5e38b385837248590018eb133444b4e440190414e6756191200a10c8fa5615) ly_associate_package(PACKAGE_NAME mikkelsen-1.0.0.4-ios TARGETS mikkelsen PACKAGE_HASH 976aaa3ccd8582346132a10af253822ccc5d5bcc9ea5ba44d27848f65ee88a8a) ly_associate_package(PACKAGE_NAME googletest-1.8.1-rev4-ios TARGETS googletest PACKAGE_HASH 2f121ad9784c0ab73dfaa58e1fee05440a82a07cc556bec162eeb407688111a7) From 48313cd6dee676e90775b744e0625e54837a9b34 Mon Sep 17 00:00:00 2001 From: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> Date: Tue, 8 Feb 2022 12:40:10 -0800 Subject: [PATCH 57/59] Remove const reference to prevent issues in nightly builds. (#7491) Signed-off-by: Danilo Aimini <82231674+AMZN-daimini@users.noreply.github.com> --- .../AzToolsFramework/Prefab/PrefabFocusHandler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp index 62c6518d4c..800464a336 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Prefab/PrefabFocusHandler.cpp @@ -292,7 +292,7 @@ namespace AzToolsFramework::Prefab return false; } - const InstanceOptionalConstReference instance = m_instanceEntityMapperInterface->FindOwningInstance(entityId); + InstanceOptionalReference instance = m_instanceEntityMapperInterface->FindOwningInstance(entityId); if (!instance.has_value()) { return false; @@ -308,7 +308,7 @@ namespace AzToolsFramework::Prefab return false; } - InstanceOptionalConstReference instance = m_instanceEntityMapperInterface->FindOwningInstance(entityId); + InstanceOptionalReference instance = m_instanceEntityMapperInterface->FindOwningInstance(entityId); while (instance.has_value()) { if (instance->get().GetAbsoluteInstanceAliasPath() == m_rootAliasFocusPath) From c46c55803860cec45f2bb197c159116e90604ec6 Mon Sep 17 00:00:00 2001 From: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> Date: Tue, 8 Feb 2022 15:00:19 -0600 Subject: [PATCH 58/59] Switched Gradient Surface benchmarks to use actual surface components. (#7468) * Switched Gradient Surface benchmarks to use actual surface components. The gradient unit tests and benchmarks were previously using a mock surface data system, which led to misleading benchmark results. Now, the actual SurfaceData system gets constructed, and the tests use a mock provider, but the benchmarks use actual shape providers for more realistic benchmarking. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> * Fixed unit tests to have better query ranges. Half of each previous range was querying outside the surface provider's data. Signed-off-by: Mike Balfour <82224783+mbalfour-amzn@users.noreply.github.com> --- Gems/FastNoise/Code/Tests/FastNoiseTest.cpp | 2 +- .../Code/Tests/GradientSignalBenchmarks.cpp | 9 --- .../Tests/GradientSignalGetValuesTests.cpp | 43 +++++----- .../Tests/GradientSignalReferencesTests.cpp | 63 +++++++++------ .../Code/Tests/GradientSignalSurfaceTests.cpp | 7 +- .../Code/Tests/GradientSignalTestFixtures.cpp | 80 +++++++++++-------- .../Code/Tests/GradientSignalTestFixtures.h | 10 +-- .../Code/Tests/GradientSignalTestHelpers.cpp | 6 +- .../Code/Tests/GradientSignalTestHelpers.h | 2 +- .../Code/Tests/GradientSignalTestMocks.h | 61 ++++++++++++++ .../Components/SurfaceDataColliderComponent.h | 0 .../Components/SurfaceDataShapeComponent.h | 0 .../Components}/SurfaceDataSystemComponent.h | 4 + .../SurfaceData/SurfaceDataSystemRequestBus.h | 4 + .../SurfaceData/Tests/SurfaceDataTestMocks.h | 10 +++ .../SurfaceDataColliderComponent.cpp | 2 +- .../Components/SurfaceDataShapeComponent.cpp | 2 +- .../EditorSurfaceDataColliderComponent.h | 2 +- .../Editor/EditorSurfaceDataShapeComponent.h | 2 +- .../Code/Source/SurfaceDataEditorModule.cpp | 2 +- .../Code/Source/SurfaceDataModule.cpp | 6 +- .../Source/SurfaceDataSystemComponent.cpp | 30 ++++++- .../Code/Source/SurfaceDataTypes.cpp | 4 +- .../Code/Tests/SurfaceDataBenchmarks.cpp | 4 +- .../SurfaceDataColliderComponentTest.cpp | 2 +- .../Code/Tests/SurfaceDataTest.cpp | 2 +- .../Code/Tests/SurfaceDataTestFixtures.cpp | 6 +- Gems/SurfaceData/Code/surfacedata_files.cmake | 6 +- Gems/Vegetation/Code/Tests/VegetationMocks.h | 10 +++ 29 files changed, 252 insertions(+), 129 deletions(-) rename Gems/SurfaceData/Code/{Source => Include/SurfaceData}/Components/SurfaceDataColliderComponent.h (100%) rename Gems/SurfaceData/Code/{Source => Include/SurfaceData}/Components/SurfaceDataShapeComponent.h (100%) rename Gems/SurfaceData/Code/{Source => Include/SurfaceData/Components}/SurfaceDataSystemComponent.h (95%) diff --git a/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp b/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp index 1ac5e8ddca..e82409d599 100644 --- a/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp +++ b/Gems/FastNoise/Code/Tests/FastNoiseTest.cpp @@ -102,7 +102,7 @@ TEST_F(FastNoiseTest, FastNoise_VerifyGetValueAndGetValuesMatch) noiseEntity->Activate(); // Create a gradient sampler and run through a series of points to see if they match expectations. - UnitTest::GradientSignalTestHelpers::CompareGetValueAndGetValues(noiseEntity->GetId(), shapeHalfBounds); + UnitTest::GradientSignalTestHelpers::CompareGetValueAndGetValues(noiseEntity->GetId(), -shapeHalfBounds, shapeHalfBounds); } // This uses custom test / benchmark hooks so that we can load LmbrCentral and GradientSignal Gems. diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalBenchmarks.cpp b/Gems/GradientSignal/Code/Tests/GradientSignalBenchmarks.cpp index 6ffb4a31c4..d8194dcc9a 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalBenchmarks.cpp +++ b/Gems/GradientSignal/Code/Tests/GradientSignalBenchmarks.cpp @@ -140,27 +140,18 @@ namespace UnitTest BENCHMARK_DEFINE_F(GradientGetValues, BM_SurfaceAltitudeGradient)(benchmark::State& state) { - auto mockSurfaceDataSystem = - CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds))); - auto entity = BuildTestSurfaceAltitudeGradient(TestShapeHalfBounds); GradientSignalTestHelpers::RunGetValueOrGetValuesBenchmark(state, entity->GetId()); } BENCHMARK_DEFINE_F(GradientGetValues, BM_SurfaceMaskGradient)(benchmark::State& state) { - auto mockSurfaceDataSystem = - CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds))); - auto entity = BuildTestSurfaceMaskGradient(TestShapeHalfBounds); GradientSignalTestHelpers::RunGetValueOrGetValuesBenchmark(state, entity->GetId()); } BENCHMARK_DEFINE_F(GradientGetValues, BM_SurfaceSlopeGradient)(benchmark::State& state) { - auto mockSurfaceDataSystem = - CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds))); - auto entity = BuildTestSurfaceSlopeGradient(TestShapeHalfBounds); GradientSignalTestHelpers::RunGetValueOrGetValuesBenchmark(state, entity->GetId()); } diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalGetValuesTests.cpp b/Gems/GradientSignal/Code/Tests/GradientSignalGetValuesTests.cpp index f0ad53ee64..e217dbb103 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalGetValuesTests.cpp +++ b/Gems/GradientSignal/Code/Tests/GradientSignalGetValuesTests.cpp @@ -24,31 +24,33 @@ namespace UnitTest TEST_F(GradientSignalGetValuesTestsFixture, ImageGradientComponent_VerifyGetValueAndGetValuesMatch) { auto entity = BuildTestImageGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, PerlinGradientComponent_VerifyGetValueAndGetValuesMatch) { auto entity = BuildTestPerlinGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, RandomGradientComponent_VerifyGetValueAndGetValuesMatch) { auto entity = BuildTestRandomGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, ConstantGradientComponent_VerifyGetValueAndGetValuesMatch) { auto entity = BuildTestConstantGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, ShapeAreaFalloffGradientComponent_VerifyGetValueAndGetValuesMatch) { auto entity = BuildTestShapeAreaFalloffGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + + // Use a query range larger than our shape to ensure that we're getting falloff values within our query bounds. + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), -TestShapeHalfBounds, TestShapeHalfBounds * 3.0f); } TEST_F(GradientSignalGetValuesTestsFixture, DitherGradientComponent_VerifyGetValueAndGetValuesMatch) @@ -56,21 +58,21 @@ namespace UnitTest auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestDitherGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, InvertGradientComponent_VerifyGetValueAndGetValuesMatch) { auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestInvertGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, LevelsGradientComponent_VerifyGetValueAndGetValuesMatch) { auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestLevelsGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, MixedGradientComponent_VerifyGetValueAndGetValuesMatch) @@ -78,62 +80,53 @@ namespace UnitTest auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto mixedEntity = BuildTestConstantGradient(TestShapeHalfBounds); auto entity = BuildTestMixedGradient(TestShapeHalfBounds, baseEntity->GetId(), mixedEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, PosterizeGradientComponent_VerifyGetValueAndGetValuesMatch) { auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestPosterizeGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, ReferenceGradientComponent_VerifyGetValueAndGetValuesMatch) { auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestReferenceGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, SmoothStepGradientComponent_VerifyGetValueAndGetValuesMatch) { auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestSmoothStepGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, ThresholdGradientComponent_VerifyGetValueAndGetValuesMatch) { auto baseEntity = BuildTestRandomGradient(TestShapeHalfBounds); auto entity = BuildTestThresholdGradient(TestShapeHalfBounds, baseEntity->GetId()); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, SurfaceAltitudeGradientComponent_VerifyGetValueAndGetValuesMatch) { - auto mockSurfaceDataSystem = - CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds))); - auto entity = BuildTestSurfaceAltitudeGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, SurfaceMaskGradientComponent_VerifyGetValueAndGetValuesMatch) { - auto mockSurfaceDataSystem = - CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds))); - auto entity = BuildTestSurfaceMaskGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } TEST_F(GradientSignalGetValuesTestsFixture, SurfaceSlopeGradientComponent_VerifyGetValueAndGetValuesMatch) { - auto mockSurfaceDataSystem = - CreateMockSurfaceDataSystem(AZ::Aabb::CreateFromMinMax(AZ::Vector3(-TestShapeHalfBounds), AZ::Vector3(TestShapeHalfBounds))); - auto entity = BuildTestSurfaceSlopeGradient(TestShapeHalfBounds); - GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), TestShapeHalfBounds); + GradientSignalTestHelpers::CompareGetValueAndGetValues(entity->GetId(), 0.0f, TestShapeHalfBounds * 2.0f); } } diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalReferencesTests.cpp b/Gems/GradientSignal/Code/Tests/GradientSignalReferencesTests.cpp index 6f90c5022f..2e602e8c80 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalReferencesTests.cpp +++ b/Gems/GradientSignal/Code/Tests/GradientSignalReferencesTests.cpp @@ -65,7 +65,11 @@ namespace UnitTest float slopeMin, float slopeMax, GradientSignal::SurfaceSlopeGradientConfig::RampType rampType, float falloffMidpoint, float falloffRange, float falloffStrength) { - MockSurfaceDataSystem mockSurfaceDataSystem; + auto surfaceEntity = CreateEntity(); + auto mockSurface = surfaceEntity->CreateComponent(); + mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(aznumeric_cast(dataSize))); + mockSurface->m_tags.emplace_back("test_mask"); + AzFramework::SurfaceData::SurfacePoint point; // Fill our mock surface with the correct normal value for each point based on our test angle set. @@ -75,9 +79,10 @@ namespace UnitTest { float angle = AZ::DegToRad(inputAngles[(y * dataSize) + x]); point.m_normal = AZ::Vector3(sinf(angle), 0.0f, cosf(angle)); - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(static_cast(x), static_cast(y))] = { { point } }; + mockSurface->m_surfacePoints[AZStd::make_pair(static_cast(x), static_cast(y))] = { { point } }; } } + ActivateEntity(surfaceEntity.get()); GradientSignal::SurfaceSlopeGradientConfig config; config.m_slopeMin = slopeMin; @@ -538,11 +543,14 @@ namespace UnitTest mockShapeComponentHandler.m_GetEncompassingAabb = AZ::Aabb::CreateFromMinMax(AZ::Vector3::CreateZero(), AZ::Vector3(10.0f)); // Set a different altitude for each point we're going to test. We'll use 0, 2, 5, 10 to test various points along the range. - MockSurfaceDataSystem mockSurfaceDataSystem; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } }; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } }; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } }; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } }; + auto surfaceEntity = CreateEntity(); + auto mockSurface = surfaceEntity->CreateComponent(); + mockSurface->m_bounds = mockShapeComponentHandler.m_GetEncompassingAabb; + mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } }; + ActivateEntity(surfaceEntity.get()); // We set the min/max to values other than 0-10 to help validate that they aren't used in the case of the pinned shape. GradientSignal::SurfaceAltitudeGradientConfig config; @@ -572,11 +580,14 @@ namespace UnitTest auto entityShape = CreateEntity(); // Set a different altitude for each point we're going to test. We'll use 0, 2, 5, 10 to test various points along the range. - MockSurfaceDataSystem mockSurfaceDataSystem; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } }; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } }; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } }; - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } }; + auto surfaceEntity = CreateEntity(); + auto mockSurface = surfaceEntity->CreateComponent(); + mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(1.0f)); + mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 0.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, 2.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 5.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 10.0f), AZ::Vector3::CreateZero() } }; + ActivateEntity(surfaceEntity.get()); // We set the min/max to 0-10, but don't set a shape. GradientSignal::SurfaceAltitudeGradientConfig config; @@ -603,9 +614,6 @@ namespace UnitTest auto entityShape = CreateEntity(); - // Don't set any points. - MockSurfaceDataSystem mockSurfaceDataSystem; - // We set the min/max to -5 - 15 so that a height of 0 would produce a non-zero value. GradientSignal::SurfaceAltitudeGradientConfig config; config.m_altitudeMin = -5.0f; @@ -631,16 +639,18 @@ namespace UnitTest auto entityShape = CreateEntity(); - MockSurfaceDataSystem mockSurfaceDataSystem; - + auto surfaceEntity = CreateEntity(); + auto mockSurface = surfaceEntity->CreateComponent(); + mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(1.0f)); // Altitude value below min - should result in 0.0f. - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -10.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -10.0f), AZ::Vector3::CreateZero() } }; // Altitude value at exactly min - should result in 0.0f. - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -5.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 0.0f)] = { { AZ::Vector3(0.0f, 0.0f, -5.0f), AZ::Vector3::CreateZero() } }; // Altitude value at exactly max - should result in 1.0f. - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 15.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(0.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 15.0f), AZ::Vector3::CreateZero() } }; // Altitude value above max - should result in 1.0f. - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 20.0f), AZ::Vector3::CreateZero() } }; + mockSurface->m_surfacePoints[AZStd::make_pair(1.0f, 1.0f)] = { { AZ::Vector3(0.0f, 0.0f, 20.0f), AZ::Vector3::CreateZero() } }; + ActivateEntity(surfaceEntity.get()); // We set the min/max to -5 - 15. By using a range without 0 at either end, and not having 0 as the midpoint, // it should be easier to verify that we're successfully clamping to 0 and 1. @@ -667,7 +677,11 @@ namespace UnitTest 0.5f, 1.0f, }; - MockSurfaceDataSystem mockSurfaceDataSystem; + auto surfaceEntity = CreateEntity(); + auto mockSurface = surfaceEntity->CreateComponent(); + mockSurface->m_bounds = AZ::Aabb::CreateFromMinMax(AZ::Vector3(0.0f), AZ::Vector3(aznumeric_cast(dataSize))); + mockSurface->m_tags.emplace_back("test_mask"); + AzFramework::SurfaceData::SurfacePoint point; // Fill our mock surface with the test_mask set and the expected gradient value at each point. @@ -677,9 +691,10 @@ namespace UnitTest { point.m_surfaceTags.clear(); point.m_surfaceTags.emplace_back(AZ_CRC_CE("test_mask"), expectedOutput[(y * dataSize) + x]); - mockSurfaceDataSystem.m_GetSurfacePoints[AZStd::make_pair(static_cast(x), static_cast(y))] = { { point } }; + mockSurface->m_surfacePoints[AZStd::make_pair(static_cast(x), static_cast(y))] = { { point } }; } } + ActivateEntity(surfaceEntity.get()); GradientSignal::SurfaceMaskGradientConfig config; config.m_surfaceTagList.push_back(AZ_CRC("test_mask", 0x7a16e9ff)); @@ -706,8 +721,6 @@ namespace UnitTest 0.0f, 0.0f, }; - MockSurfaceDataSystem mockSurfaceDataSystem; - GradientSignal::SurfaceMaskGradientConfig config; config.m_surfaceTagList.push_back(AZ_CRC("test_mask", 0x7a16e9ff)); diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalSurfaceTests.cpp b/Gems/GradientSignal/Code/Tests/GradientSignalSurfaceTests.cpp index 9f4346e09e..4ab4c76d56 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalSurfaceTests.cpp +++ b/Gems/GradientSignal/Code/Tests/GradientSignalSurfaceTests.cpp @@ -67,9 +67,6 @@ namespace UnitTest const AzFramework::SurfaceData::SurfacePoint& input, const AzFramework::SurfaceData::SurfacePoint& expectedOutput) { - // This lets our component register with surfaceData successfully. - MockSurfaceDataSystem mockSurfaceDataSystem; - // Create a mock shape entity in case our gradient test uses shape constraints. // The mock shape is a cube that goes from -0.5 to 0.5 in space. auto mockShapeEntity = CreateTestEntity(0.5f); @@ -105,7 +102,9 @@ namespace UnitTest ActivateEntity(entity.get()); // Get our registered modifier handle (and verify that it's valid) - auto modifierHandle = mockSurfaceDataSystem.GetSurfaceModifierHandle(entity->GetId()); + SurfaceData::SurfaceDataRegistryHandle modifierHandle = SurfaceData::InvalidSurfaceDataRegistryHandle; + SurfaceData::SurfaceDataSystemRequestBus::BroadcastResult( + modifierHandle, &SurfaceData::SurfaceDataSystemRequestBus::Events::GetSurfaceDataModifierHandle, entity->GetId()); EXPECT_TRUE(modifierHandle != SurfaceData::InvalidSurfaceDataRegistryHandle); // Call ModifySurfacePoints and verify the results diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.cpp b/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.cpp index 402438ee88..3ca145b7c3 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.cpp +++ b/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.cpp @@ -13,6 +13,9 @@ #include #include #include +#include +#include +#include // Base gradient components #include @@ -40,7 +43,7 @@ namespace UnitTest { void GradientSignalTestEnvironment::AddGemsAndComponents() { - AddDynamicModulePaths({ "LmbrCentral" }); + AddDynamicModulePaths({ "LmbrCentral", "SurfaceData" }); AddComponentDescriptors({ AzFramework::TransformComponent::CreateDescriptor(), @@ -65,6 +68,7 @@ namespace UnitTest GradientSignal::ThresholdGradientComponent::CreateDescriptor(), MockShapeComponent::CreateDescriptor(), + MockSurfaceProviderComponent::CreateDescriptor(), }); } @@ -82,35 +86,6 @@ namespace UnitTest AzFramework::LegacyAssetEventBus::ClearQueuedEvents(); } - AZStd::unique_ptr GradientSignalBaseFixture::CreateMockSurfaceDataSystem(const AZ::Aabb& spawnerBox) - { - AzFramework::SurfaceData::SurfacePoint point; - AZStd::unique_ptr mockSurfaceDataSystem = AZStd::make_unique(); - - // Give the mock surface data a bunch of fake point values to return. - for (float y = spawnerBox.GetMin().GetY(); y < spawnerBox.GetMax().GetY(); y+= 1.0f) - { - for (float x = spawnerBox.GetMin().GetX(); x < spawnerBox.GetMax().GetX(); x += 1.0f) - { - // Use our x distance into the spawnerBox as an arbitrary percentage value that we'll use to calculate - // our other arbitrary values below. - float arbitraryPercentage = AZStd::abs(x / spawnerBox.GetExtents().GetX()); - - // Create a position that's between min and max Z of the box. - point.m_position = AZ::Vector3(x, y, AZ::Lerp(spawnerBox.GetMin().GetZ(), spawnerBox.GetMax().GetZ(), arbitraryPercentage)); - // Create an arbitrary normal value. - point.m_normal = point.m_position.GetNormalized(); - // Create an arbitrary surface value. - point.m_surfaceTags.clear(); - point.m_surfaceTags.emplace_back(AZ_CRC_CE("test_mask"), arbitraryPercentage); - - mockSurfaceDataSystem->m_GetSurfacePoints[AZStd::make_pair(x, y)] = { { point } }; - } - } - - return mockSurfaceDataSystem; - } - AZStd::unique_ptr GradientSignalBaseFixture::CreateTestEntity(float shapeHalfBounds) { // Create the base entity @@ -120,7 +95,7 @@ namespace UnitTest auto boxComponent = testEntity->CreateComponent(LmbrCentral::AxisAlignedBoxShapeComponentTypeId); boxComponent->SetConfiguration(boxConfig); - // Create a transform that locates our gradient in the center of our desired mock Shape. + // Create a transform that locates our gradient in the center of our desired Shape. auto transform = testEntity->CreateComponent(); transform->SetLocalTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeHalfBounds))); transform->SetWorldTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeHalfBounds))); @@ -128,6 +103,23 @@ namespace UnitTest return testEntity; } + AZStd::unique_ptr GradientSignalBaseFixture::CreateTestSphereEntity(float shapeRadius) + { + // Create the base entity + AZStd::unique_ptr testEntity = CreateEntity(); + + LmbrCentral::SphereShapeConfig sphereConfig(shapeRadius); + auto sphereComponent = testEntity->CreateComponent(LmbrCentral::SphereShapeComponentTypeId); + sphereComponent->SetConfiguration(sphereConfig); + + // Create a transform that locates our gradient in the center of our desired Shape. + auto transform = testEntity->CreateComponent(); + transform->SetLocalTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeRadius))); + transform->SetWorldTM(AZ::Transform::CreateTranslation(AZ::Vector3(shapeRadius))); + + return testEntity; + } + AZStd::unique_ptr GradientSignalBaseFixture::BuildTestConstantGradient(float shapeHalfBounds) { // Create a Constant Gradient Component with arbitrary parameters. @@ -349,12 +341,18 @@ namespace UnitTest AZStd::unique_ptr GradientSignalBaseFixture::BuildTestSurfaceAltitudeGradient(float shapeHalfBounds) { // Create a Surface Altitude Gradient Component with arbitrary parameters. - auto entity = CreateTestEntity(shapeHalfBounds); + auto entity = CreateTestSphereEntity(shapeHalfBounds); GradientSignal::SurfaceAltitudeGradientConfig config; config.m_altitudeMin = -5.0f; - config.m_altitudeMax = 15.0f; + config.m_altitudeMax = 15.0f + (shapeHalfBounds * 2.0f); entity->CreateComponent(config); + // Create a SurfaceDataShape component to provide surface points from this component. + SurfaceData::SurfaceDataShapeConfig shapeConfig; + shapeConfig.m_providerTags.emplace_back("test_mask"); + auto surfaceShapeComponent = entity->CreateComponent(azrtti_typeid()); + surfaceShapeComponent->SetConfiguration(shapeConfig); + ActivateEntity(entity.get()); return entity; } @@ -362,11 +360,17 @@ namespace UnitTest AZStd::unique_ptr GradientSignalBaseFixture::BuildTestSurfaceMaskGradient(float shapeHalfBounds) { // Create a Surface Mask Gradient Component with arbitrary parameters. - auto entity = CreateTestEntity(shapeHalfBounds); + auto entity = CreateTestSphereEntity(shapeHalfBounds); GradientSignal::SurfaceMaskGradientConfig config; config.m_surfaceTagList.push_back(AZ_CRC_CE("test_mask")); entity->CreateComponent(config); + // Create a SurfaceDataShape component to provide surface points from this component. + SurfaceData::SurfaceDataShapeConfig shapeConfig; + shapeConfig.m_providerTags.emplace_back("test_mask"); + auto surfaceShapeComponent = entity->CreateComponent(azrtti_typeid()); + surfaceShapeComponent->SetConfiguration(shapeConfig); + ActivateEntity(entity.get()); return entity; } @@ -374,7 +378,7 @@ namespace UnitTest AZStd::unique_ptr GradientSignalBaseFixture::BuildTestSurfaceSlopeGradient(float shapeHalfBounds) { // Create a Surface Slope Gradient Component with arbitrary parameters. - auto entity = CreateTestEntity(shapeHalfBounds); + auto entity = CreateTestSphereEntity(shapeHalfBounds); GradientSignal::SurfaceSlopeGradientConfig config; config.m_slopeMin = 5.0f; config.m_slopeMax = 50.0f; @@ -384,6 +388,12 @@ namespace UnitTest config.m_smoothStep.m_falloffStrength = 0.25f; entity->CreateComponent(config); + // Create a SurfaceDataShape component to provide surface points from this component. + SurfaceData::SurfaceDataShapeConfig shapeConfig; + shapeConfig.m_providerTags.emplace_back("test_mask"); + auto surfaceShapeComponent = entity->CreateComponent(azrtti_typeid()); + surfaceShapeComponent->SetConfiguration(shapeConfig); + ActivateEntity(entity.get()); return entity; } diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.h b/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.h index 5fda88ea27..9a173e7df1 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.h +++ b/Gems/GradientSignal/Code/Tests/GradientSignalTestFixtures.h @@ -60,14 +60,14 @@ namespace UnitTest entity->Activate(); } - // Create a mock SurfaceDataSystem that will respond to requests for surface points with mock responses for points inside - // the given input box. - AZStd::unique_ptr CreateMockSurfaceDataSystem(const AZ::Aabb& spawnerBox); - - // Create an entity with a mock shape and a transform. It won't be activated yet though, because we expect a gradient component + // Create an entity with a box shape and a transform. It won't be activated yet though, because we expect a gradient component // to also get added to it first before activation. AZStd::unique_ptr CreateTestEntity(float shapeHalfBounds); + // Create an entity with a sphere shape and a transform. It won't be activated yet though, because we expect a gradient component + // to also get added to it first before activation. + AZStd::unique_ptr CreateTestSphereEntity(float shapeRadius); + // Create and activate an entity with a gradient component of the requested type, initialized with test data. AZStd::unique_ptr BuildTestConstantGradient(float shapeHalfBounds); AZStd::unique_ptr BuildTestImageGradient(float shapeHalfBounds); diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.cpp b/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.cpp index 46cc3475e8..0b5432abe9 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.cpp +++ b/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.cpp @@ -13,11 +13,11 @@ namespace UnitTest { - void GradientSignalTestHelpers::CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float shapeHalfBounds) + void GradientSignalTestHelpers::CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float queryMin, float queryMax) { // Create a gradient sampler and run through a series of points to see if they match expectations. - const AZ::Aabb queryRegion = AZ::Aabb::CreateFromMinMax(AZ::Vector3(-shapeHalfBounds), AZ::Vector3(shapeHalfBounds)); + const AZ::Aabb queryRegion = AZ::Aabb::CreateFromMinMax(AZ::Vector3(queryMin), AZ::Vector3(queryMax)); const AZ::Vector2 stepSize(1.0f, 1.0f); GradientSignal::GradientSampler gradientSampler; @@ -118,6 +118,7 @@ namespace UnitTest AZStd::vector results(totalQueryPoints); GradientSignal::GradientRequestBus::Event( gradientId, &GradientSignal::GradientRequestBus::Events::GetValues, positions, results); + benchmark::DoNotOptimize(results); } } @@ -174,6 +175,7 @@ namespace UnitTest // Query and get the results. AZStd::vector results(totalQueryPoints); gradientSampler.GetValues(positions, results); + benchmark::DoNotOptimize(results); } } diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.h b/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.h index 8a175939ee..15b436105e 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.h +++ b/Gems/GradientSignal/Code/Tests/GradientSignalTestHelpers.h @@ -17,7 +17,7 @@ namespace UnitTest class GradientSignalTestHelpers { public: - static void CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float shapeHalfBounds); + static void CompareGetValueAndGetValues(AZ::EntityId gradientEntityId, float queryMin, float queryMax); #ifdef HAVE_BENCHMARK // We use an enum to list out the different types of GetValue() benchmarks to run so that way we can condense our test cases diff --git a/Gems/GradientSignal/Code/Tests/GradientSignalTestMocks.h b/Gems/GradientSignal/Code/Tests/GradientSignalTestMocks.h index 30f262d9b4..f436045b4e 100644 --- a/Gems/GradientSignal/Code/Tests/GradientSignalTestMocks.h +++ b/Gems/GradientSignal/Code/Tests/GradientSignalTestMocks.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -162,4 +163,64 @@ namespace UnitTest bool m_constrainToShape; }; + // Mock out a SurfaceProvider component so that we can control exactly what surface weights get returned + // at which points for our unit tests. + struct MockSurfaceProviderComponent + : public AZ::Component + , public SurfaceData::SurfaceDataProviderRequestBus::Handler + { + public: + AZ_COMPONENT(MockSurfaceProviderComponent, "{18C71877-DB29-4CEC-B34C-B4B44E05203D}", AZ::Component); + + void Activate() override + { + SurfaceData::SurfaceDataRegistryEntry providerRegistryEntry; + providerRegistryEntry.m_entityId = GetEntityId(); + providerRegistryEntry.m_bounds = m_bounds; + providerRegistryEntry.m_tags = m_tags; + + SurfaceData::SurfaceDataSystemRequestBus::BroadcastResult( + m_providerHandle, &SurfaceData::SurfaceDataSystemRequestBus::Events::RegisterSurfaceDataProvider, providerRegistryEntry); + SurfaceData::SurfaceDataProviderRequestBus::Handler::BusConnect(m_providerHandle); + } + + void Deactivate() override + { + SurfaceData::SurfaceDataSystemRequestBus::Broadcast( + &SurfaceData::SurfaceDataSystemRequestBus::Events::UnregisterSurfaceDataProvider, m_providerHandle); + m_providerHandle = SurfaceData::InvalidSurfaceDataRegistryHandle; + SurfaceData::SurfaceDataProviderRequestBus::Handler::BusDisconnect(); + } + + static void Reflect([[maybe_unused]] AZ::ReflectContext* reflect) + { + } + + static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) + { + provided.push_back(AZ_CRC_CE("SurfaceDataProviderService")); + } + + void GetSurfacePoints(const AZ::Vector3& inPosition, SurfaceData::SurfacePointList& surfacePointList) const override + { + auto surfacePoints = m_surfacePoints.find(AZStd::make_pair(inPosition.GetX(), inPosition.GetY())); + + if (surfacePoints != m_surfacePoints.end()) + { + surfacePointList = surfacePoints->second; + } + } + + // m_surfacePoints is a mapping of locations to surface tags / weights that should be returned. + AZStd::unordered_map, SurfaceData::SurfacePointList> m_surfacePoints; + + // m_bounds is the AABB to use for our mock surface provider. + AZ::Aabb m_bounds; + + // m_tags are the possible set of tags that this provider will return. + SurfaceData::SurfaceTagVector m_tags; + + SurfaceData::SurfaceDataRegistryHandle m_providerHandle = SurfaceData::InvalidSurfaceDataRegistryHandle; + }; + } diff --git a/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.h b/Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataColliderComponent.h similarity index 100% rename from Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.h rename to Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataColliderComponent.h diff --git a/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.h b/Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataShapeComponent.h similarity index 100% rename from Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.h rename to Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataShapeComponent.h diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.h b/Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataSystemComponent.h similarity index 95% rename from Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.h rename to Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataSystemComponent.h index bb554cec78..3e1291e524 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.h +++ b/Gems/SurfaceData/Code/Include/SurfaceData/Components/SurfaceDataSystemComponent.h @@ -57,6 +57,10 @@ namespace SurfaceData void UpdateSurfaceDataModifier(const SurfaceDataRegistryHandle& handle, const SurfaceDataRegistryEntry& entry) override; void RefreshSurfaceData(const AZ::Aabb& dirtyArea) override; + + SurfaceDataRegistryHandle GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) override; + SurfaceDataRegistryHandle GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) override; + private: SurfaceDataRegistryHandle RegisterSurfaceDataProviderInternal(const SurfaceDataRegistryEntry& entry); SurfaceDataRegistryEntry UnregisterSurfaceDataProviderInternal(const SurfaceDataRegistryHandle& handle); diff --git a/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataSystemRequestBus.h b/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataSystemRequestBus.h index 616f069184..d4e84c5974 100644 --- a/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataSystemRequestBus.h +++ b/Gems/SurfaceData/Code/Include/SurfaceData/SurfaceDataSystemRequestBus.h @@ -58,6 +58,10 @@ namespace SurfaceData // Notify any dependent systems that they need to refresh their surface data for the provided area. virtual void RefreshSurfaceData(const AZ::Aabb& dirtyArea) = 0; + + // Get the SurfaceDataRegistryHandle for a given entityId. + virtual SurfaceDataRegistryHandle GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) = 0; + virtual SurfaceDataRegistryHandle GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) = 0; }; typedef AZ::EBus SurfaceDataSystemRequestBus; diff --git a/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h b/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h index 82a321756d..bafe215402 100644 --- a/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h +++ b/Gems/SurfaceData/Code/Include/SurfaceData/Tests/SurfaceDataTestMocks.h @@ -250,6 +250,16 @@ namespace UnitTest { } + SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) override + { + return GetSurfaceProviderHandle(providerEntityId); + } + + SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) override + { + return GetSurfaceModifierHandle(modifierEntityId); + } + SurfaceData::SurfaceDataRegistryHandle GetSurfaceProviderHandle(AZ::EntityId id) { return GetEntryHandle(id, m_providers); diff --git a/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp b/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp index 86a165b7d8..35f377bfe0 100644 --- a/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp +++ b/Gems/SurfaceData/Code/Source/Components/SurfaceDataColliderComponent.cpp @@ -6,7 +6,7 @@ * */ -#include "SurfaceDataColliderComponent.h" +#include #include #include diff --git a/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp b/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp index 481372b7dc..973fca232a 100644 --- a/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp +++ b/Gems/SurfaceData/Code/Source/Components/SurfaceDataShapeComponent.cpp @@ -6,7 +6,7 @@ * */ -#include "SurfaceDataShapeComponent.h" +#include #include #include diff --git a/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataColliderComponent.h b/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataColliderComponent.h index 211d819b4d..a25061c245 100644 --- a/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataColliderComponent.h +++ b/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataColliderComponent.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace SurfaceData diff --git a/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataShapeComponent.h b/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataShapeComponent.h index 79218b9317..202511c4c7 100644 --- a/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataShapeComponent.h +++ b/Gems/SurfaceData/Code/Source/Editor/EditorSurfaceDataShapeComponent.h @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include namespace SurfaceData diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataEditorModule.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataEditorModule.cpp index 936cac5954..5f1ead9873 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataEditorModule.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataEditorModule.cpp @@ -7,7 +7,7 @@ */ #include -#include +#include #include #include #include diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp index 35064bf4a4..36b8936e23 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataModule.cpp @@ -7,9 +7,9 @@ */ #include -#include -#include -#include +#include +#include +#include namespace SurfaceData { diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.cpp index 66b8c83a58..7dc6711b72 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataSystemComponent.cpp @@ -12,7 +12,7 @@ #include #include -#include "SurfaceDataSystemComponent.h" +#include #include #include #include @@ -175,6 +175,34 @@ namespace SurfaceData SurfaceDataSystemNotificationBus::Broadcast(&SurfaceDataSystemNotificationBus::Events::OnSurfaceChanged, AZ::EntityId(), dirtyBounds, dirtyBounds); } + SurfaceDataRegistryHandle SurfaceDataSystemComponent::GetSurfaceDataProviderHandle(const AZ::EntityId& providerEntityId) + { + AZStd::shared_lock registrationLock(m_registrationMutex); + + for (auto& [providerHandle, providerEntry] : m_registeredSurfaceDataProviders) + { + if (providerEntry.m_entityId == providerEntityId) + { + return providerHandle; + } + } + return {}; + } + + SurfaceDataRegistryHandle SurfaceDataSystemComponent::GetSurfaceDataModifierHandle(const AZ::EntityId& modifierEntityId) + { + AZStd::shared_lock registrationLock(m_registrationMutex); + + for (auto& [modifierHandle, modifierEntry] : m_registeredSurfaceDataModifiers) + { + if (modifierEntry.m_entityId == modifierEntityId) + { + return modifierHandle; + } + } + return {}; + } + void SurfaceDataSystemComponent::GetSurfacePoints(const AZ::Vector3& inPosition, const SurfaceTagVector& desiredTags, SurfacePointList& surfacePointList) const { const bool useTagFilters = HasValidTags(desiredTags); diff --git a/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp b/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp index 04c1ada677..a25273896e 100644 --- a/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp +++ b/Gems/SurfaceData/Code/Source/SurfaceDataTypes.cpp @@ -226,9 +226,7 @@ namespace SurfaceData void SurfacePointList::ReserveSpace(size_t maxPointsPerInput) { - AZ_Assert( - m_surfacePositionList.size() < maxPointsPerInput, - "Trying to reserve space on a list that is already using more points than requested."); + AZ_Assert(m_surfacePositionList.empty(), "Trying to reserve space on a list that is already being used."); m_surfaceCreatorIdList.reserve(maxPointsPerInput); m_surfacePositionList.reserve(maxPointsPerInput); diff --git a/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp b/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp index f8b4c675a5..df011113da 100644 --- a/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp +++ b/Gems/SurfaceData/Code/Tests/SurfaceDataBenchmarks.cpp @@ -21,8 +21,8 @@ #include #include #include -#include -#include +#include +#include namespace UnitTest { diff --git a/Gems/SurfaceData/Code/Tests/SurfaceDataColliderComponentTest.cpp b/Gems/SurfaceData/Code/Tests/SurfaceDataColliderComponentTest.cpp index 884c831393..aca5a53f4d 100644 --- a/Gems/SurfaceData/Code/Tests/SurfaceDataColliderComponentTest.cpp +++ b/Gems/SurfaceData/Code/Tests/SurfaceDataColliderComponentTest.cpp @@ -14,7 +14,7 @@ #include #include -#include +#include #include #include diff --git a/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp b/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp index f4ff0cb04c..8500e557bf 100644 --- a/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp +++ b/Gems/SurfaceData/Code/Tests/SurfaceDataTest.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/Gems/SurfaceData/Code/Tests/SurfaceDataTestFixtures.cpp b/Gems/SurfaceData/Code/Tests/SurfaceDataTestFixtures.cpp index 2ec531d2e4..28f7ea6b03 100644 --- a/Gems/SurfaceData/Code/Tests/SurfaceDataTestFixtures.cpp +++ b/Gems/SurfaceData/Code/Tests/SurfaceDataTestFixtures.cpp @@ -11,9 +11,9 @@ #include #include -#include -#include -#include +#include +#include +#include namespace UnitTest diff --git a/Gems/SurfaceData/Code/surfacedata_files.cmake b/Gems/SurfaceData/Code/surfacedata_files.cmake index 1c36ca43a0..8e7435abb3 100644 --- a/Gems/SurfaceData/Code/surfacedata_files.cmake +++ b/Gems/SurfaceData/Code/surfacedata_files.cmake @@ -7,6 +7,9 @@ # set(FILES + Include/SurfaceData/Components/SurfaceDataColliderComponent.h + Include/SurfaceData/Components/SurfaceDataShapeComponent.h + Include/SurfaceData/Components/SurfaceDataSystemComponent.h Include/SurfaceData/SurfaceDataConstants.h Include/SurfaceData/SurfaceDataTypes.h Include/SurfaceData/SurfaceDataSystemRequestBus.h @@ -18,12 +21,9 @@ set(FILES Include/SurfaceData/SurfaceTag.h Include/SurfaceData/Utility/SurfaceDataUtility.h Source/SurfaceDataSystemComponent.cpp - Source/SurfaceDataSystemComponent.h Source/SurfaceDataTypes.cpp Source/SurfaceTag.cpp Source/Components/SurfaceDataColliderComponent.cpp - Source/Components/SurfaceDataColliderComponent.h Source/Components/SurfaceDataShapeComponent.cpp - Source/Components/SurfaceDataShapeComponent.h Source/SurfaceDataUtility.cpp ) diff --git a/Gems/Vegetation/Code/Tests/VegetationMocks.h b/Gems/Vegetation/Code/Tests/VegetationMocks.h index d77862d578..33a320b03e 100644 --- a/Gems/Vegetation/Code/Tests/VegetationMocks.h +++ b/Gems/Vegetation/Code/Tests/VegetationMocks.h @@ -384,6 +384,16 @@ namespace UnitTest { ++m_count; } + + SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataProviderHandle([[maybe_unused]] const AZ::EntityId& providerEntityId) override + { + return {}; + } + + SurfaceData::SurfaceDataRegistryHandle GetSurfaceDataModifierHandle([[maybe_unused]] const AZ::EntityId& modifierEntityId) override + { + return {}; + } }; struct MockMeshAsset From 742ea34d442ceefe14a8219119a8612b9c704c64 Mon Sep 17 00:00:00 2001 From: rgba16f <82187279+rgba16f@users.noreply.github.com> Date: Tue, 8 Feb 2022 15:24:37 -0600 Subject: [PATCH 59/59] Add a function to get the internal data for a disk light from it's feature processor (#7450) * Add a function to get the internal data for a disk light from it's feature processor Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> * Address PR comments. Fixed assert message, made function const. Signed-off-by: rgba16f <82187279+rgba16f@users.noreply.github.com> --- .../CoreLights/DiskLightFeatureProcessorInterface.h | 3 ++- .../Code/Source/CoreLights/DiskLightFeatureProcessor.cpp | 7 +++++++ .../Code/Source/CoreLights/DiskLightFeatureProcessor.h | 1 + .../RPI/Code/Include/Atom/RPI.Public/AuxGeom/AuxGeomDraw.h | 4 ++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/CoreLights/DiskLightFeatureProcessorInterface.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/CoreLights/DiskLightFeatureProcessorInterface.h index 98220fae15..9622b5aa40 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/CoreLights/DiskLightFeatureProcessorInterface.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/CoreLights/DiskLightFeatureProcessorInterface.h @@ -100,7 +100,8 @@ namespace AZ //! Sets all of the the disk data for the provided LightHandle. virtual void SetDiskData(LightHandle handle, const DiskLightData& data) = 0; - + //! Get a read only copy of a disk lights data, useful for debug rendering + virtual const DiskLightData& GetDiskData(LightHandle handle) const = 0; }; } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.cpp index 168a7ea00a..9c626fccd8 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.cpp @@ -255,6 +255,13 @@ namespace AZ UpdateShadow(handle); } + const DiskLightData& DiskLightFeatureProcessor::GetDiskData(LightHandle handle) const + { + AZ_Assert(handle.IsValid(), "Invalid LightHandle passed to DiskLightFeatureProcessor::GetDiskData()."); + + return m_diskLightData.GetData(handle.GetIndex()); + } + const Data::Instance DiskLightFeatureProcessor::GetLightBuffer()const { return m_lightBufferHandler.GetBuffer(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.h index bafddacc65..d742b1fbc0 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DiskLightFeatureProcessor.h @@ -58,6 +58,7 @@ namespace AZ void SetEsmExponent(LightHandle handle, float esmExponent) override; void SetDiskData(LightHandle handle, const DiskLightData& data) override; + const DiskLightData& GetDiskData(LightHandle handle) const override; const Data::Instance GetLightBuffer()const; uint32_t GetLightCount()const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/AuxGeom/AuxGeomDraw.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/AuxGeom/AuxGeomDraw.h index 29b127407e..b3e898c4dd 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/AuxGeom/AuxGeomDraw.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/AuxGeom/AuxGeomDraw.h @@ -184,8 +184,8 @@ namespace AZ virtual void DrawDisk(const AZ::Vector3& center, const AZ::Vector3& direction, float radius, const AZ::Color& color, DrawStyle style = DrawStyle::Shaded, DepthTest depthTest = DepthTest::On, DepthWrite depthWrite = DepthWrite::On, FaceCullMode faceCull = FaceCullMode::Back, int32_t viewProjOverrideIndex = -1) = 0; //! Draw a cone. - //! @param center The center of the base circle. - //! @param direction The direction vector. The tip of the cone will point along this vector. + //! @param center The center of the cone base. + //! @param direction The direction vector. This is the vector from the center of the base to the point at the tip. //! @param radius The radius. //! @param height The height of the cone (the distance from the base center to the tip). //! @param color The color to draw the cone.