BASIC

Author Topic: 3D Alpha  (Read 1905 times)

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1543
    • View Profile
3D Alpha
« on: 2009-Nov-21 »
Objects that are drawn with an opaque alphamode only allow other objects that have been pre-drawn to be seen thru. Is there a way for post-drawn objects?


Code: GLBasic [Select]
// Sample of triangles drawn behind first are only opaque.
funStart3DAlpha()

FUNCTION funStart3DAlpha:
        funCreateTriangle(0)
        funAnimate()
ENDFUNCTION

FUNCTION funAnimate:
        LOCAL z
       
        WHILE TRUE
                X_MAKE3D 1,10, 45
                X_CAMERA 0, 0.25, -2, 0, 0, 4          
                ALPHAMODE 0.075
                FOR z=1 TO 3
                        X_MOVEMENT -1,  0, 4-z
                        X_DRAWOBJ   0, -1
                NEXT
                FOR z=1 TO 3
                        X_MOVEMENT  1,  0, z
                        X_DRAWOBJ   0, -1
                NEXT
                SHOWSCREEN
        WEND
ENDFUNCTION

FUNCTION funCreateTriangle: num
        LOCAL col

        col=RGB(255,255,255)
        X_OBJSTART num
        X_OBJADDVERTEX -0.5,  0.5, 0.0,  0.1, 1.0,  col
        X_OBJADDVERTEX  0.0, -0.5, 0.0,  0.5, 0.0,  col
        X_OBJADDVERTEX  0.5,  0.5, 0.0,  0.5, 1.0,  col
        X_OBJEND
ENDFUNCTION

[attachment deleted by admin]
« Last Edit: 2009-Nov-21 by matchy »

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: 3D Alpha
« Reply #1 on: 2009-Nov-21 »
You need to z-order the objects, need more processing.

For billboarding, Point sprites are coming in the future, these might solve blending in non ordered systems, i dont really know.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1543
    • View Profile
Re: 3D Alpha
« Reply #2 on: 2009-Nov-22 »
It's like i need to toggle the z-order only for the certain objects but it's not important for now.  :good:


Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: 3D Alpha
« Reply #3 on: 2009-Nov-23 »
It's like i need to toggle the z-order only for the certain objects but it's not important for now.  :good:

Hmm, there are objects that will render translucent, without z ordering?
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1543
    • View Profile
Re: 3D Alpha
« Reply #4 on: 2009-Nov-23 »
The order the the objects that are X_OBJDRAWn determines the translucency to the next object. That is, they are still see through, but other other objects are not seen through. For example, a player in the middle of a map can see through translucent object that are to the -x & -z from the player . This is the same for X_SPRITE.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: 3D Alpha
« Reply #5 on: 2009-Nov-23 »
I know what youre talking about now.
It is accidental z ordering.
Youll still experience blending issues in the -z direction of the cam also , if the ordering fluxuates.

Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)