OpengGL 4.5 with LWJGL
For my particle system, I have billboards that are rendered to an off screen texture. This FBO contains texture information, multiple render targets, a depth texture and a depth buffer. What I'd like to happen is for me to be able to render all my particles to the FBO, add some stuff to them, then render them to my scene with depth testing. I've tried manually depth testing, but I couldn't get that to work (It created large chunks of pixels that would appear and disappear, probably a precision error, but I'm using RGBA16 so I would assume that would be enough).
What I did for manual depth testing : if(gl_FragCoord.w < sceneDepth.x) then discard pixel.
One idea I have in mind is to manually replace the depth buffer of my FBO with the depth buffer of the scene, but I have no idea how I could do this.
I was able to get the clipping effect when it wasn't rendered to an FBO, for obvious reasons, but I have no idea how I could recreate this while using an FBO. How can I recreate this?
What I get (No clipping because no depth information)
Any help would be much appreciated.