Page 1 of 1

Making a Sprite Glow?

Posted: Tue Jul 13, 2004 8:13 pm
by DriakTravo
Is there a way to make a sprite glow without slowing the program down much?

Posted: Tue Jul 13, 2004 8:21 pm
by Num3
Make 2 sprites...

One simple and another with and outlined glow (yellow).... :D

Posted: Tue Jul 13, 2004 9:49 pm
by Codemonger
the fastest would be to create a glow effect around the sprite with a series of animated sprites ... like these:

Image
Image
Image

the glow sprites would be alphablended and rendered first then the main object sprite would be rendered on top of the glow .. the glow sprites would be animated through the sequence. Although their isn't much frames the effect looks just fine and is fairly simple.

Posted: Wed Jul 14, 2004 1:51 am
by DriakTravo
Thanks. These are great Ideas. The only problem is that you need to have a solid color background for these ideas to work. Because under the glow would be black if you had a textured background. This is why I need a way to do real-time glowing.

Posted: Wed Jul 14, 2004 3:37 am
by PolyVector
the glow sprites would be alphablended
I believe this implies that the glow sprites would have per-pixel alpha information that would treat the black (in this example) as 100% transparent and the white as mostly opaque....grays would be in-between...

Posted: Wed Jul 14, 2004 5:51 am
by Codemonger
This might help a bit, I whipped this up tonight. Heres a link to download the file with images included in exe as binaries

http://codemonger.com/uploads/CodeBlend.exe

heres the code .. uncommented as i just threw it together quickly... Also you could change the sprite3dblendmode to get some cool effects. Anyway hope this helps :wink:

Code: Select all



Result = OpenWindow(0, 100, 200, 400, 400, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, "Codemonger Blend Test")

 
UseJPEGImageDecoder() 

InitSprite()
InitSprite3D() 


OpenWindowedScreen(Result, 0, 0, 400, 400, AutoStretch, 0, 0)
CatchSprite(0, ?CodemongerLogo,#PB_Sprite_Texture)  
CatchSprite(1, ?RightArrow) 
CatchSprite(2, ?RightGlow1,#PB_Sprite_Texture) 
CatchSprite(3, ?RightGlow2,#PB_Sprite_Texture) 
CatchSprite(4, ?RightGlow3,#PB_Sprite_Texture) 
CatchSprite(5, ?RightGlow4,#PB_Sprite_Texture) 


CreateSprite3D(0, 0) 
 
CreateSprite3D(2, 2) 
CreateSprite3D(3, 3) 
CreateSprite3D(4, 4) 
CreateSprite3D(5, 5) 

 GlowVar = 2
 GlowMod = 1
 


  Repeat
    
    
    XOffset = WindowMouseX() - 11
    YOffset = WindowMouseY() - 13
   
    
    If CurrentTime - OldTime > 50
      OldTime = CurrentTime
      GlowVar = GlowVar + GlowMod
    EndIf
    
     Start3D()      
       ZoomSprite3D(0, 400, 400) 
       Sprite3DQuality(1)
       DisplaySprite3D(0,0,0,255)
       
       Sprite3DQuality(0)
       Sprite3DBlendingMode(5, 7)
  
       If GlowVar <> 1 
         DisplaySprite3D(GlowVar, -18+XOffset, -13+YOffset,255)          
       EndIf
    Stop3D()
     
     

    Select GlowVar
      Case 5
        GlowMod = -1
      Case 1
        GlowMod = 1
    EndSelect
     
       DisplayTransparentSprite(1,XOffset,YOffset) 
       FlipBuffers() 

        CurrentTime = timeGetTime_()
        FPS = FPS + 1
        If CurrentTime-OldFPSTime => 1000            
          FPSCount = FPS 
          FPS = 0
          OldFPSTime = timeGetTime_()                  
        EndIf
        
        StartDrawing(WindowOutput())
          DrawText("FPS: " + Str(FPSCount)) 
        StopDrawing()
       
     
        
       EventID.l = WindowEvent()


     


   
   
  Until EventID = #PB_Event_CloseWindow 




End 
  
CodemongerLogo: IncludeBinary "CodemongerLogo.bmp"
RightGlow1: IncludeBinary "RightGlow1.jpg"
RightGlow2: IncludeBinary "RightGlow2.jpg"
RightGlow3: IncludeBinary "RightGlow3.jpg"
RightGlow4: IncludeBinary "RightGlow4.jpg"
RightArrow: IncludeBinary "RightArrow.bmp"





Posted: Wed Jul 14, 2004 12:01 pm
by DriakTravo
Wow! That really helped. Thanks

Posted: Wed Jul 14, 2004 1:50 pm
by Codemonger
If u need any other help, let me know, glad to assist. :)

Posted: Fri Jul 16, 2004 6:33 am
by DriakTravo
As a token of my thanks, I have created 2 small programs demonstrating what you have tought me about the glow effect. You can download them here:

http://www.1matthew.com/downloads/Samples.zip (about 40KB zipped)

Thanks again! I am going to make a game also using my newly learned glow effect and the ability to includebinary which I also picked up from your code. :D

Image


Image


Image

Posted: Fri Jul 16, 2004 8:13 am
by vanleth
Cool effect's, and I love pixel exploding space games.

Looking forward to see more. :P

Running demos

Posted: Fri Jul 16, 2004 1:22 pm
by monkeyx
:cry: Why is that I have problems getting a lot of example code to run on my machine? I was interested in this product but find that 50% of the game/graphics examples do not work!

I have P4, 512MB ram and Fx5600 card.

Posted: Fri Jul 16, 2004 2:09 pm
by DriakTravo
Here are a few questions I have.

- What version of DirectX are you using?
- Do you have the most recent drivers for your video card?
- What Operating System are you running.

Posted: Fri Jul 16, 2004 2:15 pm
by Codemonger
DriakTravo very cool examples, makes for great plasma or laser effects :!:
Why is that I have problems getting a lot of example code to run on my machine? I was interested in this product but find that 50% of the game/graphics examples do not work!

I have P4, 512MB ram and Fx5600 card.
maybe you need your nvidia graphics drivers updated ... i have a fx5200 and works great here.

Posted: Fri Jul 16, 2004 4:10 pm
by monkeyx
I have just tried it on my home PC (Athlon 700) and it works fine here. The only difference between the machines is possibly the directx version I have 9.0b at home. I will have check the version number at work.

Posted: Fri Jul 16, 2004 4:18 pm
by Codemonger
If you are having the same or similar problems as monkeyx pls refer to this thread

viewtopic.php?t=11717