ATOM-14037 StandardPBR TintedTransparent Opacity
Copied tinted transparency opacity mode from EnhancedPBR to StandardPBR. Fixed a bug in EnhancedPBR where Blended opacity didn't work right because the second DrawListOverride functor was stomping on the results of the first DrawListOverride. I removed these functors and made StandardPBR_HandleOpacityMode.lua set the draw list override instead.
This commit is contained in:
@@ -1656,24 +1656,6 @@
|
||||
"file": "StandardPBR_HandleOpacityDoubleSided.lua"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "OverrideDrawList",
|
||||
"args": {
|
||||
"triggerProperty": "opacity.mode",
|
||||
"triggerValue": "Blended",
|
||||
"shaderIndex": 1,
|
||||
"drawList": "transparent"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "OverrideDrawList",
|
||||
"args": {
|
||||
"triggerProperty": "opacity.mode",
|
||||
"triggerValue": "TintedTransparent",
|
||||
"shaderIndex": 1,
|
||||
"drawList": "transparent"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Lua",
|
||||
"args": {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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",
|
||||
@@ -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
|
||||
|
||||
|
||||
+23
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user