diff options
| author | yum <yum.food.vr@gmail.com> | 2025-06-30 09:25:46 -0700 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2025-06-30 09:26:13 -0700 |
| commit | 7db318d2903ad993c618f551c455ec30c131d194 (patch) | |
| tree | 75f82a11a7841ad7d4e5a2c4c9a6a13e86c88635 | |
| parent | 31bba649de265dd83ea1af638c03d224696d07b3 (diff) | |
Add oklab color clamp & fix light volumes shading
| -rw-r--r-- | 2ner.cginc | 9 | ||||
| -rw-r--r-- | 2ner.shader | 7 | ||||
| -rw-r--r-- | Scripts/Editor/GenerateMetallicGlossMap.cs | 2 | ||||
| -rw-r--r-- | decals.cginc | 2 | ||||
| -rw-r--r-- | features.cginc | 4 | ||||
| -rw-r--r-- | globals.cginc | 5 | ||||
| -rw-r--r-- | yum_lighting.cginc | 7 | ||||
| -rw-r--r-- | yum_pbr.cginc | 6 |
8 files changed, 31 insertions, 11 deletions
@@ -313,12 +313,6 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace i.uv01.xy = eye_effect_00.uv;
#endif
- float4x4 tangentToWorld = float4x4(
- float4(i.tangent, 0),
- float4(i.binormal, 0),
- float4(i.normal, 0),
- float4(0, 0, 0, 1)
- );
#if defined(_CUSTOM30)
#if defined(FORWARD_BASE_PASS) || (!defined(_DEPTH_PREPASS) && defined(SHADOW_CASTER_PASS))
#if defined(_CUSTOM30_BASICCUBE)
@@ -343,7 +337,7 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace #endif
#endif
- tangentToWorld = float4x4(
+ float4x4 tangentToWorld = float4x4(
float4(i.tangent, 0),
float4(i.binormal, 0),
float4(i.normal, 0),
@@ -356,7 +350,6 @@ float4 frag(v2f i, uint facing : SV_IsFrontFace ssao = get_ssao(i, tangentToWorld, debug);
#endif
YumPbr pbr = GetYumPbr(i, tangentToWorld);
- //pbr.ao *= ssao;
pbr.albedo.rgb *= ssao;
#if defined(META_PASS)
diff --git a/2ner.shader b/2ner.shader index c37fecc..7a36dfa 100644 --- a/2ner.shader +++ b/2ner.shader @@ -962,6 +962,13 @@ Shader "yum_food/2ner" _Oklch_Correction_H("H", Float) = 1 [HideInInspector] m_end_Oklch_Correction("Oklch", Float) = 0 //endex + //ifex _Oklab_Brightness_Clamp_Enabled==0 + [HideInInspector] m_start_Oklab_Brightness_Clamp("Oklab brightness clamp", Float) = 0 + [ThryToggle(_OKLAB_BRIGHTNESS_CLAMP)] _Oklab_Brightness_Clamp_Enabled("Enable", Float) = 0 + _Oklab_Brightness_Clamp_Min("Min", Float) = 0 + _Oklab_Brightness_Clamp_Max("Max", Float) = 1 + [HideInInspector] m_end_Oklab_Brightness_Clamp("Oklab brightness clamp", Float) = 0 + //endex [HideInInspector] m_end_Color_Correction("Color correction", Float) = 0 //ifex _Raymarched_Fog_Enabled==0 diff --git a/Scripts/Editor/GenerateMetallicGlossMap.cs b/Scripts/Editor/GenerateMetallicGlossMap.cs index e3c6297..4e1d4ba 100644 --- a/Scripts/Editor/GenerateMetallicGlossMap.cs +++ b/Scripts/Editor/GenerateMetallicGlossMap.cs @@ -40,7 +40,7 @@ public class GenerateMetallicGlossMap : EditorWindow ? Path.GetDirectoryName(AssetDatabase.GetAssetPath(metallicMap))
: Path.GetDirectoryName(AssetDatabase.GetAssetPath(smoothnessMap));
string filename = metallicMap != null ? metallicMap.name : "black";
- string newPath = Path.Combine(directory, filename + "_metallicgloss.png");
+ string newPath = Path.Combine(directory, "metallic_gloss.png");
// Create new texture
int width = metallicMap != null ? metallicMap.width : smoothnessMap.width;
diff --git a/decals.cginc b/decals.cginc index ee4e1cd..f396b69 100644 --- a/decals.cginc +++ b/decals.cginc @@ -182,7 +182,7 @@ float4 getCmykWarpingPlanesColor(DecalParams params, float2 uv) { #define APPLY_DECAL_SDF_OFF(i, albedo, normal_tangent, metallic, smoothness, emission, params) \
float4 decal_albedo; \
{ \
- decal_albedo = params.mainTex.Sample(trilinear_repeat_s, decal_uv); \
+ decal_albedo = params.mainTex.SampleGrad(trilinear_repeat_s, decal_uv, ddx(raw_decal_uv), ddy(raw_decal_uv)); \
decal_albedo *= params.color; \
}
diff --git a/features.cginc b/features.cginc index c43e0bf..ec7cf35 100644 --- a/features.cginc +++ b/features.cginc @@ -393,6 +393,10 @@ #pragma shader_feature_local _OKLCH_CORRECTION //endex +//ifex _Oklab_Brightness_Clamp_Enabled==0 +#pragma shader_feature_local _OKLAB_BRIGHTNESS_CLAMP +//endex + //ifex _Grayscale_Lightmaps_Enabled==0 #pragma shader_feature_local _GRAYSCALE_LIGHTMAPS //endex diff --git a/globals.cginc b/globals.cginc index bffc566..ec88c60 100644 --- a/globals.cginc +++ b/globals.cginc @@ -607,4 +607,9 @@ float _Oklch_Correction_C; float _Oklch_Correction_H;
#endif // _OKLCH_CORRECTION
+#if defined(_OKLAB_BRIGHTNESS_CLAMP)
+float _Oklab_Brightness_Clamp_Min;
+float _Oklab_Brightness_Clamp_Max;
+#endif // _OKLAB_BRIGHTNESS_CLAMP
+
#endif // __GLOBALS_INC
diff --git a/yum_lighting.cginc b/yum_lighting.cginc index ade45ae..8920688 100644 --- a/yum_lighting.cginc +++ b/yum_lighting.cginc @@ -177,7 +177,12 @@ float3 yumSH9(float4 n, float3 worldPos, inout YumLighting light) { #if defined(_SPHERICAL_HARMONICS_L1) return LightVolumeEvaluate(n.xyz, light.L00, light.L01r, light.L01g, light.L01b); #else - return LightVolumeEvaluate(n.xyz, light.L00, 0, 0, 0); + [branch] + if (_UdonLightVolumeEnabled) { + return LightVolumeEvaluate(n.xyz, light.L00, light.L01r, light.L01g, light.L01b); + } else { + return LightVolumeEvaluate(n.xyz, light.L00, 0, 0, 0); + } #endif } diff --git a/yum_pbr.cginc b/yum_pbr.cginc index 76383c0..08bdd67 100644 --- a/yum_pbr.cginc +++ b/yum_pbr.cginc @@ -140,6 +140,12 @@ YumPbr GetYumPbr(v2f i, float3x3 tangentToWorld) { result.albedo.rgb = OKLCHtoLRGB(lch); #endif +#if defined(_OKLAB_BRIGHTNESS_CLAMP) + float3 lab = LRGBtoOKLAB(result.albedo.rgb); + lab.x = clamp(lab.x, _Oklab_Brightness_Clamp_Min, _Oklab_Brightness_Clamp_Max); + result.albedo.rgb = OKLABtoLRGB(lab); +#endif + result.normal = normalize(mul(normal_tangent, tangentToWorld)); #if (defined(FORWARD_BASE_PASS) || defined(FORWARD_ADD_PASS)) && defined(_GLITTER) |
