ATOM-14838 Make Parallax Look Decent By Default
Updated material types to have default parallax settings of POM, Low quality, 0.05 scale. That way the parallax effect will show up as soon as a user adds a heightmap. Updated StandardMultilayerPBR_Displacement.lua to control the o_parallax_feature_enabled, so we can have the material's parallax.enable=true by default. Again this is to allow parallax behavior to show up as soon as the user adds a heightmap or adjusts the displacement offset. Note that even though we have a functor to drive the feature based on displacement settings, we still need the parallax.enable flag that that the user can set to false when they want to use displacement blending but not parallax. Updated test materials to maintain their prior implied settings.
This commit is contained in:
@@ -973,7 +973,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": {
|
||||
@@ -1011,7 +1011,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"
|
||||
|
||||
@@ -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"
|
||||
@@ -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": {
|
||||
@@ -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": {
|
||||
@@ -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": {
|
||||
|
||||
+57
-9
@@ -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)
|
||||
|
||||
@@ -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"
|
||||
|
||||
+1
-1
@@ -132,7 +132,7 @@
|
||||
"rotateDegrees": -57.599998474121097
|
||||
},
|
||||
"parallax": {
|
||||
"enable": true
|
||||
"quality": "Medium"
|
||||
},
|
||||
"uv": {
|
||||
"center": [
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@
|
||||
"textureMap": "TestData/Textures/cc0/Concrete019_1K_Color.jpg"
|
||||
},
|
||||
"parallax": {
|
||||
"enable": true,
|
||||
"pdo": true
|
||||
"pdo": true,
|
||||
"quality": "Medium"
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -6,6 +6,9 @@
|
||||
"properties": {
|
||||
"blend": {
|
||||
"blendSource": "BlendMaskVertexColors"
|
||||
},
|
||||
"parallax": {
|
||||
"quality": "Medium"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user