ALHAMODE Error

Previous topic - Next topic

bigsofty

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...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Oh dear. Of course, if you want it that way, you should be sorting them first, and draw them back to front. later.

bigsofty

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...?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

That might be an option. Though I'm not of much help here. I don't even have a shader compatible card :(

bigsofty

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...
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

If you're putting in enough particles, z-order should not be noticable, I guess.

bigsofty

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?
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

Yes, there is:
Code (glbasic) Select
// 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.

bigsofty

Cool! Thank you... that was simple :)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

mikiex

Do you have some screenshots or examples of the problems your having? Maybe I can help

bigsofty

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.
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

Kitty Hello

...you're drawing the whole scene before the particles, are you? Just the particle's themselfes are sorted incorrectly, maybe.
Like:
SetCamera()
DrawScene()
DrawParticles()

mikiex

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

bigsofty

Quote from: mikiex
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
Anything you can add would be appreciated Mikie ;)
Cheers,

Ian.

"It is practically impossible to teach good programming style to students that have had prior exposure to BASIC.  As potential programmers, they are mentally mutilated beyond hope of regeneration."
(E. W. Dijkstra)

mikiex

need an example screenshot or exe to see what it looks like