Skip to content

Commit

Permalink
Draft: Use copyDepthFrameBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed May 13, 2024
1 parent e4a93bb commit fd2c9fd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
22 changes: 13 additions & 9 deletions packages/engine/Source/Scene/PickDepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import FramebufferManager from "../Renderer/FramebufferManager.js";
import RenderState from "../Renderer/RenderState.js";
import PassThrough from "../Shaders/PostProcessStages/PassThrough.js";
import PassThroughDepth from "../Shaders/PostProcessStages/PassThroughDepth.js";

/**
* @private
Expand Down Expand Up @@ -30,17 +32,19 @@ function updateFramebuffers(pickDepth, context, depthTexture) {

function updateCopyCommands(pickDepth, context, depthTexture) {
if (!defined(pickDepth._copyDepthCommand)) {
const fs =
"uniform highp sampler2D u_texture;\n" +
"in vec2 v_textureCoordinates;\n" +
"void main()\n" +
"{\n" +
" out_FragColor = czm_packDepth(texture(u_texture, v_textureCoordinates).r);\n" +
"}\n";
pickDepth._copyDepthCommand = context.createViewportQuadCommand(fs, {
// pickDepth._copyDepthCommand = context.createViewportQuadCommand(PassThroughDepth, {
// renderState: RenderState.fromCache(),
// uniformMap: {
// u_depthTexture: function () {
// return pickDepth._textureToCopy;
// },
// },
// owner: pickDepth,
// });
pickDepth._copyDepthCommand = context.createViewportQuadCommand(PassThrough, {
renderState: RenderState.fromCache(),
uniformMap: {
u_texture: function () {
colorTexture: function () {
return pickDepth._textureToCopy;
},
},
Expand Down
3 changes: 2 additions & 1 deletion packages/engine/Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -2688,7 +2688,8 @@ function executeCommands(scene, passState) {
renderTranslucentDepthForPick)
) {
// PERFORMANCE_IDEA: Use MRT to avoid the extra copy.
const depthStencilTexture = globeDepth.depthStencilTexture;
//const depthStencilTexture = globeDepth.depthStencilTexture;
const depthStencilTexture = globeDepth._copyDepthFramebuffer.getColorTexture();
const pickDepth = scene._picking.getPickDepth(scene, index);
pickDepth.update(context, depthStencilTexture);
pickDepth.executeCopyDepth(context, passState);
Expand Down

0 comments on commit fd2c9fd

Please sign in to comment.