feat(firms): add Navara renderer checkpoint

This commit is contained in:
German Khokhlov committed 2026-10-28 09:36:50 +04:00
1 parent a9b3125a99
commit 5dd05a4a81
33 files changed
+2112 -285

No files matched your search

@@ -0,0 +1,45 @@
// Public depth inputs shared by actual terrain/tiles classifiers.
import {
DataTexture,
FloatType,
RGBAFormat,
NearestFilter,
Matrix4,
Uniform,
RGBADepthPacking,
} from 'three';
export function createGroundTexture(data, width, height) {
const texture = new DataTexture(data, width, height, RGBAFormat, FloatType);
texture.minFilter = NearestFilter;
texture.magFilter = NearestFilter;
texture.needsUpdate = true;
return texture;
}
export function createGroundStorage(texels) {
const width = Math.min(1024, Math.max(1, texels));
const height = Math.max(1, Math.ceil(texels / width));
const data = new Float32Array(width * height * 4);
return {
data,
width,
height,
texture: createGroundTexture(data, width, height),
};
}
export function groundSurfaceUniforms() {
return [
['tAllDepth', new Uniform(null)],
['tSurfaceDepth', new Uniform(null)],
['uInverseProjection', new Uniform(new Matrix4())],
['uLogDepthFC', new Uniform(1)],
];
}
export function updateGroundSurface(effect, camera, context, mrt) {
if (mrt?.depthBufferPacking !== RGBADepthPacking)
throw new Error('Ground classification requires packed scene depth');
const u = effect.uniforms;
u.get('tAllDepth').value = mrt.depthBuffer;
u.get('tSurfaceDepth').value = context.getRenderTarget().depthTexture;
u.get('uInverseProjection').value.copy(camera.projectionMatrixInverse);
u.get('uLogDepthFC').value = 2 / Math.log2(camera.far + 1);
}