Archive

Posts Tagged ‘LOD’

GSoC final deadline

The final GSoC deadline is tomorrow, or rather the firm ‘pencils down’ date, so I have decided to make a really short self-evaluation of the features I’ve managed to implement.

Done :

  • Generate geometry – iFurMaterial (until the midterm)
  • Animate geometry – iFurPhysicsControl (until the midterm)
  • Write specific shaders – iFurStrandGenerator (until the midterm)
  • External parameters – density and height maps, 3D textures, etc.
  • LOD system and optimizations – iFurMesh inherits from iMeshObject
  • Extend from hair to fur – thanks to Frankie the squirrel

There is still some code rearranging to be done, but nothing much, really: deciding what classes should inherit from what interfaces, making loaders and savers for the mesh, just better organizing the code.

I leave you with this footage of the CS fur plugin as it is now (the FPS is actually double than in the video and above 60 on release settings and ~30 FPS on debug):

Advertisements
Categories: Crystal Space Tags: , , ,

LOD

As you have probably seen from my previous YouTube videos, the FPS in the fur plugin isn’t quite real-time, but about ~10 FPS.

After doing some manual profiling (i.e. not using any profiling tool, but just commenting code and analyzing the average FPS in various situations), I came out with the following findings regarding the fur mesh plugin:

  • Hair simulation
Number of Guide Hairs 0 50 100 200 367
Average FPS 46.07 37.70 32.63 24.76 18.76

Because I used Bullet ropes in order to simulate the physical model for guide hairs, I couldn’t really optimize the code to get better performance, so the only option was to generate as few Bullet ropes as possible, for the lowest LOD and also, not to many for the highest LOD setting.

This is why I made two types of guide hairs: pure guide hairs and LOD guide hairs. The pure guide hairs always have a Bullet rope attached, they represent the lowest LOD setting and grow on each vertex of the base mesh. On the other hand, LOD guide hairs are only synchronized with ropes at higher LOD, otherwise their position is updated just like for normal hair strands, using interpolation and barycentric coefficients.

So in order to have really good results, having a low poly mesh on which to grow fur is essential, and this can be done either by having a fake low poly mesh specified in the model file, or better yet, by obtaining a low poly mesh using the LOD system from another CS GSoC 2010 project, by Eduardo Poyart.

  • Hair modeling
Number of Hair Strands 0 500 1000 2000 3670
Average FPS 49.34 31.56 23.12 15.41 10.53

When I collected this data for hair modeling I was using a genmesh to represent the fur geometry. The problem was that when I called functions to compute normals, tangents or binormals followed by a call to Invalidate() the FPS was really low for thousands of hair strands. However, I realized that I can easily compute all this data having in mind that the hair strands are created so they always face the camera. Furthermore, doing some C/C++ optimizations by increasing pointers, instead of iterating through vectors, gave some performance boost as well.

And of course, when the camera is situated further away from the fur mesh, having a low LOD setting, which draws fewer, thicker hair strands seemed a good idea. The only trick was to generate the hair strands in such a way that they always cover the base mesh (skull) and as they grow in number they give the impression of more dense hair.

  • Hair rendering
Number of Hair Strands 0 500 1000 2000 3670
Average FPS 49.12 47.34 45.82 44.06 40.26

After testing the hair rendering data with both the Marschner implementation and a simple default CS Phong shader, I realized that the hair rendering didn’t need any more optimizations nor various LOD versions. The optimizations done by using lookup textures, as described in the Marschner Shader Part III post, provide good results by themselves.

  • Overall
Number of Guide Hairs 0 50 100 200 367
Number of Hair Strands 0 500 1000 2000 3670
Average FPS (1024×768) 47.62 26.07 17.96 11.15 7.56
Average FPS (1440×900) 49.12 26.82 18.62 11.24 7.66

So, by making all of these optimizations and various LOD settings I managed to run the hairtest demo at a constant ~28 FPS at the lowest LOD and at ~15 FPS at the highest LOD setting.

Also, I realized that although sometimes a hair simulation will not be needed, animating the hair would still be a good idea, so I wrote an implementation of the iFurPhysicsControl that only updates guide hairs based on the base mesh movement, and also added the possibility to switch between various iFurPhysicsControl implementations on the fly. Not having Bullet ropes at all made the application run at ~37 FPS for the lowest LOD setting.

Categories: Crystal Space Tags: , ,