|
@@ -13,10 +13,12 @@
|
|
#include <viewsrg.srgi>
|
|
#include <viewsrg.srgi>
|
|
#include <Atom/Features/PBR/AlphaUtils.azsli>
|
|
#include <Atom/Features/PBR/AlphaUtils.azsli>
|
|
#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
|
|
#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
|
|
|
|
+#include <Atom/Features/PBR/ForwardPassSrg.azsli>
|
|
#include <Atom/Features/PBR/ForwardPassOutput.azsli>
|
|
#include <Atom/Features/PBR/ForwardPassOutput.azsli>
|
|
#include <Atom/Features/ColorManagement/TransformColor.azsli>
|
|
#include <Atom/Features/ColorManagement/TransformColor.azsli>
|
|
#include <Atom/Features/SrgSemantics.azsli>
|
|
#include <Atom/Features/SrgSemantics.azsli>
|
|
-#include <Atom/Features/ColorManagement/TransformColor.azsli>
|
|
|
|
|
|
+#include <Atom/Features/PBR/Lighting/StandardLighting.azsli>
|
|
|
|
+#include <Atom/Features/PBR/Decals.azsli>
|
|
|
|
|
|
ShaderResourceGroup MaterialSrg : SRG_PerMaterial
|
|
ShaderResourceGroup MaterialSrg : SRG_PerMaterial
|
|
{
|
|
{
|
|
@@ -54,7 +56,6 @@ struct VSOutput
|
|
float3 m_shadowCoords[ViewSrg::MaxCascadeCount] : UV3;
|
|
float3 m_shadowCoords[ViewSrg::MaxCascadeCount] : UV3;
|
|
};
|
|
};
|
|
|
|
|
|
-#include <Atom/Features/PBR/LightingModel.azsli>
|
|
|
|
#include <Atom/Features/Vertex/VertexHelper.azsli>
|
|
#include <Atom/Features/Vertex/VertexHelper.azsli>
|
|
option bool o_emissive_useTexture;
|
|
option bool o_emissive_useTexture;
|
|
|
|
|
|
@@ -69,33 +70,69 @@ VSOutput MainVS(VSInput IN)
|
|
|
|
|
|
ForwardPassOutput MainPS(VSOutput IN)
|
|
ForwardPassOutput MainPS(VSOutput IN)
|
|
{
|
|
{
|
|
- ForwardPassOutput OUT;
|
|
|
|
|
|
+ // ------- Surface -------
|
|
|
|
+
|
|
|
|
+ Surface surface;
|
|
|
|
|
|
- const float3 baseColor = {0.05,0.05,0.05};
|
|
|
|
- const float metallic = 0.0;
|
|
|
|
- const float roughness = 1.0;
|
|
|
|
- const float specularF0Factor = 0.5;
|
|
|
|
- const float3 normal = normalize(IN.m_normal);
|
|
|
|
- const float occlusion = 1;
|
|
|
|
- const float clearCoatFactor = 0.0;
|
|
|
|
- const float clearCoatRoughness = 0.0;
|
|
|
|
- const float3 clearCoatNormal = {0,0,0};
|
|
|
|
- const float4 transmissionTintThickness = {0,0,0,0};
|
|
|
|
- const float4 transmissionParams = {0,0,0,0};
|
|
|
|
- const float2 anisotropy = 0.0; // Does not affect calculations unless 'o_enableAnisotropy' is enabled
|
|
|
|
- const float alpha = 1.0;
|
|
|
|
|
|
+ // Position, Normal, Roughness
|
|
|
|
+ surface.position = IN.m_worldPosition.xyz;
|
|
|
|
+ surface.normal = normalize(IN.m_normal);
|
|
|
|
+ surface.roughnessLinear = 1.0f;
|
|
|
|
+ surface.CalculateRoughnessA();
|
|
|
|
+
|
|
|
|
+ // Albedo, SpecularF0
|
|
|
|
+ const float3 baseColor = float3(0.05f, 0.05f, 0.05f);
|
|
|
|
+ const float metallic = 0.0f;
|
|
|
|
+ const float specularF0Factor = 0.5f;
|
|
|
|
+ surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
|
|
|
|
+
|
|
|
|
+ // Clear Coat, Transmission
|
|
|
|
+ surface.clearCoat.InitializeToZero();
|
|
|
|
+ surface.transmission.InitializeToZero();
|
|
|
|
|
|
|
|
+ // ------- LightingData -------
|
|
|
|
+
|
|
|
|
+ LightingData lightingData;
|
|
|
|
+
|
|
|
|
+ // Light iterator
|
|
|
|
+ lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData);
|
|
|
|
+ lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
|
|
|
|
+
|
|
|
|
+ // Shadow, Occlusion
|
|
|
|
+ lightingData.shadowCoords = IN.m_shadowCoords;
|
|
|
|
+
|
|
|
|
+ // Emissive
|
|
float3 emissive = MaterialSrg::m_emissiveColor.rgb * MaterialSrg::m_emissiveIntensity;
|
|
float3 emissive = MaterialSrg::m_emissiveColor.rgb * MaterialSrg::m_emissiveIntensity;
|
|
if (o_emissive_useTexture)
|
|
if (o_emissive_useTexture)
|
|
{
|
|
{
|
|
float4 sampledValue = MaterialSrg::m_emissiveMap.Sample(MaterialSrg::m_sampler, IN.m_uv);
|
|
float4 sampledValue = MaterialSrg::m_emissiveMap.Sample(MaterialSrg::m_sampler, IN.m_uv);
|
|
emissive *= TransformColor(sampledValue.rgb, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
|
|
emissive *= TransformColor(sampledValue.rgb, ColorSpaceId::LinearSRGB, ColorSpaceId::ACEScg);
|
|
}
|
|
}
|
|
|
|
+ lightingData.emissiveLighting = emissive;
|
|
|
|
+
|
|
|
|
+ // Diffuse and Specular response
|
|
|
|
+ lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
|
|
|
|
+ lightingData.diffuseResponse = 1.0f - lightingData.specularResponse;
|
|
|
|
|
|
- PbrLightingOutput lightingOutput = PbrLighting(IN,
|
|
|
|
- baseColor, metallic, roughness, specularF0Factor,
|
|
|
|
- normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
|
|
|
- emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
|
|
|
|
|
+ const float alpha = 1.0f;
|
|
|
|
+
|
|
|
|
+ // ------- Lighting Calculation -------
|
|
|
|
+
|
|
|
|
+ // Apply Decals
|
|
|
|
+ ApplyDecals(lightingData.tileIterator, surface);
|
|
|
|
+
|
|
|
|
+ // Apply Direct Lighting
|
|
|
|
+ ApplyDirectLighting(surface, lightingData);
|
|
|
|
+
|
|
|
|
+ // Apply Image Based Lighting (IBL)
|
|
|
|
+ ApplyIBL(surface, lightingData);
|
|
|
|
+
|
|
|
|
+ // Finalize Lighting
|
|
|
|
+ lightingData.FinalizeLighting(surface.transmission.tint);
|
|
|
|
+
|
|
|
|
+ PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha);
|
|
|
|
+
|
|
|
|
+ ForwardPassOutput OUT;
|
|
|
|
|
|
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
|
|
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
|
|
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
|
|
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
|
|
@@ -103,8 +140,6 @@ ForwardPassOutput MainPS(VSOutput IN)
|
|
OUT.m_specularF0 = lightingOutput.m_specularF0;
|
|
OUT.m_specularF0 = lightingOutput.m_specularF0;
|
|
OUT.m_albedo = lightingOutput.m_albedo;
|
|
OUT.m_albedo = lightingOutput.m_albedo;
|
|
OUT.m_normal = lightingOutput.m_normal;
|
|
OUT.m_normal = lightingOutput.m_normal;
|
|
- OUT.m_scatterDistance = float3(0,0,0);
|
|
|
|
-
|
|
|
|
return OUT;
|
|
return OUT;
|
|
}
|
|
}
|
|
|
|
|