Hologram calls, HaulOS phone, Enhanced lighting, smoother camera; Blender remaster review files
Game: - Assistant and Director portraits: GPT backgrounds and a holographic appear/disappear shader (Talk/TalkHolo) instead of on/off - Phone redesigned (HaulOS home, address bar, dock, error/loading states) and the browser link made sturdier - Settings > Graphics > Lighting: Classic / Enhanced (runtime volume, no project assets changed); Enhanced SSAO uses the smooth interleaved-gradient method at high samples so flat panels don't speckle - Painted board textures (T_HullPanel, T_BarnRed) keep only edge wear: the big bare-wood patches read as dirty smudges - The head leans into a sidestep smoothly instead of snapping with A / D - New keys in all 11 languages Review only (nothing swapped into the game yet): ArtSource/Blender/remaster (v1 paint pass of our own models, Synty-built ones left out), remaster/crew (crew repaint with arm, colour-edge and face fixes), remaster_v2 (smooth-geometry pilot). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -1653,6 +1653,9 @@ namespace GrassCutter
|
||||
float wait = Time.time;
|
||||
while (Time.time - wait < 8f && !(Phone.I && Phone.I.Mode != PhoneMode.Away)) yield return null;
|
||||
if (Phone.I) Phone.I.Show(PhoneMode.Up);
|
||||
// the hologram coming in
|
||||
yield return new WaitForSeconds(0.35f);
|
||||
yield return Shot("c00_call_appearing");
|
||||
(float at, string name)[] marks = { (1.5f, "c01"), (3f, "c02"), (6f, "c03"), (9f, "c04"), (13f, "c05"), (20f, "c06") };
|
||||
float t0 = Time.time;
|
||||
foreach (var (at, name) in marks)
|
||||
@ -1666,12 +1669,17 @@ namespace GrassCutter
|
||||
foreach (var line in new[] { "asst_twister", "asst_meteors" })
|
||||
{
|
||||
Assistant.Say(line);
|
||||
yield return new WaitForSeconds(1.4f);
|
||||
yield return new WaitForSeconds(0.45f);
|
||||
yield return Shot("c09_" + line + "_appearing");
|
||||
yield return new WaitForSeconds(0.95f);
|
||||
yield return Shot("c10_" + line);
|
||||
yield return Booths("c10_" + line);
|
||||
yield return new WaitForSeconds(0.9f);
|
||||
yield return Booths("c11_" + line);
|
||||
while (Assistant.Busy) yield return null;
|
||||
// and going out
|
||||
yield return new WaitForSeconds(0.2f);
|
||||
yield return Shot("c12_" + line + "_leaving");
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
}
|
||||
UIRoot.I.OpenSettings();
|
||||
|
||||
@ -90,6 +90,8 @@ namespace GrassCutter
|
||||
/// <summary>Blades of grass drawn: 0 fewer, 1 more, 2 all.</summary>
|
||||
public static int GrassDetail { get => PlayerPrefs.GetInt("s_grass", PGrass[P]); set => SetOwn("s_grass", value); }
|
||||
public static bool Bloom { get => PlayerPrefs.GetInt("s_bloom", PBloom[P]) == 1; set => SetOwn("s_bloom", value ? 1 : 0); }
|
||||
/// <summary>LightingStyle: 0 the classic look, 1 enhanced (the default). Not part of the quality presets.</summary>
|
||||
public static int Lighting { get => Mathf.Clamp(PlayerPrefs.GetInt("s_light", LightingStyle.Enhanced), 0, 1); set { PlayerPrefs.SetInt("s_light", value); ApplyGraphics(); } }
|
||||
|
||||
/// <summary>A single row changed: the others keep what they show, and the preset becomes the player's own mix.</summary>
|
||||
static void SetOwn(string key, float v)
|
||||
@ -131,7 +133,7 @@ namespace GrassCutter
|
||||
{
|
||||
new[] { "s_shake", "s_bob", "s_tips", "s_hints" },
|
||||
new[] { "s_dmode", "s_fs", "s_resw", "s_resh", "s_vsync", "s_fpscap", "s_fov", "s_bright" },
|
||||
new[] { "s_quality", "s_rscale", "s_shadows", "s_msaa", "s_grass", "s_bloom" },
|
||||
new[] { "s_quality", "s_rscale", "s_shadows", "s_msaa", "s_grass", "s_bloom", "s_light" },
|
||||
new[] { "s_master", "s_music", "s_sfx", "s_voice", "s_phone", "s_bgsound" },
|
||||
new[] { "s_sens", "s_padsens", "s_invy", "s_sprinttog" },
|
||||
};
|
||||
@ -244,6 +246,7 @@ namespace GrassCutter
|
||||
s_rp.mainLightShadowmapResolution = new[] { 1024, 1024, 2048, 2048, 4096 }[sh];
|
||||
s_rp.msaaSampleCount = new[] { 1, 2, 4, 8 }[Mathf.Clamp(Antialias, 0, 3)];
|
||||
}
|
||||
LightingStyle.Apply();
|
||||
GrassField.Detail = new[] { 0.5f, 0.75f, 1f }[Mathf.Clamp(GrassDetail, 0, 2)];
|
||||
ApplyBloom();
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ namespace GrassCutter
|
||||
/// </summary>
|
||||
public class PhoneWeb
|
||||
{
|
||||
const int TallW = 390, WideH = 390, FrameTall = 540, FrameWide = 1120;
|
||||
const int TallW = 390, WideH = 390, FrameTall = 640, FrameWide = 1120;
|
||||
const int Retries = 4;
|
||||
// our eyes in every document and frame: the game's volume, quiet when the phone goes away, and new windows in the one tab
|
||||
const string Keep =
|
||||
@ -64,6 +64,7 @@ namespace GrassCutter
|
||||
public readonly CancellationTokenSource Stop = new CancellationTokenSource();
|
||||
public readonly BlockingCollection<string> Out = new BlockingCollection<string>();
|
||||
public volatile bool Ready;
|
||||
public bool Dressed;
|
||||
}
|
||||
|
||||
/// <summary>A frame on its way to the screen. Reused: at 30 a second, fresh arrays of half a megabyte would be a garbage collection a second.</summary>
|
||||
@ -114,8 +115,9 @@ namespace GrassCutter
|
||||
_mute = CommandLine.Has("-autodemo");
|
||||
_profile = Path.Combine(_mute ? Application.temporaryCachePath : Application.persistentDataPath, "PhoneWeb");
|
||||
_decoded = new Texture2D(FrameTall, FrameTall, TextureFormat.RGB24, false);
|
||||
_rt = new RenderTexture(1024, 1024, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB) { name = "PhoneWeb" };
|
||||
_rt = new RenderTexture(FrameTall, FrameTall * _pageH / TallW, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB) { name = "PhoneWeb" };
|
||||
_rt.Create();
|
||||
ClearPicture();
|
||||
}
|
||||
|
||||
// ───────────────────────── what the phone asks of it ─────────────────────────
|
||||
@ -130,6 +132,7 @@ namespace GrassCutter
|
||||
_pending = url;
|
||||
_loading = true;
|
||||
_restarts = 0;
|
||||
ClearPicture();
|
||||
Boot();
|
||||
}
|
||||
|
||||
@ -140,9 +143,31 @@ namespace GrassCutter
|
||||
_pending = _wanted = _last = null;
|
||||
_loading = false;
|
||||
_url = null;
|
||||
ClearPicture();
|
||||
if (Ready) Cmd("Page.navigate", "{\"url\":\"about:blank\"}");
|
||||
}
|
||||
|
||||
/// <summary>Black, so the last site's last frame isn't what the next one opens on.</summary>
|
||||
void ClearPicture()
|
||||
{
|
||||
var was = RenderTexture.active;
|
||||
RenderTexture.active = _rt;
|
||||
GL.Clear(false, true, Color.black);
|
||||
RenderTexture.active = was;
|
||||
var s = Interlocked.Exchange(ref _shot, null);
|
||||
if (s != null) Ack(s);
|
||||
}
|
||||
|
||||
public void Stop() { if (Ready) { Cmd("Page.stopLoading"); _loading = false; } }
|
||||
|
||||
/// <summary>Something else has the phone's screen (a call): whatever plays on the page is paused under it.</summary>
|
||||
public bool Hold
|
||||
{
|
||||
get => _hold;
|
||||
set { if (_hold != value) { _hold = value; _nextState = 0f; } }
|
||||
}
|
||||
bool _hold;
|
||||
|
||||
public void Back() { if (Ready) Cmd("Runtime.evaluate", "{\"expression\":\"void history.back()\"}"); }
|
||||
public void Forward() { if (Ready) Cmd("Runtime.evaluate", "{\"expression\":\"void history.forward()\"}"); }
|
||||
public void Reload() { if (Ready) { _loading = true; Cmd("Page.reload"); } }
|
||||
@ -160,14 +185,15 @@ namespace GrassCutter
|
||||
{
|
||||
if (_wide == on) return;
|
||||
_wide = on;
|
||||
ClearPicture();
|
||||
if (Ready) { Metrics(); if (_shown) { Cmd("Page.stopScreencast"); Screencast(true); } }
|
||||
}
|
||||
|
||||
void Screencast(bool on)
|
||||
{
|
||||
if (on) Cmd("Page.startScreencast", _wide
|
||||
? $"{{\"format\":\"jpeg\",\"quality\":62,\"maxWidth\":{FrameWide},\"maxHeight\":{FrameWide * WideH / _fullW},\"everyNthFrame\":1}}"
|
||||
: $"{{\"format\":\"jpeg\",\"quality\":58,\"maxWidth\":{FrameTall},\"maxHeight\":{FrameTall * _pageH / TallW},\"everyNthFrame\":1}}");
|
||||
? $"{{\"format\":\"jpeg\",\"quality\":70,\"maxWidth\":{FrameWide},\"maxHeight\":{FrameWide * WideH / _fullW},\"everyNthFrame\":1}}"
|
||||
: $"{{\"format\":\"jpeg\",\"quality\":68,\"maxWidth\":{FrameTall},\"maxHeight\":{FrameTall * _pageH / TallW},\"everyNthFrame\":1}}");
|
||||
else Cmd("Page.stopScreencast");
|
||||
}
|
||||
|
||||
@ -226,7 +252,10 @@ namespace GrassCutter
|
||||
}
|
||||
|
||||
/// <summary>The mouse wheel, one notch at a time. Positive is on down the page.</summary>
|
||||
public void Wheel(int dir)
|
||||
public void Wheel(int dir) => Wheel(dir, CssW / 2f, CssH / 2f);
|
||||
|
||||
/// <summary>The wheel over a point of the page: what's under it scrolls (a chat beside a stream, a list in a menu).</summary>
|
||||
public void Wheel(int dir, float x, float y)
|
||||
{
|
||||
if (!Ready) return;
|
||||
if (OnFeed)
|
||||
@ -236,23 +265,30 @@ namespace GrassCutter
|
||||
Flick(dir);
|
||||
return;
|
||||
}
|
||||
Cmd("Input.dispatchMouseEvent", string.Format(CultureInfo.InvariantCulture, "{{\"type\":\"mouseWheel\",\"x\":{0},\"y\":{1},\"deltaX\":0,\"deltaY\":{2}}}", CssW / 2, CssH / 2, dir * 260));
|
||||
Cmd("Input.dispatchMouseEvent", string.Format(CultureInfo.InvariantCulture, "{{\"type\":\"mouseWheel\",\"x\":{0:0.#},\"y\":{1:0.#},\"deltaX\":0,\"deltaY\":{2}}}", x, y, dir * 220));
|
||||
}
|
||||
|
||||
public void Insert(string text) { if (Ready) Cmd("Input.insertText", "{\"text\":" + Str(text) + "}"); }
|
||||
|
||||
public void Key(string name, int code, string text)
|
||||
/// <param name="modifiers">CDP's: 1 Alt, 2 Ctrl, 4 Meta, 8 Shift.</param>
|
||||
public void Key(string name, int code, string text, int modifiers = 0)
|
||||
{
|
||||
if (!Ready) return;
|
||||
string common = $"\"key\":\"{name}\",\"code\":\"{name}\",\"windowsVirtualKeyCode\":{code}";
|
||||
string common = $"\"key\":\"{name}\",\"code\":\"{name}\",\"windowsVirtualKeyCode\":{code},\"modifiers\":{modifiers}";
|
||||
Cmd("Input.dispatchKeyEvent", "{\"type\":\"" + (text != null ? "keyDown" : "rawKeyDown") + "\"," + common + (text != null ? ",\"text\":\"" + text + "\"" : "") + "}");
|
||||
Cmd("Input.dispatchKeyEvent", "{\"type\":\"keyUp\"," + common + "}");
|
||||
}
|
||||
|
||||
/// <summary>An editing command on the focused text box: selectAll, undo, redo.</summary>
|
||||
public void Command(string name)
|
||||
{
|
||||
if (Ready) Cmd("Input.dispatchKeyEvent", "{\"type\":\"rawKeyDown\",\"key\":\"\",\"windowsVirtualKeyCode\":0,\"commands\":[\"" + name + "\"]}");
|
||||
}
|
||||
|
||||
/// <summary>Is the page waiting for typing?</summary>
|
||||
public async Task<bool> FieldActive()
|
||||
{
|
||||
const string js = "(()=>{const e=document.activeElement;return String(!!e&&(e.isContentEditable||e.tagName==='TEXTAREA'||e.tagName==='IFRAME'||(e.tagName==='INPUT'&&!/^(checkbox|radio|button|submit|range|file)$/.test(e.type))))})()";
|
||||
const string js = "(()=>{const e=document.activeElement;return String(!!e&&(e.isContentEditable||e.tagName==='TEXTAREA'||(e.tagName==='INPUT'&&!/^(checkbox|radio|button|submit|range|file)$/.test(e.type))))})()";
|
||||
return await Ask(js) == "true";
|
||||
}
|
||||
|
||||
@ -288,6 +324,13 @@ namespace GrassCutter
|
||||
_link = null;
|
||||
}
|
||||
if (_died) Revive();
|
||||
if (Ready && !_link.Dressed)
|
||||
{
|
||||
// the page's shape and the frames, as they are now: a Show or a turn while it started can't be lost
|
||||
_link.Dressed = true;
|
||||
Metrics();
|
||||
if (_shown) Screencast(true);
|
||||
}
|
||||
if (Ready)
|
||||
{
|
||||
if (_pending != null)
|
||||
@ -314,6 +357,14 @@ namespace GrassCutter
|
||||
float started = Time.realtimeSinceStartup;
|
||||
if (_decoded.LoadImage(s.Jpeg, false))
|
||||
{
|
||||
// the texture takes the frame's own size: no squeezing a 1120-wide frame into less and back
|
||||
if (_rt.width != _decoded.width || _rt.height != _decoded.height)
|
||||
{
|
||||
_rt.Release();
|
||||
_rt.width = _decoded.width;
|
||||
_rt.height = _decoded.height;
|
||||
_rt.Create();
|
||||
}
|
||||
Graphics.Blit(_decoded, _rt);
|
||||
Fresh = true;
|
||||
}
|
||||
@ -361,7 +412,7 @@ namespace GrassCutter
|
||||
if (Time.unscaledTime < _nextState) return;
|
||||
_nextState = Time.unscaledTime + 0.5f;
|
||||
string v = (GameSettings.Master * GameSettings.PhoneVolume).ToString("0.00", CultureInfo.InvariantCulture);
|
||||
Cmd("Runtime.evaluate", "{\"expression\":\"void(window.__gc&&(__gc.vol=" + v + ",__gc.hold=" + (_shown ? "false" : "true") + "))\"}");
|
||||
Cmd("Runtime.evaluate", "{\"expression\":\"void(window.__gc&&(__gc.vol=" + v + ",__gc.hold=" + (_shown && !_hold ? "false" : "true") + "))\"}");
|
||||
}
|
||||
|
||||
void Revive()
|
||||
@ -393,7 +444,7 @@ namespace GrassCutter
|
||||
foreach (var root in new[] { pf86, pf, local })
|
||||
{
|
||||
if (string.IsNullOrEmpty(root)) continue;
|
||||
foreach (var exe in new[] { @"Microsoft\Edge\Application\msedge.exe", @"Google\Chrome\Application\chrome.exe" })
|
||||
foreach (var exe in new[] { @"Microsoft\Edge\Application\msedge.exe", @"Google\Chrome\Application\chrome.exe", @"BraveSoftware\Brave-Browser\Application\brave.exe", @"Chromium\Application\chrome.exe" })
|
||||
{
|
||||
var path = Path.Combine(root, exe);
|
||||
if (File.Exists(path)) return path;
|
||||
@ -440,7 +491,7 @@ namespace GrassCutter
|
||||
if (port == null) throw new TimeoutException("The browser didn't start.");
|
||||
|
||||
string ws, ua, chrome;
|
||||
using (var http = new HttpClient(new HttpClientHandler { UseProxy = false }))
|
||||
using (var http = new HttpClient(new HttpClientHandler { UseProxy = false }) { Timeout = TimeSpan.FromSeconds(10) })
|
||||
{
|
||||
// the debug server hangs up after each answer, so no reusing the connection
|
||||
http.DefaultRequestHeaders.ConnectionClose = true;
|
||||
@ -461,7 +512,11 @@ namespace GrassCutter
|
||||
|
||||
link.Ws = new ClientWebSocket();
|
||||
link.Ws.Options.Proxy = null;
|
||||
await link.Ws.ConnectAsync(new Uri(ws), link.Stop.Token);
|
||||
using (var limit = CancellationTokenSource.CreateLinkedTokenSource(link.Stop.Token))
|
||||
{
|
||||
limit.CancelAfter(TimeSpan.FromSeconds(10));
|
||||
await link.Ws.ConnectAsync(new Uri(ws), limit.Token);
|
||||
}
|
||||
_ = Task.Run(() => Sender(link));
|
||||
_ = Task.Run(() => Receiver(link));
|
||||
|
||||
@ -478,8 +533,6 @@ namespace GrassCutter
|
||||
int win = Interlocked.Increment(ref _id);
|
||||
_winAsk = win;
|
||||
Send(link, "{\"id\":" + win + ",\"method\":\"Browser.getWindowForTarget\",\"params\":{}}");
|
||||
Metrics();
|
||||
if (_shown) Screencast(true);
|
||||
link.Ready = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -609,7 +662,13 @@ namespace GrassCutter
|
||||
}
|
||||
else if (m.method == "Page.frameNavigated")
|
||||
{
|
||||
if (string.IsNullOrEmpty(m.@params?.frame?.parentId)) _url = m.@params?.frame?.url;
|
||||
if (string.IsNullOrEmpty(m.@params?.frame?.parentId))
|
||||
{
|
||||
var u = m.@params?.frame?.url;
|
||||
// the blank page from going home, landing after the next site was asked for
|
||||
if (u == "about:blank" && (_wanted != null || _pending != null)) return;
|
||||
_url = u;
|
||||
}
|
||||
}
|
||||
else if (m.method == "Page.navigatedWithinDocument") _url = m.@params?.url;
|
||||
else if (m.method == "Page.frameStartedLoading") { if (m.@params?.frameId == link.Tab) _loading = true; }
|
||||
@ -660,8 +719,10 @@ namespace GrassCutter
|
||||
_died = true;
|
||||
}
|
||||
|
||||
/// <summary>Closed properly, so the logins from this session make it to disk.</summary>
|
||||
public void Close()
|
||||
/// <summary>Closed properly, so the logins from this session make it to disk. The game doesn't wait for it, unless it's quitting.</summary>
|
||||
public void Close() => Close(true);
|
||||
|
||||
public void Close(bool quitting)
|
||||
{
|
||||
Application.quitting -= Close;
|
||||
var link = _link;
|
||||
@ -675,6 +736,15 @@ namespace GrassCutter
|
||||
{
|
||||
link.Ready = false;
|
||||
Send(link, "Browser.close", "{}");
|
||||
if (!quitting)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
try { link.Proc?.WaitForExit(4000); } catch (InvalidOperationException) { }
|
||||
Drop(link);
|
||||
});
|
||||
return;
|
||||
}
|
||||
try { link.Proc?.WaitForExit(1500); } catch (InvalidOperationException) { }
|
||||
}
|
||||
Drop(link);
|
||||
|
||||
@ -84,6 +84,13 @@ namespace GrassCutter
|
||||
|
||||
public void Bind(PlayerAgent p) { _p = p; }
|
||||
|
||||
/// <summary>The scene goes (back to the menu): the browser goes with it.</summary>
|
||||
void OnDestroy()
|
||||
{
|
||||
Screen?.Close();
|
||||
if (I == this) I = null;
|
||||
}
|
||||
|
||||
/// <summary>The match is over: the phone goes away, and the browser with it.</summary>
|
||||
public void Unbind()
|
||||
{
|
||||
@ -132,7 +139,7 @@ namespace GrassCutter
|
||||
if (Ctl.PhoneUpPressed) Show(_mode == PhoneMode.Up ? PhoneMode.Side : PhoneMode.Up);
|
||||
if (Ctl.PhoneTurnPressed) Screen.Turn();
|
||||
float w = Ctl.PhoneWheel;
|
||||
if (w != 0f) Screen.Wheel(w < 0f ? 1 : -1);
|
||||
if (w != 0f) Screen.Wheel(w < 0f ? 1 : -1, _mode == PhoneMode.Up ? ScreenToPhone(Ctl.Pointer) : new Vector2(-1f, -1f));
|
||||
if (_mode == PhoneMode.Up)
|
||||
{
|
||||
var uv = ScreenToPhone(Ctl.Pointer);
|
||||
|
||||
@ -152,7 +152,7 @@ namespace GrassCutter
|
||||
CameraFx.FovTarget(_vel.magnitude > 12f ? 7f : 0f);
|
||||
}
|
||||
|
||||
float _coyote, _jumpBuffer, _bobPhase, _stepAcc, _landDip, _airTime;
|
||||
float _coyote, _jumpBuffer, _bobPhase, _stepAcc, _landDip, _airTime, _lean;
|
||||
bool _wasGrounded = true;
|
||||
|
||||
void Awake()
|
||||
@ -421,7 +421,11 @@ namespace GrassCutter
|
||||
if (!Seated) transform.rotation = _frame;
|
||||
float flat = Vector3.ProjectOnPlane(_vel, up).magnitude;
|
||||
float bob = (Grounded || _swimming) && !Seated && GameSettings.HeadBob ? Mathf.Sin(_bobPhase * 2f) * (_swimming ? 0.05f : 0.035f) * Mathf.Clamp01(flat / sprintSpeed + (_swimming ? 0.4f : 0f)) : 0f;
|
||||
float roll = -Ctl.Move.x * 1.5f;
|
||||
// the head leans into a sidestep: it follows the body's sideways speed and eases in and out, instead of snapping
|
||||
// with the A / D key (which jerked the view on every press and release)
|
||||
float side = Seated || Flying ? 0f : Mathf.Clamp(Vector3.Dot(_vel, _frame * Vector3.right) / walkSpeed, -1.3f, 1.3f);
|
||||
_lean = Mathf.Lerp(_lean, -side * 1.2f, 1f - Mathf.Exp(-Time.deltaTime * 6f));
|
||||
float roll = _lean;
|
||||
if (_swimming) roll += Mathf.Sin(Time.time * 1.3f) * 2f;
|
||||
_landDip = Mathf.Lerp(_landDip, 0f, Time.deltaTime * 8f);
|
||||
head.localPosition = new Vector3(0, eyeHeight + bob - _landDip, 0);
|
||||
|
||||
@ -77,7 +77,7 @@ namespace GrassCutter
|
||||
readonly Dictionary<string, float> _said = new Dictionary<string, float>();
|
||||
readonly float[] _mood = new float[7];
|
||||
AudioSource _voice;
|
||||
VisualElement _panel, _picture;
|
||||
VisualElement _panel, _frame, _picture;
|
||||
Label _caption;
|
||||
Booth _booth;
|
||||
// the user's filmed loops of her, one per mood
|
||||
@ -128,6 +128,7 @@ namespace GrassCutter
|
||||
I._voice.Stop();
|
||||
I._queue.Clear();
|
||||
I.Panel(false);
|
||||
I._talk?.Cut();
|
||||
I._on = false;
|
||||
}
|
||||
|
||||
@ -135,6 +136,8 @@ namespace GrassCutter
|
||||
{
|
||||
// she lives on the cinema layer, above the windows: a window opened mid-line hides her till it closes
|
||||
if (_panel != null) _panel.style.visibility = UIRoot.I && UIRoot.I.AnyModal ? Visibility.Hidden : Visibility.Visible;
|
||||
// the frame lights up ahead of the hologram filling it, and goes out after
|
||||
if (_frame != null && _talk != null) _frame.style.opacity = Mathf.Clamp01(_talk.Appear * 3f);
|
||||
if (_on || _queue.Count == 0) return;
|
||||
if (!Ready()) return;
|
||||
var (line, at) = _queue.Dequeue();
|
||||
@ -214,22 +217,26 @@ namespace GrassCutter
|
||||
if (on && (_panel == null || _panel.panel == null)) Build();
|
||||
if (_panel == null) return;
|
||||
_booth?.Show(on);
|
||||
if (on) _talk?.Play(0);
|
||||
else _talk?.Stop();
|
||||
// the picture comes in and goes out as a hologram; the panel goes once it has (TalkVideo.Gone)
|
||||
_talk?.Show(on);
|
||||
_caption.style.display = on ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
if (on)
|
||||
{
|
||||
_panel.style.display = DisplayStyle.Flex;
|
||||
_panel.BringToFront();
|
||||
UIK.PopIn(_panel, 0f, 0.25f);
|
||||
UIK.PopIn(_caption, 0.2f, 0.25f);
|
||||
}
|
||||
else _panel.style.display = DisplayStyle.None;
|
||||
else if (_talk == null) _panel.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
void Build()
|
||||
{
|
||||
var root = UIRoot.I ? UIRoot.I.Cinema : null;
|
||||
if (root == null) return;
|
||||
_talk = new TalkVideo("asst", new[] { "happy", "stern", "fed" }, 400, 406);
|
||||
// the window inside its 3 px border, at 1.5x
|
||||
int outW = Mathf.RoundToInt((PicW * 0.8f - 6f) * 1.5f), outH = Mathf.RoundToInt((PicH * 0.8f - 6f) * 1.5f);
|
||||
_talk = new TalkVideo("asst", new[] { "happy", "stern", "fed" }, 400, 406, outW, outH, new Rect(0f, 0f, 1f, 1f), "T_Talk_AsstBg");
|
||||
_talk.Gone = () => { if (_panel != null) _panel.style.display = DisplayStyle.None; };
|
||||
_panel = new VisualElement { pickingMode = PickingMode.Ignore };
|
||||
_panel.style.position = Position.Absolute;
|
||||
_panel.style.left = 22;
|
||||
@ -246,20 +253,15 @@ namespace GrassCutter
|
||||
var edge = new Color(0.55f, 0.85f, 0.95f, 0.9f);
|
||||
frame.style.borderLeftColor = frame.style.borderRightColor = frame.style.borderTopColor = frame.style.borderBottomColor = edge;
|
||||
frame.style.overflow = Overflow.Hidden;
|
||||
frame.style.backgroundColor = new Color(0.08f, 0.12f, 0.22f);
|
||||
var bg = AssetBank.I ? AssetBank.I.Tex("T_Dir_Bg") : null;
|
||||
if (bg)
|
||||
{
|
||||
frame.style.backgroundImage = new StyleBackground(bg);
|
||||
frame.style.unityBackgroundScaleMode = ScaleMode.ScaleAndCrop;
|
||||
frame.style.unityBackgroundImageTintColor = new Color(0.82f, 0.86f, 0.95f);
|
||||
}
|
||||
// see-through glass: the room behind her is in the picture, which the hologram brings in
|
||||
frame.style.backgroundColor = new Color(0.02f, 0.06f, 0.12f, 0.35f);
|
||||
frame.style.opacity = 0f;
|
||||
_frame = frame;
|
||||
_panel.Add(frame);
|
||||
_picture = new VisualElement { pickingMode = PickingMode.Ignore };
|
||||
_picture.style.flexGrow = 1;
|
||||
_picture.style.unityBackgroundScaleMode = ScaleMode.ScaleAndCrop;
|
||||
_talk.Switched = rt => _picture.style.backgroundImage = new StyleBackground(Background.FromRenderTexture(rt));
|
||||
_talk.Switched(_talk.Rt);
|
||||
_picture.style.unityBackgroundScaleMode = ScaleMode.StretchToFill;
|
||||
_picture.style.backgroundImage = new StyleBackground(Background.FromRenderTexture(_talk.Rt));
|
||||
frame.Add(_picture);
|
||||
var tag = UIK.Text(Loc.T("ASSISTANT · G.R.A.S.S.A."), "", frame, true);
|
||||
tag.style.position = Position.Absolute;
|
||||
|
||||
@ -405,20 +405,15 @@ namespace GrassCutter
|
||||
public PhoneCall(VisualElement screen)
|
||||
{
|
||||
_root = Box(screen, 0f, 0f, W, H);
|
||||
_root.style.backgroundColor = new Color(0.1f, 0.16f, 0.3f);
|
||||
// mission control behind him, and him in front from the hips up, like a video call
|
||||
var bg = AssetBank.I ? AssetBank.I.Tex("T_Dir_Bg") : null;
|
||||
if (bg)
|
||||
{
|
||||
_root.style.backgroundImage = new StyleBackground(bg);
|
||||
_root.style.unityBackgroundScaleMode = ScaleMode.ScaleAndCrop;
|
||||
_root.style.unityBackgroundImageTintColor = new Color(0.82f, 0.86f, 0.95f);
|
||||
}
|
||||
_talk = new TalkVideo("boss", new[] { "calm", "stern", "angry" }, 640, 650);
|
||||
_picture = Box(_root, 0f, PicTop, W, H - PicTop - PicBottom);
|
||||
_picture.style.unityBackgroundScaleMode = ScaleMode.ScaleAndCrop;
|
||||
_talk.Switched = rt => _picture.style.backgroundImage = new StyleBackground(Background.FromRenderTexture(rt));
|
||||
_talk.Switched(_talk.Rt);
|
||||
_root.style.backgroundColor = new Color(0.02f, 0.04f, 0.09f);
|
||||
// his office on Earth behind him, him in front from the hips up, like a video call: the whole screen is one
|
||||
// picture, which comes in and goes out as a hologram (TalkVideo)
|
||||
var fig = new Rect(0f, PicBottom / H, 1f, (H - PicTop - PicBottom) / H);
|
||||
_talk = new TalkVideo("boss", new[] { "calm", "stern", "angry" }, 640, 650, RtW, RtH, fig, "T_Talk_BossBg");
|
||||
_picture = Box(_root, 0f, 0f, W, H);
|
||||
_picture.style.unityBackgroundScaleMode = ScaleMode.StretchToFill;
|
||||
_picture.style.backgroundImage = new StyleBackground(Background.FromRenderTexture(_talk.Rt));
|
||||
_talk.Gone = () => _root.style.display = DisplayStyle.None;
|
||||
_fx = Box(_root, 0f, 0f, W, H);
|
||||
|
||||
// the anger vein on his forehead
|
||||
@ -438,7 +433,7 @@ namespace GrassCutter
|
||||
var bar = Box(_root, 0f, 0f, W, 230f);
|
||||
bar.style.backgroundColor = new Color(0.02f, 0.05f, 0.12f, 0.72f);
|
||||
bar.style.alignItems = Align.Center;
|
||||
bar.style.paddingTop = 78;
|
||||
bar.style.paddingTop = 46;
|
||||
var name = UIK.Text("G.R.A.S.S.A.", "", bar, true);
|
||||
name.style.fontSize = 64; name.style.color = new Color(1f, 0.86f, 0.4f);
|
||||
var row = new VisualElement { pickingMode = PickingMode.Ignore };
|
||||
@ -454,6 +449,10 @@ namespace GrassCutter
|
||||
who.style.fontSize = 28; who.style.color = new Color(0.86f, 0.92f, 1f);
|
||||
_timer = UIK.Text("00:00", "", bar, false);
|
||||
_timer.style.fontSize = 26; _timer.style.color = new Color(0.7f, 0.8f, 0.9f, 0.8f);
|
||||
_timer.style.marginTop = 6;
|
||||
// the bar is a fixed height: nothing in it may be squeezed (the row under the name was, to nothing, and the
|
||||
// timer sat on top of it)
|
||||
name.style.flexShrink = 0; row.style.flexShrink = 0; _timer.style.flexShrink = 0;
|
||||
|
||||
// the red button at the foot
|
||||
var hang = Box(_root, (W - 110f) * 0.5f, H - 160f, 110f, 110f);
|
||||
@ -463,7 +462,9 @@ namespace GrassCutter
|
||||
key.style.fontSize = 48; key.style.color = Color.white;
|
||||
key.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
key.style.flexGrow = 1;
|
||||
Show(false);
|
||||
// the agency's bar and the button light up ahead of the picture, and go out after it
|
||||
_talk.Drawn = a => { float o = Mathf.Clamp01(a * 3f); bar.style.opacity = o; hang.style.opacity = o; };
|
||||
_root.style.display = DisplayStyle.None;
|
||||
}
|
||||
|
||||
static VisualElement Box(VisualElement parent, float x, float y, float w, float h)
|
||||
@ -482,9 +483,15 @@ namespace GrassCutter
|
||||
|
||||
public void Show(bool on)
|
||||
{
|
||||
_root.style.display = on ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
_booth?.Show(on);
|
||||
if (!on) { _talk?.Stop(); return; }
|
||||
// off: the hologram fades out, then TalkVideo.Gone hides the screen
|
||||
_talk?.Show(on);
|
||||
if (!on)
|
||||
{
|
||||
if (_talk == null) _root.style.display = DisplayStyle.None;
|
||||
return;
|
||||
}
|
||||
_root.style.display = DisplayStyle.Flex;
|
||||
_root.BringToFront();
|
||||
_lastT = 0f;
|
||||
for (int i = 0; i < _mood.Length; i++) _mood[i] = 0f;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -5,35 +5,52 @@ using UnityEngine.Video;
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// A character's talking loops (Assets/StreamingAssets/Talk/<who>_<mood>.webm, VP8 with alpha, made by
|
||||
/// Tools/director/talk_videos.py): one player per mood, each looping into its own texture. The picture shows the one for
|
||||
/// the mood of the moment; the others wait where they left off, so a change of mood is a cut, not a stall.
|
||||
/// A character's talking loops (Assets/StreamingAssets/Talk/<who>_<mood>.webm, made by Tools/director/talk_videos.py):
|
||||
/// one player per mood, each looping into its own texture; the picture shows the one for the mood of the moment, the others
|
||||
/// wait where they left off, so a change of mood is a cut, not a stall.
|
||||
///
|
||||
/// Unity's player drops the webm's alpha and shows the figure on the black it was filmed on. Every frame the shader
|
||||
/// (Resources/Talk/TalkHolo) cuts the black away again, puts the figure over the room behind the character, and draws the
|
||||
/// hologram: <see cref="Show"/> fades the call in with a sweep of light, scanlines
|
||||
/// and glitches, and out the same way; while on, only faint scanlines are left.
|
||||
/// </summary>
|
||||
public class TalkVideo
|
||||
{
|
||||
const float InTime = 0.8f, OutTime = 0.5f;
|
||||
|
||||
readonly VideoPlayer[] _players;
|
||||
readonly RenderTexture[] _rts;
|
||||
readonly RenderTexture[] _raw;
|
||||
readonly RenderTexture _out;
|
||||
readonly Material _mat;
|
||||
int _on = -1;
|
||||
float _appear, _target;
|
||||
bool _clear = true;
|
||||
|
||||
/// <summary>The picture now; <see cref="Switched"/> says when it changes.</summary>
|
||||
public RenderTexture Rt => _rts[Mathf.Max(0, _on)];
|
||||
public System.Action<RenderTexture> Switched;
|
||||
/// <summary>The finished picture, the size of the window it fills.</summary>
|
||||
public RenderTexture Rt => _out;
|
||||
/// <summary>0 gone .. 1 fully there.</summary>
|
||||
public float Appear => _appear;
|
||||
/// <summary>Called once the picture has faded right out after <see cref="Show"/>(false).</summary>
|
||||
public System.Action Gone;
|
||||
/// <summary>Called every frame the picture is drawn, with <see cref="Appear"/>: for what fades along with it.</summary>
|
||||
public System.Action<float> Drawn;
|
||||
|
||||
public TalkVideo(string who, string[] moods, int w, int h)
|
||||
/// <param name="figW">The loops' width and height (the picture half).</param>
|
||||
/// <param name="outW">The window's shape, in pixels to render.</param>
|
||||
/// <param name="figRect">Where the figure stands in the window, 0..1 from the bottom left; it fills it like ScaleAndCrop.</param>
|
||||
/// <param name="bg">Resources/Talk/<bg>: the room behind, filling the window.</param>
|
||||
public TalkVideo(string who, string[] moods, int figW, int figH, int outW, int outH, Rect figRect, string bg)
|
||||
{
|
||||
var go = new GameObject("Talk " + who);
|
||||
Object.DontDestroyOnLoad(go);
|
||||
go.AddComponent<TalkVideoTicker>().Owner = this;
|
||||
_players = new VideoPlayer[moods.Length];
|
||||
_rts = new RenderTexture[moods.Length];
|
||||
_raw = new RenderTexture[moods.Length];
|
||||
for (int i = 0; i < moods.Length; i++)
|
||||
{
|
||||
var rt = new RenderTexture(w, h, 0, RenderTextureFormat.ARGB32) { name = $"Talk {who} {moods[i]}" };
|
||||
var rt = new RenderTexture(figW, figH, 0, RenderTextureFormat.ARGB32) { name = $"Talk {who} {moods[i]}" };
|
||||
rt.Create();
|
||||
// see-through until the first frame is in
|
||||
var was = RenderTexture.active;
|
||||
RenderTexture.active = rt;
|
||||
GL.Clear(true, true, Color.clear);
|
||||
RenderTexture.active = was;
|
||||
Clear(rt, Color.black);
|
||||
var vp = go.AddComponent<VideoPlayer>();
|
||||
vp.playOnAwake = false;
|
||||
vp.source = VideoSource.Url;
|
||||
@ -45,8 +62,38 @@ namespace GrassCutter
|
||||
vp.targetTexture = rt;
|
||||
vp.Prepare();
|
||||
_players[i] = vp;
|
||||
_rts[i] = rt;
|
||||
_raw[i] = rt;
|
||||
}
|
||||
_out = new RenderTexture(outW, outH, 0, RenderTextureFormat.ARGB32) { name = $"Talk {who}" };
|
||||
_out.Create();
|
||||
Clear(_out, Color.clear);
|
||||
|
||||
var shader = Resources.Load<Shader>("Talk/TalkHolo");
|
||||
_mat = new Material(shader) { hideFlags = HideFlags.DontSave };
|
||||
var bgTex = Resources.Load<Texture2D>("Talk/" + bg);
|
||||
_mat.SetTexture("_BgTex", bgTex);
|
||||
_mat.SetFloat("_HasBg", bgTex ? 1f : 0f);
|
||||
_mat.SetVector("_FigST", Cover(figRect, outW, outH, figW, figH));
|
||||
_mat.SetVector("_BgST", Cover(new Rect(0f, 0f, 1f, 1f), outW, outH, bgTex ? bgTex.width : outW, bgTex ? bgTex.height : outH));
|
||||
_mat.SetVector("_Px", new Vector4(outW, outH, 0f, 0f));
|
||||
}
|
||||
|
||||
/// <summary>uv in the window -> uv in a picture of srcW x srcH that fills <paramref name="r"/> (cropped, not squeezed).</summary>
|
||||
static Vector4 Cover(Rect r, int outW, int outH, float srcW, float srcH)
|
||||
{
|
||||
float rw = r.width * outW, rh = r.height * outH;
|
||||
float s = Mathf.Max(rw / srcW, rh / srcH);
|
||||
float fx = rw / (srcW * s), fy = rh / (srcH * s);
|
||||
float sx = fx / r.width, sy = fy / r.height;
|
||||
return new Vector4(sx, sy, 0.5f - fx * 0.5f - r.x * sx, 0.5f - fy * 0.5f - r.y * sy);
|
||||
}
|
||||
|
||||
static void Clear(RenderTexture rt, Color c)
|
||||
{
|
||||
var was = RenderTexture.active;
|
||||
RenderTexture.active = rt;
|
||||
GL.Clear(true, true, c);
|
||||
RenderTexture.active = was;
|
||||
}
|
||||
|
||||
/// <summary>Plays the loop for this mood (and only it).</summary>
|
||||
@ -57,14 +104,44 @@ namespace GrassCutter
|
||||
{
|
||||
if (_on >= 0) _players[_on].Pause();
|
||||
_on = mood;
|
||||
Switched?.Invoke(_rts[mood]);
|
||||
}
|
||||
if (!_players[mood].isPlaying) _players[mood].Play();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
/// <summary>Fades the call in (with the hologram's sweep) or out; out, the loop stops once it's gone.</summary>
|
||||
public void Show(bool on)
|
||||
{
|
||||
if (_on >= 0) _players[_on].Pause();
|
||||
_target = on ? 1f : 0f;
|
||||
if (on && _on < 0) Play(0);
|
||||
}
|
||||
|
||||
/// <summary>Gone at once, no fade (a film cuts in).</summary>
|
||||
public void Cut()
|
||||
{
|
||||
_target = _appear = 0f;
|
||||
Tick();
|
||||
}
|
||||
|
||||
internal void Tick()
|
||||
{
|
||||
float dt = Time.unscaledDeltaTime;
|
||||
_appear = Mathf.MoveTowards(_appear, _target, dt / (_target > _appear ? InTime : OutTime));
|
||||
if (_appear <= 0f && _target <= 0f)
|
||||
{
|
||||
if (_clear) return;
|
||||
_clear = true;
|
||||
if (_on >= 0) _players[_on].Pause();
|
||||
Clear(_out, Color.clear);
|
||||
Drawn?.Invoke(0f);
|
||||
Gone?.Invoke();
|
||||
return;
|
||||
}
|
||||
_clear = false;
|
||||
if (_on < 0) return;
|
||||
_mat.SetFloat("_Appear", _appear);
|
||||
_mat.SetFloat("_T", Time.unscaledTime);
|
||||
Graphics.Blit(_raw[_on], _out, _mat);
|
||||
Drawn?.Invoke(_appear);
|
||||
}
|
||||
|
||||
/// <summary>The Director: calm (and pleased), stern (and worried), furious.</summary>
|
||||
@ -81,4 +158,11 @@ namespace GrassCutter
|
||||
return (Mood)best;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Draws a <see cref="TalkVideo"/>'s picture once a frame, after the players have had theirs.</summary>
|
||||
public class TalkVideoTicker : MonoBehaviour
|
||||
{
|
||||
public TalkVideo Owner;
|
||||
void LateUpdate() => Owner?.Tick();
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,6 +163,8 @@ namespace GrassCutter
|
||||
SetChoice(Loc.T("Grass density"), Loc.T("How many blades are drawn. There is just as much to cut either way."),
|
||||
new[] { Loc.T("Low"), Loc.T("Medium"), Loc.T("High") }, () => GameSettings.GrassDetail, v => { GameSettings.GrassDetail = v; RefreshRows(); });
|
||||
SetToggle(Loc.T("Bloom"), Loc.T("A soft glow around the sun, lamps and anything bright."), () => GameSettings.Bloom, v => { GameSettings.Bloom = v; RefreshRows(); });
|
||||
SetChoice(Loc.T("Lighting"), Loc.T("Enhanced: richer colour, warm light and cool shadows, deeper shade, and the world out of focus behind the phone and windows. Classic: the original look."),
|
||||
new[] { Loc.T("Classic"), Loc.T("Enhanced") }, () => GameSettings.Lighting, v => GameSettings.Lighting = v);
|
||||
}
|
||||
|
||||
void AudioTab()
|
||||
|
||||
@ -85,8 +85,9 @@ namespace GrassCutter
|
||||
_sky = RenderSettings.ambientSkyColor;
|
||||
_mid = RenderSettings.ambientEquatorColor;
|
||||
_low = RenderSettings.ambientGroundColor;
|
||||
var volume = FindAnyObjectByType<Volume>();
|
||||
if (volume && volume.profile.TryGet(out _grade)) _exposure = _grade.postExposure.value;
|
||||
// the scene's own post volume, not the enhanced look laid over it (LightingStyle)
|
||||
foreach (var volume in FindObjectsByType<Volume>(FindObjectsSortMode.None))
|
||||
if (!LightingStyle.IsOurs(volume) && volume.profile.TryGet(out _grade)) { _exposure = _grade.postExposure.value; break; }
|
||||
if (!GetComponent<WeatherFx>()) gameObject.AddComponent<WeatherFx>();
|
||||
}
|
||||
|
||||
@ -130,6 +131,7 @@ namespace GrassCutter
|
||||
var sky = RenderSettings.skybox;
|
||||
if (sky) sky.SetVector(SunId, Quaternion.Inverse(Planet.Frame) * Sun.Dir);
|
||||
TickLamp(cam);
|
||||
LightingStyle.Tick();
|
||||
}
|
||||
|
||||
void TickLamp(Camera cam)
|
||||
|
||||
246
Assets/Scripts/World/LightingStyle.cs
Normal file
246
Assets/Scripts/World/LightingStyle.cs
Normal file
@ -0,0 +1,246 @@
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// The look of the light, from Settings › Graphics › Lighting: Classic is the scene's own post volume as it always was;
|
||||
/// Enhanced lays a second volume over it with the grade of the prototype (TheWorstEscape's prison yard), softened for a
|
||||
/// bright cartoon: split toning (cool shadows, warm highlights), a touch of cool in the shadows,
|
||||
/// a little more colour and warmth, a warmer and wider bloom, a vignette, a fine grain and a hair of chromatic aberration,
|
||||
/// stronger contact shadows (SSAO) and a glint on the sun. The prototype's ACES stays out: on this sunny meadow it crushed
|
||||
/// the shade to black and burnt the colours (tried, 2026-11-23), and so did switching the pipeline to HDR grading at
|
||||
/// runtime: the scene's own Neutral tonemapping and LDR grading stay. It also takes the world out of focus behind the phone held up and behind a window.
|
||||
///
|
||||
/// Nothing here touches the project's assets: the volumes and profiles are made at runtime, the pipeline is the
|
||||
/// settings' own copy, and the SSAO strength changed in memory is put back on quit. Classic switches it all off again.
|
||||
/// </summary>
|
||||
public static class LightingStyle
|
||||
{
|
||||
public const int Classic = 0, Enhanced = 1;
|
||||
|
||||
static Volume s_look, s_focus;
|
||||
static DepthOfField s_dof;
|
||||
static float s_blur;
|
||||
static ScriptableRendererFeature s_ssao;
|
||||
static object s_ssaoSettings;
|
||||
static float s_ssaoIntensity = -1f, s_ssaoDirect = -1f;
|
||||
static int s_ssaoMethod = -1, s_ssaoSamples = -1;
|
||||
|
||||
public static bool On => GameSettings.Lighting == Enhanced;
|
||||
|
||||
/// <summary>
|
||||
/// Test runs: -lookskip bloom,grade,wb,split,smh,vig,grain,ca,ssao,flare,dof leaves those parts of the look
|
||||
/// out, to see which one does what; aooff switches the renderer's SSAO off altogether.
|
||||
/// </summary>
|
||||
public static bool Skip(string part) => (CommandLine.Get("-lookskip") ?? "").Contains(part);
|
||||
|
||||
/// <summary>The profile of the Enhanced look, so the day/night grade can tell the scene's volume from ours.</summary>
|
||||
public static bool IsOurs(Volume v) => v && (v == s_look || v == s_focus);
|
||||
|
||||
public static void Apply()
|
||||
{
|
||||
Make();
|
||||
s_look.enabled = On;
|
||||
s_focus.enabled = On;
|
||||
if (!Skip("flare")) Flare(RenderSettings.sun);
|
||||
if (s_flare) s_flare.enabled = On;
|
||||
if (!Skip("ssao")) Ssao(On);
|
||||
if (Skip("dof")) s_focus.enabled = false;
|
||||
}
|
||||
|
||||
static void Make()
|
||||
{
|
||||
if (s_look) return;
|
||||
var go = new GameObject("Lighting (enhanced)");
|
||||
Object.DontDestroyOnLoad(go);
|
||||
go.hideFlags = HideFlags.DontSave;
|
||||
|
||||
var p = ScriptableObject.CreateInstance<VolumeProfile>();
|
||||
p.name = "Enhanced look";
|
||||
if (!Skip("bloom")) {
|
||||
var bloom = p.Add<Bloom>(true);
|
||||
bloom.intensity.Override(0.85f);
|
||||
bloom.threshold.Override(0.95f);
|
||||
bloom.scatter.Override(0.7f);
|
||||
bloom.tint.Override(new Color(1f, 0.93f, 0.85f)); }
|
||||
// contrast and saturation only: exposure and the colour filter stay the scene volume's, which the day and the
|
||||
// night vision drive (DayNight)
|
||||
if (!Skip("grade")) {
|
||||
var grade = p.Add<ColorAdjustments>();
|
||||
grade.contrast.Override(17f);
|
||||
grade.saturation.Override(18f); }
|
||||
if (!Skip("wb")) p.Add<WhiteBalance>().temperature.Override(4f);
|
||||
if (!Skip("split")) {
|
||||
var split = p.Add<SplitToning>();
|
||||
split.shadows.Override(new Color(0.46f, 0.5f, 0.56f));
|
||||
split.highlights.Override(new Color(0.56f, 0.53f, 0.48f));
|
||||
split.balance.Override(-10f); }
|
||||
if (!Skip("smh")) {
|
||||
var smh = p.Add<ShadowsMidtonesHighlights>();
|
||||
smh.shadows.Override(new Vector4(0.97f, 1f, 1.05f, 0f));
|
||||
smh.midtones.Override(new Vector4(1f, 1f, 1f, 0.02f)); }
|
||||
if (!Skip("vig")) {
|
||||
var vig = p.Add<Vignette>();
|
||||
vig.intensity.Override(0.24f);
|
||||
vig.smoothness.Override(0.45f); }
|
||||
if (!Skip("grain")) {
|
||||
var grain = p.Add<FilmGrain>();
|
||||
grain.type.Override(FilmGrainLookup.Thin1);
|
||||
grain.intensity.Override(0.1f);
|
||||
grain.response.Override(0.8f); }
|
||||
if (!Skip("ca")) p.Add<ChromaticAberration>().intensity.Override(0.04f);
|
||||
|
||||
s_look = go.AddComponent<Volume>();
|
||||
s_look.isGlobal = true;
|
||||
s_look.priority = 10f;
|
||||
s_look.sharedProfile = p;
|
||||
|
||||
var f = ScriptableObject.CreateInstance<VolumeProfile>();
|
||||
f.name = "Focus";
|
||||
s_dof = f.Add<DepthOfField>(true);
|
||||
s_dof.mode.Override(DepthOfFieldMode.Gaussian);
|
||||
s_dof.gaussianStart.Override(0.4f);
|
||||
s_dof.gaussianEnd.Override(5f);
|
||||
s_dof.gaussianMaxRadius.Override(1.5f);
|
||||
s_dof.highQualitySampling.Override(true);
|
||||
s_focus = go.AddComponent<Volume>();
|
||||
s_focus.isGlobal = true;
|
||||
s_focus.priority = 11f;
|
||||
s_focus.weight = 0f;
|
||||
s_focus.sharedProfile = f;
|
||||
GameSettings.ApplyBloom();
|
||||
}
|
||||
|
||||
static LensFlareComponentSRP s_flare;
|
||||
|
||||
/// <summary>
|
||||
/// A glint on the sun: a warm glow, a faint halo and a few soft ghosts across the screen, all drawn shapes (no
|
||||
/// textures), hidden behind anything in front of the sun.
|
||||
/// </summary>
|
||||
static void Flare(Light sun)
|
||||
{
|
||||
if (!sun) return;
|
||||
if (!s_flare || s_flare.gameObject != sun.gameObject)
|
||||
{
|
||||
s_flare = sun.GetComponent<LensFlareComponentSRP>();
|
||||
if (!s_flare)
|
||||
{
|
||||
var d = ScriptableObject.CreateInstance<LensFlareDataSRP>();
|
||||
d.name = "Sun glint";
|
||||
d.elements = new[]
|
||||
{
|
||||
Shape(SRPLensFlareType.Circle, 0f, 2.2f, 0.55f, new Color(1f, 0.86f, 0.62f), 0.12f),
|
||||
Shape(SRPLensFlareType.Ring, 0f, 5.5f, 0.05f, new Color(0.8f, 0.9f, 1f), 0.5f),
|
||||
Shape(SRPLensFlareType.Polygon, 0.45f, 0.7f, 0.06f, new Color(0.55f, 1f, 0.85f), 0.6f, 6),
|
||||
Shape(SRPLensFlareType.Polygon, 0.85f, 0.35f, 0.08f, new Color(1f, 0.7f, 0.45f), 0.6f, 6),
|
||||
Shape(SRPLensFlareType.Circle, 1.25f, 1.1f, 0.035f, new Color(0.6f, 0.75f, 1f), 0.9f),
|
||||
Shape(SRPLensFlareType.Polygon, 1.6f, 0.5f, 0.05f, new Color(1f, 0.9f, 0.6f), 0.5f, 6),
|
||||
};
|
||||
s_flare = sun.gameObject.AddComponent<LensFlareComponentSRP>();
|
||||
s_flare.lensFlareData = d;
|
||||
s_flare.useOcclusion = true;
|
||||
s_flare.occlusionRadius = 0.6f;
|
||||
s_flare.sampleCount = 8;
|
||||
s_flare.allowOffScreen = false;
|
||||
}
|
||||
}
|
||||
s_flare.enabled = On;
|
||||
}
|
||||
|
||||
static LensFlareDataElementSRP Shape(SRPLensFlareType kind, float at, float size, float strength, Color tint, float soft, int sides = 4)
|
||||
{
|
||||
return new LensFlareDataElementSRP
|
||||
{
|
||||
flareType = kind,
|
||||
position = at,
|
||||
uniformScale = size,
|
||||
localIntensity = strength,
|
||||
tint = tint,
|
||||
fallOff = soft,
|
||||
sideCount = sides,
|
||||
blendMode = SRPLensFlareBlendMode.Additive,
|
||||
modulateByLightColor = true,
|
||||
visible = true,
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>Every frame (DayNight): the world goes soft behind the phone up at your face and behind a window.</summary>
|
||||
public static void Tick()
|
||||
{
|
||||
if (!s_focus || !On) return;
|
||||
var sun = RenderSettings.sun;
|
||||
if (sun && !Skip("flare") && (!s_flare || s_flare.gameObject != sun.gameObject)) Flare(sun);
|
||||
// the glint is the sun's: it goes with the daylight (the same light is the moon at night) and the clouds
|
||||
if (s_flare) s_flare.intensity = (1f - DayNight.Dark) * Mathf.Clamp01(sun ? sun.intensity / 2f : 0f);
|
||||
bool soft = Phone.Focused || (UIRoot.I && UIRoot.I.AnyModal) || Ctl.UIOpen;
|
||||
s_blur = Mathf.MoveTowards(s_blur, soft ? 1f : 0f, Time.unscaledDeltaTime * 4f);
|
||||
s_focus.weight = s_blur * s_blur * (3f - 2f * s_blur);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The renderer's SSAO, stronger and reaching into the sunlight a little. Its settings are private to URP, so they
|
||||
/// are found by name; if a URP update renames them this quietly does nothing.
|
||||
/// </summary>
|
||||
static void Ssao(bool strong)
|
||||
{
|
||||
if (s_ssaoSettings == null)
|
||||
{
|
||||
var rp = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
|
||||
var data = rp ? rp.rendererDataList : default;
|
||||
foreach (var d in data)
|
||||
{
|
||||
if (!d) continue;
|
||||
foreach (var feature in d.rendererFeatures)
|
||||
if (feature && feature.GetType().Name == "ScreenSpaceAmbientOcclusion") s_ssao = feature;
|
||||
if (s_ssao) break;
|
||||
}
|
||||
if (!s_ssao) return;
|
||||
var field = s_ssao.GetType().GetField("m_Settings", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
s_ssaoSettings = field?.GetValue(s_ssao);
|
||||
if (s_ssaoSettings == null) return;
|
||||
s_ssaoIntensity = Get("Intensity");
|
||||
s_ssaoDirect = Get("DirectLightingStrength");
|
||||
s_ssaoMethod = GetEnum("AOMethod");
|
||||
s_ssaoSamples = GetEnum("Samples");
|
||||
Application.quitting += () => Ssao(false);
|
||||
}
|
||||
if (s_ssaoIntensity < 0f) return;
|
||||
// the scene's blue-noise SSAO at medium samples speckles the flat panels once it is stronger (seen on the travel
|
||||
// terminal, 2026-11-23): the stronger look takes the smooth interleaved-gradient method and the most samples
|
||||
Set("Intensity", strong ? 0.6f : s_ssaoIntensity);
|
||||
if (s_ssaoDirect >= 0f) Set("DirectLightingStrength", strong ? 0.15f : s_ssaoDirect);
|
||||
if (s_ssaoMethod >= 0) SetEnum("AOMethod", strong ? 1 : s_ssaoMethod);
|
||||
if (s_ssaoSamples >= 0) SetEnum("Samples", strong ? 0 : s_ssaoSamples);
|
||||
s_ssao.SetActive(false);
|
||||
s_ssao.SetActive(!Skip("aooff"));
|
||||
Debug.Log($"[Look] SSAO {(Skip("aooff") ? "off" : "on")}: intensity {Get("Intensity")}, direct {Get("DirectLightingStrength")}, method {GetEnum("AOMethod")}, samples {GetEnum("Samples")}");
|
||||
}
|
||||
|
||||
static float Get(string name)
|
||||
{
|
||||
var f = s_ssaoSettings.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
return f != null && f.FieldType == typeof(float) ? (float)f.GetValue(s_ssaoSettings) : -1f;
|
||||
}
|
||||
|
||||
static void Set(string name, float v)
|
||||
{
|
||||
var f = s_ssaoSettings.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (f != null && f.FieldType == typeof(float)) f.SetValue(s_ssaoSettings, v);
|
||||
}
|
||||
|
||||
static int GetEnum(string name)
|
||||
{
|
||||
var f = s_ssaoSettings.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
return f != null && f.FieldType.IsEnum ? System.Convert.ToInt32(f.GetValue(s_ssaoSettings)) : -1;
|
||||
}
|
||||
|
||||
static void SetEnum(string name, int v)
|
||||
{
|
||||
var f = s_ssaoSettings.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
if (f != null && f.FieldType.IsEnum) f.SetValue(s_ssaoSettings, System.Enum.ToObject(f.FieldType, v));
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/World/LightingStyle.cs.meta
Normal file
2
Assets/Scripts/World/LightingStyle.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44bc328baa8f46f498af396975b6991a
|
||||
Reference in New Issue
Block a user