Special Effects - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Special Effects (/thread-7805.html)
Pages: 1 2
Special Effects - Josh - Apr 19, 2002 07:50 PM
In my game, I want the buttons to do something cool when the user puts his/her mouse over it. I can make seperate buttons that are different, but then I have a texture for the normal button, mask for the normal button, texture for the mouse over button, mask for the mouse over button. That can add up really quickly as I am trying to keep the size as small as possible. So here is my question (finally!): is there any cool effect that OGL can render to a texture on the spur of the moment? I hope I made sense in all that
Special Effects - swcrissman - Apr 20, 2002 10:40 AM
The easiest way I've found to do this is to use some sort of blending effect to accomplish what I want to do. For instance, when I was making my tetris game, I wanted a completed line to glow briefly before fading out of existance, but didnt want to make glowing textures for every block type if I could avoid it, so I made one texture, and when a block was supposed to glow, I overlaid that texture over the block and used blending to make it appear to glow.
Depending on what you are trying to accomplish, you could use something similar to make your buttons do something, simply write code which does the effect, and overlay it on your buttons whenever the mouse is over them, and don't draw the effect when it isnt. Nothing about the buttons themselves will change.
Hope that gives you some ideas.
Special Effects - Josh - Apr 20, 2002 11:06 AM
So you created a "glow" texture and used blending to put it over the "block" texture?
Special Effects - swcrissman - Apr 22, 2002 08:03 AM
Well, actually, I cheated a bit. What I was doing in that example was so simple that I didnt even need a texture, I just drew a solid color poly with the right alpha set to give the effect I was looking for. Later I changed it slightly to include a second rectangle that met the first in the center of the effect, but in both cases, I simply used the blending of a quad with the block in question.
So, you could use either a texture with the alpha set, or programmatically draw a solid poly in place with the alpha you needed, but in either case, blending is what gives you the special effect.
Special Effects - David - Apr 27, 2002 12:04 PM
It is also possible to write to a texture in realtime with gltexsubimage2d and stuff like that
Special Effects - kainsin - May 1, 2002 08:22 AM
Related to the glowing part above, you can also have an alpha value that sort of rotates around the corners of the "glowing" polygon.
In other words the alpha value at one corner is at 1.0 while the other three are at 0.0, then an adjacent corner to the 1.0 corner starts incrementing its alpha value while the other decreases. Once the alpha value has shifted over to the other corner, you move on to the next one.
In this way it will look like a light is rotating around the corners of your button texture, and it's relativly simple to do.
Special Effects - DaFalcon - May 1, 2002 11:14 AM
A trick we are using with the current SQ interface screen is to draw the button at, say 75% opacity, then on mouseover it simply displays the button at 100% opacity, making it appear to "light up." Actually the graphics are kind of bright/shiny in their natural state, so when at 75% opacity they appear properly dimmed. Nothing to do with OpenGL or anything, and not a very cool effect, but cheap relative to disk space :-) And we are ditching that in our next release and just using completely new "mouseover" graphics, though I am hoping to still use some fade effects to make it look cool.
Special Effects - Josh - May 1, 2002 03:05 PM
Quote:Originally posted by DaFalconThat sounds like a pretty good idea. Kinda combine it with the post before and have the alpha values rise so that it appears to "fade-in" or even pulse I never even thought to use the alpha value! Thanks to all who helped me out!
Special Effects - Josh - May 1, 2002 06:11 PM
Hehe, I just realized that... I don't know how to set a texture to a certain amount of transparency :confused: Would it just be glColor4f(0.0,0.0,0.0,0.4); before drawing the quad?
Special Effects - OneSadCookie - May 1, 2002 06:40 PM
That will work if you don't have lighting enabled.
If you do have lighting enabled, using GL_ARB_multitexture with a second, single-texel transparent texture is probably the easiest way to achieve the desired effect.
Special Effects - Josh - May 2, 2002 05:22 AM
Nope, no lighting. Thanks again.
Special Effects - Josh - May 2, 2002 05:40 AM
Grr. It doesn't work. It colors the texture. Is there any way to add translucency w/o coloring the texture?
Special Effects - Jeff Binder - May 2, 2002 07:02 AM
The color should be white. If it is, the texture will look normal, then you can add transparency.
Special Effects - David - May 8, 2002 04:49 PM
glColor4f(1.0,1.0,1.0,0.4); would be better than glColor4f(0.0,0.0,0.0,0.4); for what you're trying to do I think
Special Effects - Josh - May 10, 2002 05:54 AM
Quote:Originally posted by DavidI have tried both of those and both display the texture, but no matter what alpha value I give, it NEVER become semi-transparent! Does a special blending have to be enabled? Should I put this code before I draw the mask, or the texture? Should I put it after I bind the texture, or before?