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:
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user