7000+ Civilians / "Semi-Instancing"

Published March 30, 2008
Advertisement
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 . 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.<br><br>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.<br><br><pre><br>float ColorMod = tex2D(NormalSampler,i.Tex0).a;<br>float4 Tex = (((1-ColorMod)*tex2D(DiffuseSampler,i.Tex0))+(ColorMod*g_InstanceColor));<br></pre><br><br>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) <br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Civilians4.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Civilians2.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Civilians3.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Civilians1.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Civilians5.jpg" border="0"></A><br><br>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.<br><br>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.<br><br>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.<br><br>//1000s of SWAT characters all @ full detail…<br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/SWAT_Line1.jpg" border="0"></A><br><br>//Older tests with SWAT model….<br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Instancing1.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Instancing3.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Instancing2.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Instancing4.jpg" border="0"></A><br><br><br>//Here is some more fckin around with an Irish Gangster<br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Irish1.jpg" border="0"></A><br><br><IMG SRC="http://www.radioactive-software.com/urbanempires/March30/Irish2.jpg" border="0"></A><div> </div>
0 likes 6 comments

Comments

Moomin
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.
March 30, 2008 02:01 PM
dgreen02
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'
March 30, 2008 02:04 PM
ViLiO
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
March 30, 2008 02:28 PM
dgreen02
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.
March 30, 2008 02:54 PM
ndatxcod
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.
April 09, 2008 01:16 PM
dgreen02
Check out my next project, on my forums...or...

www.to-serve-man.com
April 13, 2008 02:32 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement