I seem to be stuck a bit or cannot wrap my head around it.
I do have a (generated) mesh, which I want to render semi-transparent and I stumble over the issue with rendering order - as you can see some faces are visible behind on the transparent mesh (this is from my voxel engine voyage)
Is this solveable with a custom blendstate by only considering backbuffer pixels and not freshly plotted pixels? Obviously I cannot change the rendering order of the faces in that mesh but I think this can be done with a custom blendstate somehow but I can’t wrap my head over the different parameters
PS: Yes those transparent objects are already done in their own pass
Just turn off the depth buffer when rendering the transparent mesh
That’s not changing the problem, because the main problem is, that the face behind is drawn first, and the face in front is rendered afterwards - the results get blended - depth buffer would not change that behaviour. DepthBuffer WOULD prevent that, if the rendering order is correct (which is why you pre-oder transparent parts for rendering) - but this is just a whole mesh
I actually may just be wrong and this cannot be solved with BlendStates, and maybe it just can’t get solved at all, except rendering all models which are supposed to be semitransparent to another rendertarget and just overlay that rendertarget with alpa over the backbuffer … that would actually work, I just wonder if there is a better approach
Then you need to start reading up on stencil buffers, that may be your solution.
That would involve an additional render pass - I use stencil for Unit Selection. I guess I am going with the variant with the additional rendertarget, as I have plenty available from the deferred pipeline anyway (those transparent things are rendered in a forward pass)
I had this problem before, I ended up rendering it first CCCW and then CCW for polyhydron model and single pass only if quad, not sure if it will work on your case.
nice idea in general - anyway, if it’s not possible in one pass, I rather just render it to a rendertarget and plot the result over the screen with 0.5 opacity