Sign in to follow this  
FredrikHolmstr

Force field around a model and pushing vertices outwards in shader.

Recommended Posts

I've been working on a pretty simple "Force Field" shader which is supposed to wrap a model inside a slightly larger version of it self which is render using some alpha transparent material. My current progress looks like this:

[img]http://dl.dropbox.com/u/19877504/2012-08-06%2016-54-27.jpg[/img]

My current approach looks like this:
[source lang="cpp"]
vertex_output o;

float4 world = mul(MATRIX_MVP, v_in.vertex);
float4 normal = mul(MATRIX_MVP, v_in.normal);
o.pos = world + (normal * 1.05f);

return o;[/source]

It's pretty obvious what it does, it offsets the vertex by a fraction of it's normal it works reasonably well for objects that don't have a lot of duplicate vertices to create sharp edges, like the blue around the solider for example. But it does not work at all around the weapon due to the sharp edge/duplicate vertices.

Now, my question is pretty simple: Is there a better way of achieving this effect, and more specifically offsetting the vertices in the shader.

Share this post


Link to post
Share on other sites
I saw a nice talk on this on the [url="http://www.bungie.net/Inside/publications.aspx"]Bungie website[/url], because Halo has a LOT of force fields. I can't remember the exact talk but it's on that page somewhere sorry!

Share this post


Link to post
Share on other sites
It looks preety decent for me. You can also add more glow to it and maybe some subtle distortion (like heat haze), It will make it more lively :)
(I know it's only 'visual' opinion which you weren't after :) )

Share this post


Link to post
Share on other sites
You could try to move all vertices a little bit towards the camera. Though that won't cause model to look a little bigger.

Share this post


Link to post
Share on other sites
Try something like this instead:[code]float4 world = mul(MATRIX_MVP, v_in.vertex + v_in.normal * 1.05f);[/code]
Although you way want to try a value > 1.05, it's basically what Quake 2 did back in 1998, so it should work.

Share this post


Link to post
Share on other sites
[quote name='Tasaq' timestamp='1344276729' post='4966739']
It looks preety decent for me. You can also add more glow to it and maybe some subtle distortion (like heat haze), It will make it more lively
(I know it's only 'visual' opinion which you weren't after )
[/quote]Thank you! I've been thinking about putting other effects on top of this, but both glow and heat haze would require a post-processing effect if i'm not mistaken?

[quote name='Ripiz' timestamp='1344277505' post='4966744']
You could try to move all vertices a little bit towards the camera. Though that won't cause model to look a little bigger.
[/quote]Hmmm, I will try this and see what I come up with.
[quote name='Daniel Wilson' timestamp='1344267481' post='4966698']
I saw a nice talk on this on the Bungie website, because Halo has a LOT of force fields. I can't remember the exact talk but it's on that page somewhere sorry!
[/quote]I can't find the text you're talking about in any of the articles, you sure it's there?

[quote name='mhagain' timestamp='1344281162' post='4966768']
Try something like this instead:[code]float4 world = mul(MATRIX_MVP, v_in.vertex + v_in.normal * 1.05f);[/code]
Although you way want to try a value > 1.05, it's basically what Quake 2 did back in 1998, so it should work.
[/quote]I've done the vertex movement in both local and world space without any major difference in end result.

Share this post


Link to post
Share on other sites
[quote name='fholm' timestamp='1344283223' post='4966785']
Thank you! I've been thinking about putting other effects on top of this, but both glow and heat haze would require a post-processing effect if i'm not mistaken?
[/quote]
Yes, as glow shouldn't be a problem but heat haze can be more complicated :)
I am not a pro, more of a begginer, I still am more 'artist' than a graphics programmer :) (hope that will change soon :D )

Share this post


Link to post
Share on other sites
I think you could achieve something similar with a rim lighting pixel shader.
You just highlight the pixels that are almost perpendicular to the view direction.

Share this post


Link to post
Share on other sites
Okay I found it, sorry it wasn't on the publications page hope I didn't waste your whole night!

[url="http://www.gdcvault.com/play/1014348/HALO-REACH-Effects"]This link[/url] contains the ppt presentation, it's a whopping 433mb so thank goodness for broadband.
An overview of the talk is discussed [url="http://www.beyond3d.com/content/articles/116/1"]here[/url] as well, with the shield stuff on page 3.

Pretty nice ideas about colorizing it with tiny colour palette ramps, and fading out the effect as a function related to the depth buffer.

Share this post


Link to post
Share on other sites
Thank you for that presentation! That was great. As it turns out I was on the right way (using vertex normals to push the vertices outwards). I'm working on implementing the fading part of the technique they talk about it the presentation, more specifically this is said:

[quote]To make the character more visible, we sample the depth buffer and fade the shield as a function of the distance to the shell.
So the nearby areas (likely the character) become more transparent, while the farther areas (which are probably the background) get the full effect.[/quote]

The shield here is the enlarged mesh.
The shell means the original model (I assume).

I am well familiar with sampling the depth buffer, but how would I calculate the distance to the shell from my current pixel based on the value from the depth buffer? there is no way (I can think of) to know if the depth value comes from the original model or from another player, a wall, etc. ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this