summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-03-26 00:40:45 -0700
committeryum <yum.food.vr@gmail.com>2025-03-26 00:40:45 -0700
commit36dbdde9a08c66c5be2e8b8b6c822968a73041b6 (patch)
treedf26dbd531b8a665c0af4f38dfd3f78e7e5b1ddb
parent70f30643e6c392535cfbf0b82054bd4b53868833 (diff)
Fix how outlines work with shatterwave & tessellation heightmap
-rw-r--r--math.cginc2
-rw-r--r--tessellation.cginc12
-rw-r--r--yum_brdf.cginc3
-rw-r--r--yum_lighting.cginc12
4 files changed, 20 insertions, 9 deletions
diff --git a/math.cginc b/math.cginc
index 78b93ec..8d404d9 100644
--- a/math.cginc
+++ b/math.cginc
@@ -194,7 +194,7 @@ float3 blendNormalsHill12(float3 n0, float3 n1) {
return normalize(n0 * dot(n0, n1) - n1 * n0.z);
}
-float3 luminance(float3 color) {
+float luminance(float3 color) {
return dot(color, float3(0.2126, 0.7152, 0.0722));
}
diff --git a/tessellation.cginc b/tessellation.cginc
index 8ba2595..faadd72 100644
--- a/tessellation.cginc
+++ b/tessellation.cginc
@@ -62,15 +62,25 @@ v2f domain(
o.uv01 = DOMAIN_INTERP(uv01);
#if defined(_TESSELLATION) && defined(_SHATTER_WAVE)
+#if defined(OUTLINE_PASS)
+ shatterWaveVert(o.objPos.xyz, -o.normal, o.tangent);
+#else
shatterWaveVert(o.objPos.xyz, o.normal, o.tangent);
#endif
+#endif
#if defined(_TESSELLATION_HEIGHTMAP)
float height = _Tessellation_Heightmap.SampleLevel(linear_repeat_s,
o.uv01.xy * _Tessellation_Heightmap_ST.xy + _Tessellation_Heightmap_ST.zw, 0).r *
- _Tessellation_Heightmap_Scale + _Tessellation_Heightmap_Offset;
+ _Tessellation_Heightmap_Scale +
+ _Tessellation_Heightmap_Offset -
+ _Tessellation_Heightmap_Scale * 0.5;
+#if defined(OUTLINE_PASS)
+ o.objPos.xyz += -o.normal * height;
+#else
o.objPos.xyz += o.normal * height;
#endif
+#endif
o.pos = UnityObjectToClipPos(o.objPos);
o.worldPos = mul(unity_ObjectToWorld, float4(o.objPos, 1.0)).xyz;
diff --git a/yum_brdf.cginc b/yum_brdf.cginc
index db37397..9bc01bf 100644
--- a/yum_brdf.cginc
+++ b/yum_brdf.cginc
@@ -116,8 +116,7 @@ float4 YumBRDF(v2f i, const YumLighting light, YumPbr pbr) {
// Simple indirect lighting for cloth
// Add additional corrective term to account for the fact that vrchat map
// makers suck shit and don't use enough reflection probes.
- float diffuse_luminosity = dot(light.diffuse, float3(0.2126, 0.7152, 0.0722));
- float3 Fr = _Cloth_Sheen_Color * light.specular * diffuse_luminosity;
+ float3 Fr = _Cloth_Sheen_Color * light.specular * light.diffuse_luminance;
float3 Fd = pbr.albedo * light.diffuse * pbr.ao;
#if defined(_MATERIAL_TYPE_CLOTH_SUBSURFACE)
diff --git a/yum_lighting.cginc b/yum_lighting.cginc
index 0b4e077..5e627d5 100644
--- a/yum_lighting.cginc
+++ b/yum_lighting.cginc
@@ -47,6 +47,7 @@ struct YumLighting {
float3 dir;
float3 direct;
float3 diffuse;
+ float diffuse_luminance;
float3 specular;
float NoL;
#if defined(_WRAPPED_LIGHTING)
@@ -103,7 +104,7 @@ float GetLodRoughness(float roughness) {
return roughness * (1.7 - 0.7 * roughness);
}
-float3 getIndirectSpecular(v2f i, YumPbr pbr, float3 view_dir) {
+float3 getIndirectSpecular(v2f i, YumPbr pbr, float3 view_dir, float diffuse_luminance) {
float roughness = GetLodRoughness(pbr.roughness_perceptual);
float3 reflect_dir = reflect(-view_dir, pbr.normal);
@@ -135,7 +136,7 @@ float3 getIndirectSpecular(v2f i, YumPbr pbr, float3 view_dir) {
half mip = roughness * UNITY_SPECCUBE_LOD_STEPS;
float4 envSample = UNITY_SAMPLE_TEXCUBE_LOD(_Fallback_Cubemap, reflectVector, mip);
- return DecodeHDR(envSample, _Fallback_Cubemap_HDR) * _Fallback_Cubemap_Brightness;
+ return DecodeHDR(envSample, _Fallback_Cubemap_HDR) * _Fallback_Cubemap_Brightness * diffuse_luminance;
}
#endif
@@ -215,7 +216,8 @@ YumLighting GetYumLighting(v2f i, YumPbr pbr) {
light.diffuse = max(_Min_Brightness, light.diffuse);
#endif
- light.specular = getIndirectSpecular(i, pbr, light.view_dir);
+ light.diffuse_luminance = luminance(light.diffuse);
+ light.specular = getIndirectSpecular(i, pbr, light.view_dir, light.diffuse_luminance);
#if defined(_LTCGI)
ltcgi_acc acc = (ltcgi_acc) 0;
@@ -235,8 +237,8 @@ YumLighting GetYumLighting(v2f i, YumPbr pbr) {
light.specular = light.specular * floor(specular_luminance * _Quantize_Specular_Steps) / _Quantize_Specular_Steps;
#endif
#if defined(_QUANTIZE_DIFFUSE)
- float diffuse_luminance = luminance(light.diffuse);
- light.diffuse = light.diffuse * floor(diffuse_luminance * _Quantize_Diffuse_Steps) / _Quantize_Diffuse_Steps;
+ light.diffuse = light.diffuse * floor(light.diffuse_luminance * _Quantize_Diffuse_Steps) / _Quantize_Diffuse_Steps;
+ light.diffuse_luminance = luminance(light.diffuse);
#endif
#if defined(_BRIGHTNESS_CONTROL)