The view: near and far go by the distance (no more vanishing far out or cutting close up), a coarser grid out to the horizon; outline and lines over the model agree while a touch turns the view (worked out once, just before drawing); outlines from a cached edge list, points tried for sight only when drawn

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-21 00:45:17 +02:00
commit f1f7a3fecc
3 changed files with 120 additions and 77 deletions

View file

@ -100,7 +100,7 @@ glm::mat4 viewProjection(const Camera& c, float aspect) {
const glm::vec3 forward = forwardOf(c);
const glm::vec3 up = glm::vec3(glm::rotate(glm::mat4(1), glm::radians(c.roll), forward) * glm::vec4(0, 0, 1, 0));
glm::mat4 view = glm::lookAt(c.origin, c.origin + forward, up);
glm::mat4 proj = glm::perspective(glm::radians(c.fovY), aspect, 2.0f, 16384.0f);
glm::mat4 proj = glm::perspective(glm::radians(c.fovY), aspect, c.zNear, c.zFar);
proj[1][1] *= -1.0f; // clip-space Y points down (Vulkan; OpenGL is set up to match)
proj[2][0] -= c.shift.x, proj[2][1] -= c.shift.y;
return proj * view;
@ -789,7 +789,7 @@ void Renderer::buildPacket(uint32_t width, uint32_t height) {
p.post.sunColor = glm::vec4(sunColor_, 0.0f);
}
}
p.post.proj = glm::vec4(tanY * float(width) / float(height), tanY, 2.0f, 16384.0f);
p.post.proj = glm::vec4(tanY * float(width) / float(height), tanY, camera_.zNear, camera_.zFar);
p.clearColor = glm::vec3(srgbToLinear(sky.r), srgbToLinear(sky.g), srgbToLinear(sky.b)) / p.exposure;
// The mirror's pass: this frame's data, but seen from the reflected eye, cut at the mirror,
// lit by every light (the clusters are this view's), and no fog grid (that's this view's too).

View file

@ -22,6 +22,7 @@ struct Camera {
float roll = 0.0f; // degrees, positive tilts right
float fovY = 74.0f; // degrees
glm::vec2 shift{0.0f}; // where the picture's middle sits on the screen (-1..1 across, down): a view beside panels
float zNear = 2.0f, zFar = 16384.0f; // what's nearer or further isn't drawn (units)
};
// Baked light for a moving model (from the map's probes): ambient cube + sun visibility.