Alphamode does not work in 3D, It simply does not blend properly using 'X_SPRITE' for example. Im writing a 3D particle system and its stopping the particles from blending properly. Works fine in 2D mode thought.
I have seen this problem before, as part of the development of Blitz3D, its a depth sorting issue with alpha blended textures... it was sorted by introducing the W-Buffer... not sure if its the same for OpenGL...
Oh dear. Of course, if you want it that way, you should be sorting them first, and draw them back to front. later.
Quote from: GernotFrischOh dear. Of course, if you want it that way, you should be sorting them first, and draw them back to front. later.
Eek! 10000+ particles!,,, I'll look into it, maybe there's an OpenGL solution to this...
Tried disabling the Z-buffer, this fixes the blending artefacts but messes up the draw order...
Idea: maybe use a vertex shader to sort the the vectors with the GPU...?
That might be an option. Though I'm not of much help here. I don't even have a shader compatible card :(
Sorry to hear that Gernot... :(
Im not making much headway Im afraid, everything I try is slowing the system down or messing up the graphics... its designed to work in 2D as well, so Ill concentrate on that for now...
If you're putting in enough particles, z-order should not be noticable, I guess.
The more particles, the more 'artefacts' are shown unfortunately, also if the Z-order is off, it kinda messes with other 3D objects... so a spaceship with particles, for its weapons, can sometimes be seen with shooting away from the camera with particles visible 'within' the spaceship body...
...Ive not given up yet, though, Im converting the system from frame based movement to time based and with this adding more custom OpenGL code to try and minimise this unwanted affect.
P.S. Gernot, is there any way I can get access, via in-line C, to the GLBasic internal data structures, say the pointer to a sprite image in memory?
Yes, there is:
// Now access a GLBasic sprite's internal
LOCAL someid
someid = get_sprite_texture(2);
That's the internal sprite/texture id you use with glBindTexture e.g.
Cool! Thank you... that was simple :)
Do you have some screenshots or examples of the problems your having? Maybe I can help
I've removed the alphablending from the particles for now and concentrated on the functionality.
The problem is simple but hard to fix.
If you make an x_sprite alphablended and do not display them (that is from back to front) in the correct Z order (usually the GFX card does this for you, but not when alphablending is on), then the usual depth sorting that OpenGL does for a scene simply gets messed up. Objects appear in front of objects, when they should be behind and in this case, blending does not work properly because the Z-buffer is messed up.
...you're drawing the whole scene before the particles, are you? Just the particle's themselfes are sorted incorrectly, maybe.
Like:
SetCamera()
DrawScene()
DrawParticles()
Quote from: bigsoftyI've removed the alphablending from the particles for now and concentrated on the functionality.
The problem is simple but hard to fix.
If you make an x_sprite alphablended and do not display them (that is from back to front) in the correct Z order (usually the GFX card does this for you, but not when alphablending is on), then the usual depth sorting that OpenGL does for a scene simply gets messed up. Objects appear in front of objects, when they should be behind and in this case, blending does not work properly because the Z-buffer is messed up.
I understand the problem, its something game developers have lived with for a long long time,
I just might be able to show you how to minimize the artefacts
Quote from: mikiexQuote from: bigsoftyI've removed the alphablending from the particles for now and concentrated on the functionality.
The problem is simple but hard to fix.
If you make an x_sprite alphablended and do not display them (that is from back to front) in the correct Z order (usually the GFX card does this for you, but not when alphablending is on), then the usual depth sorting that OpenGL does for a scene simply gets messed up. Objects appear in front of objects, when they should be behind and in this case, blending does not work properly because the Z-buffer is messed up.
I understand the problem, its something game developers have lived with for a long long time,
I just might be able to show you how to minimize the artefacts
Anything you can add would be appreciated Mikie ;)
need an example screenshot or exe to see what it looks like
Outa town at the mo... will post a couple of screenies when I get back...
...hmmm, you cant attach images here... better find a host...
Imageshack
Z buffer off, Alpha on
(http://img.photobucket.com/albums/v160/tidles666/part_z_off.jpg)
http://img.photobucket.com/albums/v160/tidles666/part_z_off.jpg
Z on, Alpha on
(http://img.photobucket.com/albums/v160/tidles666/part_alpha.jpg)
http://img.photobucket.com/albums/v160/tidles666/part_alpha.jpg
Z on, No Alpha
(http://img.photobucket.com/albums/v160/tidles666/part_noblend.jpg)
http://img.photobucket.com/albums/v160/tidles666/part_noblend.jpg
Opps sorry I've not been about.
If your going for an glowy explosion type effect you would want to use additive blending with no Z write. If the particles are additive it doesnt matter how they sort.
There all actually additive, I use my own openGL blending inline commands. Anything dependant on the the ZBuffer for blending has this problem unfortunately... this covers a LOT of the blending modes when in 3D.