Merge pull request #979 from aws-lumberyard-dev/Atom/santorac/MaterialTypeCleanup

Various Cleanup of Core Material Types

Did a bunch of general cleanup on Atom's core material types. This gives us much better alignment of configuration between StandardPBR, EnhancedPBR, and Skin material types where they have common functionality. Also made some quality of life improvements for the user like making parallax mapping and UV transforms easier to set up.

ATOM-14838 Make Parallax Look Decent By Default
ATOM-13828 UV Transform Center Default Middle
ATOM-15133 Clean Up EnhancedPBR
ATOM-13216 Delete Deprecated Functors
ATOM-14037 StandardPBR TintedTransparent Opacity
ATOM-15295 Remove Unnecessary Enable Material Properties
This commit is contained in:
Chris Santora
2021-05-27 17:01:35 -07:00
committed by GitHub
62 changed files with 493 additions and 1363 deletions
File diff suppressed because it is too large Load Diff
@@ -267,16 +267,16 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
// Directional light shadow coordinates
lightingData.shadowCoords = IN.m_shadowCoords;
// ------- Occlusion -------
lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
// ------- Emissive -------
float2 emissiveUv = IN.m_uv[MaterialSrg::m_emissiveMapUvIndex];
lightingData.emissiveLighting = GetEmissiveInput(MaterialSrg::m_emissiveMap, MaterialSrg::m_sampler, emissiveUv, MaterialSrg::m_emissiveIntensity, MaterialSrg::m_emissiveColor.rgb, o_emissiveEnabled, o_emissive_useTexture);
// ------- Occlusion -------
lightingData.diffuseAmbientOcclusion = GetOcclusionInput(MaterialSrg::m_diffuseOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_diffuseOcclusionMapUvIndex], MaterialSrg::m_diffuseOcclusionFactor, o_diffuseOcclusion_useTexture);
lightingData.specularOcclusion = GetOcclusionInput(MaterialSrg::m_specularOcclusionMap, MaterialSrg::m_sampler, IN.m_uv[MaterialSrg::m_specularOcclusionMapUvIndex], MaterialSrg::m_specularOcclusionFactor, o_specularOcclusion_useTexture);
// ------- Clearcoat -------
// [GFX TODO][ATOM-14603]: Clean up the double uses of these clear coat flags
@@ -287,6 +287,13 @@
"id": "m_specularF0Map"
}
},
{
"id": "useTexture",
"displayName": "Use Texture",
"description": "Whether to use the texture map, or just default to the Factor value.",
"type": "Bool",
"defaultValue": true
},
{
"id": "textureMapUv",
"displayName": "UV",
@@ -299,13 +306,7 @@
"id": "m_specularF0MapUvIndex"
}
},
{
"id": "useTexture",
"displayName": "Use Texture",
"description": "Whether to use the texture map, or just default to the Factor value.",
"type": "Bool",
"defaultValue": true
},
// Consider moving this to the "general" group to be consistent with StandardMultilayerPBR
{
"id": "enableMultiScatterCompensation",
"displayName": "Multiscattering Compensation",
@@ -616,7 +617,7 @@
"type": "float",
"defaultValue": 6.0,
"min": 0.0,
"softMax": 20.0
"softMax": 20.0
},
{
"id": "transmissionDistortion",
@@ -909,7 +910,7 @@
"description": "Center point for scaling and rotation transformations.",
"type": "vector2",
"vectorLabels": [ "U", "V" ],
"defaultValue": [ 0.0, 0.0 ]
"defaultValue": [ 0.5, 0.5 ]
},
{
"id": "tileU",
@@ -1011,18 +1012,18 @@
"type": "HandleSubsurfaceScatteringParameters",
"args": {
"mode": "subsurfaceScattering.transmissionMode",
"scale" : "subsurfaceScattering.transmissionScale",
"power" : "subsurfaceScattering.transmissionPower",
"distortion" : "subsurfaceScattering.transmissionDistortion",
"attenuation" : "subsurfaceScattering.transmissionAttenuation",
"tintColor" : "subsurfaceScattering.transmissionTint",
"thickness" : "subsurfaceScattering.thickness",
"scale": "subsurfaceScattering.transmissionScale",
"power": "subsurfaceScattering.transmissionPower",
"distortion": "subsurfaceScattering.transmissionDistortion",
"attenuation": "subsurfaceScattering.transmissionAttenuation",
"tintColor": "subsurfaceScattering.transmissionTint",
"thickness": "subsurfaceScattering.thickness",
"enabled": "subsurfaceScattering.enableSubsurfaceScattering",
"scatterDistanceColor" : "subsurfaceScattering.scatterColor",
"scatterDistanceIntensity" : "subsurfaceScattering.scatterDistance",
"scatterDistanceShaderInput" : "m_scatterDistance",
"parametersShaderInput" : "m_transmissionParams",
"tintThickenssShaderInput" : "m_transmissionTintThickness"
"scatterDistanceColor": "subsurfaceScattering.scatterColor",
"scatterDistanceIntensity": "subsurfaceScattering.scatterDistance",
"scatterDistanceShaderInput": "m_scatterDistance",
"parametersShaderInput": "m_transmissionParams",
"tintThickenssShaderInput": "m_transmissionTintThickness"
}
},
{
@@ -1038,8 +1039,8 @@
"type": "UseTexture",
"args": {
"textureProperty": "specularF0.textureMap",
"dependentProperties": ["specularF0.textureMapUv"],
"useTextureProperty": "specularF0.useTexture",
"dependentProperties": ["specularF0.textureMapUv"],
"shaderOption": "o_specularF0_useTexture"
}
},
@@ -369,15 +369,14 @@
],
"parallax": [
{
// Note parallax is enabled by default so that as soon as a user hooks up displacement settings they will see some parallax applied.
// The functor that controls parallax will set o_parallax_feature_enabled=false when all the individual layers have no displacement, so
// a default value of true here will not have any initial impact on performance.
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the parallax feature for this material.",
"type": "Bool",
"defaultValue": false,
"connection": {
"type": "ShaderOption",
"id": "o_parallax_feature_enabled"
}
"defaultValue": true
},
{
"id": "parallaxUv",
@@ -409,7 +408,7 @@
"description": "Quality of parallax mapping.",
"type": "Enum",
"enumValues": [ "Low", "Medium", "High", "Ultra" ],
"defaultValue": "Medium",
"defaultValue": "Low",
"connection": {
"type": "ShaderOption",
"id": "o_parallax_quality"
@@ -445,7 +444,7 @@
"description": "Center point for scaling and rotation transformations.",
"type": "vector2",
"vectorLabels": [ "U", "V" ],
"defaultValue": [ 0.0, 0.0 ]
"defaultValue": [ 0.5, 0.5 ]
},
{
"id": "tileU",
@@ -1141,7 +1140,7 @@
"displayName": "Scale",
"description": "The total height of the displacement texture map in local model units.",
"type": "Float",
"defaultValue": 0.0,
"defaultValue": 0.05,
"min": 0.0,
"softMax": 0.1,
"connection": {
@@ -1170,7 +1169,7 @@
"description": "Center point for scaling and rotation transformations.",
"type": "vector2",
"vectorLabels": [ "U", "V" ],
"defaultValue": [ 0.0, 0.0 ]
"defaultValue": [ 0.5, 0.5 ]
},
{
"id": "tileU",
@@ -1847,7 +1846,7 @@
"displayName": "Scale",
"description": "The total height of the displacement texture map in local model units.",
"type": "Float",
"defaultValue": 0.0,
"defaultValue": 0.05,
"min": 0.0,
"softMax": 0.1,
"connection": {
@@ -1876,7 +1875,7 @@
"description": "Center point for scaling and rotation transformations.",
"type": "vector2",
"vectorLabels": [ "U", "V" ],
"defaultValue": [ 0.0, 0.0 ]
"defaultValue": [ 0.5, 0.5 ]
},
{
"id": "tileU",
@@ -2553,7 +2552,7 @@
"displayName": "Scale",
"description": "The total height of the displacement texture map in local model units.",
"type": "Float",
"defaultValue": 0.0,
"defaultValue": 0.05,
"min": 0.0,
"softMax": 0.1,
"connection": {
@@ -2582,7 +2581,7 @@
"description": "Center point for scaling and rotation transformations.",
"type": "vector2",
"vectorLabels": [ "U", "V" ],
"defaultValue": [ 0.0, 0.0 ]
"defaultValue": [ 0.5, 0.5 ]
},
{
"id": "tileU",
@@ -35,6 +35,10 @@ function GetMaterialPropertyDependencies()
}
end
function GetShaderOptionDependencies()
return {"o_parallax_feature_enabled"}
end
-- These values must align with LayerBlendSource in StandardMultilayerPBR_Common.azsli.
LayerBlendSource_BlendMaskTexture = 0
LayerBlendSource_BlendMaskVertexColors = 1
@@ -50,6 +54,39 @@ function BlendSourceUsesDisplacement(context)
return blendSourceIncludesDisplacement
end
function IsParallaxNeededForLayer(context, layerNumber)
local enableLayer = true
if(layerNumber > 1) then -- layer 1 is always enabled, it is the implicit base layer
enableLayer = context:GetMaterialPropertyValue_bool("blend.enableLayer" .. layerNumber)
end
if not enableLayer then
return false
end
local parallaxGroupName = "layer" .. layerNumber .. "_parallax."
local factor = context:GetMaterialPropertyValue_float(parallaxGroupName .. "factor")
local offset = context:GetMaterialPropertyValue_float(parallaxGroupName .. "offset")
if factor == 0.0 and offset == 0.0 then
return false
end
local hasTexture = nil ~= context:GetMaterialPropertyValue_Image(parallaxGroupName .. "textureMap")
local useTexture = context:GetMaterialPropertyValue_bool(parallaxGroupName .. "useTexture")
if not hasTexture or not useTexture then
factorLayer = 0.0
end
if factor == 0.0 and offset == 0.0 then
return false
end
return true
end
-- Calculates the min and max displacement height values encompassing all enabled layers.
-- @return a table with two values {min,max}. Negative values are below the surface and positive values are above the surface.
function CalcOverallHeightRange(context)
@@ -114,21 +151,32 @@ function Process(context)
local heightMinMax = CalcOverallHeightRange(context)
context:SetShaderConstant_float("m_displacementMin", heightMinMax[0])
context:SetShaderConstant_float("m_displacementMax", heightMinMax[1])
local parallaxFeatureEnabled = context:GetMaterialPropertyValue_bool("parallax.enable")
if parallaxFeatureEnabled then
if not IsParallaxNeededForLayer(context, 1) and
not IsParallaxNeededForLayer(context, 2) and
not IsParallaxNeededForLayer(context, 3) then
parallaxFeatureEnabled = false
end
end
context:SetShaderOptionValue_bool("o_parallax_feature_enabled", parallaxFeatureEnabled)
end
function ProcessEditor(context)
local enable = context:GetMaterialPropertyValue_bool("parallax.enable")
local enableParallaxSettings = context:GetMaterialPropertyValue_bool("parallax.enable")
local visibility = MaterialPropertyVisibility_Enabled
if(not enable) then
visibility = MaterialPropertyVisibility_Hidden
local parallaxSettingVisibility = MaterialPropertyVisibility_Enabled
if(not enableParallaxSettings) then
parallaxSettingVisibility = MaterialPropertyVisibility_Hidden
end
context:SetMaterialPropertyVisibility("parallax.parallaxUv", visibility)
context:SetMaterialPropertyVisibility("parallax.algorithm", visibility)
context:SetMaterialPropertyVisibility("parallax.quality", visibility)
context:SetMaterialPropertyVisibility("parallax.pdo", visibility)
context:SetMaterialPropertyVisibility("parallax.showClipping", visibility)
context:SetMaterialPropertyVisibility("parallax.parallaxUv", parallaxSettingVisibility)
context:SetMaterialPropertyVisibility("parallax.algorithm", parallaxSettingVisibility)
context:SetMaterialPropertyVisibility("parallax.quality", parallaxSettingVisibility)
context:SetMaterialPropertyVisibility("parallax.pdo", parallaxSettingVisibility)
context:SetMaterialPropertyVisibility("parallax.showClipping", parallaxSettingVisibility)
if BlendSourceUsesDisplacement(context) then
context:SetMaterialPropertyVisibility("blend.displacementBlendDistance", MaterialPropertyVisibility_Enabled)
@@ -601,7 +601,7 @@
"displayName": "Opacity Mode",
"description": "Opacity mode for this texture.",
"type": "Enum",
"enumValues": [ "Opaque", "Cutout", "Blended" ],
"enumValues": [ "Opaque", "Cutout", "Blended", "TintedTransparent" ],
"defaultValue": "Opaque",
"connection": {
"type": "ShaderOption",
@@ -669,12 +669,12 @@
"description": "Center point for scaling and rotation transformations.",
"type": "vector2",
"vectorLabels": [ "U", "V" ],
"defaultValue": [ 0.0, 0.0 ]
"defaultValue": [ 0.5, 0.5 ]
},
{
"id": "tileU",
"displayName": "Tile U",
"description": "Scales texture coordinates in V.",
"description": "Scales texture coordinates in U.",
"type": "float",
"defaultValue": 1.0,
"step": 0.1
@@ -879,13 +879,6 @@
}
],
"parallax": [
{
"id": "enable",
"displayName": "Enable",
"description": "Whether to enable the parallax feature.",
"type": "Bool",
"defaultValue": false
},
{
"id": "textureMap",
"displayName": "Texture Map",
@@ -896,6 +889,13 @@
"id": "m_depthMap"
}
},
{
"id": "useTexture",
"displayName": "Use Texture",
"description": "Whether to use the texture map.",
"type": "Bool",
"defaultValue": true
},
{
"id": "textureMapUv",
"displayName": "UV",
@@ -913,7 +913,7 @@
"displayName": "Heightmap Scale",
"description": "The total height of the heightmap in local model units.",
"type": "Float",
"defaultValue": 0.0,
"defaultValue": 0.05,
"min": 0.0,
"softMax": 0.1,
"connection": {
@@ -951,7 +951,7 @@
"description": "Select the algorithm to use for parallax mapping.",
"type": "Enum",
"enumValues": [ "Basic", "Steep", "POM", "Relief", "ContactRefinement" ],
"defaultValue": "Basic",
"defaultValue": "POM",
"connection": {
"type": "ShaderOption",
"id": "o_parallax_algorithm"
@@ -1139,7 +1139,7 @@
"type": "float",
"defaultValue": 6.0,
"min": 0.0,
"softMax": 20.0
"softMax": 20.0
},
{
"id": "transmissionDistortion",
@@ -1170,7 +1170,7 @@
}
],
"irradiance": [
// Note: this property group is used in the DiffuseGlobalIllumination pass, it is not read by the StandardPBR shader
// Note: this property group is used in the DiffuseGlobalIllumination pass and not by the main forward shader
{
"id": "color",
"displayName": "Color",
@@ -1277,18 +1277,18 @@
"type": "HandleSubsurfaceScatteringParameters",
"args": {
"mode": "subsurfaceScattering.transmissionMode",
"scale" : "subsurfaceScattering.transmissionScale",
"power" : "subsurfaceScattering.transmissionPower",
"distortion" : "subsurfaceScattering.transmissionDistortion",
"attenuation" : "subsurfaceScattering.transmissionAttenuation",
"tintColor" : "subsurfaceScattering.transmissionTint",
"thickness" : "subsurfaceScattering.thickness",
"scale": "subsurfaceScattering.transmissionScale",
"power": "subsurfaceScattering.transmissionPower",
"distortion": "subsurfaceScattering.transmissionDistortion",
"attenuation": "subsurfaceScattering.transmissionAttenuation",
"tintColor": "subsurfaceScattering.transmissionTint",
"thickness": "subsurfaceScattering.thickness",
"enabled": "subsurfaceScattering.enableSubsurfaceScattering",
"scatterDistanceColor" : "subsurfaceScattering.scatterColor",
"scatterDistanceIntensity" : "subsurfaceScattering.scatterDistance",
"scatterDistanceShaderInput" : "m_scatterDistance",
"parametersShaderInput" : "m_transmissionParams",
"tintThickenssShaderInput" : "m_transmissionTintThickness"
"scatterDistanceColor": "subsurfaceScattering.scatterColor",
"scatterDistanceIntensity": "subsurfaceScattering.scatterDistance",
"scatterDistanceShaderInput": "m_scatterDistance",
"parametersShaderInput": "m_transmissionParams",
"tintThickenssShaderInput": "m_transmissionTintThickness"
}
},
{
@@ -1387,15 +1387,6 @@
"file": "StandardPBR_HandleOpacityDoubleSided.lua"
}
},
{
"type": "OverrideDrawList",
"args": {
"triggerProperty": "opacity.mode",
"triggerValue": "Blended",
"shaderIndex": 1,
"drawList": "transparent"
}
},
{
"type": "Lua",
"args": {
@@ -294,6 +294,24 @@ PbrLightingOutput ForwardPassPS_Common(VSOutput IN, bool isFrontFace, out float
lightingOutput.m_diffuseColor.rgb *= lightingOutput.m_diffuseColor.w; // pre-multiply diffuse
lightingOutput.m_diffuseColor.rgb += lightingOutput.m_specularColor.rgb; // add specular
}
else if (o_opacity_mode == OpacityMode::TintedTransparent)
{
// See OpacityMode::Blended above for the basic method. TintedTransparent adds onto the above concept by supporting
// colored alpha. This is currently a very basic calculation that uses the baseColor as a multiplier with strength
// determined by the alpha. We'll modify this later to be more physically accurate and allow surface depth,
// absorption, and interior color to be specified.
//
// The technique uses dual source blending to allow two separate sources to be part of the blending equation
// even though ultimately only a single render target is being written to. m_diffuseColor is render target 0 and
// m_specularColor render target 1, and the blend mode is (dest * source1color) + (source * 1.0).
//
// This means that m_specularColor.rgb (source 1) is multiplied against the destination, then
// m_diffuseColor.rgb (source) is added to that, and the final result is stored in render target 0.
lightingOutput.m_diffuseColor.rgb *= lightingOutput.m_diffuseColor.w; // pre-multiply diffuse
lightingOutput.m_diffuseColor.rgb += lightingOutput.m_specularColor.rgb; // add specular
lightingOutput.m_specularColor.rgb = baseColor * (1.0 - lightingOutput.m_diffuseColor.w);
}
else
{
// Pack factor and quality, drawback: because of precision limit of float16 cannot represent exact 1, maximum representable value is 0.9961
@@ -60,10 +60,13 @@ function Process(context)
if(opacityMode == OpacityMode_Blended) then
ConfigureAlphaBlending(context:GetShader(ForwardPassIndex))
context:GetShader(ForwardPassIndex):SetDrawListTagOverride("transparent")
elseif(opacityMode == OpacityMode_TintedTransparent) then
ConfigureDualSourceBlending(context:GetShader(ForwardPassIndex))
context:GetShader(ForwardPassIndex):SetDrawListTagOverride("transparent")
else
ResetAlphaBlending(context:GetShader(ForwardPassIndex))
context:GetShader(ForwardPassIndex):SetDrawListTagOverride("") -- reset to default draw list
end
end
@@ -13,7 +13,7 @@
----------------------------------------------------------------------------------------------------
function GetMaterialPropertyDependencies()
return {"parallax.enable", "parallax.textureMap"}
return {"parallax.textureMap", "parallax.useTexture"}
end
function GetShaderOptionDependencies()
@@ -21,27 +21,31 @@ function GetShaderOptionDependencies()
end
function Process(context)
local enable = context:GetMaterialPropertyValue_bool("parallax.enable")
local textureMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
local useTexture = context:GetMaterialPropertyValue_bool("parallax.useTexture")
local enable = textureMap ~= nil and useTexture
context:SetShaderOptionValue_bool("o_parallax_feature_enabled", enable)
context:SetShaderOptionValue_bool("o_useDepthMap", enable and textureMap ~= nil)
context:SetShaderOptionValue_bool("o_useDepthMap", enable)
end
function ProcessEditor(context)
local enable = context:GetMaterialPropertyValue_bool("parallax.enable")
if enable then
context:SetMaterialPropertyVisibility("parallax.textureMap", MaterialPropertyVisibility_Enabled)
else
context:SetMaterialPropertyVisibility("parallax.textureMap", MaterialPropertyVisibility_Hidden)
end
local textureMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
local visibility = MaterialPropertyVisibility_Enabled
if(not enable or textureMap == nil) then
visibility = MaterialPropertyVisibility_Hidden
if textureMap ~= nil then
context:SetMaterialPropertyVisibility("parallax.useTexture", MaterialPropertyVisibility_Enabled)
else
context:SetMaterialPropertyVisibility("parallax.useTexture", MaterialPropertyVisibility_Hidden)
end
local useTexture = context:GetMaterialPropertyValue_bool("parallax.useTexture")
local visibility = MaterialPropertyVisibility_Enabled
if(textureMap == nil) then
visibility = MaterialPropertyVisibility_Hidden
elseif not useTexture then
visibility = MaterialPropertyVisibility_Disabled
end
context:SetMaterialPropertyVisibility("parallax.factor", visibility)
context:SetMaterialPropertyVisibility("parallax.offset", visibility)
context:SetMaterialPropertyVisibility("parallax.showClipping", visibility)
@@ -13,7 +13,7 @@
----------------------------------------------------------------------------------------------------
function GetMaterialPropertyDependencies()
return {"opacity.mode", "parallax.enable", "parallax.pdo"}
return {"opacity.mode", "parallax.textureMap", "parallax.useTexture", "parallax.pdo"}
end
OpacityMode_Opaque = 0
@@ -21,41 +21,61 @@ OpacityMode_Cutout = 1
OpacityMode_Blended = 2
OpacityMode_TintedTransparent = 3
function TryGetShaderByTag(context, shaderTag)
if context:HasShaderWithTag(shaderTag) then
return context:GetShaderByTag(shaderTag)
else
return nil
end
end
function TrySetShaderEnabled(shader, enabled)
if shader then
shader:SetEnabled(enabled)
end
end
function Process(context)
local opacityMode = context:GetMaterialPropertyValue_enum("opacity.mode")
local parallaxEnabled = context:GetMaterialPropertyValue_bool("parallax.enable")
local displacementMap = context:GetMaterialPropertyValue_Image("parallax.textureMap")
local useDisplacementMap = context:GetMaterialPropertyValue_bool("parallax.useTexture")
local parallaxEnabled = displacementMap ~= nil and useDisplacementMap
local parallaxPdoEnabled = context:GetMaterialPropertyValue_bool("parallax.pdo")
local depthPass = context:GetShaderByTag("DepthPass")
local shadowMap = context:GetShaderByTag("Shadowmap")
local forwardPassEDS = context:GetShaderByTag("ForwardPass_EDS")
local lowEndForwardEDS = context:GetShaderByTag("LowEndForward_EDS")
local depthPassWithPS = context:GetShaderByTag("DepthPass_WithPS")
local shadowMapWithPS = context:GetShaderByTag("Shadowmap_WithPS")
local forwardPass = context:GetShaderByTag("ForwardPass")
local lowEndForward = context:GetShaderByTag("LowEndForward")
-- Use TryGetShaderByTag because these shaders only exist in StandardPBR but this script is also used for EnhancedPBR
local lowEndForwardEDS = TryGetShaderByTag(context, "LowEndForward_EDS")
local lowEndForward = TryGetShaderByTag(context, "LowEndForward")
if parallaxEnabled and parallaxPdoEnabled then
depthPass:SetEnabled(false)
shadowMap:SetEnabled(false)
forwardPassEDS:SetEnabled(false)
lowEndForwardEDS:SetEnabled(false)
depthPassWithPS:SetEnabled(true)
shadowMapWithPS:SetEnabled(true)
forwardPass:SetEnabled(true)
lowEndForward:SetEnabled(true)
TrySetShaderEnabled(lowEndForwardEDS, false)
TrySetShaderEnabled(lowEndForward, true)
else
depthPass:SetEnabled(opacityMode == OpacityMode_Opaque)
shadowMap:SetEnabled(opacityMode == OpacityMode_Opaque)
forwardPassEDS:SetEnabled((opacityMode == OpacityMode_Opaque) or (opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
lowEndForwardEDS:SetEnabled((opacityMode == OpacityMode_Opaque) or (opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
depthPassWithPS:SetEnabled(opacityMode == OpacityMode_Cutout)
shadowMapWithPS:SetEnabled(opacityMode == OpacityMode_Cutout)
forwardPass:SetEnabled(opacityMode == OpacityMode_Cutout)
lowEndForward:SetEnabled(opacityMode == OpacityMode_Cutout)
TrySetShaderEnabled(lowEndForwardEDS, (opacityMode == OpacityMode_Opaque) or (opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
TrySetShaderEnabled(lowEndForward, opacityMode == OpacityMode_Cutout)
end
context:GetShaderByTag("DepthPassTransparentMin"):SetEnabled((opacityMode == OpacityMode_Blended) or (opacityMode == OpacityMode_TintedTransparent))
@@ -14,8 +14,6 @@
#include <Source/Material/UseTextureFunctor.h>
#include <Source/Material/SubsurfaceTransmissionParameterFunctor.h>
#include <Source/Material/Transform2DFunctor.h>
#include <Source/Material/ShaderEnableFunctor.h>
#include <Source/Material/PropertyVisibilityFunctor.h>
#include <Source/Material/DrawListFunctor.h>
#include <Source/Material/ConvertEmissiveUnitFunctor.h>
@@ -114,7 +112,6 @@ namespace AZ
ProjectedShadowFeatureProcessor::Reflect(context);
SkyBoxFeatureProcessor::Reflect(context);
UseTextureFunctor::Reflect(context);
PropertyVisibilityFunctor::Reflect(context);
DrawListFunctor::Reflect(context);
SubsurfaceTransmissionParameterFunctor::Reflect(context);
Transform2DFunctor::Reflect(context);
@@ -126,7 +123,6 @@ namespace AZ
DisplayMapperPassData::Reflect(context);
ConvertEmissiveUnitFunctor::Reflect(context);
LookupTableAsset::Reflect(context);
ShaderEnableFunctor::Reflect(context);
ReflectionProbeFeatureProcessor::Reflect(context);
DecalTextureArrayFeatureProcessor::Reflect(context);
SMAAFeatureProcessor::Reflect(context);
@@ -12,11 +12,9 @@
#include <EditorCommonSystemComponent.h>
#include <Source/Material/UseTextureFunctorSourceData.h>
#include <Source/Material/PropertyVisibilityFunctorSourceData.h>
#include <Source/Material/DrawListFunctorSourceData.h>
#include <Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.h>
#include <Source/Material/Transform2DFunctorSourceData.h>
#include <Source/Material/ShaderEnableFunctorSourceData.h>
#include <Source/Material/ConvertEmissiveUnitFunctorSourceData.h>
#include <Atom/Feature/Utils/EditorLightingPreset.h>
@@ -58,11 +56,9 @@ namespace AZ
}
AZ::Render::UseTextureFunctorSourceData::Reflect(context);
AZ::Render::PropertyVisibilityFunctorSourceData::Reflect(context);
AZ::Render::DrawListFunctorSourceData::Reflect(context);
AZ::Render::Transform2DFunctorSourceData::Reflect(context);
AZ::Render::ConvertEmissiveUnitFunctorSourceData::Reflect(context);
AZ::Render::ShaderEnableFunctorSourceData::Reflect(context);
AZ::Render::SubsurfaceTransmissionParameterFunctorSourceData::Reflect(context);
AZ::Render::EditorLightingPreset::Reflect(context);
@@ -104,11 +100,9 @@ namespace AZ
}
materialFunctorRegistration->RegisterMaterialFunctor("UseTexture", azrtti_typeid<UseTextureFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("UpdatePropertyVisibility", azrtti_typeid<PropertyVisibilityFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("OverrideDrawList", azrtti_typeid<DrawListFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("Transform2D", azrtti_typeid<Transform2DFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("ConvertEmissiveUnit", azrtti_typeid<ConvertEmissiveUnitFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("ShaderEnable", azrtti_typeid<ShaderEnableFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("HandleSubsurfaceScatteringParameters", azrtti_typeid<SubsurfaceTransmissionParameterFunctorSourceData>());
materialFunctorRegistration->RegisterMaterialFunctor("Lua", azrtti_typeid<RPI::LuaMaterialFunctorSourceData>());
@@ -1,77 +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.
*
*/
#include "PropertyVisibilityFunctor.h"
namespace AZ
{
namespace Render
{
void PropertyVisibilityFunctor::Reflect(ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<Action>()
->Version(1)
->Field("triggerProperty", &Action::m_triggerPropertyIndex)
->Field("triggerValue", &Action::m_triggerValue)
->Field("visibility", &Action::m_visibility)
;
serializeContext->Class<PropertyVisibilityFunctor, RPI::MaterialFunctor>()
->Version(1)
->Field("actions", &PropertyVisibilityFunctor::m_actions)
->Field("affectedProperties", &PropertyVisibilityFunctor::m_affectedProperties)
;
}
}
void PropertyVisibilityFunctor::Process(EditorContext& context)
{
bool visibilityApplied = false;
RPI::MaterialPropertyVisibility lastAppliedVisibility;
for (const auto& action : m_actions)
{
bool willSetVisibility = false;
if (action.m_triggerValue.Is<bool>() || action.m_triggerValue.Is<int32_t>() || action.m_triggerValue.Is<uint32_t>())
{
willSetVisibility = action.m_triggerValue == context.GetMaterialPropertyValue(action.m_triggerPropertyIndex);
}
else if (action.m_triggerValue.Is<float>())
{
willSetVisibility = AZ::IsClose(action.m_triggerValue.GetValue<float>(),
context.GetMaterialPropertyValue<float>(action.m_triggerPropertyIndex),
std::numeric_limits<float>::epsilon());
}
else // for types Vector2, Vector3, Vector4, Color, Image
{
AZ_Error("PropertyVisibilityFunctor", false, "Unsupported property data type as an enable property.");
}
if (willSetVisibility)
{
visibilityApplied = true;
lastAppliedVisibility = action.m_visibility;
}
}
if (visibilityApplied)
{
for (const auto& propertyIndex : m_affectedProperties)
{
context.SetMaterialPropertyVisibility(propertyIndex, lastAppliedVisibility);
}
}
}
} // namespace Render
} // namespace AZ
@@ -1,49 +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.
*
*/
#pragma once
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
#include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
namespace AZ
{
namespace Render
{
//! Materials can use this functor to control when and how to set the visibility of a group of properties.
class PropertyVisibilityFunctor final
: public RPI::MaterialFunctor
{
friend class PropertyVisibilityFunctorSourceData;
public:
AZ_RTTI(AZ::Render::PropertyVisibilityFunctor, "{2582B36F-FA7C-450F-B46A-39AAE18356A0}", RPI::MaterialFunctor);
static void Reflect(ReflectContext* context);
void Process(EditorContext& context) override;
private:
struct Action
{
AZ_TYPE_INFO(AZ::Render::PropertyVisibilityFunctor::Action, "{5DF4D981-9D0C-4040-A6C5-52E1D0BD876B}");
RPI::MaterialPropertyIndex m_triggerPropertyIndex; //! The control property for affected properties.
RPI::MaterialPropertyValue m_triggerValue; //! The trigger value of the control property.
RPI::MaterialPropertyVisibility m_visibility; //! The visibility of affected properties when the trigger value is hit.
};
// Material property inputs...
AZStd::vector<Action> m_actions; //! The actions that describes when and what to do with visibilities.
AZStd::vector<RPI::MaterialPropertyIndex> m_affectedProperties; //! The properties that are affected by actions.
};
} // namespace Render
} // namespace AZ
@@ -1,100 +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.
*
*/
#include "PropertyVisibilityFunctorSourceData.h"
#include <Atom/RPI.Reflect/Shader/ShaderOptionGroupLayout.h>
#include <AzCore/Serialization/SerializeContext.h>
#include <Atom/RPI.Edit/Material/MaterialUtils.h>
namespace AZ
{
namespace Render
{
void PropertyVisibilityFunctorSourceData::Reflect(ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<ActionSourceData>()
->Version(1)
->Field("triggerProperty", &ActionSourceData::m_triggerPropertyName)
->Field("triggerValue", &ActionSourceData::m_triggerValue)
->Field("visibility", &ActionSourceData::m_visibility)
;
serializeContext->Class<PropertyVisibilityFunctorSourceData>()
->Version(2)
->Field("actions", &PropertyVisibilityFunctorSourceData::m_actions)
->Field("affectedProperties", &PropertyVisibilityFunctorSourceData::m_affectedPropertyNames)
;
}
}
RPI::MaterialFunctorSourceData::FunctorResult PropertyVisibilityFunctorSourceData::CreateFunctor(const EditorContext& context) const
{
using namespace RPI;
RPI::Ptr<PropertyVisibilityFunctor> functor = aznew PropertyVisibilityFunctor;
functor->m_actions.reserve(m_actions.size());
for (const auto& actionSource : m_actions)
{
functor->m_actions.emplace_back();
PropertyVisibilityFunctor::Action& action = functor->m_actions.back();
action.m_triggerPropertyIndex = context.FindMaterialPropertyIndex(AZ::Name{ actionSource.m_triggerPropertyName });
if (action.m_triggerPropertyIndex.IsNull())
{
return Failure();
}
AddMaterialPropertyDependency(functor, action.m_triggerPropertyIndex);
if (!actionSource.m_triggerValue.Resolve(*context.GetMaterialPropertiesLayout(), Name{ actionSource.m_triggerPropertyName }))
{
// Error is reported in Resolve().
return Failure();
}
const MaterialPropertyDescriptor* propertyDescriptor = context.GetMaterialPropertiesLayout()->GetPropertyDescriptor(action.m_triggerPropertyIndex);
// Enum type should resolve further to a unit32_t from the string source.
if (propertyDescriptor->GetDataType() == RPI::MaterialPropertyDataType::Enum)
{
if (!RPI::MaterialUtils::ResolveMaterialPropertyEnumValue(
propertyDescriptor,
Name(actionSource.m_triggerValue.GetValue().GetValue<AZStd::string>()),
action.m_triggerValue))
{
return Failure();
}
}
else
{
action.m_triggerValue = actionSource.m_triggerValue.GetValue();
}
action.m_visibility = actionSource.m_visibility;
}
functor->m_affectedProperties.reserve(m_affectedPropertyNames.size());
for (const AZStd::string& name : m_affectedPropertyNames)
{
RPI::MaterialPropertyIndex index = context.FindMaterialPropertyIndex(AZ::Name{ name });
if (index.IsNull())
{
return Failure();
}
functor->m_affectedProperties.push_back(index);
}
return Success(RPI::Ptr<MaterialFunctor>(functor));
}
} // namespace Render
} // namespace AZ
@@ -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.
*
*/
#pragma once
#include "PropertyVisibilityFunctor.h"
#include <Atom/RPI.Edit/Material/MaterialFunctorSourceData.h>
#include <Atom/RPI.Edit/Material/MaterialPropertyValueSourceData.h>
namespace AZ
{
namespace Render
{
//! Builds a PropertyVisibilityFunctor.
//! Materials can use this functor to control whether a specific property group will be enabled.
class PropertyVisibilityFunctorSourceData final
: public RPI::MaterialFunctorSourceData
{
public:
AZ_RTTI(AZ::Render::PropertyVisibilityFunctorSourceData, "{B44E6929-8FFF-405F-9056-B9B811F97676}", RPI::MaterialFunctorSourceData);
static void Reflect(ReflectContext* context);
FunctorResult CreateFunctor(const EditorContext& context) const override;
private:
struct ActionSourceData
{
AZ_TYPE_INFO(AZ::Render::PropertyVisibilityFunctorSourceData::ActionSourceData, "{70E01DA6-0B42-4CCB-AAD0-51980DB43F62}");
AZStd::string m_triggerPropertyName; //! The control property for affected properties.
RPI::MaterialPropertyValueSourceData m_triggerValue; //! The trigger value of the control property.
RPI::MaterialPropertyVisibility m_visibility; //! The visibility of affected properties when the trigger value is hit.
};
// Material property inputs...
AZStd::vector<ActionSourceData> m_actions; //! The actions that describes when and what to do with visibilities.
AZStd::vector<AZStd::string> m_affectedPropertyNames; //! The properties that are affected by actions.
};
} // namespace Render
} // namespace AZ
@@ -1,74 +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.
*
*/
#include "./ShaderEnableFunctor.h"
#include <Atom/RPI.Public/Material/Material.h>
#include <Atom/RPI.Reflect/Image/Image.h>
#include <Atom/RPI.Reflect/Shader/ShaderOptionGroup.h>
namespace AZ
{
namespace Render
{
void ShaderEnableFunctor::Reflect(ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<ShaderEnableFunctor, RPI::MaterialFunctor>()
->Version(4)
->Field("opacityModeIndex", &ShaderEnableFunctor::m_opacityModeIndex)
->Field("parallaxEnableIndex", &ShaderEnableFunctor::m_parallaxEnableIndex)
->Field("parallaxPdoEnableIndex", &ShaderEnableFunctor::m_parallaxPdoEnableIndex)
->Field("shadowShaderNoPSIndex", &ShaderEnableFunctor::m_shadowShaderNoPSIndex)
->Field("shadowShaderWithPSIndex", &ShaderEnableFunctor::m_shadowShaderWithPSIndex)
->Field("depthShaderNoPSIndex", &ShaderEnableFunctor::m_depthShaderNoPSIndex)
->Field("depthShaderWithPSIndex", &ShaderEnableFunctor::m_depthShaderWithPSIndex)
->Field("pbrShaderNoEdsIndex", &ShaderEnableFunctor::m_pbrShaderNoEdsIndex)
->Field("pbrShaderWithEdsIndex", &ShaderEnableFunctor::m_pbrShaderWithEdsIndex)
->Field("depthShaderTransparentMin", &ShaderEnableFunctor::m_depthShaderTransparentMin)
->Field("depthShaderTransparentMax", &ShaderEnableFunctor::m_depthShaderTransparentMax)
;
}
}
void ShaderEnableFunctor::Process(RuntimeContext& context)
{
unsigned int opacityMode = context.GetMaterialPropertyValue<uint32_t>(m_opacityModeIndex);
bool parallaxEnabled = context.GetMaterialPropertyValue<bool>(m_parallaxEnableIndex);
bool parallaxPdoEnabled = context.GetMaterialPropertyValue<bool>(m_parallaxPdoEnableIndex);
if (parallaxEnabled && parallaxPdoEnabled)
{
context.SetShaderEnabled(m_depthShaderNoPSIndex, false);
context.SetShaderEnabled(m_shadowShaderNoPSIndex, false);
context.SetShaderEnabled(m_pbrShaderWithEdsIndex, false);
context.SetShaderEnabled(m_depthShaderWithPSIndex, true);
context.SetShaderEnabled(m_shadowShaderWithPSIndex, true);
context.SetShaderEnabled(m_pbrShaderNoEdsIndex, true);
}
else
{
context.SetShaderEnabled(m_depthShaderNoPSIndex, opacityMode == OpacityMode::Opaque );
context.SetShaderEnabled(m_shadowShaderNoPSIndex, opacityMode == OpacityMode::Opaque);
context.SetShaderEnabled(m_pbrShaderWithEdsIndex, opacityMode == OpacityMode::Opaque || opacityMode == OpacityMode::Blended || opacityMode == OpacityMode::TintedTransparent);
context.SetShaderEnabled(m_depthShaderWithPSIndex, opacityMode == OpacityMode::Cutout);
context.SetShaderEnabled(m_shadowShaderWithPSIndex, opacityMode == OpacityMode::Cutout);
context.SetShaderEnabled(m_pbrShaderNoEdsIndex, opacityMode == OpacityMode::Cutout);
}
context.SetShaderEnabled(m_depthShaderTransparentMin, opacityMode == OpacityMode::Blended || opacityMode == OpacityMode::TintedTransparent);
context.SetShaderEnabled(m_depthShaderTransparentMax, opacityMode == OpacityMode::Blended || opacityMode == OpacityMode::TintedTransparent);
}
}
}
@@ -1,63 +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.
*
*/
#pragma once
#include <Atom/RPI.Reflect/Material/MaterialFunctor.h>
#include <Atom/RPI.Reflect/Material/MaterialPropertyDescriptor.h>
#include <Atom/RHI.Reflect/Limits.h>
namespace AZ
{
namespace Render
{
enum OpacityMode
{
Opaque = 0,
Cutout,
Blended,
TintedTransparent,
};
//! Select shadow and depth shader based on opacity mode and parallax state
//! Opaque: Enable shader without PS
//! Cutout or Parallax enable: Enable shader with PS
//! Blended: Disable both
//! TintedTransparent: Disable both
class ShaderEnableFunctor final
: public RPI::MaterialFunctor
{
friend class ShaderEnableFunctorSourceData;
public:
AZ_RTTI(ShaderEnableFunctor, "{2079A693-FE4F-46A7-95C0-09D88AC156D0}", RPI::MaterialFunctor);
static void Reflect(ReflectContext* context);
void Process(RuntimeContext& context) override;
private:
RPI::MaterialPropertyIndex m_opacityModeIndex;
RPI::MaterialPropertyIndex m_parallaxEnableIndex;
RPI::MaterialPropertyIndex m_parallaxPdoEnableIndex;
uint32_t m_shadowShaderNoPSIndex = -1;
uint32_t m_shadowShaderWithPSIndex = -1;
uint32_t m_depthShaderNoPSIndex = -1;
uint32_t m_depthShaderWithPSIndex = -1;
uint32_t m_pbrShaderWithEdsIndex = -1;
uint32_t m_pbrShaderNoEdsIndex = -1;
// The following are used by the light culling system to produce min/max depth bounds
uint32_t m_depthShaderTransparentMin = -1;
uint32_t m_depthShaderTransparentMax = -1;
};
}
}
@@ -1,116 +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.
*
*/
#include "./ShaderEnableFunctorSourceData.h"
#include <Atom/RPI.Reflect/Shader/ShaderOptionGroupLayout.h>
#include <AzCore/Serialization/SerializeContext.h>
namespace AZ
{
namespace Render
{
void ShaderEnableFunctorSourceData::Reflect(ReflectContext* context)
{
if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
{
serializeContext->Class<ShaderEnableFunctorSourceData>()
->Version(5)
->Field("opacityMode", &ShaderEnableFunctorSourceData::m_opacityMode)
->Field("parallaxEnable", &ShaderEnableFunctorSourceData::m_parallaxEnable)
->Field("parallaxPdoEnable", &ShaderEnableFunctorSourceData::m_parallaxPdoEnable)
->Field("shadowShaderNoPSIndex", &ShaderEnableFunctorSourceData::m_shadowShaderNoPSIndex)
->Field("shadowShaderWithPSIndex", &ShaderEnableFunctorSourceData::m_shadowShaderWithPSIndex)
->Field("depthShaderNoPSIndex", &ShaderEnableFunctorSourceData::m_depthShaderNoPSIndex)
->Field("depthShaderWithPSIndex", &ShaderEnableFunctorSourceData::m_depthShaderWithPSIndex)
->Field("pbrShaderNoEdsIndex", &ShaderEnableFunctorSourceData::m_pbrShaderNoEdsIndex)
->Field("pbrShaderWithEdsIndex", &ShaderEnableFunctorSourceData::m_pbrShaderWithEdsIndex)
->Field("depthShaderTransparentMin", &ShaderEnableFunctorSourceData::m_depthShaderTransparentMin)
->Field("depthShaderTransparentMax", &ShaderEnableFunctorSourceData::m_depthShaderTransparentMax)
;
}
}
RPI::MaterialFunctorSourceData::FunctorResult ShaderEnableFunctorSourceData::CreateFunctor(const RuntimeContext& context) const
{
RPI::Ptr<ShaderEnableFunctor> functor = aznew ShaderEnableFunctor;
functor->m_opacityModeIndex = context.FindMaterialPropertyIndex(Name{ m_opacityMode });
if (functor->m_opacityModeIndex.IsNull())
{
return Failure();
}
AddMaterialPropertyDependency(functor, functor->m_opacityModeIndex);
functor->m_parallaxEnableIndex = context.FindMaterialPropertyIndex(Name{ m_parallaxEnable });
if (functor->m_parallaxEnableIndex.IsNull())
{
return Failure();
}
AddMaterialPropertyDependency(functor, functor->m_parallaxEnableIndex);
functor->m_parallaxPdoEnableIndex = context.FindMaterialPropertyIndex(Name{ m_parallaxPdoEnable });
if (functor->m_parallaxPdoEnableIndex.IsNull())
{
return Failure();
}
AddMaterialPropertyDependency(functor, functor->m_parallaxPdoEnableIndex);
if (!context.CheckShaderIndexValid(m_shadowShaderWithPSIndex))
{
return Failure();
}
functor->m_shadowShaderWithPSIndex = m_shadowShaderWithPSIndex;
if (!context.CheckShaderIndexValid(m_shadowShaderNoPSIndex))
{
return Failure();
}
functor->m_shadowShaderNoPSIndex = m_shadowShaderNoPSIndex;
if (!context.CheckShaderIndexValid(m_depthShaderWithPSIndex))
{
return Failure();
}
functor->m_depthShaderWithPSIndex = m_depthShaderWithPSIndex;
if (!context.CheckShaderIndexValid(m_depthShaderNoPSIndex))
{
return Failure();
}
functor->m_depthShaderNoPSIndex = m_depthShaderNoPSIndex;
if (!context.CheckShaderIndexValid(m_pbrShaderNoEdsIndex))
{
return Failure();
}
functor->m_pbrShaderNoEdsIndex = m_pbrShaderNoEdsIndex;
if (!context.CheckShaderIndexValid(m_pbrShaderWithEdsIndex))
{
return Failure();
}
functor->m_pbrShaderWithEdsIndex = m_pbrShaderWithEdsIndex;
if (!context.CheckShaderIndexValid(m_depthShaderTransparentMin))
{
return Failure();
}
functor->m_depthShaderTransparentMin = m_depthShaderTransparentMin;
if (!context.CheckShaderIndexValid(m_depthShaderTransparentMax))
{
return Failure();
}
functor->m_depthShaderTransparentMax = m_depthShaderTransparentMax;
return Success(RPI::Ptr<RPI::MaterialFunctor>(functor));
}
}
}
@@ -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.
*
*/
#pragma once
#include "./ShaderEnableFunctor.h"
#include <Atom/RPI.Edit/Material/MaterialFunctorSourceData.h>
namespace AZ
{
namespace Render
{
class ShaderEnableFunctor;
//! Builds a ShaderEnableFunctor
class ShaderEnableFunctorSourceData final
: public RPI::MaterialFunctorSourceData
{
public:
AZ_RTTI(ShaderEnableFunctorSourceData, "{63775ECB-5C3E-44D3-B175-4537BF76C3A7}", RPI::MaterialFunctorSourceData);
static void Reflect(ReflectContext* context);
FunctorResult CreateFunctor(const RuntimeContext& context) const override;
private:
AZStd::string m_opacityMode;
AZStd::string m_parallaxEnable;
AZStd::string m_parallaxPdoEnable;
uint32_t m_shadowShaderNoPSIndex = -1;
uint32_t m_shadowShaderWithPSIndex = -1;
uint32_t m_depthShaderNoPSIndex = -1;
uint32_t m_depthShaderWithPSIndex = -1;
uint32_t m_pbrShaderWithEdsIndex = -1;
uint32_t m_pbrShaderNoEdsIndex = -1;
// The following are used by the light culling system to produce min/max depth bounds
uint32_t m_depthShaderTransparentMin = -1;
uint32_t m_depthShaderTransparentMax = -1;
};
}
}
@@ -24,16 +24,12 @@ set(FILES
Source/Material/ConvertEmissiveUnitFunctorSourceData.h
Source/Material/MaterialConverterSystemComponent.cpp
Source/Material/MaterialConverterSystemComponent.h
Source/Material/ShaderEnableFunctorSourceData.cpp
Source/Material/ShaderEnableFunctorSourceData.h
Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.cpp
Source/Material/SubsurfaceTransmissionParameterFunctorSourceData.h
Source/Material/Transform2DFunctorSourceData.cpp
Source/Material/Transform2DFunctorSourceData.h
Source/Material/UseTextureFunctorSourceData.cpp
Source/Material/UseTextureFunctorSourceData.h
Source/Material/PropertyVisibilityFunctorSourceData.cpp
Source/Material/PropertyVisibilityFunctorSourceData.h
Source/Material/DrawListFunctorSourceData.cpp
Source/Material/DrawListFunctorSourceData.h
)
@@ -155,16 +155,12 @@ set(FILES
Source/LookupTable/LookupTableAsset.cpp
Source/Material/ConvertEmissiveUnitFunctor.cpp
Source/Material/ConvertEmissiveUnitFunctor.h
Source/Material/ShaderEnableFunctor.cpp
Source/Material/ShaderEnableFunctor.h
Source/Material/SubsurfaceTransmissionParameterFunctor.cpp
Source/Material/SubsurfaceTransmissionParameterFunctor.h
Source/Material/Transform2DFunctor.cpp
Source/Material/Transform2DFunctor.h
Source/Material/UseTextureFunctor.cpp
Source/Material/UseTextureFunctor.h
Source/Material/PropertyVisibilityFunctor.cpp
Source/Material/PropertyVisibilityFunctor.h
Source/Material/DrawListFunctor.cpp
Source/Material/DrawListFunctor.h
Source/Math/GaussianMathFilter.h
@@ -288,6 +288,7 @@ namespace AZ
AZStd::size_t GetShaderCount() const;
LuaMaterialFunctorShaderItem GetShader(AZStd::size_t index);
LuaMaterialFunctorShaderItem GetShaderByTag(const char* shaderTag);
bool HasShaderWithTag(const char* shaderTag);
private:
@@ -296,6 +296,7 @@ namespace AZ
->Method("GetShaderCount", &LuaMaterialFunctorRuntimeContext::GetShaderCount)
->Method("GetShader", &LuaMaterialFunctorRuntimeContext::GetShader)
->Method("GetShaderByTag", &LuaMaterialFunctorRuntimeContext::GetShaderByTag)
->Method("HasShaderWithTag", &LuaMaterialFunctorRuntimeContext::HasShaderWithTag)
;
}
@@ -424,6 +425,11 @@ namespace AZ
return LuaMaterialFunctorShaderItem{nullptr};
}
}
bool LuaMaterialFunctorRuntimeContext::HasShaderWithTag(const char* shaderTag)
{
return m_runtimeContextImpl->m_shaderCollection->HasShaderTag(AZ::Name{shaderTag});
}
void LuaMaterialFunctorEditorContext::LuaMaterialFunctorEditorContext::Reflect(BehaviorContext* behaviorContext)
{
@@ -17,7 +17,6 @@
"textureMap": "TestData/Textures/cc0/Rock030_2K_Normal.jpg"
},
"parallax": {
"enable": true,
"algorithm": "POM",
"factor": 0.03,
"quality": "High",
@@ -86,6 +86,10 @@
"textureMap": "TestData/Textures/cc0/Lava004_1K_Roughness.jpg"
},
"layer2_uv": {
"center": [
0.0,
0.0
],
"offsetU": 0.5,
"offsetV": 0.25
},
@@ -128,11 +132,15 @@
"factor": 0.47474750876426699
},
"layer3_uv": {
"center": [
0.0,
0.0
],
"offsetU": 0.11999999731779099,
"rotateDegrees": -57.599998474121097
},
"parallax": {
"enable": true
"quality": "Medium"
},
"uv": {
"center": [
@@ -48,8 +48,8 @@
"textureMap": "TestData/Textures/cc0/Concrete019_1K_Color.jpg"
},
"parallax": {
"enable": true,
"pdo": true
"pdo": true,
"quality": "Medium"
}
}
}
@@ -6,6 +6,9 @@
"properties": {
"blend": {
"blendSource": "BlendMaskVertexColors"
},
"parallax": {
"quality": "Medium"
}
}
}
}
@@ -46,8 +46,8 @@
},
"layer2_uv": {
"center": [
0.5,
0.5
0.0,
0.0
],
"offsetU": 0.1599999964237213,
"offsetV": 0.07999999821186066,
@@ -67,13 +67,15 @@
"textureMap": "TestData/Textures/cc0/Rocks002_1K_Roughness.jpg"
},
"layer3_uv": {
"center": [
0.0,
0.0
],
"scale": 3.4999988079071047
},
"parallax": {
"algorithm": "Relief",
"enable": true,
"pdo": true,
"quality": "Low"
"pdo": true
}
}
}
@@ -0,0 +1,23 @@
{
"description": "",
"materialType": "Materials/Types/StandardPBR.materialtype",
"parentMaterial": "",
"propertyLayoutVersion": 3,
"properties": {
"baseColor": {
"color": [
0.5906767249107361,
1.0,
0.11703670024871826,
1.0
],
"textureMap": "Textures/Default/default_basecolor.tif"
},
"opacity": {
"alphaSource": "Split",
"factor": 0.75,
"mode": "TintedTransparent",
"textureMap": "TestData/Textures/checker8x8_gray_512.png"
}
}
}
@@ -8,7 +8,6 @@
},
"parallax": {
"algorithm": "POM",
"enable": true,
"factor": 0.02500000037252903,
"quality": "High",
"textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_disp.png"
@@ -13,13 +13,15 @@
"textureMap": "TestData/Textures/checker8x8_512.png"
},
"parallax": {
"algorithm": "POM",
"enable": true,
"factor": 0.10000000149011612,
"quality": "High",
"textureMap": "TestData/Textures/TextureHaven/4k_castle_brick_02_red/4k_castle_brick_02_red_disp.png"
},
"uv": {
"center": [
0.0,
0.0
],
"scale": 0.5
}
}
@@ -6,7 +6,6 @@
"properties": {
"subsurfaceScattering": {
"enableSubsurfaceScattering": true,
"enableTransmission": true,
"scatterDistance": 64.6464614868164,
"subsurfaceScatterFactor": 1.0,
"thicknessMap": "TestData/Textures/checker8x8_512.png",
@@ -13,7 +13,6 @@
},
"parallax": {
"algorithm": "POM",
"enable": true,
"factor": 0.10000000149011612,
"quality": "High",
"textureMap": "TestData/Objects/cube/cube_diff.tif"
@@ -13,7 +13,6 @@
},
"parallax": {
"algorithm": "POM",
"enable": true,
"factor": 0.05000000074505806,
"quality": "High",
"textureMap": "TestData/Objects/cube/cube_diff.tif"
@@ -8,18 +8,24 @@
"textureMap": "Objects/Lucy/Lucy_bronze_BaseColor.png",
"textureMapUv": "Unwrapped"
},
"detailUV": {
"center": [
0.0,
0.0
]
},
"metallic": {
"textureMap": "Objects/Lucy/Lucy_bronze_metallic.png",
"textureMap": "Objects/Lucy/Lucy_bronze_Metallic.png",
"textureMapUv": "Unwrapped"
},
"normal": {
"flipY": true,
"textureMap": "Objects/Lucy/Lucy_normal.png",
"textureMap": "Objects/Lucy/Lucy_Normal.png",
"textureMapUv": "Unwrapped"
},
"roughness": {
"textureMap": "Objects/Lucy/Lucy_bronze_roughness.png",
"textureMap": "Objects/Lucy/Lucy_bronze_Roughness.png",
"textureMapUv": "Unwrapped"
}
}
}
}
@@ -5,7 +5,7 @@
"propertyLayoutVersion": 3,
"properties": {
"baseColor": {
"textureMap": "Objects/Lucy/Lucy_bronze_baseColor.png",
"textureMap": "Objects/Lucy/Lucy_bronze_BaseColor.png",
"textureMapUv": "Unwrapped"
},
"detailLayerGroup": {
@@ -19,20 +19,24 @@
"normalDetailStrength": 1.5
},
"detailUV": {
"center": [
0.0,
0.0
],
"scale": 10.0
},
"metallic": {
"textureMap": "Objects/Lucy/Lucy_bronze_metallic.png",
"textureMap": "Objects/Lucy/Lucy_bronze_Metallic.png",
"textureMapUv": "Unwrapped"
},
"normal": {
"flipY": true,
"textureMap": "Objects/Lucy/Lucy_normal.png",
"textureMap": "Objects/Lucy/Lucy_Normal.png",
"textureMapUv": "Unwrapped"
},
"roughness": {
"textureMap": "Objects/Lucy/Lucy_bronze_roughness.png",
"textureMap": "Objects/Lucy/Lucy_bronze_Roughness.png",
"textureMapUv": "Unwrapped"
}
}
}
}
@@ -5,7 +5,7 @@
"propertyLayoutVersion": 3,
"properties": {
"baseColor": {
"textureMap": "Objects/Lucy/Lucy_bronze_baseColor.png",
"textureMap": "Objects/Lucy/Lucy_bronze_BaseColor.png",
"textureMapUv": "Unwrapped"
},
"detailLayerGroup": {
@@ -18,20 +18,24 @@
"normalDetailStrength": 1.5
},
"detailUV": {
"center": [
0.0,
0.0
],
"scale": 10.0
},
"metallic": {
"textureMap": "Objects/Lucy/Lucy_bronze_metallic.png",
"textureMap": "Objects/Lucy/Lucy_bronze_Metallic.png",
"textureMapUv": "Unwrapped"
},
"normal": {
"flipY": true,
"textureMap": "Objects/Lucy/Lucy_normal.png",
"textureMap": "Objects/Lucy/Lucy_Normal.png",
"textureMapUv": "Unwrapped"
},
"roughness": {
"textureMap": "Objects/Lucy/Lucy_bronze_roughness.png",
"textureMap": "Objects/Lucy/Lucy_bronze_Roughness.png",
"textureMapUv": "Unwrapped"
}
}
}
}
@@ -26,7 +26,6 @@
},
"parallax": {
"algorithm": "POM",
"enable": true,
"factor": 0.02500000037252903,
"pdo": true,
"quality": "Ultra",
@@ -31,7 +31,8 @@
"algorithm": "ContactRefinement",
"factor": 0.019999999552965165,
"quality": "Ultra",
"textureMap": "Materials/Concrete016_8K/Concrete016_8K_Displacement.png"
"textureMap": "Materials/Concrete016_8K/Concrete016_8K_Displacement.png",
"useTexture": false
},
"roughness": {
"textureMap": "Materials/Concrete016_8K/Concrete016_8K_Roughness.png"
@@ -20,7 +20,6 @@
},
"parallax": {
"algorithm": "ContactRefinement",
"enable": true,
"factor": 0.004999999888241291,
"quality": "Ultra",
"textureMap": "Materials/Fabric001_8K/Fabric001_8K_Displacement.png"
@@ -20,7 +20,6 @@
},
"parallax": {
"algorithm": "ContactRefinement",
"enable": true,
"factor": 0.0020000000949949028,
"pdo": true,
"quality": "Medium",
@@ -19,7 +19,6 @@
},
"parallax": {
"algorithm": "ContactRefinement",
"enable": true,
"factor": 0.009999999776482582,
"pdo": true,
"quality": "Ultra",
@@ -30,7 +30,8 @@
"factor": 0.02500000037252903,
"pdo": true,
"quality": "Ultra",
"textureMap": "Materials/Bricks038_8K/Bricks038_8K_Displacement.png"
"textureMap": "Materials/Bricks038_8K/Bricks038_8K_Displacement.png",
"useTexture": false
},
"roughness": {
"factor": 0.4343433976173401,
@@ -22,7 +22,6 @@
},
"parallax": {
"algorithm": "POM",
"enable": true,
"factor": 0.02500000037252903,
"pdo": true,
"quality": "Ultra",
@@ -19,7 +19,8 @@
},
"parallax": {
"factor": 0.0010101000079885126,
"textureMap": "Materials/ConcreteStucco/concrete_stucco_height.jpg"
"textureMap": "Materials/ConcreteStucco/concrete_stucco_height.jpg",
"useTexture": false
},
"specularF0": {
"factor": 0.5050504803657532
@@ -41,7 +41,8 @@
"factor": 0.050999999046325687,
"pdo": true,
"quality": "High",
"textureMap": "Textures/arch_1k_height.png"
"textureMap": "Textures/arch_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/arch_1k_roughness.png"
@@ -47,7 +47,8 @@
"factor": 0.03099999949336052,
"pdo": true,
"quality": "High",
"textureMap": "Textures/background_1k_height.png"
"textureMap": "Textures/background_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/background_1k_roughness.png"
@@ -46,7 +46,8 @@
"algorithm": "ContactRefinement",
"factor": 0.03500000014901161,
"quality": "Medium",
"textureMap": "Textures/bricks_1k_height.png"
"textureMap": "Textures/bricks_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/bricks_1k_roughness.png"
@@ -48,7 +48,8 @@
"factor": 0.019999999552965165,
"pdo": true,
"quality": "Medium",
"textureMap": "Textures/ceiling_1k_height.png"
"textureMap": "Textures/ceiling_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/ceiling_1k_roughness.png"
@@ -47,7 +47,8 @@
"factor": 0.017000000923871995,
"pdo": true,
"quality": "High",
"textureMap": "Textures/columnA_1k_height.png"
"textureMap": "Textures/columnA_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/columnA_1k_roughness.png"
@@ -46,7 +46,8 @@
"factor": 0.020999999716877939,
"pdo": true,
"quality": "High",
"textureMap": "Textures/columnB_1k_height.png"
"textureMap": "Textures/columnB_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/columnB_1k_roughness.png"
@@ -47,7 +47,8 @@
"factor": 0.014000000432133675,
"pdo": true,
"quality": "High",
"textureMap": "Textures/columnC_1k_height.png"
"textureMap": "Textures/columnC_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/columnC_1k_roughness.png"
@@ -38,7 +38,8 @@
"algorithm": "POM",
"factor": 0.02500000037252903,
"pdo": true,
"textureMap": "Textures/details_1k_height.png"
"textureMap": "Textures/details_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/details_1k_roughness.png"
@@ -41,7 +41,8 @@
"factor": 0.014000000432133675,
"pdo": true,
"quality": "High",
"textureMap": "Textures/flagpole_1k_height.png"
"textureMap": "Textures/flagpole_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/flagpole_1k_roughness.png"
@@ -43,7 +43,8 @@
"algorithm": "POM",
"factor": 0.012000000104308129,
"pdo": true,
"textureMap": "Textures/floor_1k_height.png"
"textureMap": "Textures/floor_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/floor_1k_roughness.png"
@@ -42,7 +42,8 @@
"mode": "Cutout"
},
"parallax": {
"textureMap": "Textures/thorn_height.png"
"textureMap": "Textures/thorn_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/thorn_roughness.png"
@@ -38,7 +38,6 @@
},
"parallax": {
"algorithm": "ContactRefinement",
"enable": true,
"factor": 0.009999999776482582,
"pdo": true,
"quality": "Ultra",
@@ -35,7 +35,8 @@
"algorithm": "ContactRefinement",
"factor": 0.019999999552965165,
"quality": "Medium",
"textureMap": "Textures/roof_1k_height.png"
"textureMap": "Textures/roof_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/roof_1k_roughness.png"
@@ -41,7 +41,8 @@
"factor": 0.027000000700354577,
"pdo": true,
"quality": "High",
"textureMap": "Textures/vase_1k_height.png"
"textureMap": "Textures/vase_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/vase_1k_roughness.png"
@@ -41,7 +41,8 @@
"factor": 0.04600000008940697,
"pdo": true,
"quality": "High",
"textureMap": "Textures/vaseHanging_1k_height.png"
"textureMap": "Textures/vaseHanging_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/vaseHanging_1k_roughness.png"
@@ -45,7 +45,8 @@
"factor": 0.019999999552965165,
"pdo": true,
"quality": "High",
"textureMap": "Textures/vaseRound_1k_height.png"
"textureMap": "Textures/vaseRound_1k_height.png",
"useTexture": false
},
"roughness": {
"textureMap": "Textures/vaseRound_1k_roughness.png"