Skip to content

Commit 77223f5

Browse files
committed
body: address codex P2 review — highp LOD lookup, vessel depth-write, portable bake paths
Three P2s from the codex review on #64: - Server-LOD row lookup is now highp (aRow attribute + vRow varying + uLodN + the texel-center divide). mediump's minimum precision can't distinguish all 1658 concept IDs, so the LOD texture sampled neighboring actions → wrong cull on mobile GPUs. - The always-blended #17 vessel pass (transMat) no longer flips depthWrite=true when returning to solid mode; it stays depthWrite=false in both modes, so its unsorted triangles can't self-occlude later transparent surfaces. - body-soa-wire (soabake reference) uses sibling-relative path deps (../../../../../{lance-graph,ndarray}) instead of absolute /home/user paths, so the BSO2 wire + LOD blocks rebuild from any checkout (/build/q2, /workspace/q2).
1 parent d7718e4 commit 77223f5

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

cockpit/src/BodyV3.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,23 @@ function decodeBso2(buf: ArrayBuffer): Decoded {
178178
}
179179

180180
const VERT = `
181-
attribute vec3 aColor; attribute float aAlpha; attribute float aLayer; attribute float aRow;
182-
varying vec3 vNormal; varying vec3 vColor; varying float vAlpha; varying float vLayer; varying float vRow;
181+
attribute vec3 aColor; attribute float aAlpha; attribute float aLayer; attribute highp float aRow;
182+
varying vec3 vNormal; varying vec3 vColor; varying float vAlpha; varying float vLayer; varying highp float vRow;
183183
void main(){ vNormal = normalMatrix * normal; vColor = aColor; vAlpha = aAlpha; vLayer = aLayer; vRow = aRow;
184184
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); }`;
185185
const FRAG = `
186186
precision mediump float;
187187
uniform float uEnabled[9]; uniform float uGlobalAlpha;
188-
uniform sampler2D uLod; uniform float uLodN; uniform float uLodOn; // server HHTL LOD gate
189-
varying vec3 vNormal; varying vec3 vColor; varying float vAlpha; varying float vLayer; varying float vRow;
188+
uniform sampler2D uLod; uniform highp float uLodN; uniform float uLodOn; // server HHTL LOD gate
189+
varying vec3 vNormal; varying vec3 vColor; varying float vAlpha; varying float vLayer;
190+
varying highp float vRow; // highp: concept IDs up to ~1658 + the texel-center divide must
191+
// resolve exactly; mediump's min precision aliases adjacent rows.
190192
void main(){
191193
int li = int(vLayer + 0.5);
192194
if(li < 1 || li > 8 || uEnabled[li] < 0.5) discard; // compartment gate
193195
if(uLodOn > 0.5){ // server LOD: HhtlAction 0=Reject ⇒ cull
194-
float act = texture2D(uLod, vec2((vRow + 0.5) / uLodN, 0.5)).r;
196+
highp vec2 uv = vec2((vRow + 0.5) / uLodN, 0.5);
197+
float act = texture2D(uLod, uv).r;
195198
if(act < 0.002) discard; // 0/255 = Reject
196199
}
197200
vec3 n = normalize(vNormal); if(!gl_FrontFacing) n = -n;
@@ -306,9 +309,10 @@ function mount(container: HTMLDivElement, d: Decoded, st: RenderState, onStats:
306309
camera.position.lerp(tmp.clone().add(dir.multiplyScalar(st.focus.d)), 0.12);
307310
}
308311
if (st.transparent !== wasT) {
309-
// flip the solid group into the x-ray (whole-body translucent) and back
312+
// flip ONLY the solid group into the x-ray (whole-body translucent) and back.
313+
// transMat is the always-blended #17 vessel pass — it must keep depthWrite OFF
314+
// in both modes, or its unsorted triangles self-occlude later transparent ones.
310315
opaqueMat.transparent = st.transparent; opaqueMat.depthWrite = !st.transparent; opaqueMat.needsUpdate = true;
311-
transMat.depthWrite = !st.transparent;
312316
wasT = st.transparent;
313317
}
314318
postLod(now);

crates/osint-bake/tools/body-soa-wire/Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@ edition = "2021"
55
publish = false
66
[workspace]
77
[dependencies]
8-
lance-graph-contract = { path = "/home/user/lance-graph/crates/lance-graph-contract", features = ["guid-v3-tail"] }
9-
ndarray = { path = "/home/user/ndarray", default-features = false, features = ["std", "splat3d"] }
8+
# Relative to the sibling-clone layout (lance-graph + ndarray next to q2 — the same
9+
# /build/q2 + /build/lance-graph + /build/ndarray the Dockerfile clones, and the local
10+
# /home/user/{q2,lance-graph,ndarray} dev layout). Rebuildable from any checkout.
11+
lance-graph-contract = { path = "../../../../../lance-graph/crates/lance-graph-contract", features = ["guid-v3-tail"] }
12+
ndarray = { path = "../../../../../ndarray", default-features = false, features = ["std", "splat3d"] }
1013
serde_json = "1"
1114
[profile.release]
1215
opt-level = 3

0 commit comments

Comments
 (0)