Reputation: 31
I'm creating a box and placing "magnets" on the bottom. The sides are slightly see through(alpha is somewhere between .2 and .5) and the bottom is solid. I'm trying to use gluUnProject() to select where the "magnet" is placed, but when the sides of the box are rendered, I can't get my magnets into the box.
Is there anyway to still have the sides of the wall to be rendered but ignore them for the sake of mouse clicks?
I've tried GL_CULL_FACE but at first glance that doesn't seem to be what I'm looking for.
Upvotes: 0
Views: 144
Reputation: 772
So if I understand correctly, you have semi-transparent boxes and when the magnet is inside the boxes you want to see the magnet in according to the semi-transparency of the boxes.
My guess is that when you're drawing the boxes you have the depth writes turned on, this way if boxes happen to get drawn before the magnet, then when you draw the magnet it will fail the depth test and the part that's inside won't get drawn as a result.
The easiest way to do this is:
Draw all the solid objects first
Disable depth writes:
glDepthMask(GL_FALSE);
Use an order-independent blending function when drawing the semi-transparent objects, for example:
glBlendFunc(GL_ONE, GL_ONE)
Draw all your transparent objects
Enable depth writes again
glDepthMask(GL_TRUE);
Bear in mind this simple method will only work if you can get away with using an commutative blending equation, if not then consider using order-independent transparency, a good article is "Efficient Layered Fragment Buffer Techniques" By Pyarelal Knowles, Geoff Leach, and Fabio Zambetta
Upvotes: 4