I'm having problems with alphamode again. When I use it in 2D no problems but in 3D drawing several objects on top of eachothers there is no blending if the camera is placed straight in front of the objects (0,0,-50 -> 0,0,0). However if I move the look at point slightly up or down the objects starts blending. I have tried moving some objects a little bit further back or in front with no difference.
Here is the code, use the mouse to move the middle square, buttons for aiming the camera up or down. As you might notice not all objects are blending the whole time, it depends on where the center square is placed. Try moving it around a bit.
SETTRANSPARENCY RGB(0,0,0)
DRAWRECT 5,5,22,22,RGB(128,128,128)
GRABSPRITE 1, 0,0, 32,32
LOCAL mx, my, b1, b2
WHILE TRUE
PRINT "Move the mouse!", 5, 5
mx = mx + MOUSEAXIS(0)
my = my + MOUSEAXIS(1)
IF MOUSEAXIS(3) THEN INC look_at, 0.1
IF MOUSEAXIS(4) THEN DEC look_at, 0.1
X_MAKE3D 1, 1000, 45
X_CAMERA 0, 0, -50, 0, look_at, 0
X_AMBIENT_LT 0, RGB(255,255,255)
ALPHAMODE .4
X_SPRITE 1, 8, 0, 0, 1
X_SPRITE 1, -8, 0, 0, 1
X_SPRITE 1, -mx/10, -my/10, 0, 1
X_SPRITE 1, 0, 8, 0, 1
X_SPRITE 1, 0, -8, 0, 1
//X_DRAWAXES 0, 0, 0
SHOWSCREEN
WEND
Ya this is a known issue.
The solution i think is to point at 0,1,0
a position of 1 in any axis, is truely an insignificant size.
The problem is looking at 0,0,0
Correct me if im wrong, if im not mistaking, this is an opengl "feature".
Try the example, there is still problems if you point in other directions than 0 0 0.
Aye x_sprite and alpha are not working together properly.
Have you tried this with normal objects?
Z-fighting problem here.
Make sure you draw the "further away" objects first.
I have tried setting them in the order back->front but that didn't do any difference
I found the problem: x_sprite
z-ordering didnt help x_sprite blending.
Proof of concept, z-ordered( back to front ), below i used a 3 point object, instead of x_sprite:
SETTRANSPARENCY RGB(0,0,0)
DRAWRECT 5,5,22,22,RGB(128,128,128)
GRABSPRITE 1, 0,0, 32,32
LOCAL mx, my, b1, b2
X_OBJSTART 0
X_OBJADDVERTEX 0,10,0, 0, 0, RGB(255,255,255)
X_OBJADDVERTEX 0,0,0, 0, 0, RGB(255,255,255)
X_OBJADDVERTEX 10,0,0, 0, 0, RGB(255,255,255)
X_OBJEND
WHILE TRUE
PRINT "Move the mouse!", 5, 5
mx = mx + MOUSEAXIS(0)
my = my + MOUSEAXIS(1)
IF MOUSEAXIS(3) THEN INC look_at, 0.1
IF MOUSEAXIS(4) THEN DEC look_at, 0.1
X_MAKE3D 1, 1000, 90
X_CAMERA 1000 , 1000, 950, 1000 , 1000+look_at, 1000
X_AMBIENT_LT 0, RGB(255,255,255)
ALPHAMODE .4
X_MOVEMENT 1000, 1000+4, 1000+5
X_DRAWOBJ 0,0
X_MOVEMENT 1000+4, 1000, 1000+4
X_DRAWOBJ 0,0
X_MOVEMENT 1000-4, 1000, 1000+3
X_DRAWOBJ 0,0
X_MOVEMENT 1000-mx/10, 1000-my/10, 1000+2
X_DRAWOBJ 0,0
X_MOVEMENT 1000, 1000-4, 1000+1
X_DRAWOBJ 0,0
X_DRAWAXES 1000, 1000, 1000
SHOWSCREEN
WEND
I can probably make a billboard function where the object faces the camera, but the problem with this is, that itll be a slow down using CPU to do the math.
Im pretty sure it is x_sprite with the issue, because objects work just fine(as long as z-ordering back to front is positioning the objects correctly).
I think it's because the objects are on the same z-level when rendered. I'll take a peek, though.
Quote from: Kitty Hello on 2009-Aug-17
I think it's because the objects are on the same z-level when rendered. I'll take a peek, though.
Ill post a code showing both objects and xsprite on the same screen.
Youll see objects are OK, and xsprite is bad.
Be back in about 10 minutes..
Gernot,
Test this code below....and follow these steps to watch the effects...
Test step 1: first run, dont click the mouse, just move the mouse.
You will see how the blending is working for both xsprite and xobject when camera is center.
Test step2: right click or left click, the camera moves up or down.
here you will see x object properly blends, and x sprite does not.
SETTRANSPARENCY RGB(0,0,0)
DRAWRECT 5,5,22,22,RGB(128,128,128)
GRABSPRITE 1, 0,0, 32,32
LOCAL mx, my, b1, b2,look_at
X_OBJSTART 0
X_OBJADDVERTEX 0,10,0, 0, 0, RGB(255,255,255)
X_OBJADDVERTEX 0,0,0, 0, 0, RGB(255,255,255)
X_OBJADDVERTEX 10,0,0, 0, 0, RGB(255,255,255)
X_OBJEND
WHILE TRUE
PRINT "Move the mouse, and click right or left mouse buttons!", 5, 5
mx = mx + MOUSEAXIS(0)
my = my + MOUSEAXIS(1)
IF MOUSEAXIS(3) THEN look_at=20
IF MOUSEAXIS(4) THEN look_at=-20
X_MAKE3D 1, 1000, 45
//starting z ordering from front with 950
X_CAMERA 1000 , 1000+look_at, 950, 1000 , 1000, 1000
X_AMBIENT_LT 0, RGB(255,255,255)
ALPHAMODE .4
X_MOVEMENT 1000, 1000+4, 1000+4
X_DRAWOBJ 0,0
X_MOVEMENT 1000+4, 1000, 1000+3
X_DRAWOBJ 0,0
X_MOVEMENT 1000-4, 1000, 1000+2
X_DRAWOBJ 0,0
X_MOVEMENT 1000-mx/10, 1000-my/10, 1000+1
X_DRAWOBJ 0,0
X_MOVEMENT 1000, 1000-4, 1000
X_DRAWOBJ 0,0
X_SPRITE 1, 1000+20, 1000+4, 1000+4 ,1
X_SPRITE 1, 1000+4+20, 1000, 1000+3 ,1
X_SPRITE 1, 1000-4+20, 1000, 1000+2 ,1
X_SPRITE 1, 1000-mx/10+20, 1000-my/10, 1000+1 ,1
X_SPRITE 1, 1000+20, 1000-4, 1000 ,1
X_DRAWAXES 1000+10, 1000, 1000
SHOWSCREEN
WEND
X_SPRITE 1, 1000+20, 1000+4, 1000+55 ,1
X_SPRITE 1, 1000+4+20, 1000, 1000+44 ,1
X_SPRITE 1, 1000-4+20, 1000, 1000+33 ,1
X_SPRITE 1, 1000-mx/10+20, 1000-my/10, 1000+22 ,1
X_SPRITE 1, 1000+20, 1000-4, 1000 ,1
Really, it _is_ a Z-fighting problem. The x_obj is not rotated to face the camera. The billboards are.
Try putting a 3D object in between the 2 X_Sprites to see that it's not possible.