fix(scene): render raster images at correct position and size (#98)

Match the image shader's uniform layout to the shared 112-byte Uniforms
struct (was 144) and project quad corners via view_proj so texture-quad
draws no longer fail uniform binding validation.

Offset image quad corners by world_offset, matching all other Model-space
geometry, so rasters land in the same local space instead of being shifted
away. Downscale oversized images to the GPU's max texture dimension (8192)
to keep texture creation from failing.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-14 15:06:06 +03:00
1 parent a819a47c08
commit a2cb833c83
3 files changed
+35 -14

No files matched your search

+10 -7
View File
@@ -2,13 +2,16 @@
// Renders a four-vertex quad (two triangles) with a sampled texture.
// ── Bind group 0: shared projection uniforms ─────────────────────────────────
// Must match the shared `Uniforms` struct (scene::pipeline::uniforms, 112 B).
struct Uniforms {
mvp: mat4x4<f32>,
view: mat4x4<f32>,
width: f32,
height: f32,
cam_z: f32,
_pad: f32,
view_proj: mat4x4<f32>,
camera_pos: vec4<f32>,
viewport_size: vec2<f32>,
world_per_pixel: f32,
lwdisplay_enable: f32,
flat_shade: f32,
transparency_enable: f32,
_pad: vec2<f32>,
};
@group(0) @binding(0) var<uniform> u: Uniforms;
@@ -43,7 +46,7 @@ struct VertOut {
@vertex
fn vs_main(in: VertIn) -> VertOut {
var out: VertOut;
out.clip_pos = u.mvp * vec4<f32>(in.pos, 1.0);
out.clip_pos = u.view_proj * vec4<f32>(in.pos, 1.0);
out.clip_pos.z = out.clip_pos.z - img_params.draw_depth * DRAW_ORDER_BIAS * out.clip_pos.w;
out.uv = in.uv;
return out;