Jump to content
  • Advertisement
Sign in to follow this  
FredrikHolmstr

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

This topic is 2204 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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:

2012-08-06%2016-54-27.jpg

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
Advertisement
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:float4 world = mul(MATRIX_MVP, v_in.vertex + v_in.normal * 1.05f);
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

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 )
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?


You could try to move all vertices a little bit towards the camera. Though that won't cause model to look a little bigger.
Hmmm, I will try this and see what I come up with.

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!
I can't find the text you're talking about in any of the articles, you sure it's there?


Try something like this instead:float4 world = mul(MATRIX_MVP, v_in.vertex + v_in.normal * 1.05f);
Although you way want to try a value > 1.05, it's basically what Quake 2 did back in 1998, so it should work.
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

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?

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!

This link contains the ppt presentation, it's a whopping 433mb so thank goodness for broadband.
An overview of the talk is discussed here 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:

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!