Drive parallax height and relief from the painted occlusion channel

Reuse the existing occlusion paint channel (no new map, MAP_COUNT stays 3):
0.5 is neutral, above 0.5 raises a hill, below 0.5 sinks a hole and also
fades ambient occlusion (saturate(2*occ)). Bind the MSO map to _ParallaxMap,
enable _PARALLAXMAP, derive a relief normal from the height gradient, and
reseed unpainted occlusion to 0.5 so untouched surfaces stay visually neutral.
Pin the _PARALLAXMAP runtime variant in the build keep-alive material.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 4.8 committed 2026-06-30 22:40:23 +02:00
1 parent e349446fb7
commit fdcb4f8d8a
6 files changed
+78 -13

No files matched your search

+7 -4
View File
@@ -130,9 +130,10 @@ public partial class MeshPainter : MonoBehaviour
[Range(0f, 1f)]
public float metallicSmoothnessOpacity = 1f;
[Tooltip("Ambient occlusion painted into the mask map (1 = fully lit / no darkening, " +
"0 = fully occluded / dark). NOTE: URP only darkens INDIRECT light (ambient + " +
"reflections), so the effect is subtle under strong direct lighting. 1 = no-op.")]
[Tooltip("Occlusion + HEIGHT painted into the mask map (one value, 0..1, 0.5 = neutral/no-op). " +
"Drives parallax + a relief normal: 0.5 = flat, >0.5 = raised hill, <0.5 = carved hole. " +
"Also drives ambient occlusion, but only the LOWER half darkens: 0.5..1 = fully lit, " +
"0.5..0 = AO fades 1..0 (so a hole is also darker). See Custom/PlayerCamoLit.")]
[Range(0f, 1f)]
public float occlusion = 0.5f;
@@ -284,7 +285,7 @@ public partial class MeshPainter : MonoBehaviour
// Seed colors per map in canonical (material) layout, built once at Start:
// albedo -> RGB color
// MSO -> R = metallic, G = occlusion (1 = unoccluded), A = smoothness (mask map)
// MSO -> R = metallic, G = occlusion/height (0.5 = neutral: no relief, AO = 1), A = smoothness
// emission -> RGB emission
private Color32[][] _seedCanonical;
@@ -322,6 +323,8 @@ public partial class MeshPainter : MonoBehaviour
private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor");
private static readonly int OcclusionMapId = Shader.PropertyToID("_OcclusionMap");
private static readonly int OcclusionStrengthId = Shader.PropertyToID("_OcclusionStrength");
private static readonly int ParallaxMapId = Shader.PropertyToID("_ParallaxMap");
private static readonly int ParallaxId = Shader.PropertyToID("_Parallax");
private static readonly int HalfLambertId = Shader.PropertyToID("_HalfLambert");
private static readonly int HalfLambertBrightnessId = Shader.PropertyToID("_HalfLambertBrightness");
private static readonly int SpecularDampenId = Shader.PropertyToID("_SpecularDampen");