Author Topic: Fake (Bloom, Glow 3d FX)  (Read 2679 times)

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Fake (Bloom, Glow 3d FX)
« on: 2011-Apr-27 »
Hi this is a little trick, for have a bloom, or a glow effect on 3D, geometry. You have to take care, whit the numers of polygons of mesh and the FOR TO command variables. On devices mobiles works fine, whit a litlle probe, I maded.

The code. (Media is attached on this post).
Code: GLBasic [Select]
         SETCURRENTDIR("Media") // seperate media and binaries?

        X_LOADOBJ "cube.dda",1

        LOADSPRITE "spr_Xsprite.png", 2

        LOADSPRITE "Untitled.png", 2

        WHILE TRUE

                X_MAKE3D 1,1000,45
                X_CULLMODE 1
                X_CAMERA 0,0,-100,0,0,0
                INC phi,1.0
               
                FOR p=0 TO 50
                ALPHAMODE -0.1+COS(phi)*p              
                X_SETTEXTURE 2,0
                zc=10
                        X_SCALING COS(phi)*(2+(p*2)/zc),COS(phi)*(2+(p*2)/zc),COS(phi)*(2+(p*2)/zc)
                X_ROTATION phi*3,1,1,1
                X_DRAWOBJ 1,0
                NEXT
               
               
                X_SETTEXTURE 1,0
                ALPHAMODE 0.8
                X_SCALING COS(phi)*1.2,COS(phi)*1.2,COS(phi)*1.2
                X_DRAWOBJ 1,0
               
               


        SHOWSCREEN
        WEND



[attachment deleted by admin]

Offline Slydog

  • Prof. Inline
  • *****
  • Posts: 930
  • KodeSource
    • View Profile
    • KodeSource
Re: Fake (Bloom, Glow 3d FX)
« Reply #1 on: 2011-Apr-27 »
Will check this out tonight when I get home.  (I have no un-rar program at work!)

But, by looking at the code, you used LOADSPRITE on two files but storing them internally in the same sprite id, '2'.
Then you use X_SETTEXTURE with both '1' and '2', so should one of the LOADSPRITEs be a '1' sprite id?

Here's a guess as to what this does: draws the same object (cube) 50 times a frame, but at different alphas and scales, to gradually get bigger and more transparent, to the effect that the cube is glowing?  (Then draws the original cube again on top).  Oh well, I'll know in a few hours!
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Offline mentalthink

  • Prof. Inline
  • *****
  • Posts: 3366
  • Integrated Brain
    • View Profile
Re: Fake (Bloom, Glow 3d FX)
« Reply #2 on: 2011-Apr-27 »
Hi Slydog, yes you are in the correct point, are only the same mesh duplicated, varies the effect whit the number of cubes, meshes or any type of .ddd files.

About the 2 loadsprite, don´t have too much sense, don´t care, when I maded the code, I try 2 textures is only this, you can use one, or another, in example a white texture and a sphere objets is a cool bloom effect. On my Palm Pre whit 1.4.5 when I put a some numbers of spheres go down too much.

How I say is a little trick, no is a killer of a shader, but now I don´t have too much idea how make a shader, and OpenGles minus.

Kinds regards
Iván J.