You are not logged in.

#1 2010-12-07 00:33:23

EvilTroopa
Member

[RESOLVED] Transparency problem in 3D

Hi !
I've been using GRRLIB for a while now and I'm very happy with it, especially since it came to 3D.

I've been making a 3D demo using GRRLIB and homemade obj import (my youtube video here : http://www.youtube.com/watch?v=naTD3JPOKzI and french tutorial if interested)

I want to take that project to the next step. I already have new, nicer objects, but my problem is about sprites with transparency.
I use them for grass, it's just 2 tris with a mostly transparent texture.
When I draw them, it prints transparent zones into the Z-Buffer and objets behind the printed later have a rectangle on them showing the background.
I could pass through that problem printing all my transparent objects last, but I don't like that solution.

I'm not really good with GX, so I'm not sure where to search.
I've already been able to make a sky sphere that doesn't put any data in the ZBuffer. But alpha and ZBuffer together are my current limit ^^
I've been looking at GX_SetBlendMode but I'm not sure how I could use it.

So... please help me !

Last edited by EvilTroopa (2010-12-07 00:48:22)

Offline

 

#2 2010-12-07 01:22:47

EvilTroopa
Member

Re: [RESOLVED] Transparency problem in 3D

OK, so after a little search in the "official" (hum) documentation, I found what to add in GRRLIB 3D init to make transparency and ZBuffer work the way I want them to.

In GRRLIB_3D.c, function GRRLIB_3dMode, after line 90 :

Code:

GX_SetZMode (GX_TRUE, GX_LEQUAL, GX_TRUE);
GX_SetZCompLoc(GX_FALSE); // This make ZBuffer update AFTER texturing

By default, on GX_Init(), GX_SetZCompLoc is set to true, which means ZBuffer is updated before texturing, thus ignoring alpha.

I don't know if this has any inconvenience for any other GRRLIB function, so please test it if you're interested in it and want to add it to the official release.



To admins : Can you tag that topic as Solved ?
(Thanks)

EDIT
====

So after a little more testing, this trick works perfectly fine with completely transparent areas, but any semi-transparent area will be put in the Z-Buffer.
I guess, I'll still have to sort my objects from far to near if I use transparency.

If anyone have any other trick for that kind of problem, please post it !

Last edited by EvilTroopa (2010-12-08 21:48:14)

Offline

 

Board footer

Powered by FluxBB