transparency in 3d

M.Oostrik's picture

Simple question

I have 3 semi transparent sprites in a trackball. I like the blending to be over. The Depth testing is read/Write

When i look at them from the front the blend right. but when i look at them from the back they don't blend at all.

what am i missing here?

or

what is the solution?

PreviewAttachmentSize
front.PNG
front.PNG26.93 KB
back.PNG
back.PNG22.82 KB
3D transparancy.qtz4.97 KB

gtoledo3's picture
Re: transparency in 3d

You're butting up against QC's layering scheme...

What you could try is to use Kineme Depth Sort Sprite/Environment (there should be a sample composition, I think). I believe this would solve your problem.

You could also try making or using a patch that draws quad strips or discrete quads (or whatever), and then specify all your points/colors...it seems like that works, but I can't remember for sure.

Scratchpole's picture
Re: transparency in 3d

Yep Depth Sort Sprite inside Depth Sort Environment sorts that out. I do find it amazing that things like this managed to escape the notice of apples programmers. Good on you Kineme!

toneburst's picture
Re: transparency in 3d

It's not an Apple issue- it's an OpenGL issue, and a problem that's hard to deal with effectively in any realtime 3D setup.

Apple could have worked around that by implementing depth-sorting or some kind of multipass rendering solution for order-independent transparency 'out of the box', but that would have a knockon effect on performance, and would be unnecessary in most common scenarios. Even checking to see if such a workaround would be necessary, and switching it on dynamically would degrade performance, since any QC geometry could become less that 100% opaque at any time.

Also, the idea of the render-order of QC patches changing at runtime goes against some of QCs fundamental concepts.

a|x

M.Oostrik's picture
Re: transparency in 3d

The Depth Sort stuff is a good solution for this example. thanx

Unfortunately I'm not working with with sprites but with meshes. The sprites are just there for a simple example.

I guess i'll use add blending for transparency or just work without transparency. it's a bloody shame ;)

gtoledo3's picture
Re: transparency in 3d

Core animation does z sort layers for free.

Scenegraph environments do z sorting.

If every object in qc is in an array like they end up in, one would make sure they're ordered in z... I see your theory about this being more expensive, but done correctly, it could be more effective and perform better, since offscreen or occluded geometry could be kept from rendering, plus the benefits of a modern z sort/ graph environment and geometry being able to be "aware" of other geometry since so much of it isn't tied into a renderer that dictates a bunch of stuff.