Added support for cavity maps by changing the "Ambient Occlusion" material property group go just "Occlusion", which now contains properties for both "Diffuse AO" and "Specular Cavity".

Added new input attachment to the fullscreen reflection pass to receive the "ambient" gbuffer.
Added diffuse and specular occlusion to the Skin material type; it was missing before.

ATOM-14040 Add Support for Cavity Maps

Testing:
AtomSampleViewer automation, with updates that will be submitted in that repo.
Manual testing in Material Editor.
Built all AtomTest assets and opened a few test levels, with updates that will be submitted in that repo.
Made local copies of the occlusion test materials and changed replaced the material types with EnhancedPBR and Skin, and got identical results (with clear coat disabled since it works different in EnhancedPBR and is absent in Skin).
This commit is contained in:
Chris Santora
2021-04-20 12:52:56 -07:00
parent f5cb6f438b
commit 64e625a79f
41 changed files with 775 additions and 347 deletions
@@ -401,38 +401,6 @@
"step": 0.1
}
],
"ambientOcclusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"type": "Bool",
"defaultValue": false
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionFactor"
}
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMap"
}
}
],
"emissive": [
{
"id": "enable",
@@ -49,9 +49,9 @@
"description": "Properties for configuring UV transforms."
},
{
"id": "ambientOcclusion",
"displayName": "Ambient Occlusion",
"description": "Properties for baked AO texture."
"id": "occlusion",
"displayName": "Occlusion",
"description": "Properties for baked textures that represent geometric occlusion of light."
},
{
"id": "emissive",
@@ -780,47 +780,96 @@
"step": 0.1
}
],
"ambientOcclusion": [
"occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionFactor"
}
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMap"
"id": "m_diffuseOcclusionMap"
}
},
{
"id": "textureMapUv",
"displayName": "UV",
"description": "Ambient occlusion texture map UV set",
"id": "diffuseUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Diffuse AO texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "diffuseTextureMapUv",
"displayName": " UV",
"description": "Diffuse AO texture map UV set.",
"type": "Enum",
"enumValues": [ "UV0", "UV1" ],
"defaultValue": "UV0",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMapUvIndex"
"id": "m_diffuseOcclusionMapUvIndex"
}
},
{
"id": "diffuseFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Diffuse AO",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_diffuseOcclusionFactor"
}
},
{
"id": "specularTextureMap",
"displayName": "Specular Cavity",
"description": "Texture map for defining occlusion area for specular lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionMap"
}
},
{
"id": "specularUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Specular Cavity texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "specularTextureMapUv",
"displayName": " UV",
"description": "Specular Cavity texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionMapUvIndex"
}
},
{
"id": "specularFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Specular Cavity",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionFactor"
}
}
],
@@ -1641,17 +1690,15 @@
}
},
{
// See the comment above for details.
"type": "UseTexture",
"type": "Lua",
"args": {
"textureProperty": "ambientOcclusion.textureMap",
"dependentProperties": ["ambientOcclusion.textureMapUv"],
"useTextureProperty": "ambientOcclusion.enable",
"shaderTags": [
"ForwardPass",
"ForwardPass_EDS"
],
"shaderOption": "o_ambientOcclusion_useTexture"
"file": "StandardPBR_DiffuseOcclusionState.lua"
}
},
{
"type": "Lua",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua"
}
},
{
@@ -1712,31 +1759,6 @@
"shaderOption": "o_transmission_useTexture"
}
},
{
// Controls visibility for properties in the editor.
// @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue.
// @param affectedProperties - the properties that are affected by actions.
"type": "UpdatePropertyVisibility",
"args": {
"actions": [
{
"triggerProperty": "ambientOcclusion.enable",
"triggerValue": true,
"visibility": "Enabled"
},
{
"triggerProperty": "ambientOcclusion.enable",
"triggerValue": false,
"visibility": "Disabled"
}
],
"affectedProperties": [
"ambientOcclusion.factor",
"ambientOcclusion.textureMap",
"ambientOcclusion.textureMapUv"
]
}
},
{
// Controls visibility for properties in the editor.
// @param actions - a list of actions that are executed in order. visibility will be set when triggerProperty hits the triggerValue.
@@ -212,9 +212,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture);
// ------- Occlusion -------
float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex];
float occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture);
float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
// ------- Subsurface -------
@@ -250,7 +250,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
normal, IN.m_tangent, IN.m_bitangent, anisotropy,
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
// ------- Opacity -------
@@ -12,19 +12,23 @@
#pragma once
// This file provides utilities for common handling of inputs for ambient occlusion maps for PBR materials.
// This file provides utilities for common handling of inputs for baked occlusion maps for PBR materials.
// These macros can be used to declare common shader inputs for this feature.
// Use the COMMON_SRG_INPUTS_* macro in your material SRG definition, and use the COMMON_OPTIONS_* macro at the global scope in your shader. Then you can pass these variables to the Get*Input() function below.
// You can optionally provide a prefix for the set of inputs which corresponds to a prefix string supplied by the .materialtype file. This is common for multi-layered material types.
#define COMMON_SRG_INPUTS_OCCLUSION(prefix) \
float prefix##m_ambientOcclusionFactor; \
Texture2D prefix##m_ambientOcclusionMap; \
uint prefix##m_ambientOcclusionMapUvIndex;
float prefix##m_diffuseOcclusionFactor; \
Texture2D prefix##m_diffuseOcclusionMap; \
uint prefix##m_diffuseOcclusionMapUvIndex; \
float prefix##m_specularOcclusionFactor; \
Texture2D prefix##m_specularOcclusionMap; \
uint prefix##m_specularOcclusionMapUvIndex;
#define COMMON_OPTIONS_OCCLUSION(prefix) \
option bool prefix##o_ambientOcclusion_useTexture;
option bool prefix##o_diffuseOcclusion_useTexture; \
option bool prefix##o_specularOcclusion_useTexture;
float GetOcclusionInput(Texture2D map, sampler mapSampler, float2 uv, float factor, bool useTexture)
{
@@ -271,6 +271,11 @@ PbrLightingOutput SkinPS_Common(VSOutput IN)
float roughness = GetRoughnessInput(MaterialSrg::m_roughnessMap, MaterialSrg::m_sampler, roughnessUv, MaterialSrg::m_roughnessFactor,
MaterialSrg::m_roughnessLowerBound, MaterialSrg::m_roughnessUpperBound, o_roughness_useTexture);
// ------- Occlusion -------
float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
// ------- Specular -------
float2 specularUv = IN.m_uv[MaterialSrg::m_specularF0MapUvIndex];
@@ -299,7 +304,6 @@ PbrLightingOutput SkinPS_Common(VSOutput IN)
float metallic = 0;
float3 emissive = float3(0,0,0);
float occlusion = 1;
float2 anisotropy = float2(0,0);
float clearCoatFactor = 0.0;
float clearCoatRoughness = 0.0;
@@ -308,7 +312,7 @@ PbrLightingOutput SkinPS_Common(VSOutput IN)
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
normalWS, tangents[0], bitangents[0], anisotropy,
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
// ------- Preparing output -------
@@ -24,9 +24,9 @@
"description": "Properties related to configuring surface normal."
},
{
"id": "ambientOcclusion",
"displayName": "Ambient Occlusion",
"description": "Properties for baked AO texture."
"id": "occlusion",
"displayName": "Occlusion",
"description": "Properties for baked textures that represent geometric occlusion of light."
},
{
"id": "subsurfaceScattering",
@@ -383,48 +383,96 @@
}
}
],
"ambientOcclusion": [
"occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMap"
"id": "m_diffuseOcclusionMap"
}
},
{
"id": "textureMapUv",
"displayName": "UV",
"description": "Ambient occlusion texture map UV set",
"id": "diffuseUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Diffuse AO texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "diffuseTextureMapUv",
"displayName": " UV",
"description": "Diffuse AO texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Unwrapped",
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMapUvIndex"
"id": "m_diffuseOcclusionMapUvIndex"
}
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"id": "diffuseFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Diffuse AO",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionFactor"
"id": "m_diffuseOcclusionFactor"
}
},
{
"id": "specularTextureMap",
"displayName": "Specular Cavity",
"description": "Texture map for defining occlusion area for specular lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionMap"
}
},
{
"id": "specularUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Specular Cavity texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "specularTextureMapUv",
"displayName": " UV",
"description": "Specular Cavity texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionMapUvIndex"
}
},
{
"id": "specularFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Specular Cavity",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionFactor"
}
}
],
@@ -1023,7 +1071,13 @@
{
"type": "Lua",
"args": {
"file": "StandardPBR_AoState.lua"
"file": "StandardPBR_DiffuseOcclusionState.lua"
}
},
{
"type": "Lua",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua"
}
},
{
@@ -73,9 +73,9 @@
"description": "Properties for configuring gloss clear coat"
},
{
"id": "layer1_ambientOcclusion",
"displayName": "Layer 1: Ambient Occlusion",
"description": "Properties for baked AO texture."
"id": "layer1_occlusion",
"displayName": "Layer 1: Occlusion",
"description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting."
},
{
"id": "layer1_emissive",
@@ -126,9 +126,9 @@
"description": "Properties for configuring gloss clear coat"
},
{
"id": "layer2_ambientOcclusion",
"displayName": "Layer 2: Ambient Occlusion",
"description": "Properties for baked AO texture."
"id": "layer2_occlusion",
"displayName": "Layer 2: Occlusion",
"description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting."
},
{
"id": "layer2_emissive",
@@ -179,9 +179,9 @@
"description": "Properties for configuring gloss clear coat"
},
{
"id": "layer3_ambientOcclusion",
"displayName": "Layer 3: Ambient Occlusion",
"description": "Properties for baked AO texture."
"id": "layer3_occlusion",
"displayName": "Layer 3: Occlusion",
"description": "Properties for baked textures for diffuse and specular occlusion of ambient lighting."
},
{
"id": "layer3_emissive",
@@ -1169,47 +1169,96 @@
}
}
],
"layer1_ambientOcclusion": [
"layer1_occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_layer1_m_ambientOcclusionMap"
"id": "m_layer1_m_diffuseOcclusionMap"
}
},
{
"id": "textureMapUv",
"displayName": "UV",
"description": "Ambient occlusion texture map UV set",
"id": "diffuseUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Diffuse AO texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "diffuseTextureMapUv",
"displayName": " UV",
"description": "Diffuse AO texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_layer1_m_ambientOcclusionMapUvIndex"
"id": "m_layer1_m_diffuseOcclusionMapUvIndex"
}
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"id": "diffuseFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Diffuse AO",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_layer1_m_ambientOcclusionFactor"
"id": "m_layer1_m_diffuseOcclusionFactor"
}
},
{
"id": "specularTextureMap",
"displayName": "Specular Cavity",
"description": "Texture map for defining occlusion area for specular lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_layer1_m_specularOcclusionMap"
}
},
{
"id": "specularUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Specular Cavity texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "specularTextureMapUv",
"displayName": " UV",
"description": "Specular Cavity texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_layer1_m_specularOcclusionMapUvIndex"
}
},
{
"id": "specularFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Specular Cavity",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_layer1_m_specularOcclusionFactor"
}
}
],
@@ -1820,47 +1869,96 @@
}
}
],
"layer2_ambientOcclusion": [
"layer2_occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_layer2_m_ambientOcclusionMap"
"id": "m_layer2_m_diffuseOcclusionMap"
}
},
{
"id": "textureMapUv",
"displayName": "UV",
"description": "Ambient occlusion texture map UV set",
"id": "diffuseUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Diffuse AO texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "diffuseTextureMapUv",
"displayName": " UV",
"description": "Diffuse AO texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_layer2_m_ambientOcclusionMapUvIndex"
"id": "m_layer2_m_diffuseOcclusionMapUvIndex"
}
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"id": "diffuseFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Diffuse AO",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_layer2_m_ambientOcclusionFactor"
"id": "m_layer2_m_diffuseOcclusionFactor"
}
},
{
"id": "specularTextureMap",
"displayName": "Specular Cavity",
"description": "Texture map for defining occlusion area for specular lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_layer2_m_specularOcclusionMap"
}
},
{
"id": "specularUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Specular Cavity texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "specularTextureMapUv",
"displayName": " UV",
"description": "Specular Cavity texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_layer2_m_specularOcclusionMapUvIndex"
}
},
{
"id": "specularFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Specular Cavity",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_layer2_m_specularOcclusionFactor"
}
}
],
@@ -2471,47 +2569,96 @@
}
}
],
"layer3_ambientOcclusion": [
"layer3_occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_layer3_m_ambientOcclusionMap"
"id": "m_layer3_m_diffuseOcclusionMap"
}
},
{
"id": "textureMapUv",
"displayName": "UV",
"description": "Ambient occlusion texture map UV set",
"id": "diffuseUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Diffuse AO texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "diffuseTextureMapUv",
"displayName": " UV",
"description": "Diffuse AO texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_layer3_m_ambientOcclusionMapUvIndex"
"id": "m_layer3_m_diffuseOcclusionMapUvIndex"
}
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"id": "diffuseFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Diffuse AO",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_layer3_m_ambientOcclusionFactor"
"id": "m_layer3_m_diffuseOcclusionFactor"
}
},
{
"id": "specularTextureMap",
"displayName": "Specular Cavity",
"description": "Texture map for defining occlusion area for specular lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_layer3_m_specularOcclusionMap"
}
},
{
"id": "specularUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Specular Cavity texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "specularTextureMapUv",
"displayName": " UV",
"description": "Specular Cavity texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_layer3_m_specularOcclusionMapUvIndex"
}
},
{
"id": "specularFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Specular Cavity",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_layer3_m_specularOcclusionFactor"
}
}
],
@@ -2896,7 +3043,16 @@
{
"type": "Lua",
"args": {
"file": "StandardPBR_AoState.lua",
"file": "StandardPBR_DiffuseOcclusionState.lua",
"propertyNamePrefix": "layer1_",
"srgNamePrefix": "m_layer1_",
"optionsNamePrefix": "o_layer1_"
}
},
{
"type": "Lua",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua",
"propertyNamePrefix": "layer1_",
"srgNamePrefix": "m_layer1_",
"optionsNamePrefix": "o_layer1_"
@@ -3024,7 +3180,16 @@
{
"type": "Lua",
"args": {
"file": "StandardPBR_AoState.lua",
"file": "StandardPBR_DiffuseOcclusionState.lua",
"propertyNamePrefix": "layer2_",
"srgNamePrefix": "m_layer2_",
"optionsNamePrefix": "o_layer2_"
}
},
{
"type": "Lua",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua",
"propertyNamePrefix": "layer2_",
"srgNamePrefix": "m_layer2_",
"optionsNamePrefix": "o_layer2_"
@@ -3152,7 +3317,16 @@
{
"type": "Lua",
"args": {
"file": "StandardPBR_AoState.lua",
"file": "StandardPBR_DiffuseOcclusionState.lua",
"propertyNamePrefix": "layer3_",
"srgNamePrefix": "m_layer3_",
"optionsNamePrefix": "o_layer3_"
}
},
{
"type": "Lua",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua",
"propertyNamePrefix": "layer3_",
"srgNamePrefix": "m_layer3_",
"optionsNamePrefix": "o_layer3_"
@@ -267,10 +267,15 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// ------- Occlusion -------
float layer1_occlusion = GetOcclusionInput(MaterialSrg::m_layer1_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer1_m_ambientOcclusionFactor, o_layer1_o_ambientOcclusion_useTexture);
float layer2_occlusion = GetOcclusionInput(MaterialSrg::m_layer2_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer2_m_ambientOcclusionFactor, o_layer2_o_ambientOcclusion_useTexture);
float layer3_occlusion = GetOcclusionInput(MaterialSrg::m_layer3_m_ambientOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_ambientOcclusionMapUvIndex], MaterialSrg::m_layer3_m_ambientOcclusionFactor, o_layer3_o_ambientOcclusion_useTexture);
float occlusion = BlendLayers(layer1_occlusion, layer2_occlusion, layer3_occlusion, blendMaskValues);
float layer1_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer1_m_diffuseOcclusionFactor, o_layer1_o_diffuseOcclusion_useTexture);
float layer2_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer2_m_diffuseOcclusionFactor, o_layer2_o_diffuseOcclusion_useTexture);
float layer3_diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_diffuseOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_diffuseOcclusionMapUvIndex], MaterialSrg::m_layer3_m_diffuseOcclusionFactor, o_layer3_o_diffuseOcclusion_useTexture);
float diffuseAmbientOcclusion = BlendLayers(layer1_diffuseAmbientOcclusion, layer2_diffuseAmbientOcclusion, layer3_diffuseAmbientOcclusion, blendMaskValues);
float layer1_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer1_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer1[MaterialSrg::m_layer1_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer1_m_specularOcclusionFactor, o_layer1_o_specularOcclusion_useTexture);
float layer2_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer2_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer2[MaterialSrg::m_layer2_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer2_m_specularOcclusionFactor, o_layer2_o_specularOcclusion_useTexture);
float layer3_specularOcclusion = GetOcclusionInput(MaterialSrg::m_layer3_m_specularOcclusionMap, MaterialSrg::m_sampler, uvLayer3[MaterialSrg::m_layer3_m_specularOcclusionMapUvIndex], MaterialSrg::m_layer3_m_specularOcclusionFactor, o_layer3_o_specularOcclusion_useTexture);
float specularOcclusion = BlendLayers(layer1_specularOcclusion, layer2_specularOcclusion, layer3_specularOcclusion, blendMaskValues);
// ------- Subsurface -------
@@ -348,7 +353,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
normalWS, tangents[0], bitangents[0], anisotropy,
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
// ------- Opacity -------
@@ -44,9 +44,9 @@
"description": "Properties for configuring UV transforms."
},
{
"id": "ambientOcclusion",
"displayName": "Ambient Occlusion",
"description": "Properties for baked AO texture."
"id": "occlusion",
"displayName": "Occlusion",
"description": "Properties for baked textures that represent geometric occlusion of light."
},
{
"id": "emissive",
@@ -724,47 +724,96 @@
"step": 0.1
}
],
"ambientOcclusion": [
"occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the ambient occlusion feature.",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "textureMap",
"displayName": "Texture Map",
"description": "Texture map for defining ambient occlusion area.",
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
"description": "Texture map for defining occlusion area for diffuse ambient lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMap"
"id": "m_diffuseOcclusionMap"
}
},
{
"id": "textureMapUv",
"displayName": "UV",
"description": "Ambient occlusion texture map UV set",
"id": "diffuseUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Diffuse AO texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "diffuseTextureMapUv",
"displayName": " UV",
"description": "Diffuse AO texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionMapUvIndex"
"id": "m_diffuseOcclusionMapUvIndex"
}
},
{
"id": "factor",
"displayName": "Factor",
"description": "Strength factor for scaling the values",
"id": "diffuseFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Diffuse AO",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"max": 2.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_ambientOcclusionFactor"
"id": "m_diffuseOcclusionFactor"
}
},
{
"id": "specularTextureMap",
"displayName": "Specular Cavity",
"description": "Texture map for defining occlusion area for specular lighting.",
"type": "Image",
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionMap"
}
},
{
"id": "specularUseTexture",
"displayName": " Use Texture",
"description": "Whether to use the Specular Cavity texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "specularTextureMapUv",
"displayName": " UV",
"description": "Specular Cavity texture map UV set.",
"type": "Enum",
"enumIsUv": true,
"defaultValue": "Tiled",
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionMapUvIndex"
}
},
{
"id": "specularFactor",
"displayName": " Factor",
"description": "Strength factor for scaling the values of Specular Cavity",
"type": "Float",
"defaultValue": 1.0,
"min": 0.0,
"softMax": 2.0,
"connection": {
"type": "ShaderInput",
"id": "m_specularOcclusionFactor"
}
}
],
@@ -1272,7 +1321,13 @@
{
"type": "Lua",
"args": {
"file": "StandardPBR_AoState.lua"
"file": "StandardPBR_DiffuseOcclusionState.lua"
}
},
{
"type": "Lua",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua"
}
},
{
@@ -1,48 +0,0 @@
--------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
function GetMaterialPropertyDependencies()
return {"ambientOcclusion.enable", "ambientOcclusion.textureMap"}
end
function GetShaderOptionDependencies()
return {"o_ambientOcclusion_useTexture"}
end
function Process(context)
local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable")
local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap")
context:SetShaderOptionValue_bool("o_ambientOcclusion_useTexture", enableAo and textureMap ~= nil)
end
function ProcessEditor(context)
local enableAo = context:GetMaterialPropertyValue_bool("ambientOcclusion.enable")
if(not enableAo) then
context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden)
else
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMap", MaterialPropertyVisibility_Enabled)
local textureMap = context:GetMaterialPropertyValue_image("ambientOcclusion.textureMap")
if(textureMap == nil) then
context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Hidden)
else
context:SetMaterialPropertyVisibility("ambientOcclusion.factor", MaterialPropertyVisibility_Enabled)
context:SetMaterialPropertyVisibility("ambientOcclusion.textureMapUv", MaterialPropertyVisibility_Enabled)
end
end
end
@@ -0,0 +1,52 @@
--------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
function GetMaterialPropertyDependencies()
return {"occlusion.enable", "occlusion.diffuseTextureMap", "occlusion.diffuseUseTexture"}
end
function GetShaderOptionDependencies()
return {"o_diffuseOcclusion_useTexture"}
end
function Process(context)
local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable")
local textureMap = context:GetMaterialPropertyValue_image("occlusion.diffuseTextureMap")
local enableDiffuse = context:GetMaterialPropertyValue_bool("occlusion.diffuseUseTexture")
context:SetShaderOptionValue_bool("o_diffuseOcclusion_useTexture", enableOcclusionMaps and textureMap ~= nil and enableDiffuse)
end
function ProcessEditor(context)
local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable")
if(not enableOcclusionMaps) then
context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMap", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Hidden)
else
context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMap", MaterialPropertyVisibility_Enabled)
local textureMap = context:GetMaterialPropertyValue_image("occlusion.diffuseTextureMap")
if(textureMap == nil) then
context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Hidden)
else
context:SetMaterialPropertyVisibility("occlusion.diffuseUseTexture", MaterialPropertyVisibility_Enabled)
context:SetMaterialPropertyVisibility("occlusion.diffuseTextureMapUv", MaterialPropertyVisibility_Enabled)
context:SetMaterialPropertyVisibility("occlusion.diffuseFactor", MaterialPropertyVisibility_Enabled)
end
end
end
@@ -171,9 +171,9 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
float3 emissive = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture);
// ------- Occlusion -------
float2 occlusionUv = IN.m_uv[MaterialSrg::m_ambientOcclusionMapUvIndex];
float occlusion = GetOcclusionInput(MaterialSrg::m_ambientOcclusionMap, MaterialSrg::m_sampler, occlusionUv, MaterialSrg::m_ambientOcclusionFactor, o_ambientOcclusion_useTexture);
float diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
float specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
// ------- Subsurface -------
@@ -208,7 +208,7 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
PbrLightingOutput lightingOutput = PbrLighting(IN, baseColor, metallic, roughness, specularF0Factor,
normalWS, tangents[0], bitangents[0], anisotropy,
emissive, occlusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, MaterialSrg::m_transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, o_opacity_mode);
// ------- Opacity -------
@@ -0,0 +1,52 @@
--------------------------------------------------------------------------------------
--
-- All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
-- its licensors.
--
-- For complete copyright and license terms please see the LICENSE at the root of this
-- distribution (the "License"). All use of this software is governed by the License,
-- or, if provided, by the license below or the license accompanying this file. Do not
-- remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--
--
----------------------------------------------------------------------------------------------------
function GetMaterialPropertyDependencies()
return {"occlusion.enable", "occlusion.specularTextureMap", "occlusion.specularUseTexture"}
end
function GetShaderOptionDependencies()
return {"o_specularOcclusion_useTexture"}
end
function Process(context)
local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable")
local textureMap = context:GetMaterialPropertyValue_image("occlusion.specularTextureMap")
local enableDiffuse = context:GetMaterialPropertyValue_bool("occlusion.specularUseTexture")
context:SetShaderOptionValue_bool("o_specularOcclusion_useTexture", enableOcclusionMaps and textureMap ~= nil and enableDiffuse)
end
function ProcessEditor(context)
local enableOcclusionMaps = context:GetMaterialPropertyValue_bool("occlusion.enable")
if(not enableOcclusionMaps) then
context:SetMaterialPropertyVisibility("occlusion.specularTextureMap", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Hidden)
else
context:SetMaterialPropertyVisibility("occlusion.specularTextureMap", MaterialPropertyVisibility_Enabled)
local textureMap = context:GetMaterialPropertyValue_image("occlusion.specularTextureMap")
if(textureMap == nil) then
context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Hidden)
context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Hidden)
else
context:SetMaterialPropertyVisibility("occlusion.specularUseTexture", MaterialPropertyVisibility_Enabled)
context:SetMaterialPropertyVisibility("occlusion.specularTextureMapUv", MaterialPropertyVisibility_Enabled)
context:SetMaterialPropertyVisibility("occlusion.specularFactor", MaterialPropertyVisibility_Enabled)
end
end
end
@@ -180,6 +180,13 @@
"Attachment": "SpecularF0Output"
}
},
{
"LocalSlot": "AlbedoInput",
"AttachmentRef": {
"Pass": "ForwardMSAAPass",
"Attachment": "AlbedoOutput"
}
},
{
"LocalSlot": "ClearCoatNormalInput",
"AttachmentRef": {
@@ -27,6 +27,12 @@
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
},
{
// This is needed for the alpha channel which has specularOcclusion factor
"Name": "AlbedoInput",
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
},
{
"Name": "ClearCoatNormalInput",
"SlotType": "Input",
@@ -17,6 +17,11 @@
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
},
{
"Name": "AlbedoInput",
"SlotType": "Input",
"ScopeAttachmentUsage": "Shader"
},
{
"Name": "ClearCoatNormalInput",
"SlotType": "Input",
@@ -127,6 +132,13 @@
"Attachment": "SpecularF0Input"
}
},
{
"LocalSlot": "AlbedoInput",
"AttachmentRef": {
"Pass": "Parent",
"Attachment": "AlbedoInput"
}
},
{
"LocalSlot": "ClearCoatNormalInput",
"AttachmentRef": {
@@ -12,19 +12,19 @@
struct ForwardPassOutput
{
// m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled
float4 m_diffuseColor : SV_Target0;
float4 m_specularColor : SV_Target1;
float4 m_albedo : SV_Target2;
float4 m_specularF0 : SV_Target3;
float4 m_normal : SV_Target4;
float4 m_clearCoatNormal : SV_Target5;
float4 m_diffuseColor : SV_Target0; //!< RGB = Diffuse Lighting, A = Blend Alpha (for blended surfaces) OR A = special encoding of surfaceScatteringFactor, m_subsurfaceScatteringQuality, o_enableSubsurfaceScattering
float4 m_specularColor : SV_Target1; //!< RGB = Specular Lighting, A = Unused
float4 m_albedo : SV_Target2; //!< RGB = Surface albedo pre-multiplied by other factors that will be multiplied later by diffuse GI, A = specularOcclusion
float4 m_specularF0 : SV_Target3; //!< RGB = Specular F0, A = roughness
float4 m_normal : SV_Target4; //!< RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled
float4 m_clearCoatNormal : SV_Target5; //!< RG = EncodeNormalSphereMap(clearCoatNormal), B = clearCoatFactor, A = clearCoatRoughness
float3 m_scatterDistance : SV_Target6;
};
struct ForwardPassOutputWithDepth
{
// m_diffuseColor.a should be encoded with subsurface scattering's strength factor and quality factor if enabled
// See above for descriptions of special encodings
float4 m_diffuseColor : SV_Target0;
float4 m_specularColor : SV_Target1;
float4 m_albedo : SV_Target2;
@@ -100,6 +100,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN,
float2 anisotropy, // angle and factor
float3 emissive,
float diffuseAmbientOcclusion,
float specularOcclusion,
float4 transmissionTintThickness,
float4 transmissionParams,
float clearCoatFactor,
@@ -237,11 +238,6 @@ PbrLightingOutput PbrLighting( in VSOutput IN,
}
}
// Emissive contribution
// Emissive light is apply to specular now, as diffuse will be used for subsurface scattering later down the pipeline
// We may change this if specular is also used for other processing
specularLighting += emissive;
if (o_enableDirectionalLights)
{
ApplyDirectionalLights(dirToCamera, surface, IN.m_shadowCoords, diffuseLighting, specularLighting, translucentBackLighting);
@@ -253,6 +249,13 @@ PbrLightingOutput PbrLighting( in VSOutput IN,
diffuseLighting += translucentBackLighting * transmissionTintThickness.xyz;
}
specularLighting *= specularOcclusion;
// Emissive contribution
// Emissive light is apply to specular now, as diffuse will be used for subsurface scattering later down the pipeline
// We may change this if specular is also used for other processing
specularLighting += emissive;
PbrLightingOutput lightingOutput;
lightingOutput.m_diffuseColor = float4(diffuseLighting, alpha);
@@ -261,6 +264,7 @@ PbrLightingOutput PbrLighting( in VSOutput IN,
// albedo, specularF0, roughness, and normals for later passes (specular IBL, Diffuse GI, SSR, AO, etc)
lightingOutput.m_specularF0 = float4(specularF0, roughness);
lightingOutput.m_albedo.rgb = surface.albedo * diffuseResponse * diffuseAmbientOcclusion;
lightingOutput.m_albedo.a = specularOcclusion;
lightingOutput.m_normal.rgb = EncodeNormalSignedOctahedron(normal);
lightingOutput.m_normal.a = o_specularF0_enableMultiScatterCompensation ? 1.0f : 0.0f;
@@ -299,7 +303,7 @@ PbrLightingOutput MakeDebugOutput(VSOutput IN, float3 debugColor, float3 normalW
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);
emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
return lightingOutput;
}
@@ -43,8 +43,9 @@
ShaderResourceGroup PassSrg : SRG_PerPass
{
Texture2DMS<float> m_depth;
Texture2DMS<float4> m_normal; // RGB10 = Normal (Encoded), A2 = Flags
Texture2DMS<float4> m_normal; // RGB10 = EncodeNormalSignedOctahedron(worldNormal), A2 = multiScatterCompensationEnabled
Texture2DMS<float4> m_specularF0; // RGB8 = SpecularF0, A8 = Roughness
Texture2DMS<float4> m_albedo; // RGB = Not used here, A = specularOcclusion
Texture2DMS<float4> m_clearCoatNormal; // R16G16 = Normal (Packed), B16A16 = (factor, perceptual roughness)
Texture2DMS<float> m_blendWeight;
Texture2D<float2> m_brdfMap;
@@ -80,6 +81,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
float4 encodedNormal = PassSrg::m_normal.Load(IN.m_position.xy, sampleIndex);
float3 normal = DecodeNormalSignedOctahedron(encodedNormal.rgb);
bool multiScatterCompensationEnabled = (encodedNormal.a > 0.0f);
float4 albedo = PassSrg::m_albedo.Load(IN.m_position.xy, sampleIndex);
float specularOcclusion = albedo.a;
// reconstruct world space position from the depth at this location in screenspace
float3 positionWS = ReconstructWorldPositionFromDepth(IN.m_position.xy, sampleIndex).xyz;
@@ -136,6 +140,9 @@ PSOutput MainPS(VSOutput IN, in uint sampleIndex : SV_SampleIndex)
// apply exposure setting
specular *= pow(2.0, SceneSrg::m_iblExposure);
// maybe attenuate the specular
specular *= specularOcclusion;
PSOutput OUT;
OUT.m_color = float4(specular, 1.0f);
return OUT;
@@ -36,7 +36,6 @@ set(FILES
Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.azsl
Materials/Types/StandardMultilayerPBR_Shadowmap_WithPS.shader
Materials/Types/StandardPBR.materialtype
Materials/Types/StandardPBR_AoState.lua
Materials/Types/StandardPBR_ClearCoatEnableFeature.lua
Materials/Types/StandardPBR_ClearCoatState.lua
Materials/Types/StandardPBR_Common.azsli
@@ -4,9 +4,9 @@
"parentMaterial": "Materials/Presets/PBR/default_grid.material",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"enable": true,
"textureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg"
"diffuseTextureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg"
},
"baseColor": {
"textureMap": "TestData/Textures/cc0/Rock030_2K_Color.jpg"
@@ -4,11 +4,6 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"layer1_ambientOcclusion": {
"enable": true,
"factor": 1.6399999856948853,
"textureMap": "TestData/Textures/cc0/bark1_disp.jpg"
},
"layer1_baseColor": {
"color": [
0.3495536744594574,
@@ -32,6 +27,11 @@
"flipY": true,
"textureMap": "TestData/Textures/cc0/bark1_norm.jpg"
},
"layer1_occlusion": {
"diffuseFactor": 1.6399999856948853,
"diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg",
"enable": true
},
"layer1_parallax": {
"enable": true,
"factor": 0.02500000037252903,
@@ -53,10 +53,6 @@
"offsetU": 0.5,
"offsetV": 0.25
},
"layer2_ambientOcclusion": {
"factor": 1.2200000286102296,
"textureMap": "TestData/Textures/cc0/bark1_disp.jpg"
},
"layer2_baseColor": {
"textureMap": "TestData/Textures/cc0/Lava004_1K_Color.jpg"
},
@@ -76,6 +72,11 @@
"flipY": true,
"textureMap": "TestData/Textures/cc0/Lava004_1K_Normal.jpg"
},
"layer2_occlusion": {
"enable": true,
"specularFactor": 2.0,
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
},
"layer2_parallax": {
"enable": true,
"factor": 0.01600000075995922,
@@ -88,11 +89,6 @@
"offsetU": 0.5,
"offsetV": 0.25
},
"layer3_ambientOcclusion": {
"enable": true,
"factor": 1.0399999618530274,
"textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg"
},
"layer3_baseColor": {
"color": [
0.6315556764602661,
@@ -115,6 +111,11 @@
"layer3_normal": {
"textureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Normal.jpg"
},
"layer3_occlusion": {
"diffuseFactor": 1.0399999618530274,
"diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg",
"enable": true
},
"layer3_parallax": {
"enable": true,
"factor": 0.004999999888241291,
@@ -1,21 +1,13 @@
{
"description": "",
"materialType": "Materials/Types/StandardPBR.materialtype",
"parentMaterial": "",
"parentMaterial": "010_OcclusionBase.material",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"enable": true,
"factor": 2.0,
"textureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg"
},
"baseColor": {
"color": [
1.0,
1.0,
0.21223773062229157,
1.0
]
"occlusion": {
"diffuseFactor": 2.0,
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg",
"enable": true
}
}
}
@@ -0,0 +1,15 @@
{
"description": "",
"materialType": "Materials/Types/StandardPBR.materialtype",
"parentMaterial": "010_OcclusionBase.material",
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseFactor": 2.0,
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg",
"specularFactor": 2.0,
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
}
}
}
@@ -0,0 +1,25 @@
{
"description": "",
"materialType": "Materials/Types/StandardPBR.materialtype",
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"baseColor": {
"color": [
0.06784161180257797,
0.2073090672492981,
0.29570457339286806,
1.0
]
},
"clearCoat": {
"enable": true
},
"normal": {
"textureMap": "TestData/Textures/cc0/Tiles009_1K_Normal.jpg"
},
"roughness": {
"factor": 0.0
}
}
}
@@ -0,0 +1,13 @@
{
"description": "",
"materialType": "Materials/Types/StandardPBR.materialtype",
"parentMaterial": "010_OcclusionBase.material",
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"specularFactor": 2.0,
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
}
}
}
@@ -4,9 +4,9 @@
"parentMaterial": "TestData\\Materials\\StandardPbrTestCases\\UvTilingBase.material",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"enable": true,
"textureMap": "TestData/Objects/cube/cube_diff.tif"
"diffuseTextureMap": "TestData/Objects/cube/cube_diff.tif"
}
}
}
@@ -163,7 +163,8 @@ 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 diffuseAmbientOcclusion = 1.0f - surfaceDepth * AutoBrickSrg::m_aoFactor;
const float specularOcclusion = 1;
const float metallic = 0;
const float roughness = 1;
const float specularF0Factor = 0.5;
@@ -178,7 +179,7 @@ ForwardPassOutput AutoBrick_ForwardPassPS(VSOutput IN)
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);
emissive, diffuseAmbientOcclusion, specularOcclusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
@@ -76,7 +76,7 @@ ForwardPassOutput MinimalPBR_MainPassPS(VSOutput IN)
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);
emissive, occlusion, occlusion, transmissionTintThickness, transmissionParams, clearCoatFactor, clearCoatRoughness, clearCoatNormal, alpha, OpacityMode::Opaque);
OUT.m_diffuseColor = lightingOutput.m_diffuseColor;
OUT.m_diffuseColor.w = -1; // Subsurface scattering is disabled
@@ -4,9 +4,9 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"enable": true,
"textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
"diffuseTextureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
},
"baseColor": {
"color": [
@@ -4,10 +4,10 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"enable": true,
"factor": 0.30000001192092898,
"textureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png"
"diffuseFactor": 0.30000001192092898,
"diffuseTextureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png"
},
"baseColor": {
"textureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_BaseColor.png"
@@ -4,9 +4,6 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
},
"baseColor": {
"color": [
0.496940553188324,
@@ -4,9 +4,6 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"textureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
},
"baseColor": {
"color": [
0.496940553188324,
@@ -4,9 +4,9 @@
"parentMaterial": "Materials/Presets/PBR/metal_brass.material",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"enable": true,
"textureMap": "Objects/Lucy/Lucy_ao.tif"
"diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif"
},
"baseColor": {
"color": [
@@ -4,9 +4,9 @@
"parentMaterial": "Materials/Presets/PBR/metal_brass.material",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"enable": true,
"textureMap": "Objects/Lucy/Lucy_ao.tif"
"diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif"
},
"baseColor": {
"color": [
@@ -4,10 +4,9 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"factor": 1.0,
"useTexture": true,
"textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
"diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
},
"baseColor": {
"color": [ 1.0, 1.0, 1.0 ],
@@ -4,10 +4,9 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"occlusion": {
"factor": 1.0,
"useTexture": true,
"textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
"diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
},
"baseColor": {
"color": [ 1.0, 1.0, 1.0 ],
@@ -7,10 +7,13 @@
"general": {
"texcoord": 0
},
"ambientOcclusion": {
"factor": 1.0,
"useTexture": false,
"textureMap": ""
"occlusion": {
"diffuseFactor": 1.0,
"diffuseUseTexture": false,
"diffuseTextureMap": "",
"specularFactor": 1.0,
"specularUseTexture": false,
"specularTextureMap": ""
},
"baseColor": {
"color": [
@@ -7,10 +7,13 @@
"general": {
"texcoord": 0
},
"ambientOcclusion": {
"factor": 1.0,
"useTexture": false,
"textureMap": ""
"occlusion": {
"diffuseFactor": 1.0,
"diffuseUseTexture": false,
"diffuseTextureMap": "",
"specularFactor": 1.0,
"specularUseTexture": false,
"specularTextureMap": ""
},
"baseColor": {
"color": [
@@ -4,10 +4,13 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"factor": 1.0,
"useTexture": true,
"textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
"occlusion": {
"diffuseFactor": 1.0,
"diffuseUseTexture": true,
"diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif",
"specularFactor": 1.0,
"specularUseTexture": true,
"specularTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
},
"baseColor": {
"color": [ 1.0, 1.0, 1.0 ],
@@ -4,10 +4,13 @@
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"ambientOcclusion": {
"factor": 1.0,
"useTexture": true,
"textureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
"occlusion": {
"diffuseFactor": 1.0,
"diffuseUseTexture": false,
"diffuseTextureMap": "",
"specularFactor": 1.0,
"specularUseTexture": false,
"specularTextureMap": ""
},
"baseColor": {
"color": [ 1.0, 1.0, 1.0 ],