feat(app): render landblock with height-ramp shader + orbit camera
Adds a 2-stage GLSL shader (vertex + fragment), a Shader helper that compiles/links and exposes SetMatrix4 for uniforms, and an OrbitCamera with yaw/pitch/distance and a 192-unit-centered target for a single landblock. TerrainRenderer now takes a Shader and issues an actual DrawElements call with uView + uProjection uniforms. GameWindow owns the Shader and Camera, routes mouse drag to camera yaw/pitch, and scroll wheel to camera distance. The fragment shader maps world Z to a green-brown-white ramp so lowlands read green, midlands brown, and peaks white — no textures yet, but enough to visually confirm the terrain shape. Shaders are copied to the output dir via a <None Update> item group. Smoke verified against real dats: process stays alive with no GL errors, no shader compile/link failures, and no exception trail. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8356fe65a0
commit
87c45c70ac
7 changed files with 154 additions and 7 deletions
28
src/AcDream.App/Rendering/OrbitCamera.cs
Normal file
28
src/AcDream.App/Rendering/OrbitCamera.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System.Numerics;
|
||||
|
||||
namespace AcDream.App.Rendering;
|
||||
|
||||
public sealed class OrbitCamera
|
||||
{
|
||||
public Vector3 Target { get; set; } = new(96, 96, 0); // center of a 192x192 landblock
|
||||
public float Distance { get; set; } = 300f;
|
||||
public float Yaw { get; set; } = MathF.PI / 4f;
|
||||
public float Pitch { get; set; } = MathF.PI / 6f;
|
||||
public float FovY { get; set; } = MathF.PI / 3f;
|
||||
public float Aspect { get; set; } = 16f / 9f;
|
||||
|
||||
public Matrix4x4 View
|
||||
{
|
||||
get
|
||||
{
|
||||
var eye = Target + new Vector3(
|
||||
Distance * MathF.Cos(Pitch) * MathF.Cos(Yaw),
|
||||
Distance * MathF.Cos(Pitch) * MathF.Sin(Yaw),
|
||||
Distance * MathF.Sin(Pitch));
|
||||
return Matrix4x4.CreateLookAt(eye, Target, Vector3.UnitZ);
|
||||
}
|
||||
}
|
||||
|
||||
public Matrix4x4 Projection
|
||||
=> Matrix4x4.CreatePerspectiveFieldOfView(FovY, Aspect, 1f, 5000f);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue