Special Effects

Moderator
Posts: 608
Joined: 2002.04
Post: #1
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 Rasp
Quote this message in a reply
swcrissman
Unregistered
 
Post: #2
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.

Spencer
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #3
So you created a "glow" texture and used blending to put it over the "block" texture?
Quote this message in a reply
swcrissman
Unregistered
 
Post: #4
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.

Spencer
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #5
It is also possible to write to a texture in realtime with gltexsubimage2d and stuff like that
Quote this message in a reply
kainsin
Unregistered
 
Post: #6
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.
Quote this message in a reply
Member
Posts: 328
Joined: 2002.04
Post: #7
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.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #8
Quote:Originally posted by DaFalcon
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.
That 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 Smile I never even thought to use the alpha value! Thanks to all who helped me out!
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #9
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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
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.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #11
Nope, no lighting. Thanks again.
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #12
Grr. It doesn't work. It colors the texture. Is there any way to add translucency w/o coloring the texture?
Quote this message in a reply
Jeff Binder
Unregistered
 
Post: #13
The color should be white. If it is, the texture will look normal, then you can add transparency.
Quote this message in a reply
Member
Posts: 164
Joined: 2002.04
Post: #14
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
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #15
Quote:Originally posted by David
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
I 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?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Pixel Art: a special program required?!?! Max 4 4,757 May 1, 2005 02:06 PM
Last Post: Max