• Create Account

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

9 replies to this topic

### #1fholm  Members

262
Like
0Likes
Like

Posted 06 August 2012 - 09:03 AM

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:

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.

### #2Daniel Wilson  Members

159
Like
0Likes
Like

Posted 06 August 2012 - 09:38 AM

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!

### #3Tasaq  Members

1530
Like
0Likes
Like

Posted 06 August 2012 - 12:12 PM

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 )

### #4Ripiz  Members

538
Like
0Likes
Like

Posted 06 August 2012 - 12:25 PM

You could try to move all vertices a little bit towards the camera. Though that won't cause model to look a little bigger.

### #5mhagain  Members

12437
Like
0Likes
Like

Posted 06 August 2012 - 01:26 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.

### #6fholm  Members

262
Like
0Likes
Like

Posted 06 August 2012 - 02:00 PM

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?

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.

### #7Tasaq  Members

1530
Like
0Likes
Like

Posted 06 August 2012 - 04:14 PM

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 )

4090
Like
0Likes
Like

Posted 06 August 2012 - 04:21 PM

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.

### #9Daniel Wilson  Members

159
Like
0Likes
Like

Posted 06 August 2012 - 05:58 PM

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.

### #10fholm  Members

262
Like
0Likes
Like

Posted 07 August 2012 - 08:35 AM

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.

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

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.