Replaced StandardPBR_DiffuseOcclusionState and StandardPBR_SpecularOcclusionState functor scripts with just UseTexture functors. The behavior is the basically the same and a lot simpler. All we lose is the occlusion "enable" flag, which is cleaner anyway.

ATOM-14040 Add Support for Cavity Maps
This commit is contained in:
Chris Santora
2021-04-20 16:40:10 -07:00
parent 64e625a79f
commit 94b11e5c8f
18 changed files with 65 additions and 205 deletions
@@ -781,13 +781,6 @@
}
],
"occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
@@ -1690,15 +1683,21 @@
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_DiffuseOcclusionState.lua"
"textureProperty": "occlusion.diffuseTextureMap",
"useTextureProperty": "occlusion.diffuseUseTexture",
"dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"],
"shaderOption": "o_diffuseOcclusion_useTexture"
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua"
"textureProperty": "occlusion.specularTextureMap",
"useTextureProperty": "occlusion.specularUseTexture",
"dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"],
"shaderOption": "o_specularOcclusion_useTexture"
}
},
{
@@ -384,13 +384,6 @@
}
],
"occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
@@ -1069,15 +1062,21 @@
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_DiffuseOcclusionState.lua"
"textureProperty": "occlusion.diffuseTextureMap",
"useTextureProperty": "occlusion.diffuseUseTexture",
"dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"],
"shaderOption": "o_diffuseOcclusion_useTexture"
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua"
"textureProperty": "occlusion.specularTextureMap",
"useTextureProperty": "occlusion.specularUseTexture",
"dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"],
"shaderOption": "o_specularOcclusion_useTexture"
}
},
{
@@ -1170,13 +1170,6 @@
}
],
"layer1_occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
@@ -1870,13 +1863,6 @@
}
],
"layer2_occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
@@ -2570,13 +2556,6 @@
}
],
"layer3_occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
@@ -3041,21 +3020,21 @@
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_DiffuseOcclusionState.lua",
"propertyNamePrefix": "layer1_",
"srgNamePrefix": "m_layer1_",
"optionsNamePrefix": "o_layer1_"
"textureProperty": "layer1_occlusion.diffuseTextureMap",
"useTextureProperty": "layer1_occlusion.diffuseUseTexture",
"dependentProperties": ["layer1_occlusion.diffuseTextureMapUv", "layer1_occlusion.diffuseFactor"],
"shaderOption": "o_layer1_o_diffuseOcclusion_useTexture"
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua",
"propertyNamePrefix": "layer1_",
"srgNamePrefix": "m_layer1_",
"optionsNamePrefix": "o_layer1_"
"textureProperty": "layer1_occlusion.specularTextureMap",
"useTextureProperty": "layer1_occlusion.specularUseTexture",
"dependentProperties": ["layer1_occlusion.specularTextureMapUv", "layer1_occlusion.specularFactor"],
"shaderOption": "o_layer1_o_specularOcclusion_useTexture"
}
},
{
@@ -3178,21 +3157,21 @@
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_DiffuseOcclusionState.lua",
"propertyNamePrefix": "layer2_",
"srgNamePrefix": "m_layer2_",
"optionsNamePrefix": "o_layer2_"
"textureProperty": "layer2_occlusion.diffuseTextureMap",
"useTextureProperty": "layer2_occlusion.diffuseUseTexture",
"dependentProperties": ["layer2_occlusion.diffuseTextureMapUv", "layer2_occlusion.diffuseFactor"],
"shaderOption": "o_layer2_o_diffuseOcclusion_useTexture"
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua",
"propertyNamePrefix": "layer2_",
"srgNamePrefix": "m_layer2_",
"optionsNamePrefix": "o_layer2_"
"textureProperty": "layer2_occlusion.specularTextureMap",
"useTextureProperty": "layer2_occlusion.specularUseTexture",
"dependentProperties": ["layer2_occlusion.specularTextureMapUv", "layer2_occlusion.specularFactor"],
"shaderOption": "o_layer2_o_specularOcclusion_useTexture"
}
},
{
@@ -3315,21 +3294,21 @@
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_DiffuseOcclusionState.lua",
"propertyNamePrefix": "layer3_",
"srgNamePrefix": "m_layer3_",
"optionsNamePrefix": "o_layer3_"
"textureProperty": "layer3_occlusion.diffuseTextureMap",
"useTextureProperty": "layer3_occlusion.diffuseUseTexture",
"dependentProperties": ["layer3_occlusion.diffuseTextureMapUv", "layer3_occlusion.diffuseFactor"],
"shaderOption": "o_layer3_o_diffuseOcclusion_useTexture"
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua",
"propertyNamePrefix": "layer3_",
"srgNamePrefix": "m_layer3_",
"optionsNamePrefix": "o_layer3_"
"textureProperty": "layer3_occlusion.specularTextureMap",
"useTextureProperty": "layer3_occlusion.specularUseTexture",
"dependentProperties": ["layer3_occlusion.specularTextureMapUv", "layer3_occlusion.specularFactor"],
"shaderOption": "o_layer3_o_specularOcclusion_useTexture"
}
},
{
@@ -725,13 +725,6 @@
}
],
"occlusion": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the occlusion features.",
"type": "Bool",
"defaultValue": false
},
{
"id": "diffuseTextureMap",
"displayName": "Diffuse AO",
@@ -1319,15 +1312,21 @@
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_DiffuseOcclusionState.lua"
"textureProperty": "occlusion.diffuseTextureMap",
"useTextureProperty": "occlusion.diffuseUseTexture",
"dependentProperties": ["occlusion.diffuseTextureMapUv", "occlusion.diffuseFactor"],
"shaderOption": "o_diffuseOcclusion_useTexture"
}
},
{
"type": "Lua",
"type": "UseTexture",
"args": {
"file": "StandardPBR_SpecularOcclusionState.lua"
"textureProperty": "occlusion.specularTextureMap",
"useTextureProperty": "occlusion.specularUseTexture",
"dependentProperties": ["occlusion.specularTextureMapUv", "occlusion.specularFactor"],
"shaderOption": "o_specularOcclusion_useTexture"
}
},
{
@@ -1,52 +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 {"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
@@ -1,52 +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 {"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
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseTextureMap": "TestData/Textures/cc0/Rock030_2K_AmbientOcclusion.jpg"
},
"baseColor": {
@@ -29,8 +29,7 @@
},
"layer1_occlusion": {
"diffuseFactor": 1.6399999856948853,
"diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg",
"enable": true
"diffuseTextureMap": "TestData/Textures/cc0/bark1_disp.jpg"
},
"layer1_parallax": {
"enable": true,
@@ -73,7 +72,6 @@
"textureMap": "TestData/Textures/cc0/Lava004_1K_Normal.jpg"
},
"layer2_occlusion": {
"enable": true,
"specularFactor": 2.0,
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
},
@@ -113,8 +111,7 @@
},
"layer3_occlusion": {
"diffuseFactor": 1.0399999618530274,
"diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg",
"enable": true
"diffuseTextureMap": "TestData/Textures/cc0/PaintedMetal003_1K_Displacement.jpg"
},
"layer3_parallax": {
"enable": true,
@@ -6,8 +6,7 @@
"properties": {
"occlusion": {
"diffuseFactor": 2.0,
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg",
"enable": true
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg"
}
}
}
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseFactor": 2.0,
"diffuseTextureMap": "TestData/Textures/cc0/Tiles009_1K_AmbientOcclusion.jpg",
"specularFactor": 2.0,
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"specularFactor": 2.0,
"specularTextureMap": "TestData/Textures/cc0/Tiles009_1K_Displacement.jpg"
}
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseTextureMap": "TestData/Objects/cube/cube_diff.tif"
}
}
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseTextureMap": "Materials/Bricks038_8K/Bricks038_8K_AmbientOcclusion.png"
},
"baseColor": {
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseFactor": 0.30000001192092898,
"diffuseTextureMap": "Materials/PaintedPlaster015_8K/PaintedPlaster015_8K_AmbientOcclusion.png"
},
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif"
},
"baseColor": {
@@ -5,7 +5,6 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"enable": true,
"diffuseTextureMap": "Objects/Lucy/Lucy_ao.tif"
},
"baseColor": {
@@ -5,7 +5,7 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"factor": 1.0,
"diffuseFactor": 1.0,
"diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
},
"baseColor": {
@@ -5,7 +5,7 @@
"propertyLayoutVersion": 3,
"properties": {
"occlusion": {
"factor": 1.0,
"diffuseFactor": 1.0,
"diffuseTextureMap": "EngineAssets/TextureMsg/DefaultNoUVs.tif"
},
"baseColor": {