Open martinRenou opened 1 month ago
For reference, this is where the logarithmic depth computation is performed using the new ThreeJS shading language (TSL) https://github.com/mrdoob/three.js/blob/48e6e2ee4e769013b911a079a433aecc2686d5b2/src/nodes/display/ViewportDepthNode.js#L119.
We could then simply offset the result of this function, and pass this to the depth parameter of the NodeMaterial.
With the recent changes in ThreeJS, and the introduction of NodeMaterials in core ThreeJS accessible when using the WebGPURenderer, it may be interesting to look into switching to using it.
Though after a quick look, it seems the
stencil
buffer is not usable yet using this renderer? So this may be a no-go as of today.Using node materials could eventually allow us to fix the z-fighting issue when using the logarithmic depth buffer (failed attempt in https://github.com/jupytercad/JupyterCAD/pull/503 with using the default renderer). Node materials would allow tweaking the depth computation in the fragment shader, by extending
MeshBasicNodeMaterial
.