diff --git a/atom_gems/AtomTutorials/Assets/SixPointLighting/SixPointLighting.azsli b/atom_gems/AtomTutorials/Assets/SixPointLighting/SixPointLighting.azsli index e2c882c..fbb8d06 100644 --- a/atom_gems/AtomTutorials/Assets/SixPointLighting/SixPointLighting.azsli +++ b/atom_gems/AtomTutorials/Assets/SixPointLighting/SixPointLighting.azsli @@ -62,11 +62,7 @@ float3 GetIblSample(Surface surface, float3 direction) return diffuseSample; } -float3 GetIblDiffuse( - float3 normal, - float3 albedo, - float3 diffuseResponse, - Surface surface) +float3 GetIblDiffuse(Surface surface, float3 diffuseResponse) { float3 rightSample = GetIblSample(surface, float3(1.0f, 0.0f, 0.0f)); float3 leftSample = GetIblSample(surface, float3(-1.0f, 0.0f, 0.0f)); @@ -82,7 +78,7 @@ float3 GetIblDiffuse( + (frontsideSample * surface.frontside) + (backsideSample * surface.backside); - return diffuseResponse * albedo * totalDiffuseSample; + return diffuseResponse * surface.albedo * totalDiffuseSample; } void ApplyIBL(Surface surface, inout LightingData lightingData) @@ -103,7 +99,7 @@ void ApplyIBL(Surface surface, inout LightingData lightingData) if(useDiffuseIbl) { - float3 iblDiffuse = GetIblDiffuse(surface.normal, surface.albedo, lightingData.diffuseResponse, surface); + float3 iblDiffuse = GetIblDiffuse(surface, lightingData.diffuseResponse); lightingData.diffuseLighting += (iblDiffuse * globalIblExposure * lightingData.diffuseAmbientOcclusion); } } diff --git a/atom_gems/AtomTutorials/Templates/SixPointLighting/MaterialFunctions/EvaluateSixPointSurface.azsli b/atom_gems/AtomTutorials/Templates/SixPointLighting/MaterialFunctions/EvaluateSixPointSurface.azsli new file mode 100644 index 0000000..14b761b --- /dev/null +++ b/atom_gems/AtomTutorials/Templates/SixPointLighting/MaterialFunctions/EvaluateSixPointSurface.azsli @@ -0,0 +1,39 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include <../SixPointSurface.azsli> +#include + +void EvaluateSixPointSurface( + float3 vertexNormal, + float2 uv[UvSetCount], + float3 tangents[UvSetCount], + float3 bitangents[UvSetCount], + bool isFrontFace, + bool displacementIsClipped, + inout Surface surface) +{ + // ------- Base Color ------- + float2 baseColorUv = uv[MaterialSrg::m_baseColorMapUvIndex]; + float3 sampledColor = GetBaseColorInput(MaterialSrg::m_baseColorMap, MaterialSrg::m_sampler, baseColorUv, MaterialSrg::m_baseColor.rgb, o_baseColor_useTexture); + float3 baseColor = BlendBaseColor(sampledColor, MaterialSrg::m_baseColor.rgb, MaterialSrg::m_baseColorFactor, o_baseColorTextureBlendMode, o_baseColor_useTexture); + + // ------- Metallic ------- + float metallic = MaterialSrg::m_metallicFactor; + + // ------- Specular ------- + float specularF0Factor = MaterialSrg::m_specularF0Factor; + surface.SetAlbedoAndSpecularF0(baseColor, specularF0Factor, metallic); + + // ------- Roughness ------- + surface.roughnessLinear = MaterialSrg::m_roughnessFactor;; + surface.CalculateRoughnessA(); + + // ------- Clearcoat ------- + surface.clearCoat.InitializeToZero(); +} diff --git a/atom_gems/AtomTutorials/Templates/SixPointLighting/MaterialInputs/SixPointLightingPropertyGroup.json b/atom_gems/AtomTutorials/Templates/SixPointLighting/MaterialInputs/SixPointLightingPropertyGroup.json new file mode 100644 index 0000000..7a92590 --- /dev/null +++ b/atom_gems/AtomTutorials/Templates/SixPointLighting/MaterialInputs/SixPointLightingPropertyGroup.json @@ -0,0 +1,148 @@ +{ + "name": "sixPointLighting", + "displayName": "Six Point Lighting", + "description": "Six point lighting settings.", + "properties": [ + { + "name": "texturePackMode", + "displayName": "Texture Pack Mode", + "description": "Determines how the textures are sampled.", + "type": "Enum", + "enumValues": [ "TpLftRtBt_FrBck", "RtLftTp_BtBckFr" ], + "defaultValue": "TpLftRtBt_FrBck", + "connection": { + "type": "ShaderOption", + "name": "o_sixPointTexturePackMode" + } + }, + { + "name": "TLRB", + "displayName": "Top Left Right Bottom", + "description": "Top Left Right Bottom Lightmap", + "type": "Image", + "connection": { + "type": "ShaderInput", + "name": "m_topLeftRightBottomMap" + } + }, + { + "name": "FB", + "displayName": "Front Back", + "description": "Front Back Lightmap", + "type": "Image", + "connection": { + "type": "ShaderInput", + "name": "m_frontBackMap" + } + }, + { + "name": "RLT", + "displayName": "Right Left Top", + "description": "Right Left Top Lightmap", + "type": "Image", + "connection": { + "type": "ShaderInput", + "name": "m_rightLeftTopMap" + } + }, + { + "name": "BBF", + "displayName": "Bottom Back Front", + "description": "Bottom Back Front Lightmap", + "type": "Image", + "connection": { + "type": "ShaderInput", + "name": "m_bottomBackFrontMap" + } + }, + { + "name": "useDepthTexture", + "displayName": "Use Depth", + "description": "Whether to use the depth map.", + "type": "Bool", + "defaultValue": false + }, + { + "name": "depthMap", + "displayName": "Depth", + "description": "Depth texture map", + "type": "Image", + "connection": { + "type": "ShaderInput", + "name": "m_depthMap" + } + }, + { + "name": "depthScale", + "displayName": "Scale the Depth Texture", + "description": "Multiplier for the depth texture", + "type": "Float", + "defaultValue": 10.0, + "min": 0.01, + "connection": { + "type": "ShaderInput", + "name": "m_depthScale" + } + }, + { + "name": "rowCount", + "displayName": "Rows in Flipbook", + "description": "Total rows of animation in the flipbook", + "type": "Float", + "defaultValue": 8.0, + "min": 1.0, + "step": 1.0, + "connection": { + "type": "ShaderInput", + "name": "m_rowCount" + } + }, + { + "name": "columnCount", + "displayName": "Columns in Flipbook", + "description": "Total columns of animation in the flipbook", + "type": "Float", + "defaultValue": 8.0, + "min": 1.0, + "step": 1.0, + "connection": { + "type": "ShaderInput", + "name": "m_columnCount" + } + }, + { + "name": "enableDebugFrame", + "displayName": "Enable debugging a specific frame", + "description": "Locks the frame of the animation", + "type": "Bool", + "defaultValue": false, + "connection": { + "type": "ShaderOption", + "name": "o_enableDebugFrame" + } + }, + { + "name": "debugFrame", + "displayName": "Debug Frame", + "description": "The frame you want to debug", + "type": "Float", + "defaultValue": 1.0, + "min": 1.0, + "step": 1.0, + "connection": { + "type": "ShaderInput", + "name": "m_debugFrame" + } + } + ], + "functors": [ + { + "type": "UseTexture", + "args": { + "textureProperty": "depthMap", + "useTextureProperty": "useDepthTexture", + "shaderOption": "o_enableDepthTexture" + } + } + ] +} diff --git a/atom_gems/AtomTutorials/Templates/SixPointLighting/SixPointLighting.azsli b/atom_gems/AtomTutorials/Templates/SixPointLighting/SixPointLighting.azsli index f49a797..4f57291 100644 --- a/atom_gems/AtomTutorials/Templates/SixPointLighting/SixPointLighting.azsli +++ b/atom_gems/AtomTutorials/Templates/SixPointLighting/SixPointLighting.azsli @@ -70,10 +70,10 @@ float3 GetSpecularLighting(Surface surface, LightingData lightingData, const flo // Include IBL functions float3 GetIblDiffuse(Surface surface, float3 diffuseResponse) { - float3 irradianceDir = MultiplyVectorQuaternion(normal, SceneSrg::m_iblOrientation); + float3 irradianceDir = MultiplyVectorQuaternion(surface.normal, SceneSrg::m_iblOrientation); float3 diffuseSample = SceneSrg::m_diffuseEnvMap.Sample(SceneSrg::m_samplerEnv, GetCubemapCoords(irradianceDir)).rgb; - return diffuseResponse * albedo * diffuseSample; + return diffuseResponse * surface.albedo * diffuseSample; } void ApplyIBL(Surface surface, inout LightingData lightingData)