• entries
    338
  • comments
    2046
  • views
    1155754

7000+ Civilians / "Semi-Instancing"

Sign in to follow this  

1381 views

Yea if you've been following the game you've probably been wondering where the hell the civilians are at. I've recently got them back into the game...but with a twist. I coded a light weight character class for the civilians, and based their rendering around a sort of "semi-instancing", it's not true hardware instancing...but is the most efficient method of throwing many characters @ the hardware [while being able to change some aspects of the rendering, per-character, like shader-LOD]. Each instance being rendered using a SM 3.0 shader w/normal mapping, shadowing, specular lighting, etc...up close, and a very simple fallback SM2.0 shader for distant rendering.

There are 3 2048x2048 maps associated with each character type [ color map, normal map, specular map]. For the civilians I made a slight modification and packed a mask into the alpha channel of the normal map that modulates the color of the character's texture by a shader constant representing the desired color.

For instance here is how the final texture color is calculated in the pixel-shader for a civilian character...where NormalSampler contains the character's normal map w/ the mask packed into the alpha channel. i.Tex0 are the vert's UV coords, and DiffSampler contains the character's diffuse/color texture. g_InstanceColor is a global shader constant containing the desired color.


float ColorMod = tex2D(NormalSampler,i.Tex0).a;
float4 Tex = (((1-ColorMod)*tex2D(DiffuseSampler,i.Tex0))+(ColorMod*g_InstanceColor));


So let's try it out with 7500 characters in the world...heavily CPU limited by DrawPrimitive calls in most situations. Very simple AI, they just chase the camera. The whole system falls apart when they all congregate like this, but it looks cool 8)











By having more "actual" models to "instance" I can increase the variety. I have 4 more character types to implement, I can seed their animation controllers with a much different time to remove the lock-step appearence of the characters.

Since the game is completely multiplayer based your next question is probably: how the hell are you going to sync all these civilians across the 18 potential clients per-game server. Over the last few years I've been playing with several techniques to optimize the network traffic in the game...but there is still no way something like this would fly in the real world.

What I've done is made the crowd density a server-side parm with a much lower default value than the client's. Also if you're playing on a LAN it might be possible to sync the characters no problem, so I'll make it completely adjustable.

//1000s of SWAT characters all @ full detail...



//Older tests with SWAT model....










//Here is some more fckin around with an Irish Gangster


Sign in to follow this  


7 Comments


Recommended Comments

The civilians seem to be wearing ... vivid clothing? The general public normally has a bit of a toned down taste I would suggest. Everything else = awesome.

Share this comment


Link to comment
Yup, you're right.

I already cut them down to the range of (128,128,128) as the max in these screens...looks like I'm gonna have to do more cutting. Probably down to a max of 64 per channel.

I just finished the system this morning, it still needs some tweakin'

Share this comment


Link to comment
Looks amazing (as always) [cool]

Have all those civilians running down a hill and you could probably sell the footage to Sony for their next Bravia advert [grin]

I'd also definitely tone down the specular on that Irish guy, he looks like he has been laminated [smile]

All the best,
ViLiO

Share this comment


Link to comment
He's wearing a leather jacket [ the spec-reflections look ace in motion ], note that the specular on the pants are much more toned down.

But yea, I see what you mean :-D I'll cut the specular on his jacket to 60% it's current value.

I will record HD video of all the characters on my triple-sli machine I just got...I'll post 'em up soon.

Share this comment


Link to comment
Two words: Zombie Game

I can imagine a game about zombies, hundreds of them chasing humans or anything that emits heat, the goal is to survive. It could be easily done with the engine of this game. Cool shots btw.

Share this comment


Link to comment

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