Skip to content

Commit

Permalink
Merge pull request #1176 from Kurtil/fix/pickNormal32bit
Browse files Browse the repository at this point in the history
fix pick normal
  • Loading branch information
xeolabs authored Oct 13, 2023
2 parents 5f99490 + d7acbd4 commit 7f8ae48
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/viewer/scene/webgl/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,10 @@ const Renderer = function (scene, options) {
getClipPosY(canvasPos[1], gl.drawingBufferHeight),
];

const pickNormalBuffer = renderBufferManager.getRenderBuffer("pick-normal", { size: [1, 1] });

pickNormalBuffer.bind(gl.RGBA32I);

gl.viewport(0, 0, 1, 1);

gl.enable(gl.DEPTH_TEST);
Expand All @@ -1496,7 +1500,9 @@ const Renderer = function (scene, options) {

pickable.drawPickNormals(frameCtx); // Draw color-encoded fragment World-space normals

const pix = pickBuffer.read(0, 0);
const pix = pickNormalBuffer.read(0, 0, gl.RGBA_INTEGER, gl.INT, Int32Array, 4);

pickNormalBuffer.unbind();

const worldNormal = [
pix[0] / math.MAX_INT,
Expand Down

0 comments on commit 7f8ae48

Please sign in to comment.