Laggy depth texture

I am trying to implement outlines using custom post process and though I have managed to get outlines, it seems to lag a bit. Its does not looks performance issue but not sure what causing it but I suspect it is because of depth texture. this is playground of reproduction.

Looks super fast for me:

Oh, didn’t profile it, since scene seems to not lag but just the post-processing layer which is seem to lagging behind. Thank you so much.

1 Like

You can get rid of the post-process lag by turning the reusable argument of the PostProcess constructor to false:

I honestly have no idea why it fixes it, but it works x)

When reusable is set to true, it is expected the post-process will be reused by another post-process in the same frame, so there’s a ping-pong texture which is setup. If you don’t have another post-process, the ping-pong is still done, and the texture you get in your “depthbuffer” post-process is the wrong one. So, as @CrashMaster said, the right fix is to set reusable=false.

Also, you should name the fragment shader customPixelShader in the shader store, not customFragmentShader. And you must instruct the shader material with the uniforms you want to use in your shader (see line 55):

With these changes, you will generate the right render target texture:

1 Like