Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

Triangle Size

Sign in to follow this  


Over the last couple of days I ran into a couple of issues related to triangle size. The first issue was with large triangles. To save memory, I used 4-meter tall walls in my Karnathus level. This means that there were 2 4-meter tall triangles making each face of a 1x1 square meter of wall top. This was causing issues in two areas : lighting and decals.

The lighting was looked bit off, due to classic problem of per-polygon shadowing, and per-pixel lighting. As an optimization, I exclude triangles that are backfacing wrt the light, based on their face normals. Come to think of it, I should get rid of that step, and instead, rely on the per-pixel tests instead. The per-pixel test goes through each texel of a triangle's lightmap to see if at least one texel is lit wrt the light. If the triangle is out of range, or fully shadowed, or back facing, it will fail the test. The back facing test, though is a per-triangle test, so triangles can get prematurely shadowed compared to what the bump-map might do. This is usually more of an issue when doing stencil shadow volumes. It's also made a bit worse in my lighting scheme, b/c I use ~sqrt( N.L ) for the diffuse lighting, to soften it up a bit more, which makes the shadow edge more dramatic.

This was exacerbated with large triangles, because when I added the vertex noise, some verts would get pulled out from the wall, and made a long vertical fold, which generated overly harsh triangular shadows.

OK, just made the fix, and it fixes the lighting issue, and the lighting is still about the same speed as before.

Another problem with large triangles was with the decals. When deciding how to map a planar texture map onto world geometry, you have to choose one or more projection directions. In my case, I want to only choose a single projection plane for all polygons in the same decal. So, you have to make a tradeoff between using the incoming velocity direction, which can give nice streaks at oblique angles, and using the average normal of the affected tris, which reduces over-streaking and stretching.

I used the average normal, but weighted each triangle the same, which caused an issue when the wall side triangulation was less dense than the tops of the walls. This caused large decal streaks to appear. I fixed it by weighting the normals by triangle area.

The other triangle size issue was triangles that were too small. Most world geometry in the engine uses triangles that are .5x5 meters in size, and this seems to be a good number for efficiency's sake, altough many more could and are used when needed for a certain effect.

I was having a heck of a time getting the simplified hanging cot model to display properly in the game as a mesh, so I used the un-simplified verison. This model is a fairly low-poly bunch of wooden slabs, held up by two diagonal chains, which are very dense. It looked good in game, but when I shot near the chain, things would really start to choke when the smoke particles had to deal with hundreds of small chain triangles.

So, to fix it, I made a 'ghost' material. Each material has a 'solidity' parameter, that effects whether it blocks movement. There is a separate 'opacity' parameter to handle blocking light. I just copied the bronze material, and made the new ghost version have a solidity of 0.0, and now the chain is still drawn, but does not collide with anything.

If I wanted to maintain collision for it, I could make some sort of proxy object, like a thin cylinder around the chain, but I actually prefer not having collision with it. I imagine a similar ghost material will be used for foliage and other very dense but not important items.

Sign in to follow this  


Recommended Comments

Just a random thought: drop that skymap and keep it black. You wouldn't see the sky in a dungeon anyway and I don't think it looks nice either.

Otherwise you're making great progress, keep it going!

Share this comment

Link to comment
Those screenshots look interesting. I sort of like the skymap myself. Especially if this is being played on the top level of a tower, or something of that nature.

Great work and interesting entry.

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
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!