Best way to do temporary effects

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
shenjoku
Gremlin
Posts: 193
Joined: Sat Aug 06, 2011 11:02 pm
x 6

Best way to do temporary effects

Post by shenjoku »

I'm finally getting to the point in development where graphical effects need to be figured out and I'm unsure of how to approach the current one. There is a skill that, once used, makes the player invisible for some time. For now, until we figure out the exact effect we need, I'd like to add something that just makes the player's entity model mostly transparent during the duration of the skill and then reverts back to normal afterwards. I'm curious as to what the best way to do these kinds of temporary graphical effects is. Would I just swap to a different material that somehow makes it transparent and change back to the default after? That's the only thing I can think of at the moment. I'd just like to get an idea of what there is available for doing this kind of thing.
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Best way to do temporary effects

Post by c6burns »

I have a similar effect ... an octopus character has to blend into the background by changing the colors on his skin. This happens when the user hits a button, and a slide whistle sound plays. As the whistle sound goes from low to high, I blend the effect from bottom to top in object space. Vice versa when the user lets go of the button.

I like to avoid transparancy, as it raises depth issues in my scenario. I render the entire scene to texture without the octopus and then track how much I should blend to the background per-vertex. This also allows me to refract the scene behind the octopus for a funny predator-like effect. And yes I switch materials and use a time-based uniform in the shaders.
shenjoku
Gremlin
Posts: 193
Joined: Sat Aug 06, 2011 11:02 pm
x 6

Re: Best way to do temporary effects

Post by shenjoku »

That's interesting. How difficult was it to set something up like that? It sounds fairly complicated. I would have no idea how to split out rendering of the scene without the player and then render them later. Would that just be a render queue thing?
User avatar
c6burns
Beholder
Posts: 1512
Joined: Fri Feb 22, 2013 4:44 am
Location: Deep behind enemy lines
x 138

Re: Best way to do temporary effects

Post by c6burns »

It sounds complex as a whole but each part of the effect is pretty simple and mainly founded upon techniques demonstrated in the ogre samples. So let's forget about how I blend the verts over time bottom to top because that is just icing on the cake. Starting with render targets and selectively rendering objects into them, the fresnel sample is a gold mine. In case you don't remember it, it's the sample with a bath house, a pool of water, and fish swimming around in the water. It uses 2 rendertargets, one for reflection and one for refraction. It maintains a std::vector of entities that are submerged or not, and it controls their visibility by using a RenderTargetListener. Check it out :)

Anyway someone else might have a different (and better) idea for how you can do this effect. You can probably even control alpha blending without using a shader, just I wanted something a bit more than transparency. Also straight up transparency caused problems for my octopus because his tentacles wouldn't have each triangle z-sorted ... so they would render over each other inappropriately from certain angles. Perhaps that's not an issue for your situation though.

Anyway if you get stuck I'm willing to provide additional guidance or even GLSL snippets. Here's my effect in action, for the lolz:
Image
Image
Image
shenjoku
Gremlin
Posts: 193
Joined: Sat Aug 06, 2011 11:02 pm
x 6

Re: Best way to do temporary effects

Post by shenjoku »

I don't think I've ever seen that sample. I'll have to take a look at it.
Post Reply