Project_WL/AgentScripts/WL816j2_Sweep2.cs

111 lines
4.9 KiB
C#
Raw Normal View History

// WL-816j2 — ⑦ 격자선을 「금 간 유리」가 아니게: FoamColor 후보 + 무늬를 더 잘게 (PD 구도)
using System.Collections;
using System.Text;
using UnityEngine;
public static class WL816j2_Sweep2
{
public const string D = "Screenshots_WL/WL816j2/";
public static void Start()
{
var go = GameObject.Find("~WL816j2S2");
if (go != null) Object.DestroyImmediate(go);
go = new GameObject("~WL816j2S2");
go.AddComponent<WL816j2_Sweep2Runner>();
}
}
public class WL816j2_Sweep2Runner : MonoBehaviour
{
static StringBuilder sb;
static void L(string s) { sb.AppendLine(s); }
const string D = WL816j2_Sweep2.D;
const int PW = 1280, PH = 720;
const string C_Light = "Color_1ec6cccf8ead489ebb917674f7e8b3b1";
const string C_Water = "Color_9af4ad59934f40d1ae6565e6ab22c45e";
const string C_Foam = "Color_e1f155248d144786a62fc1585ca21e9a";
const string C_FoamShadow = "Color_2323d69962e04c499c5d5f0925432b55";
const string R_Size = "Vector1_07238257334b4a149e675e2451801030";
const string R_Strength = "Vector1_99cc56b5c6fd474082f07f00a6df94f9";
const string R_Speed = "Vector1_8e22a98f75c94b218c49e6c4805e799d";
const string R_NoiseSpeed = "Vector1_ad7e0fcd37f44d68b68de6f06bb43b96";
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();
long r = 0, g = 0, b = 0; int n = 0;
for (int y = 20; y < 320; y += 2)
for (int x = 20; x < 340; x += 2) { var c = px[y * PW + x]; r += c.r; g += c.g; b += c.b; n++; }
Object.DestroyImmediate(t);
return "바다 평균 #" + ((int)(r / n)).ToString("X2") + ((int)(g / n)).ToString("X2") + ((int)(b / n)).ToString("X2") + " → " + path;
}
static void Cell(Material m, float cellM)
{
float size = 1000f / (cellM * 6f);
m.SetFloat(R_Size, size);
m.SetFloat(R_Strength, 0.3085f / size);
m.SetFloat(R_Speed, 0.8f * size / 1000f);
m.SetFloat(R_NoiseSpeed, 0.8f * size / 1000f);
}
IEnumerator Co()
{
sb = new StringBuilder();
L("=== WL-816j2 ⑦ FoamColor 후보 + 무늬 잘게 ===");
Renderer water = null;
foreach (var r in Object.FindObjectsByType<Renderer>(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<Camera>(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;
}
if (water == null || live == null) { L("🔴 없음"); Done(); yield break; }
var E = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>("Assets/WL/Look/Farm/Materials/Farm_Water_WL_E.mat");
Color W = E.GetColor(C_Water);
var soft = new Color(0.42f, 0.72f, 0.845f, 1f);
var names = new[]
{
"0 Light 부드럽게(2.5 m)",
"1 + FoamColor = 물색",
"2 + FoamColor = 물색 · 1.5 m",
"3 + FoamColor = 물색 · 1.0 m",
"4 FoamColor 흰색 · 1.0 m",
"5 + FoamColor = 물색 · 0.6 m",
"6 FoamColor=물색 · Shadow=흰색 · Light=물색 · 1.0 m (선 최소)",
};
for (int i = 0; i < names.Length; i++)
{
var m = new Material(E);
m.SetColor(C_Light, soft);
if (i >= 1 && i != 4) m.SetColor(C_Foam, W);
if (i == 2) Cell(m, 1.5f);
if (i == 3 || i == 4) Cell(m, 1.0f);
if (i == 5) Cell(m, 0.6f);
if (i == 6) { Cell(m, 1.0f); m.SetColor(C_Foam, W); m.SetColor(C_FoamShadow, Color.white); m.SetColor(C_Light, W); }
water.sharedMaterial = m; yield return null; yield return new WaitForSeconds(0.25f);
L(names[i] + " · " + Shot(live, D + "n_s2_" + i + ".png"));
}
Done();
}
void Done()
{
System.IO.File.WriteAllText("AgentScripts/WL816j2_SWEEP2.txt", sb.ToString());
Debug.Log("[816j2 sweep2]\n" + sb);
}
}