Updated AutoBrick and MinimalPBR
This commit is contained in:
@@ -32,108 +32,108 @@
|
||||
|
||||
// DEPRECATED: Please use the functions in StandardLighting.azsli instead.
|
||||
// For an example on how to use those functions, see StandardPBR_forwardPass.azsl
|
||||
PbrLightingOutput PbrLighting( VSOutput IN,
|
||||
float3 baseColor,
|
||||
float metallic,
|
||||
float roughness,
|
||||
float specularF0Factor,
|
||||
float3 normal,
|
||||
float3 vtxTangent,
|
||||
float3 vtxBitangent,
|
||||
float2 anisotropy, // angle and factor
|
||||
float3 emissive,
|
||||
float occlusion,
|
||||
float4 transmissionTintThickness,
|
||||
float4 transmissionParams,
|
||||
float clearCoatFactor,
|
||||
float clearCoatRoughness,
|
||||
float3 clearCoatNormal,
|
||||
float alpha,
|
||||
OpacityMode opacityMode)
|
||||
{
|
||||
float3 worldPosition = IN.m_worldPosition;
|
||||
float4 position = IN.m_position;
|
||||
float3 shadowCoords[ViewSrg::MaxCascadeCount] = IN.m_shadowCoords;
|
||||
|
||||
// ______________________________________________________________________________________________
|
||||
// Surface
|
||||
|
||||
Surface surface;
|
||||
|
||||
surface.position = worldPosition;
|
||||
surface.normal = normal;
|
||||
surface.roughnessLinear = roughness;
|
||||
surface.transmission.tint = transmissionTintThickness.rgb;
|
||||
surface.transmission.thickness = transmissionTintThickness.w;
|
||||
surface.transmission.transmissionParams = transmissionParams;
|
||||
surface.clearCoat.factor = clearCoatFactor;
|
||||
surface.clearCoat.roughness = clearCoatRoughness;
|
||||
surface.clearCoat.normal = clearCoatNormal;
|
||||
|
||||
surface.CalculateRoughnessA();
|
||||
surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
|
||||
surface.anisotropy.Init(normal, vtxTangent, vtxBitangent, anisotropy.x, anisotropy.y, surface.roughnessA);
|
||||
|
||||
// ______________________________________________________________________________________________
|
||||
// LightingData
|
||||
|
||||
LightingData lightingData;
|
||||
|
||||
// Light iterator
|
||||
lightingData.tileIterator.Init(position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData);
|
||||
lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
|
||||
|
||||
lightingData.emissiveLighting = emissive;
|
||||
lightingData.occlusion = occlusion;
|
||||
|
||||
// Directional light shadow coordinates
|
||||
lightingData.shadowCoords = shadowCoords;
|
||||
|
||||
// manipulate base layer f0 if clear coat is enabled
|
||||
if(o_clearCoat_feature_enabled)
|
||||
{
|
||||
// modify base layer's normal incidence reflectance
|
||||
// for the derivation of the following equation please refer to:
|
||||
// https://google.github.io/filament/Filament.md.html#materialsystem/clearcoatmodel/baselayermodification
|
||||
float3 f0 = (1.0 - 5.0 * sqrt(surface.specularF0)) / (5.0 - sqrt(surface.specularF0));
|
||||
surface.specularF0 = lerp(surface.specularF0, f0 * f0, clearCoatFactor);
|
||||
}
|
||||
|
||||
// Diffuse and Specular response (used in IBL calculations)
|
||||
lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
|
||||
lightingData.diffuseResponse = 1.0 - lightingData.specularResponse;
|
||||
|
||||
if(o_clearCoat_feature_enabled)
|
||||
{
|
||||
// Clear coat layer has fixed IOR = 1.5 and transparent => F0 = (1.5 - 1)^2 / (1.5 + 1)^2 = 0.04
|
||||
lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor);
|
||||
}
|
||||
|
||||
// Multiscatter compensation factor
|
||||
lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation);
|
||||
|
||||
// ______________________________________________________________________________________________
|
||||
// Lighting
|
||||
|
||||
// Apply Decals
|
||||
ApplyDecals(lightingData.tileIterator, surface);
|
||||
|
||||
// Apply Direct Lighting
|
||||
ApplyDirectLighting(surface, lightingData);
|
||||
|
||||
// Apply Image Based Lighting (IBL)
|
||||
ApplyIBL(surface, lightingData);
|
||||
|
||||
// Finalize Lighting
|
||||
lightingData.FinalizeLighting(surface.transmission.tint);
|
||||
|
||||
if (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent)
|
||||
{
|
||||
alpha = FresnelSchlickWithRoughness(lightingData.NdotV, alpha, surface.roughnessLinear).x; // Increase opacity at grazing angles.
|
||||
}
|
||||
|
||||
PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha);
|
||||
|
||||
return lightingOutput;
|
||||
}
|
||||
// PbrLightingOutput PbrLighting( VSOutput IN,
|
||||
// float3 baseColor,
|
||||
// float metallic,
|
||||
// float roughness,
|
||||
// float specularF0Factor,
|
||||
// float3 normal,
|
||||
// float3 vtxTangent,
|
||||
// float3 vtxBitangent,
|
||||
// float2 anisotropy, // angle and factor
|
||||
// float3 emissive,
|
||||
// float occlusion,
|
||||
// float4 transmissionTintThickness,
|
||||
// float4 transmissionParams,
|
||||
// float clearCoatFactor,
|
||||
// float clearCoatRoughness,
|
||||
// float3 clearCoatNormal,
|
||||
// float alpha,
|
||||
// OpacityMode opacityMode)
|
||||
// {
|
||||
// float3 worldPosition = IN.m_worldPosition;
|
||||
// float4 position = IN.m_position;
|
||||
// float3 shadowCoords[ViewSrg::MaxCascadeCount] = IN.m_shadowCoords;
|
||||
//
|
||||
// // ______________________________________________________________________________________________
|
||||
// // Surface
|
||||
//
|
||||
// Surface surface;
|
||||
//
|
||||
// surface.position = worldPosition;
|
||||
// surface.normal = normal;
|
||||
// surface.roughnessLinear = roughness;
|
||||
// surface.transmission.tint = transmissionTintThickness.rgb;
|
||||
// surface.transmission.thickness = transmissionTintThickness.w;
|
||||
// surface.transmission.transmissionParams = transmissionParams;
|
||||
// surface.clearCoat.factor = clearCoatFactor;
|
||||
// surface.clearCoat.roughness = clearCoatRoughness;
|
||||
// surface.clearCoat.normal = clearCoatNormal;
|
||||
//
|
||||
// surface.CalculateRoughnessA();
|
||||
// surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic);
|
||||
// surface.anisotropy.Init(normal, vtxTangent, vtxBitangent, anisotropy.x, anisotropy.y, surface.roughnessA);
|
||||
//
|
||||
// // ______________________________________________________________________________________________
|
||||
// // LightingData
|
||||
//
|
||||
// LightingData lightingData;
|
||||
//
|
||||
// // Light iterator
|
||||
// lightingData.tileIterator.Init(position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData);
|
||||
// lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
|
||||
//
|
||||
// lightingData.emissiveLighting = emissive;
|
||||
// lightingData.occlusion = occlusion;
|
||||
//
|
||||
// // Directional light shadow coordinates
|
||||
// lightingData.shadowCoords = shadowCoords;
|
||||
//
|
||||
// // manipulate base layer f0 if clear coat is enabled
|
||||
// if(o_clearCoat_feature_enabled)
|
||||
// {
|
||||
// // modify base layer's normal incidence reflectance
|
||||
// // for the derivation of the following equation please refer to:
|
||||
// // https://google.github.io/filament/Filament.md.html#materialsystem/clearcoatmodel/baselayermodification
|
||||
// float3 f0 = (1.0 - 5.0 * sqrt(surface.specularF0)) / (5.0 - sqrt(surface.specularF0));
|
||||
// surface.specularF0 = lerp(surface.specularF0, f0 * f0, clearCoatFactor);
|
||||
// }
|
||||
//
|
||||
// // Diffuse and Specular response (used in IBL calculations)
|
||||
// lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
|
||||
// lightingData.diffuseResponse = 1.0 - lightingData.specularResponse;
|
||||
//
|
||||
// if(o_clearCoat_feature_enabled)
|
||||
// {
|
||||
// // Clear coat layer has fixed IOR = 1.5 and transparent => F0 = (1.5 - 1)^2 / (1.5 + 1)^2 = 0.04
|
||||
// lightingData.diffuseResponse *= 1.0 - (FresnelSchlickWithRoughness(lightingData.NdotV, float3(0.04, 0.04, 0.04), surface.clearCoat.roughness) * surface.clearCoat.factor);
|
||||
// }
|
||||
//
|
||||
// // Multiscatter compensation factor
|
||||
// lightingData.CalculateMultiscatterCompensation(surface.specularF0, o_specularF0_enableMultiScatterCompensation);
|
||||
//
|
||||
// // ______________________________________________________________________________________________
|
||||
// // Lighting
|
||||
//
|
||||
// // Apply Decals
|
||||
// ApplyDecals(lightingData.tileIterator, surface);
|
||||
//
|
||||
// // Apply Direct Lighting
|
||||
// ApplyDirectLighting(surface, lightingData);
|
||||
//
|
||||
// // Apply Image Based Lighting (IBL)
|
||||
// ApplyIBL(surface, lightingData);
|
||||
//
|
||||
// // Finalize Lighting
|
||||
// lightingData.FinalizeLighting(surface.transmission.tint);
|
||||
//
|
||||
// if (o_opacity_mode == OpacityMode::Blended || o_opacity_mode == OpacityMode::TintedTransparent)
|
||||
// {
|
||||
// alpha = FresnelSchlickWithRoughness(lightingData.NdotV, alpha, surface.roughnessLinear).x; // Increase opacity at grazing angles.
|
||||
// }
|
||||
//
|
||||
// PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha);
|
||||
//
|
||||
// return lightingOutput;
|
||||
// }
|
||||
|
||||
|
||||
+9
@@ -17,4 +17,13 @@ class ClearCoatSurfaceData
|
||||
float factor; //!< clear coat strength factor
|
||||
float roughness; //!< clear coat linear roughness (not base layer one)
|
||||
float3 normal; //!< normal used for top layer clear coat
|
||||
|
||||
void InitializeToZero();
|
||||
};
|
||||
|
||||
void ClearCoatSurfaceData::InitializeToZero()
|
||||
{
|
||||
factor = 0.0f;
|
||||
roughness = 0.0f;
|
||||
normal = float3(0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
+9
@@ -17,4 +17,13 @@ class TransmissionSurfaceData
|
||||
float3 tint;
|
||||
float thickness; //!< pre baked local thickness, used for transmission
|
||||
float4 transmissionParams; //!< parameters: thick mode->(attenuation coefficient, power, distortion, scale), thin mode: (float3 scatter distance, scale)
|
||||
|
||||
void InitializeToZero();
|
||||
};
|
||||
|
||||
void TransmissionSurfaceData::InitializeToZero()
|
||||
{
|
||||
tint = float3(0.0f, 0.0f, 0.0f);
|
||||
thickness = 0.0f;
|
||||
transmissionParams = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
@@ -141,6 +141,7 @@ set(FILES
|
||||
Passes/Forward.pass
|
||||
Passes/ForwardCheckerboard.pass
|
||||
Passes/ForwardMSAA.pass
|
||||
Passes/ForwardSubsurfaceMSAA.pass
|
||||
Passes/FullscreenCopy.pass
|
||||
Passes/FullscreenOutputOnly.pass
|
||||
Passes/ImGui.pass
|
||||
@@ -165,6 +166,7 @@ set(FILES
|
||||
Passes/MSAAResolveDepth.pass
|
||||
Passes/OpaqueParent.pass
|
||||
Passes/PostProcessParent.pass
|
||||
Passes/ProjectedShadowmaps.pass
|
||||
Passes/RayTracingAccelerationStructure.pass
|
||||
Passes/ReflectionComposite.pass
|
||||
Passes/ReflectionCopyFrameBuffer.pass
|
||||
@@ -191,7 +193,6 @@ set(FILES
|
||||
Passes/SMAAConvertToPerceptualColor.pass
|
||||
Passes/SMAAEdgeDetection.pass
|
||||
Passes/SMAANeighborhoodBlending.pass
|
||||
Passes/ProjectedShadowmaps.pass
|
||||
Passes/SsaoCompute.pass
|
||||
Passes/SsaoHalfRes.pass
|
||||
Passes/SsaoParent.pass
|
||||
@@ -230,14 +231,16 @@ set(FILES
|
||||
ShaderLib/Atom/Features/PBR/DefaultObjectSrg.azsli
|
||||
ShaderLib/Atom/Features/PBR/ForwardPassOutput.azsli
|
||||
ShaderLib/Atom/Features/PBR/ForwardPassSrg.azsli
|
||||
ShaderLib/Atom/Features/PBR/ForwardSubsurfacePassOutput.azsli
|
||||
ShaderLib/Atom/Features/PBR/Hammersley.azsli
|
||||
ShaderLib/Atom/Features/PBR/LightingModel.azsli
|
||||
ShaderLib/Atom/Features/PBR/LightingOptions.azsli
|
||||
ShaderLib/Atom/Features/PBR/LightingUtils.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surface.azsli
|
||||
ShaderLib/Atom/Features/PBR/TransparentPassSrg.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lighting/DualSpecularLighting.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lighting/EnhancedLighting.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lighting/LightingData.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lighting/SkinLighting.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lighting/StandardLighting.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lights/CapsuleLight.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lights/DirectionalLight.azsli
|
||||
@@ -249,6 +252,8 @@ set(FILES
|
||||
ShaderLib/Atom/Features/PBR/Lights/PointLight.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lights/PolygonLight.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lights/QuadLight.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lights/SimplePointLight.azsli
|
||||
ShaderLib/Atom/Features/PBR/Lights/SimpleSpotLight.azsli
|
||||
ShaderLib/Atom/Features/PBR/Microfacet/Brdf.azsli
|
||||
ShaderLib/Atom/Features/PBR/Microfacet/Fresnel.azsli
|
||||
ShaderLib/Atom/Features/PBR/Microfacet/Ggx.azsli
|
||||
@@ -256,6 +261,8 @@ set(FILES
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/BasePbrSurfaceData.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/ClearCoatSurfaceData.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/DualSpecularSurface.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/EnhancedSurface.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/SkinSurface.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/StandardSurface.azsli
|
||||
ShaderLib/Atom/Features/PBR/Surfaces/TransmissionSurfaceData.azsli
|
||||
ShaderLib/Atom/Features/PostProcessing/Aces.azsli
|
||||
@@ -271,9 +278,12 @@ set(FILES
|
||||
ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli
|
||||
ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/JitterTablePcf.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/Shadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli
|
||||
ShaderLib/Atom/Features/Vertex/VertexHelper.azsli
|
||||
ShaderResourceGroups/RayTracingSceneSrg.azsli
|
||||
ShaderResourceGroups/RayTracingSceneSrgAll.azsli
|
||||
ShaderResourceGroups/SceneSrg.azsli
|
||||
ShaderResourceGroups/SceneSrgAll.azsli
|
||||
ShaderResourceGroups/SceneTimeSrg.azsli
|
||||
|
||||
@@ -14,9 +14,12 @@
|
||||
#include "AutoBrick_Common.azsli"
|
||||
#include <Atom/Features/PBR/AlphaUtils.azsli>
|
||||
#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
|
||||
#include <Atom/Features/PBR/ForwardPassSrg.azsli>
|
||||
#include <Atom/Features/PBR/ForwardPassOutput.azsli>
|
||||
#include <Atom/Features/ColorManagement/TransformColor.azsli>
|
||||
#include <Atom/Features/ParallaxMapping.azsli>
|
||||
#include <Atom/Features/PBR/Lighting/StandardLighting.azsli>
|
||||
#include <Atom/Features/PBR/Decals.azsli>
|
||||
|
||||
struct VSInput
|
||||
{
|
||||
@@ -38,7 +41,6 @@ struct VSOutput
|
||||
float2 m_uv : UV1;
|
||||
};
|
||||
|
||||
#include <Atom/Features/PBR/LightingModel.azsli>
|
||||
#include <Atom/Features/Vertex/VertexHelper.azsli>
|
||||
|
||||
VSOutput AutoBrick_ForwardPassVS(VSInput IN)
|
||||
@@ -129,8 +131,6 @@ float GetDepth(float2 uv, float2 uv_ddx, float2 uv_ddy)
|
||||
|
||||
ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN)
|
||||
{
|
||||
ForwardPassOutput OUT;
|
||||
|
||||
float3x3 identityUvMatrix =
|
||||
{ 1,0,0,
|
||||
0,1,0,
|
||||
@@ -164,22 +164,62 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN)
|
||||
GetSurfaceShape(IN.m_uv, surfaceDepth, surfaceNormal);
|
||||
const float3 normal = TangentSpaceToWorld(surfaceNormal, normalize(IN.m_normal), normalize(IN.m_tangent), normalize(IN.m_bitangent));
|
||||
|
||||
const float occlusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor;
|
||||
const float metallic = 0;
|
||||
const float roughness = 1;
|
||||
const float specularF0Factor = 0.5;
|
||||
const float3 emissive = {0,0,0};
|
||||
const float clearCoatFactor = 0.0;
|
||||
const float clearCoatRoughness = 0.0;
|
||||
const float3 clearCoatNormal = {0,0,0};
|
||||
const float4 transmissionTintThickness = {0,0,0,0};
|
||||
const float4 transmissionParams = {0,0,0,0};
|
||||
const float2 anisotropy = 0.0;
|
||||
const float alpha = 1.0;
|
||||
// ------- Surface -------
|
||||
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
|
||||
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
Surface surface;
|
||||
|
||||
// Position, Normal, Roughness
|
||||
surface.position = IN.m_worldPosition.xyz;
|
||||
surface.normal = normalize(normal);
|
||||
surface.roughnessLinear = 1.0f;
|
||||
surface.CalculateRoughnessA();
|
||||
|
||||
// Albedo, SpecularF0
|
||||
const float metallic = 0.0f;
|
||||
const float specularF0 = 0.5f;
|
||||
surface.SetAlbedoAndSpecularF0(baseColor, specularF0, metallic);
|
||||
|
||||
// Clear Coat, Transmission
|
||||
surface.clearCoat.InitializeToZero();
|
||||
surface.transmission.InitializeToZero();
|
||||
|
||||
// ------- LightingData -------
|
||||
|
||||
LightingData lightingData;
|
||||
|
||||
// Light iterator
|
||||
lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData);
|
||||
lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
|
||||
|
||||
// Shadow
|
||||
lightingData.shadowCoords = IN.m_shadowCoords;
|
||||
lightingData.occlusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor;
|
||||
|
||||
// Diffuse and Specular response
|
||||
lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
|
||||
lightingData.diffuseResponse = 1.0f - lightingData.specularResponse;
|
||||
|
||||
const float alpha = 1.0f;
|
||||
|
||||
// ------- Lighting Calculation -------
|
||||
|
||||
// Apply Decals
|
||||
ApplyDecals(lightingData.tileIterator, surface);
|
||||
|
||||
// Apply Direct Lighting
|
||||
ApplyDirectLighting(surface, lightingData);
|
||||
|
||||
// Apply Image Based Lighting (IBL)
|
||||
ApplyIBL(surface, lightingData);
|
||||
|
||||
// Finalize Lighting
|
||||
lightingData.FinalizeLighting(surface.transmission.tint);
|
||||
|
||||
PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha);
|
||||
|
||||
// ------- Output -------
|
||||
|
||||
ForwardPassOutput OUT;
|
||||
|
||||
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
|
||||
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
|
||||
@@ -188,7 +228,6 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN)
|
||||
OUT.m_albedo = lightingOutput.m_albedo;
|
||||
OUT.m_normal = lightingOutput.m_normal;
|
||||
OUT.m_clearCoatNormal = lightingOutput.m_clearCoatNormal;
|
||||
OUT.m_scatterDistance = float3(0,0,0);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,13 @@
|
||||
|
||||
#include <viewsrg.srgi>
|
||||
#include <Atom/Features/PBR/DefaultObjectSrg.azsli>
|
||||
#include <Atom/Features/PBR/ForwardPassSrg.azsli>
|
||||
#include <Atom/Features/PBR/ForwardPassOutput.azsli>
|
||||
#include <Atom/Features/PBR/AlphaUtils.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 MinimalPBRSrg : SRG_PerMaterial
|
||||
{
|
||||
@@ -42,7 +45,6 @@ struct VSOutput
|
||||
float3 m_shadowCoords[ViewSrg::MaxCascadeCount] : UV3;
|
||||
};
|
||||
|
||||
#include <Atom/Features/PBR/LightingModel.azsli>
|
||||
#include <Atom/Features/Vertex/VertexHelper.azsli>
|
||||
|
||||
VSOutput MinimalPBR_MainPassVS(VSInput IN)
|
||||
@@ -58,26 +60,60 @@ VSOutput MinimalPBR_MainPassVS(VSInput IN)
|
||||
|
||||
ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN)
|
||||
{
|
||||
ForwardPassOutput OUT;
|
||||
|
||||
const float3 baseColor = MinimalPBRSrg::m_baseColor;
|
||||
const float metallic = MinimalPBRSrg::m_metallic;
|
||||
const float roughness = MinimalPBRSrg::m_roughness;
|
||||
const float specularF0Factor = 0.5;
|
||||
const float3 normal = normalize(IN.m_normal);
|
||||
const float3 emissive = {0,0,0};
|
||||
const float occlusion = 1;
|
||||
const float clearCoatFactor = 0.0;
|
||||
const float clearCoatRoughness = 0.0;
|
||||
const float3 clearCoatNormal = {0,0,0};
|
||||
const float4 transmissionTintThickness = {0,0,0,0};
|
||||
const float4 transmissionParams = {0,0,0,0};
|
||||
const float2 anisotropy = 0.0; // Does not affect calculations unless 'o_enableAnisotropy' is enabled
|
||||
const float alpha = 1.0;
|
||||
// ------- Surface -------
|
||||
|
||||
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
|
||||
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
|
||||
emissive, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
|
||||
Surface surface;
|
||||
|
||||
// Position, Normal, Roughness
|
||||
surface.position = IN.m_worldPosition.xyz;
|
||||
surface.normal = normalize(IN.m_normal);
|
||||
surface.roughnessLinear = MinimalPBRSrg::m_roughness;
|
||||
surface.CalculateRoughnessA();
|
||||
|
||||
// Albedo, SpecularF0
|
||||
const float specularF0 = 0.5f;
|
||||
surface.SetAlbedoAndSpecularF0(MinimalPBRSrg::m_baseColor, specularF0, MinimalPBRSrg::m_metallic);
|
||||
|
||||
// Clear Coat, Transmission
|
||||
surface.clearCoat.InitializeToZero();
|
||||
surface.transmission.InitializeToZero();
|
||||
|
||||
// ------- LightingData -------
|
||||
|
||||
LightingData lightingData;
|
||||
|
||||
// Light iterator
|
||||
lightingData.tileIterator.Init(IN.m_position, PassSrg::m_lightListRemapped, PassSrg::m_tileLightData);
|
||||
lightingData.Init(surface.position, surface.normal, surface.roughnessLinear);
|
||||
|
||||
// Shadow, Occlusion
|
||||
lightingData.shadowCoords = IN.m_shadowCoords;
|
||||
|
||||
// Diffuse and Specular response
|
||||
lightingData.specularResponse = FresnelSchlickWithRoughness(lightingData.NdotV, surface.specularF0, surface.roughnessLinear);
|
||||
lightingData.diffuseResponse = 1.0f - lightingData.specularResponse;
|
||||
|
||||
const float alpha = 1.0f;
|
||||
|
||||
// ------- Lighting Calculation -------
|
||||
|
||||
// Apply Decals
|
||||
ApplyDecals(lightingData.tileIterator, surface);
|
||||
|
||||
// Apply Direct Lighting
|
||||
ApplyDirectLighting(surface, lightingData);
|
||||
|
||||
// Apply Image Based Lighting (IBL)
|
||||
ApplyIBL(surface, lightingData);
|
||||
|
||||
// Finalize Lighting
|
||||
lightingData.FinalizeLighting(surface.transmission.tint);
|
||||
|
||||
PbrLightingOutput lightingOutput = GetPbrLightingOutput(surface, lightingData, alpha);
|
||||
|
||||
// ------- Output -------
|
||||
|
||||
ForwardPassOutput OUT;
|
||||
|
||||
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
|
||||
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
|
||||
@@ -86,7 +122,6 @@ ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN)
|
||||
OUT.m_albedo = lightingOutput.m_albedo;
|
||||
OUT.m_normal = lightingOutput.m_normal;
|
||||
OUT.m_clearCoatNormal = lightingOutput.m_clearCoatNormal;
|
||||
OUT.m_scatterDistance = float3(0,0,0);
|
||||
|
||||
return OUT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user