Drawing to Zbuffer

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
MrJones
Posts: 15
Joined: Sun May 23, 2010 1:02 pm

Drawing to Zbuffer

Post by MrJones »

For some specific effect, I wonder how I can, inside a custom scene node's render function, draw a polygon which is completely transparent (= not changing anything visibly when drawn) but updates the zbuffer as if solid/opaque.

I think of something like the reverse of a solid opaque object with zwrite off: an invisible object but rendering to the zbuffer like with zwrite even for transparent parts.

It would be sufficient for me to use this with a triangle list, not an actual complete scene node. Also I use OpenGL if that helps.

Is there a way to do this?
blub
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

How about adding a transparent texture/color to all polys in the mesh?


Also, the last post of this thread might help -- not sure. (solid inside transparent pass or transparent inside solid pass?)

http://irrlicht.sourceforge.net/phpBB2/ ... hp?t=43178
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

just use a polylist with vertex color totally transparent and use ONE_TEXTUREBLEND as material type and as blending function use what ever suits you but use the vertex color as transparent.
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

Use the ColorMask attribute of the node's SMaterial to prevent it from drawing to the screen. (This is even the way it's recommended in the comment there)
Yarcies
Posts: 7
Joined: Wed Feb 23, 2011 1:27 am

Post by Yarcies »

While I don't know for sure, I am pretty certain that any sort of usual color masking or transparent texture will NOT cause the polygon to fill the zbuffer (since Irrlicht checks for a 0.5 alpha treshold to do that usually).

Therefore I don't think any of the usual "just make the polygon appear transparent" approaches work, since then that would also stop them from rendering to the zbuffer. If I'm wrong with that then I'll happily use that color mask approach (will test tomorrow).

I am not sure if the vertex color approach is also prone to that 'limitation' (actually it makes sense in any normal scenario that the zbuffer is left untouched for invisible parts), but I am pretty sure both color keying and simply using a transparent texture are.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just render the node as usual (EMT_SOLID), except that you change the color mask to ECM_NONE. Just like Lonesome Ducky said, this is what the color mask is meant for. And it works correctly for the usual zbuffer fill / early z-out approaches.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

If you used the transparency approach, wouldn't the node be drawn in the transparent pass? This would draw it after the other nodes. If you try drawing the node in the solid pass before the others, I don't think it will render. Food for thought :)
Yarcies
Posts: 7
Joined: Wed Feb 23, 2011 1:27 am

Post by Yarcies »

Just render the node as usual (EMT_SOLID), except that you change the color mask to ECM_NONE.
Nice, thanks :) I will go with this approach then
If you used the transparency approach, wouldn't the node be drawn in the transparent pass? This would draw it after the other nodes. If you try drawing the node in the solid pass before the others, I don't think it will render.
Well... I will have a custom scene node and then in the render method, I will manually render (using the draw triangle list) first some solid wall surface with zwrite disabled, then a semi-transparent decals thing also with zwrite disabled, and then that ECM_NONE polygon to fill out the z-depth space afterwards.

Basically I just want to draw a wall with decals on it without having any z-fight issues between the wall and the decals.
Lonesome Ducky
Competition winner
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Post by Lonesome Ducky »

A problem with that approach is that if a wall behind you has decals on it, the decals from the wall behind will be drawn ahead of the wall in front of you. Almost like xray vision :lol: . You may also end up finding that without z-write, parts of the walls will be drawn over each other when they shouldn't be.
Post Reply