// WL-816j2 — ③ 띠가 왜 안 보이나 (실측) · 물보다 뒤에 그려지는지 · 알파가 살아 있는지 using System.Collections; using System.Text; using UnityEngine; using UnityEngine.Rendering.Universal; using WL.Look.Farm; public static class WL816j2_Diag { public const string D = "Screenshots_WL/WL816j2/"; public static void Start() { var go = GameObject.Find("~WL816j2D"); if (go != null) Object.DestroyImmediate(go); go = new GameObject("~WL816j2D"); go.AddComponent(); } } public class WL816j2_DiagRunner : MonoBehaviour { static StringBuilder sb; static void L(string s) { sb.AppendLine(s); } const string D = WL816j2_Diag.D; const int PW = 1280, PH = 720; void Start() { StartCoroutine(Co()); } string Shot(Camera cam, string path) { System.IO.Directory.CreateDirectory(System.IO.Path.GetDirectoryName(path)); var rt = new RenderTexture(PW, PH, 24, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB); rt.antiAliasing = 1; rt.Create(); var pT = cam.targetTexture; var pA = RenderTexture.active; cam.targetTexture = rt; cam.Render(); RenderTexture.active = rt; var t = new Texture2D(PW, PH, TextureFormat.RGB24, false); t.ReadPixels(new Rect(0, 0, PW, PH), 0, 0); t.Apply(); RenderTexture.active = pA; cam.targetTexture = pT; rt.Release(); Object.DestroyImmediate(rt); System.IO.File.WriteAllBytes(path, t.EncodeToPNG()); var px = t.GetPixels32(); int white = 0; for (int i = 0; i < px.Length; i += 3) if (px[i].r > 205 && px[i].g > 200 && px[i].b > 200) white++; Object.DestroyImmediate(t); return "밝은픽셀 " + (300f * white / px.Length).ToString("F2") + "% → " + path; } IEnumerator Co() { sb = new StringBuilder(); L("=== WL-816j2 ③ 띠 진단 ==="); Renderer water = null; foreach (var r in Object.FindObjectsByType(FindObjectsInactive.Exclude, FindObjectsSortMode.None)) if (r != null && r.gameObject.scene.name == "Level01" && r.name == "Water") water = r; Camera live = null; foreach (var c in Object.FindObjectsByType(FindObjectsInactive.Exclude, FindObjectsSortMode.None)) { if (!c.gameObject.activeInHierarchy || !c.enabled || c.targetTexture != null) continue; if (c.name.StartsWith("~WL816")) continue; if (live == null || c.depth > live.depth) live = c; } var foam = Object.FindFirstObjectByType(FindObjectsInactive.Include); if (foam == null || water == null || live == null) { L("🔴 없음"); Done(); yield break; } var mr = foam.GetComponent(); var mf = foam.GetComponent(); var m = mr.sharedMaterial; L("띠 머티리얼 = " + m.name + " shader=" + m.shader.name + " renderQueue=" + m.renderQueue + " _Surface=" + m.GetFloat("_Surface") + " _ZWrite=" + m.GetFloat("_ZWrite") + " _SrcBlend=" + m.GetFloat("_SrcBlend") + " _DstBlend=" + m.GetFloat("_DstBlend") + " _BaseMap=" + (m.GetTexture("_BaseMap") ? m.GetTexture("_BaseMap").name : "없음") + " keyword_TRANSPARENT=" + m.IsKeywordEnabled("_SURFACE_TYPE_TRANSPARENT")); L("물 머티리얼 renderQueue = " + water.sharedMaterial.renderQueue); L("띠 메시 bounds = " + mf.sharedMesh.bounds + " · 렌더러 enabled=" + mr.enabled + " bounds=" + mr.bounds); // 카메라를 물가로 가까이 — 띠가 잘 보이는 확대 var cgo = new GameObject("~WL816j2DCam"); cgo.hideFlags = HideFlags.DontSave; var cam = cgo.AddComponent(); cam.fieldOfView = 34f; cam.nearClipPlane = 0.1f; cam.farClipPlane = 2000f; cam.clearFlags = CameraClearFlags.Skybox; cam.cullingMask = ~0; cam.depth = -100f; cgo.AddComponent().renderPostProcessing = true; var b = mr.bounds; cgo.transform.position = new Vector3(b.center.x, 3.2f, b.min.z - 9f); cgo.transform.LookAt(new Vector3(b.center.x, -1f, b.min.z + 2f)); L(""); L("1) 지금 그대로 " + Shot(cam, D + "g_diag_asis.png")); // ① 큐를 강제로 물 뒤로 var q = new Material(m); q.renderQueue = 3100; mr.sharedMaterial = q; yield return null; yield return null; L("2) renderQueue 3100 강제 " + Shot(cam, D + "g_diag_q3100.png")); // ② 물을 끄고 띠만 water.enabled = false; yield return null; yield return null; L("3) 물 끄고 띠만 " + Shot(cam, D + "g_diag_bandonly.png")); water.enabled = true; yield return null; // ③ 알파 무시하고 불투명 빨강 — 띠 메시가 어디에 있는지 var dbg = new Material(Shader.Find("Universal Render Pipeline/Unlit")); dbg.SetColor("_BaseColor", new Color(1f, 0f, 0f, 1f)); dbg.renderQueue = 3100; mr.sharedMaterial = dbg; yield return null; yield return null; L("4) 띠 메시 위치(빨강) " + Shot(cam, D + "g_diag_red.png")); L(" PD 구도에서도 " + Shot(live, D + "g_diag_red_pd.png")); mr.sharedMaterial = q; yield return null; L("5) 큐 3100 · PD 구도 " + Shot(live, D + "g_diag_q3100_pd.png")); Object.DestroyImmediate(cgo); Done(); } void Done() { System.IO.File.WriteAllText("AgentScripts/WL816j2_DIAG.txt", sb.ToString()); Debug.Log("[816j2 diag]\n" + sb); } }