0.8.1: project.json holds the version, the links, who made it and what it's built on (CMake reads it into fry_project.h and Windows' file details, which had stayed at 0.5.0); the About box lists the creators, the Help menu the website, reporting a problem and the newest version. Steadier far out: the grid's line sizes go by each pixel (not the focus, which jumps between the ground and the sky as you fly, popping every set at once), the far plane doesn't follow that focus when flying, and a wheel notch is at most twice as far as the nearest thing; the site's 0.8.1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-21 17:30:43 +02:00
commit ee56ed4005
13 changed files with 176 additions and 64 deletions

View file

@ -211,10 +211,10 @@ void Renderer::drawSprite(const glm::vec3& at, float size, const glm::vec4& colo
list.push_back({glm::vec4(at, size * 0.5f), color, glm::vec4(0, 0, 0, rotation), glm::vec4(0, 0, 0, tex)});
}
void Renderer::drawGrid(const glm::vec3& centre, const glm::vec3& u, const glm::vec3& v, float first, const glm::vec3& look, float reach) {
void Renderer::drawGrid(const glm::vec3& centre, const glm::vec3& u, const glm::vec3& v, float metre, const glm::vec3& look, float reach) {
if (packet_.sprites.size() >= 8192) return;
// (colour.a < 0 marks it; sprite.vert / sprite.frag)
packet_.sprites.push_back({glm::vec4(centre, reach), glm::vec4(look, -1.0f), glm::vec4(u, first), glm::vec4(v, 0.0f)});
packet_.sprites.push_back({glm::vec4(centre, reach), glm::vec4(look, -1.0f), glm::vec4(u, metre), glm::vec4(v, 0.0f)});
}
void Renderer::drawStreak(const glm::vec3& from, const glm::vec3& to, float width, const glm::vec4& color, TextureId texture, bool additive, float widthTo) {

View file

@ -102,10 +102,10 @@ public:
// each end turned to face the eye as much as it can (rain; lines drawn in pieces meet exactly).
void drawStreak(const glm::vec3& from, const glm::vec3& to, float width, const glm::vec4& color, TextureId texture, bool additive = false, float widthTo = -1.0f);
// A grid of lines on the plane through `centre` along u and v (unit), drawn for each pixel:
// four sets `first` × 10 apart, each showing by how far apart its lines are on the screen,
// the axes coloured; look: the lines' shade (0 dark, 1 light), how faint, how strong; fading
// out `reach` from the centre.
void drawGrid(const glm::vec3& centre, const glm::vec3& u, const glm::vec3& v, float first, const glm::vec3& look, float reach);
// every 10^n metres (`metre`: units in one), each set showing by how far apart its lines are
// on the screen, the axes coloured; look: the lines' shade (0 dark, 1 light), how faint, how
// strong; fading out `reach` from the centre.
void drawGrid(const glm::vec3& centre, const glm::vec3& u, const glm::vec3& v, float metre, const glm::vec3& look, float reach);
// skin: one matrix per joint (anim::skinMatrices) for skinned models; ignored otherwise.
// lighting: probe light for moving things (nullptr = lightmap or simple sun shading).
void drawModel(ModelId model, const glm::mat4& transform, const glm::vec4& tint = glm::vec4(1.0f),

View file

@ -393,20 +393,22 @@ uniform sampler2D u_albedo;
uniform vec4 u_color, u_posSize, u_right, u_up;
out vec4 o_color;
// A grid (a sprite with colour.a < 0), worked out for each pixel where it lies on its plane:
// four sets of lines each `first` × 10 apart, each set showing by how far apart its lines are on
// the screen (none where they crowd together, stronger where they're far apart), lines about a
// pixel wide, smooth; the axes through the middle in the colour of the world's axis they run along.
// lines every 10^n metres (`metre`: units in one), the four sets from the finest that isn't
// crowded together here, each showing by how far apart its lines are on the screen (none where
// they crowd, stronger where they're far apart: nothing jumps as the view moves), about a pixel
// wide, smooth; the axes through the middle in the colour of the world's axis they run along.
// look: x the lines' shade (0 dark, 1 light), y how faint, z how strong; reach: it fades out there.
vec3 gridAxisColor(vec3 d) {
d = abs(d);
return d.x > 0.5 ? vec3(0.9, 0.25, 0.25) : d.y > 0.5 ? vec3(0.3, 0.75, 0.25) : vec3(0.25, 0.45, 0.95);
}
vec4 gridColor(vec3 w, vec3 centre, vec3 u, vec3 v, float first, vec3 look, float reach) {
vec4 gridColor(vec3 w, vec3 centre, vec3 u, vec3 v, float metre, vec3 look, float reach) {
vec2 c = vec2(dot(w, u), dot(w, v));
vec2 fw = max(fwidth(c), vec2(1e-9));
float finest = floor(log(min(fw.x, fw.y) * 5.0 / metre) / log(10.0)); // (10^this m: 5 pixels apart or more)
float lines = 0.0;
for (int k = 0; k < 4; ++k) {
float s = first * pow(10.0, float(k));
float s = metre * pow(10.0, finest + float(k));
vec2 apart = s / fw; // (pixels between this set's lines, each way)
vec2 off = abs(fract(c / s + 0.5) - 0.5) * apart; // (pixels to the nearest of them)
vec2 strong = smoothstep(20.0, 160.0, apart);

View file

@ -11,20 +11,22 @@ PUSH_BLOCK {
layout(location = 0) in vec2 v_uv;
layout(location = 1) in vec3 v_world;
// A grid (a sprite with colour.a < 0), worked out for each pixel where it lies on its plane:
// four sets of lines each `first` × 10 apart, each set showing by how far apart its lines are on
// the screen (none where they crowd together, stronger where they're far apart), lines about a
// pixel wide, smooth; the axes through the middle in the colour of the world's axis they run along.
// lines every 10^n metres (`metre`: units in one), the four sets from the finest that isn't
// crowded together here, each showing by how far apart its lines are on the screen (none where
// they crowd, stronger where they're far apart: nothing jumps as the view moves), about a pixel
// wide, smooth; the axes through the middle in the colour of the world's axis they run along.
// look: x the lines' shade (0 dark, 1 light), y how faint, z how strong; reach: it fades out there.
vec3 gridAxisColor(vec3 d) {
d = abs(d);
return d.x > 0.5 ? vec3(0.9, 0.25, 0.25) : d.y > 0.5 ? vec3(0.3, 0.75, 0.25) : vec3(0.25, 0.45, 0.95);
}
vec4 gridColor(vec3 w, vec3 centre, vec3 u, vec3 v, float first, vec3 look, float reach) {
vec4 gridColor(vec3 w, vec3 centre, vec3 u, vec3 v, float metre, vec3 look, float reach) {
vec2 c = vec2(dot(w, u), dot(w, v));
vec2 fw = max(fwidth(c), vec2(1e-9));
float finest = floor(log(min(fw.x, fw.y) * 5.0 / metre) / log(10.0)); // (10^this m: 5 pixels apart or more)
float lines = 0.0;
for (int k = 0; k < 4; ++k) {
float s = first * pow(10.0, float(k));
float s = metre * pow(10.0, finest + float(k));
vec2 apart = s / fw; // (pixels between this set's lines, each way)
vec2 off = abs(fract(c / s + 0.5) - 0.5) * apart; // (pixels to the nearest of them)
vec2 strong = smoothstep(20.0, 160.0, apart);
@ -43,7 +45,7 @@ vec4 gridColor(vec3 w, vec3 centre, vec3 u, vec3 v, float first, vec3 look, floa
layout(location = 0) out vec4 o_color;
void main() {
if (pc.color.a < 0.0) { // a grid: right.w its finest step, color.rgb its look, posSize.w how far it reaches
if (pc.color.a < 0.0) { // a grid: right.w the units in a metre, color.rgb its look, posSize.w how far it reaches
o_color = gridColor(v_world, pc.posSize.xyz, normalize(pc.right.xyz), normalize(pc.up.xyz), pc.right.w, pc.color.rgb, pc.posSize.w);
return;
}