Smooth-shaded model viewer, OBJ/GLB export, texture decode and security fixes (on v1.4.7) #42
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/rpatty-dev--PercyStar!42
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/42/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Pokeralho on GitHub · 2026-11-22 15:33 UTC · original
Pokeralho:model-quality-audit→main· +3251 −741 · 24 files · 12 commits · merged 2026-11-22 16:10 UTCSummary
Based on v1.4.7 (
676d582). The main goal is 3D model quality, in the viewer and in exports. The PR also fixes texture decoding bugs that change how models look, and hardens the parsers, the updater and the external-tool lookup against untrusted input. v1.4.7 still does not compile on Linux, so the first commit fixes that.Each commit compiles on its own (
cargo check --lockedwas run on every one), so they can be reviewed or cherry-picked separately.fix(audio): restore the Linux build.args(*args)on an unsized[&str]in the Unix playback pathfeat(model3d): smooth-shaded, filtered, anti-aliased model rendererfix(tex): straight alpha, four-colour BC2/BC3, signed BC4/BC5feat(model3d): export smooth normals, materials and texturesfix(app): harden the updater, external tool lookup and export pathsfix(parsers): bound allocations and offsets taken from untrusted filesci: build and test every push and pull requestfix: stale audio decode result, empty map entity slots, exported glass opacitytest(model3d): drive the viewport through egui without a windowtest(model3d): siren glow in the new rendererfeat(app): open a path from the command line or by dropping it on the windowPercyStar <path>, drag and drop; the new modules pass the v1.4.7 clippy rulesdocs: state the real minimum Rust version (1.89)rust-versionand README badgeModel viewer
Before, every triangle was shaded with its face normal, textures were sampled nearest-texel and interpolated in screen space, there was no anti-aliasing, and triangles under 0.15 px were dropped (pinholes in dense meshes).
src/model3d/shading.rs). Vertex normals are not decoded from the vertex stream yet, so they are rebuilt from topology: faces that share a vertex index smooth together (a GPU vertex carries one normal), and vertices duplicated at one position (UV seams, per-geometry quantization) are welded within a tolerance and smoothed only below a seam angle, so hard edges stay hard. Angle weighted. A Smooth toggle in the viewer shows the real facets.src/model3d/texture.rs). Trilinear sampling over a lazily built linear-light mip chain, alpha-weighted filtering for cutout and blended materials.src/model3d/raster.rs). Visibility-buffer rasterizer on a 1/256 px fixed-point grid with a top-left fill rule (watertight, no double blending along shared edges of glass), perspective-correct depth, UVs and normals, per-pixel lighting in linear light, tangent-space normal maps applied on the interpolated normal, a clearcoat for vehicle paint. Rows are rendered in bands on all cores; the resting frame is supersampled and area-filtered, and resolution adapts while the camera moves.Frame times on a 4-core Linux VM (optimized build, 1x samples): 1280x720 showcase scene 11.7 ms before, 12.0 ms after; one-million-triangle sphere 79.8 ms before, 48.9 ms after. The supersampled resting frame costs 56 ms and 116 ms respectively and is rendered once when input stops.
cargo test --release viewer_frame_times -- --ignored --nocapturereproduces the numbers.Export
vnnormals, andvtwith V flipped (textures are stored top row first, OBJ counts v from the bottom, so exported models imported with upside-down textures). From the viewer the export also writes a.mtland the applied textures as PNG. The batch and CLI exporters still write one geometry file per model. Behaviour change: existing OBJ consumers that compensated for the flipped V need to drop that workaround.MASK/BLENDalpha modes; shadow-proxy geometry is left out.Texture decoding
Color32::from_rgba_unmultiplied, which premultiplies: colour was zeroed at alpha 0, so textures whose alpha channel carries data rendered dark and PNG export could not restore them. Texels are now kept straight and premultiplied only for the egui texture browser. This also fixes the GPU world view, which uploaded the premultiplied bytes as straight alpha.c0 <= c1); they are always four-colour.BC4_SNORM/BC5_SNORMwere decoded as UNORM.is_normal_format()treated single-channel BC4 masks as normal maps.Security and robustness
C:\Users\O'Brien, broke out of the command); a stale update folder aborts the update; the validated bytes are the bytes installed; "View Release" no longer goes throughcmd /C start.binkplay.exe,bink2w64.dllanddxcompiler.dllare no longer picked up from the working directory or from the folder of an opened file (a planted binary in a dump folder would run). Explicit overrides:BINKPLAY_PATH,BINK2_DLL,DXCOMPILER_DLL. Behaviour change: adxcompiler.dllfound only throughPATHis no longer loaded...\..\xcannot leave the chosen folder.tex,rsc9,anim,awc,psin,dat,rdna2,boot,sgd5,dxbc,mapdata(details in the commit message). A.rpfshorter than 4 bytes panicked the folder scan thread, which then re-ran on every launch.Testing
cargo test: 96 passed, 0 failed, 5 ignored on Linux. v1.4.7 does not compile there without the first commit. The new tests cover:cargo check --target x86_64-pc-windows-gnuis clean, and the Windows release binary cross-builds.PercyStar demo.obj: the viewer opened the model with smooth shading and hard cube edges.cargo +1.88.0 checkis rejected by the pinned dependencies andcargo +1.89.0 checkbuilds.Found during the audit, not addressed here
scan_cachenever evicts superseded keys;audio_bank_metais not cleared between folders.world_gpu.rs: surface errors are not handled (viewer freezes onOutdated/Lost), adapter failures panic instead of using the existing failure path, buffer sizes are not checked against device limits, the shadow map is refreshed every other frame while its matrix updates every frame, normals are transformed without the inverse transpose under non-uniform scale.scripts/setup_deps.ps1installsbinkplay.exefrom a reused temp folder without verifying it.LICENSEv1.2 section 1(b).@rpatty-dev on GitHub · 2026-11-22 16:10 UTC · original
Merged and released in v1.4.7! 🚀
README.mdunder Code & Research Contributors.cargo test(96 passed; 0 failed) andcargo build --release.Thanks again for the awesome 3D viewer and exporter work!