Skip to content

Commit

Permalink
XCD-196 Sort normalFillTransparentBin drawables by their distance fro…
Browse files Browse the repository at this point in the history
…m the eye before draw calls
  • Loading branch information
MichalDybizbanskiCreoox committed Dec 27, 2024
1 parent 9f2ba28 commit 20f9071
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/viewer/scene/webgl/Renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {SAODepthLimitedBlurRenderer} from "./sao/SAODepthLimitedBlurRenderer.js"
import {RenderBufferManager} from "./RenderBufferManager.js";
import {getExtension} from "./getExtension.js";

const vec3_0 = math.vec3([0,0,0]);

/**
* @private
*/
Expand Down Expand Up @@ -713,9 +715,11 @@ const Renderer = function (scene, options) {
// Transparent color fill

if (normalFillTransparentBinLen > 0) {
const eye = frameCtx.pickOrigin || scene.camera.eye;
const byDist = normalFillTransparentBin.map(d => ({ drawable: d, distSq: math.distVec3(d.origin || vec3_0, eye) }));
byDist.sort((a, b) => b.distSq - a.distSq);
for (i = 0; i < normalFillTransparentBinLen; i++) {
drawable = normalFillTransparentBin[i];
drawable.drawColorTransparent(frameCtx);
byDist[i].drawable.drawColorTransparent(frameCtx);
}
}

Expand Down

0 comments on commit 20f9071

Please sign in to comment.