Radioactive-Software Radioactive-Software
Forum to discuss Radioactive-Software Products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

12/21/2010 - Smooth terrain normals, multithreaded loading,

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Radioactive-Software Forum Index -> Gettysburg: Armored Warfare
View previous topic :: View next topic  
Author Message
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Tue Dec 21, 2010 1:19 am    Post subject: 12/21/2010 - Smooth terrain normals, multithreaded loading, Reply with quote

Hey guys,

Today's topics include:
- Terrain Tangent/Normal Smoothing
- Multithreaded loading of textures in background
- Entity Imposters cast shadows
- Foliage Imposters account for terrain lighting

Terrain Tangent/Normal Smoothing
I'm sure some of you noticed the sort of 'stairstep' artifacts on the terrain rendering in recent screenshots ... since I'm packing the height/normals into the RGBA channels of a single texture and using vertex-texture-fetch to sample them inside the vertex shader. So when saving the map I do a pass to render all these values into a single texture. Before today I wasn't doing a smoothing pass - and I wasn't doing any filtering inside the vertex shader when constructing the normal ( I'd have to do 4 samples of the height and construct the normal - so I write it into the R,G,B channels then construct the tangent/bi-normal inside the vertex shader ). The solution was to do 9 samples when saving the normal/height texture and average the normals which produced much better results Wink I should have taken care of that a long time ago.

Multithreaded loading of textures in background...
For a while I've had a texture caching system that keeps a 32x32 or smaller version of all textures possibly needed in the game. When the system gets a request for a high resolution version of a texture it loads it into memory and lets the system know the high res version is available. This worked alright for a while - until I started using models with sets of 2048x2048 color/normal/specular maps all over the place. Then it started to become an issue loading 48MB a piece. If a high resolution texture isn't referenced x seconds after it's been loaded the system un-loads it. So you can see how constant stuttering from texture loads could become a problem. The issue is the Direct3D rendering thread has to pause so the texture can be loaded using the D3DXTextureFromFile() functions.

My solution is to use multithreading - because the D3DDEVICE can only be referenced from one thread at a time, the key is to start another thread, load the file from the HD into memory, and then once the thread returns and you have it loaded - call D3DXTextureFromMemory. This virtually eliminates thrashing/stuttering from loading resources in the background of the game. I limit the system to starting 1 background texture loading thread. I find that causes the smallest impact on the rest of the game. When running 3-4 background threads all loading textures there were still noticeable hickups in the rendering system.

Entity and Foliage imposter shadow stuff
In addition to the above stuff I went through and added some more touches to the imposter systems in the game. All of the entity imposters [ for soldiers, tanks, controllable objects, etc. ] now cast shadows into the world. The foliage imposters now take into account the terrain lighting below them. I choose to use this influence instead of just doing shadow mapping, I find the results are much more pleasing to the eye - though they aren't 100% accurate.

On to the screenshots...

Here is an image showing how the terrain normals look now that I'm using a totally different method to compute them, plus a smoothing pass on them.


Here is a comparison screenshot showing how the foliage imposters looked. before/after taking the terrain lighting into account.


Imposter debug screenshots - this is how the imposters look with alpha_clipping disabled - so you can clearly see which ones are imposters and which are geometry. Also visible are the shadows cast by the imposters in both screenshots...

With clip() enabled inside the pixel shader.


Here are screenshots showing the new/smooth terrain normals compared to the old normals...
NEW...

OLD...

Until next time...

- Dan
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
adam450
Gangsta'


Joined: 11 Oct 2009
Posts: 53

PostPosted: Thu Dec 23, 2010 2:29 pm    Post subject: Reply with quote

What are you doing different in generating normals? I had/have the same type of stair stepping issue.
Back to top
View user's profile Send private message
dgreen
The One


Joined: 24 Sep 2005
Posts: 6811
Location: Raleigh, NC

PostPosted: Thu Dec 23, 2010 6:00 pm    Post subject: Reply with quote

adam450 wrote:
What are you doing different in generating normals? I had/have the same type of stair stepping issue.


Just a 3x3 average of terrain normals/tangents with the same world position. So I generate them in two passes.
_________________
I run this place.
"Some muckety-muck architecture magazine was interviewing Will Wright about SimCity, and they asked
him a question something like "which ontological urban paridigm most influenced your design of the simulator,
the Exo-Hamiltonian Pattern Language Movement, or the Intra-Urban Deconstructionist Sub-Culture Hypothesis?"
He replied, "I just kind of optimized for game play."

Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Radioactive-Software Forum Index -> Gettysburg: Armored Warfare All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group