diff --git a/client/tools/garment_qa/chromakey_scene.gd b/client/tools/garment_qa/chromakey_scene.gd index 37ebc1fd7..084071069 100644 --- a/client/tools/garment_qa/chromakey_scene.gd +++ b/client/tools/garment_qa/chromakey_scene.gd @@ -118,10 +118,15 @@ func _make_key_material() -> ShaderMaterial: return mat -## Flat unshaded cyan whose vertices are nudged `shift` metres toward the camera in -## view space (pass B). Cull is left default so only camera-facing cloth counts as the -## near layer — a far back panel shifted epsilon closer is still far and won't cover the -## body-key. Works on skinned garments: VERTEX arrives already skinned in model space. +## Flat unshaded cyan garment with a DEPTH-ONLY bias of `shift` metres toward the camera +## (pass B). The screen x/y is kept exactly (clip_orig.xy) while the NDC depth is taken +## from the epsilon-nearer vertex — so the garment renders at its true silhouette but +## depth-tests as if `shift` closer. This biases depth WITHOUT the ~1.25% silhouette +## magnification a plain view-space translation would cause, so skin merely BESIDE a +## cloth edge is not falsely covered — only skin the garment actually projects over +## (i.e. cloth truly behind it) and within epsilon flips to cyan. Cull is left default +## so a far back panel (shifted epsilon closer, still far) won't cover the body-key. +## Works on skinned garments: VERTEX arrives already skinned in model space. func _make_shift_material(epsilon: float) -> ShaderMaterial: var shader := Shader.new() shader.code = ( @@ -130,8 +135,12 @@ func _make_shift_material(epsilon: float) -> ShaderMaterial: + "uniform float shift = 0.03;\n" + "void vertex() {\n" + "\tvec4 view_pos = MODELVIEW_MATRIX * vec4(VERTEX, 1.0);\n" - + "\tview_pos.z += shift;\n" # camera looks down -Z; +Z is toward the camera - + "\tPOSITION = PROJECTION_MATRIX * view_pos;\n" + + "\tvec4 clip_orig = PROJECTION_MATRIX * view_pos;\n" + + "\tvec4 view_near = view_pos;\n" + + "\tview_near.z += shift;\n" # camera looks down -Z; +Z is toward the camera + + "\tvec4 clip_near = PROJECTION_MATRIX * view_near;\n" + + "\tfloat ndc_z_near = clip_near.z / clip_near.w;\n" + + "\tPOSITION = vec4(clip_orig.x, clip_orig.y, ndc_z_near * clip_orig.w, clip_orig.w);\n" + "}\n" + "void fragment() {\n" + "\tALBEDO = vec3(0.0, 1.0, 1.0);\n" diff --git a/tooling/garment-qa/configs/peasant.json b/tooling/garment-qa/configs/peasant.json index e8af2a240..4fc4f8705 100644 --- a/tooling/garment-qa/configs/peasant.json +++ b/tooling/garment-qa/configs/peasant.json @@ -7,6 +7,7 @@ "clips": ["Walk", "Sprint", "Crouch_Fwd"], "frames_per_clip": 3, "yaws": [0, 90, 180, 270], + "clip_epsilon_m": 0.03, "head_id": "head_001", "hair_id": "buzzed", "eyebrow_id": "regular",