SoC2008 GeometryShaders         Geometry Shader Support - GSoC 2008

Summer of Code 2008: Geometry Shader Support

Student: Noam Gat

Mentor: Assaf Raman

Location: N/A

Status: Development complete, merged into Ogre 1.6

Motivation

Keeping up with the latest in bleeding edge technologies is a tough task in the 3d rendering world. New technologies are being developed, which require a state-of-the-art 3D engine to be in constant development in order to keep up. I would like to help the Ogre project keep up with the pack by adding in support for geometry shaders.

Project

One of the biggest changes in the DirectX 10 / Shader Model 4 generation is the introduction of Geometry Shader support. Geometry shaders open up new opportunities for developers to perform operations that were used to be only possible in the CPU. Some examples of the possibilities include shadow volume extrusion ( http://msdn2.microsoft.com/en-us/library/bb172445(VS.85).aspx ), single pass render-to-cubemap (http://msdn2.microsoft.com/en-us/library/bb172445(VS.85).aspx ), GPU only particle systems ( http://msdn2.microsoft.com/en-us/library/bb172445(VS.85).aspx ) and many more.

With support for the new generation of shaders already out for both DirectX and OpenGL (Ogre's main render systems) it seems like the perfect summer to add geometry shader support to Ogre.

Timeline

Stage 1 (May 26 - June 2) (DONE) : Add geometry shader support to the GpuProgramManager and Pass, so that the render system gets the information. (Time estimation - A week, its mostly interface work and there are already similar classes to base it on)

Stage 2 : (June 3 - June 24) (DONE) : Add geometry shader support to the OpenGL render system. The GL render system has been selected because only DirectX10 supports geometry shaders, and the DX10 render system is still in early stages. (Time estimation - Three weeks, because most of the work for stage 3 will also be done here because I will need to test the implementation somehow)

Stage 3 : (June 24 - July 1st) (DONE) : Create a basic demonstration application which uses a geometry program. (Time estimation - A week. This is more of a cleanup phase. The demo will already be ready, but cleanup of the code & documentation will have to be done to move the code from an internal playpen project to a proper sample people can learn from).

Milestone 1 (July 1st) (DONE) : When these first three steps are done, Ogre already has functional geometry shader support. Won't be too comfortable to use (programs have to be defined in code) and won't have much of a wow factor (no examples showing off next-gen features) but it will work.

Stage 4 (July 1st - July 15) (DONE) : Add geometry shader support to Ogre's scripting interface. Geometry program declaration in .program scripts and referencing in material definition. (Time estimation - two weeks. Like stage 1, I have code to base this part on, but I am not currently familiar with the implementation of Ogre's scripting interface and might decide to add this to the next generation of script compilers rather than the current one)

Stage 5 (July 15 - July 29) (DONE) : Create more advanced geometry shader examples, using the scripts for their definitions this time. This set of examples should be reusable in real-world scenarios. This will probably mean porting some demos to Ogre (perhaps from the DX10 SDK). (Time estimation - This stage is the first diverse stage, because depending on time constraints I can put more (or less) effort into it since more examples can always be added).

Milestone 2 (End of july) (DONE) : Ogre now has proper geometry shader support, including script support and some eye-poking examples, making sure the whole world knows that Ogre supports geometry shaders.

Milestone 2 is the core of what definitely needs to be achieved in the project. When I achieve it, I will continue working on features which are less critical.

Stage 6 (August 1 - August 7, if selected) (NOT SELECTED) : Add geometry shader support to the DX10 render system. The render system is not part of Ogre's core distribution yet, so this is of lesser priority. Also, since DX10 is windows vista only, less end-users will be able to take advantage of this addition. I do personally know Assaf Raman, the creator of the DX10 render system, which will make it easier to integrate it into the render system if I find the time to do so. (Time estimation - If the DX10 render system will be in a state that this stage will be possible, I don't expect many difficulties since I already implemented it for one render system)

Stage 7 (August 1 - August 7, if selected) (DONE) : Add geometry shader support to the CG program manager. This is more of a future compatibility move, but is also for current user. Despite the current cg compiler not supporting DX10 HLSL or ATI cards, it does already have profiles for geometry shaders. This will enable people who are accustomed to CG but not GLSL to develop geometry shaders as well.

Stage 8 (August 1 - August 14, if selected) (NOT SELECTED) : Integrate a geometry shader-based shadow technique in Ogre. This will allow users of SM4-level hardware to utilize the additions in a relatively out-of-the-box manner, much like some of Ogre's current shadowing options. (Time estimation - Most of the code will be based on the stencil shadow implementation which Ogre already has, but this still requires quite a bit of work. However, I will already have much knowledge about geometry shaders at this point so I believe it is very possible.)

Two unplanned stages were added (and completed) - Add RenderToVertexBuffer API, and implement the feature in OpenGL.

Source Code

The code has been merged into the Ogre 1.6 code base, so it can be found in
https://svn.ogre3d.org/svnroot/ogre/branches/v1-6

If for some reason you want to have a look at the original code branch, it will still be available at
https://svn.ogre3d.org/svnroot/ogre/branches/soc08-geomshaders

Deliverables

The sample created in stage 5 is a port of NVIDIA's IsoSurf example to Ogre. The sample makes use of the API (Stage 1), the OpenGL implementation (Stage 3), Scripting interface support (Stage 4) and the CG program manager (Stage 7), so it pretty much sums up all the work that has been done so far.

It can be found in the Isosurf Showcase thread in the Ogre3D forums.

After the two unplanned stages were done, the ParticleGS demo (which required them) was also ported.

It can be found in the PartcleGS Showcase thread in the Ogre3D forums.

Thats all folks!