diff options
| author | yum <yum.food.vr@gmail.com> | 2024-09-24 13:57:26 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2024-09-24 13:57:26 -0700 |
| commit | 2b9e36fde45c5f488539f390288e0a2731d11fcf (patch) | |
| tree | ed12017282d6145830b512ec2cf1a6d2834e15c7 /Editor | |
| parent | 88a524d71bf46bca1c65c3f7ed5fcd3f6edd1d5e (diff) | |
World lighting fixes
* Add channel selection for roughness and metallic textures
* This lets u combine roughness & metallic into one texture
* Add Bakery-compatible emission slot
* Add compile-time toggle for brightness clamping
* Add toggle for world interpolators
* Add emission type dropdown (baked/realtime/none)
* Switch to bilinear filtering for base PBR maps to match standard
shader behavior
* Add bugfixes for Mochie BRDF in world lighting mode
* Rename _NormalTex to _BumpMap for compatibility with standard shader
* World lighting mode uses Unity baked GI logic instead of normal world
lighting logic
* Use uv2 instead of lmuv for lightmap UVs
Diffstat (limited to 'Editor')
| -rw-r--r-- | Editor/tooner.cs | 87 |
1 files changed, 68 insertions, 19 deletions
diff --git a/Editor/tooner.cs b/Editor/tooner.cs index 29ff40b..55e2dba 100644 --- a/Editor/tooner.cs +++ b/Editor/tooner.cs @@ -64,11 +64,11 @@ public class ToonerGUI : ShaderGUI { } void DoNormalLogic() { - MaterialProperty bct = FindProperty("_NormalTex"); + MaterialProperty bct = FindProperty("_BumpMap"); SetKeyword("_NORMAL_MAP", bct.textureValue); } void DoNormalUI() { - MaterialProperty bct = FindProperty("_NormalTex"); + MaterialProperty bct = FindProperty("_BumpMap"); editor.TexturePropertySingleLine( MakeLabel(bct, "Normal"), bct, @@ -91,6 +91,9 @@ public class ToonerGUI : ShaderGUI { bc); if (bct.textureValue) { editor.TextureScaleOffsetProperty(bct); + + bc = FindProperty("_MetallicTexChannel"); + editor.RangeProperty(bc, "Channel"); } } @@ -108,6 +111,9 @@ public class ToonerGUI : ShaderGUI { if (bct.textureValue) { editor.TextureScaleOffsetProperty(bct); + bc = FindProperty("_RoughnessTexChannel"); + editor.RangeProperty(bc, "Channel"); + bc = FindProperty("_Roughness_Invert"); bool enabled = bc.floatValue > 1E-6; EditorGUI.BeginChangeCheck(); @@ -479,19 +485,31 @@ public class ToonerGUI : ShaderGUI { MaterialProperty bc; MaterialProperty bct; + { + EditorGUILayout.LabelField($"Base slot", EditorStyles.boldLabel); + EditorGUI.indentLevel += 1; + + bc = FindProperty($"_EmissionColor"); + bct = FindProperty($"_EmissionMap"); + editor.TexturePropertyWithHDRColor( + MakeLabel(bct, "Emission (RGB)"), + bct, bc, false); + SetKeyword($"_EMISSION", bct.textureValue); + + EditorGUI.indentLevel -= 1; + } for (int i = 0; i < 2; i++) { - EditorGUILayout.LabelField($"Slot {i}", EditorStyles.boldLabel); + EditorGUILayout.LabelField($"Extra slot {i}", EditorStyles.boldLabel); EditorGUI.indentLevel += 1; { - bc = FindProperty($"_Emission{i}Tex"); - bct = FindProperty($"_Emission{i}Strength"); - editor.TexturePropertySingleLine( - MakeLabel(bct, "Map"), - bc, - bct); - SetKeyword($"_EMISSION{i}", bc.textureValue); + bc = FindProperty($"_Emission{i}Color"); + bct = FindProperty($"_Emission{i}Tex"); + editor.TexturePropertyWithHDRColor( + MakeLabel(bct, "Emission (RGB)"), + bct, bc, false); + SetKeyword($"_EMISSION{i}", bct.textureValue); - if (bc.textureValue) { + if (bct.textureValue) { bc = FindProperty($"_Emission{i}_UV_Select"); editor.RangeProperty( bc, @@ -1936,15 +1954,37 @@ public class ToonerGUI : ShaderGUI { EditorGUI.indentLevel += 1; MaterialProperty bc; - bc = FindProperty("_Min_Brightness"); - editor.RangeProperty( - bc, - "Min brightness"); - bc = FindProperty("_Max_Brightness"); - editor.RangeProperty( - bc, - "Max brightness"); + bc = FindProperty("_Enable_World_Interpolators"); + bool world_interp = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + world_interp = EditorGUILayout.Toggle("World interpolators", + world_interp); + EditorGUI.EndChangeCheck(); + bc.floatValue = world_interp ? 1.0f : 0.0f; + SetKeyword("_WORLD_INTERPOLATORS", world_interp); + + bc = FindProperty("_Enable_Brightness_Clamp"); + bool brightness_clamp_enabled = bc.floatValue > 1E-6; + EditorGUI.BeginChangeCheck(); + brightness_clamp_enabled = EditorGUILayout.Toggle("Clamp brightness", + brightness_clamp_enabled); + EditorGUI.EndChangeCheck(); + bc.floatValue = brightness_clamp_enabled ? 1.0f : 0.0f; + SetKeyword("_BRIGHTNESS_CLAMP", brightness_clamp_enabled); + if (brightness_clamp_enabled) { + EditorGUI.indentLevel += 1; + bc = FindProperty("_Min_Brightness"); + editor.RangeProperty( + bc, + "Min brightness"); + + bc = FindProperty("_Max_Brightness"); + editor.RangeProperty( + bc, + "Max brightness"); + EditorGUI.indentLevel -= 1; + } bc = FindProperty("_Ambient_Occlusion"); editor.TexturePropertySingleLine( @@ -2063,6 +2103,15 @@ public class ToonerGUI : ShaderGUI { EditorGUI.indentLevel -= 1; } + EditorGUI.BeginChangeCheck(); + editor.LightmapEmissionProperty(); + if (EditorGUI.EndChangeCheck()) { + foreach (Material m in editor.targets) { + m.globalIlluminationFlags &= + ~MaterialGlobalIlluminationFlags.EmissiveIsBlack; + } + } + EditorGUI.indentLevel -= 1; } |
