Added new ramp diffuse ambient mode.
This commit is contained in:
@@ -17,6 +17,10 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
public static MaterialProperty indirectDiffuseMatCapMap;
|
public static MaterialProperty indirectDiffuseMatCapMap;
|
||||||
public static MaterialProperty indirectDiffuseMatCapLod;
|
public static MaterialProperty indirectDiffuseMatCapLod;
|
||||||
|
|
||||||
|
public static MaterialProperty indirectDiffuseRampMap;
|
||||||
|
public static MaterialProperty indirectDiffuseRampIndex;
|
||||||
|
public static MaterialProperty indirectDiffuseRampPosition;
|
||||||
|
|
||||||
public static MaterialProperty indirectDiffuseIntensity;
|
public static MaterialProperty indirectDiffuseIntensity;
|
||||||
public static MaterialProperty ssaoWeight;
|
public static MaterialProperty ssaoWeight;
|
||||||
public static MaterialProperty ssgiWeight;
|
public static MaterialProperty ssgiWeight;
|
||||||
@@ -35,6 +39,9 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
|
|
||||||
public static readonly GUIContent indirectDiffuseMatCapMapText = new("MatCap Map", "The material capture map for indirect diffuse evaluation, with the additional setting for controlling the LOD offset when sampling the indirect diffuse material capture map.");
|
public static readonly GUIContent indirectDiffuseMatCapMapText = new("MatCap Map", "The material capture map for indirect diffuse evaluation, with the additional setting for controlling the LOD offset when sampling the indirect diffuse material capture map.");
|
||||||
|
|
||||||
|
public static readonly GUIContent indirectDiffuseRampMapText = new("Ramp Map", "The ramp map for indirect diffuse evaluation, with the additional setting for controlling the sampling index of the ramp map.");
|
||||||
|
public static readonly GUIContent indirectDiffuseRampPositionText = new("Ramp Position", "The ramp position for indirect diffuse evaluation.");
|
||||||
|
|
||||||
public static readonly GUIContent indirectDiffuseIntensityText = new("Intensity", "The indirect diffuse color is added to the material color according to the intensity value.");
|
public static readonly GUIContent indirectDiffuseIntensityText = new("Intensity", "The indirect diffuse color is added to the material color according to the intensity value.");
|
||||||
public static readonly GUIContent ssaoWeightText = new("SSAO Weight", "The weight of SSAO.");
|
public static readonly GUIContent ssaoWeightText = new("SSAO Weight", "The weight of SSAO.");
|
||||||
public static readonly GUIContent ssgiWeightText = new("SSGI Weight", "The weight of SSGI.");
|
public static readonly GUIContent ssgiWeightText = new("SSGI Weight", "The weight of SSGI.");
|
||||||
@@ -53,6 +60,10 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
Properties.indirectDiffuseMatCapMap = FindProperty("_IndirectDiffuseMatCapMap");
|
Properties.indirectDiffuseMatCapMap = FindProperty("_IndirectDiffuseMatCapMap");
|
||||||
Properties.indirectDiffuseMatCapLod = FindProperty("_IndirectDiffuseMatCapLod");
|
Properties.indirectDiffuseMatCapLod = FindProperty("_IndirectDiffuseMatCapLod");
|
||||||
|
|
||||||
|
Properties.indirectDiffuseRampMap = FindProperty("_IndirectDiffuseRampMap");
|
||||||
|
Properties.indirectDiffuseRampIndex = FindProperty("_IndirectDiffuseRampIndex");
|
||||||
|
Properties.indirectDiffuseRampPosition = FindProperty("_IndirectDiffuseRampPosition");
|
||||||
|
|
||||||
Properties.indirectDiffuseIntensity = FindProperty("_IndirectDiffuseIntensity");
|
Properties.indirectDiffuseIntensity = FindProperty("_IndirectDiffuseIntensity");
|
||||||
Properties.ssaoWeight = FindProperty("_SSAOWeight");
|
Properties.ssaoWeight = FindProperty("_SSAOWeight");
|
||||||
Properties.ssgiWeight = FindProperty("_SSGIWeight");
|
Properties.ssgiWeight = FindProperty("_SSGIWeight");
|
||||||
@@ -64,6 +75,36 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
Properties.ssrWeight = FindProperty("_SSRWeight");
|
Properties.ssrWeight = FindProperty("_SSRWeight");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void DrawIndirectDiffuseHeader()
|
||||||
|
{
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
using var indentLevelScope = new EditorGUI.IndentLevelScope(-1);
|
||||||
|
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawIndirectDiffuseProperties()
|
||||||
|
{
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
editor.ShaderProperty(Properties.indirectDiffuseIntensity, Styles.indirectDiffuseIntensityText);
|
||||||
|
editor.ShaderProperty(Properties.ssaoWeight, Styles.ssaoWeightText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DrawIndirectSpecularProperties()
|
||||||
|
{
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
|
||||||
|
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void DrawIndirectSpecularHeader()
|
||||||
|
{
|
||||||
|
EditorGUILayout.Space();
|
||||||
|
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
|
||||||
|
{
|
||||||
|
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected override void DrawContent()
|
protected override void DrawContent()
|
||||||
{
|
{
|
||||||
editor.ShaderProperty(Properties.indirectDiffuseMode, Styles.indirectDiffuseModeText);
|
editor.ShaderProperty(Properties.indirectDiffuseMode, Styles.indirectDiffuseModeText);
|
||||||
@@ -74,41 +115,43 @@ namespace Misaki.HdrpToon.Editor
|
|||||||
|
|
||||||
if (indirectDiffuseMode != IndirectDiffuseMode.Off)
|
if (indirectDiffuseMode != IndirectDiffuseMode.Off)
|
||||||
{
|
{
|
||||||
EditorGUILayout.Space();
|
DrawIndirectDiffuseHeader();
|
||||||
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
|
|
||||||
{
|
|
||||||
EditorGUILayout.LabelField("Indirect Diffuse", EditorStyles.boldLabel);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (indirectDiffuseMode == IndirectDiffuseMode.Matcap)
|
switch (indirectDiffuseMode)
|
||||||
{
|
|
||||||
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
|
|
||||||
}
|
|
||||||
|
|
||||||
editor.ShaderProperty(Properties.indirectDiffuseIntensity, Styles.indirectDiffuseIntensityText);
|
|
||||||
editor.ShaderProperty(Properties.ssaoWeight, Styles.ssaoWeightText);
|
|
||||||
|
|
||||||
if (indirectDiffuseMode == IndirectDiffuseMode.IBL)
|
|
||||||
{
|
{
|
||||||
|
case IndirectDiffuseMode.IBL:
|
||||||
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
|
editor.ShaderProperty(Properties.ssgiWeight, Styles.ssgiWeightText);
|
||||||
}
|
break;
|
||||||
|
case IndirectDiffuseMode.Matcap:
|
||||||
|
editor.TexturePropertySingleLine(Styles.indirectDiffuseMatCapMapText, Properties.indirectDiffuseMatCapMap, Properties.indirectDiffuseMatCapLod);
|
||||||
|
break;
|
||||||
|
case IndirectDiffuseMode.Ramp:
|
||||||
|
editor.TexturePropertySingleLine(Styles.indirectDiffuseRampMapText, Properties.indirectDiffuseRampMap, Properties.indirectDiffuseRampIndex);
|
||||||
|
editor.ShaderProperty(Properties.indirectDiffuseRampPosition, Styles.indirectDiffuseRampPositionText);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indirectSpecularMode != (int)IndirectSpecularMode.Off)
|
DrawIndirectDiffuseProperties();
|
||||||
{
|
|
||||||
EditorGUILayout.Space();
|
|
||||||
using (var indentLevelScope = new EditorGUI.IndentLevelScope(-1))
|
|
||||||
{
|
|
||||||
EditorGUILayout.LabelField("Indirect Specular", EditorStyles.boldLabel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indirectSpecularMode == IndirectSpecularMode.Matcap)
|
if (indirectSpecularMode != IndirectSpecularMode.Off)
|
||||||
{
|
{
|
||||||
|
DrawIndirectSpecularHeader();
|
||||||
|
|
||||||
|
switch (indirectSpecularMode)
|
||||||
|
{
|
||||||
|
case IndirectSpecularMode.IBL:
|
||||||
|
break;
|
||||||
|
case IndirectSpecularMode.Matcap:
|
||||||
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);
|
editor.TexturePropertySingleLine(Styles.indirectSpecularMatCapMapText, Properties.indirectSpecularMatCapMap, Properties.indirectSpecularMatCapLod);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
editor.ShaderProperty(Properties.indirectReflectionIntensity, Styles.indirectReflectionIntensityText);
|
DrawIndirectSpecularProperties();
|
||||||
editor.ShaderProperty(Properties.ssrWeight, Styles.ssrWeightText);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -183,6 +183,10 @@ Shader "HDRP/Toon"
|
|||||||
_IndirectSpecularMatCapMap("IndirectSpecularMatCapMap", 2D) = "black" {}
|
_IndirectSpecularMatCapMap("IndirectSpecularMatCapMap", 2D) = "black" {}
|
||||||
_IndirectSpecularMatCapLod("IndirectSpecularMatCapMapLOD", Range(-5, 5)) = 0.0
|
_IndirectSpecularMatCapLod("IndirectSpecularMatCapMapLOD", Range(-5, 5)) = 0.0
|
||||||
|
|
||||||
|
_IndirectDiffuseRampMap("_IndirectDiffuseRampMap", 2DArray) = "black" {}
|
||||||
|
_IndirectDiffuseRampIndex("IndirectDiffuseRampIndex", Integer) = 0
|
||||||
|
_IndirectDiffuseRampPosition("IndirectDiffuseRampPosition", Range(0, 1)) = 0.5
|
||||||
|
|
||||||
_IndirectSpecularIntensity("Indirect Specular Intensity", Range(0, 5)) = 1.0
|
_IndirectSpecularIntensity("Indirect Specular Intensity", Range(0, 5)) = 1.0
|
||||||
_SSRWeight("SSR Weight", Range(0.0, 1.0)) = 1.0
|
_SSRWeight("SSR Weight", Range(0.0, 1.0)) = 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -194,9 +194,10 @@ IndirectLighting UtsEvaluateBSDF_MatCapSpecular(float3 positionWS, UtsBSDFData b
|
|||||||
return lighting;
|
return lighting;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UtsEvaluateBSDF_Ramp(PositionInputs posInput, UtsBSDFData bsdfData, float3 L, inout BuiltinData builtinData)
|
void UtsEvaluateBSDF_Ramp(PositionInputs posInput, UtsBSDFData bsdfData, inout BuiltinData builtinData)
|
||||||
{
|
{
|
||||||
// TODO
|
float3 lighting = SAMPLE_TEXTURE2D_ARRAY(_IndirectDiffuseRampMap, s_trilinear_clamp_sampler, float2(_IndirectDiffuseRampPosition, 0.0), _IndirectDiffuseRampIndex).rgb;
|
||||||
|
builtinData.bakeDiffuseLighting = lighting * GetInverseCurrentExposureMultiplier();
|
||||||
}
|
}
|
||||||
|
|
||||||
IndirectLighting UtsEvaluateBSDF_Env(LightLoopContext lightLoopContext, PositionInputs posInput, PreLightData preLightData, EnvLightData lightData, UtsBSDFData bsdfData, int influenceShapeType, int GPUImageBasedLightingType, inout float hierarchyWeight)
|
IndirectLighting UtsEvaluateBSDF_Env(LightLoopContext lightLoopContext, PositionInputs posInput, PreLightData preLightData, EnvLightData lightData, UtsBSDFData bsdfData, int influenceShapeType, int GPUImageBasedLightingType, inout float hierarchyWeight)
|
||||||
|
|||||||
@@ -139,12 +139,12 @@ DirectLighting UtsShadeSurface(PositionInputs posInput, UtsBSDFData bsdfData, Pr
|
|||||||
float NdotL = dot(bsdfData.normalWS, L);
|
float NdotL = dot(bsdfData.normalWS, L);
|
||||||
float halfLambert = 0.5 * NdotL + 0.5;
|
float halfLambert = 0.5 * NdotL + 0.5;
|
||||||
|
|
||||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY_LOD(_ShadingRampMap, s_linear_clamp_sampler, float2(halfLambert * shadow.x, rampMask), _ShadingIndex, 0.0).rgb;
|
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(halfLambert * shadow.x, rampMask), _ShadingIndex).rgb;
|
||||||
|
|
||||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
||||||
specularTerm *= saturate(NdotL) * sharpShadow;
|
specularTerm *= saturate(NdotL) * sharpShadow;
|
||||||
#elif _SHADING_MODE_SDF
|
#elif _SHADING_MODE_SDF
|
||||||
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY_LOD(_ShadingRampMap, s_linear_clamp_sampler, float2(sdfShadowMask * sharpShadow.x, rampMask), _ShadingIndex, 0.0).rgb;
|
float3 rampColor = SAMPLE_TEXTURE2D_ARRAY(_ShadingRampMap, s_linear_clamp_sampler, float2(sdfShadowMask * sharpShadow.x, rampMask), _ShadingIndex).rgb;
|
||||||
|
|
||||||
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
diffuseTerm = bsdfData.diffuseColor * rampColor;
|
||||||
specularTerm = (specularTerm + sdfHighlight) * sdfShadowMask * sharpShadow;
|
specularTerm = (specularTerm + sdfHighlight) * sdfShadowMask * sharpShadow;
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ TEXTURE2D_X(_HairBlendingTex);
|
|||||||
TEXTURE2D(_IndirectDiffuseMatCapMap);
|
TEXTURE2D(_IndirectDiffuseMatCapMap);
|
||||||
TEXTURE2D(_IndirectSpecularMatCapMap);
|
TEXTURE2D(_IndirectSpecularMatCapMap);
|
||||||
|
|
||||||
|
TEXTURE2D_ARRAY(_IndirectDiffuseRampMap);
|
||||||
|
|
||||||
TEXTURE2D(_ClippingMask);
|
TEXTURE2D(_ClippingMask);
|
||||||
|
|
||||||
TEXTURE2D(_AngelRingColorMap);
|
TEXTURE2D(_AngelRingColorMap);
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ float4 _BaseColorMap_ST;
|
|||||||
float4 _BaseColorMap_TexelSize;
|
float4 _BaseColorMap_TexelSize;
|
||||||
float4 _BaseColorMap_MipInfo;
|
float4 _BaseColorMap_MipInfo;
|
||||||
|
|
||||||
float _ShadingIndex;
|
int _ShadingIndex;
|
||||||
half _ShadingRampMask;
|
float _ShadingRampMask;
|
||||||
|
|
||||||
float4 _1stShadeColor;
|
float4 _1stShadeColor;
|
||||||
float4 _2ndShadeColor;
|
float4 _2ndShadeColor;
|
||||||
@@ -72,6 +72,9 @@ float _ObjectSpaceUVMappingEmissive;
|
|||||||
// Ambient
|
// Ambient
|
||||||
float _IndirectDiffuseMatCapLod;
|
float _IndirectDiffuseMatCapLod;
|
||||||
|
|
||||||
|
int _IndirectDiffuseRampIndex;
|
||||||
|
float _IndirectDiffuseRampPosition;
|
||||||
|
|
||||||
float _IndirectDiffuseIntensity;
|
float _IndirectDiffuseIntensity;
|
||||||
float _SSAOWeight;
|
float _SSAOWeight;
|
||||||
float _SSGIWeight;
|
float _SSGIWeight;
|
||||||
|
|||||||
Reference in New Issue
Block a user