I worked on a basic naive implementation of HDR rendering few months back using old DX9 style pixel shaders. Actually I have a lot of old experimental shaders created in Nvidia FX Composer long back (tone-mapping, physically based BRDFs, etc) and I integrate them to the engine as required providing backend support in c++ code and improve on them as necessary using Direct3d11 features. So that old pixel shader based ToneMapping shader was one such example. It was not so great either in quality or the performance but not so bad for first implementation. Here are the rendering stages involved in that implementation : –
Gaussian Blur Filter is one of the most used effect in graphics programming. It helps to achieve many other effects like Bloom, DOF, etc.
I coded a version of it using pixel shaders in my naive pixel shader based HDR Renderer earlier. Even though it served the purpose it was very limited in terms of performance and hence quality since we can’t increase radius beyond some levels for real-time rendering.
Then I posted about first compute shader based implementation here which based on Frank Luna’s algorithm but even that was limiting in the fact that we can’t go beyond some blur radius (depends on GPU) for performance reasons.
Here’s a screenshot (800 x 600)-
So i have loaded them using couple of techniques: without spatial partitioning, using Quad Trees, Oct Trees, Axis Aligned BSP or KD Tree. Quad Trees are good but Oct Trees turned out to be better choice. Also KD Tree is little buggy right now and i may leave it as it for now and fix it later when i decide to do all BSP related offline rendering techniques. For now i am mainly focusing on OctTree related techniques which can be used in RealTime that means no offline pre processing.
I managed to export those levels to 3ds Max using couple of tools from Nem’s Tools. So it was just like loading any level from 3ds Max. We can load BSP files generated inside source engine directly also, there’s alot of info available on internet about the format and with a little bit of more effort it can be done. But I don’t think it was worth the effort unless you are willing to go one step further and implement BSP rendering path to take advantage of all those useful features provided by BSP
There can be many ways to load level mesh from 3ds Max. Simplest being if you want to load the whole level as a single mesh using X Files it’s just one function call – D3DXLoadMeshFromX. With a little bit of extra effort you can extract textures also.
But the way I am doing things is
- I load X Files using Hierarchical Loading Method to create separate D3DXMesh Objects for each mesh.
- Each of this mesh is then passed to my loader class which serves as interface between D3DxMesh and SpatialPartitioning code.
- Loader Class converts each of this meshes into Triangle Soup or Large Array of Triangles. Each triangle having its vertices, normal and a material id.
- These triangles are then passed to Spatial partitioning system as input which stores them depending on actual technique being used , whether polygon clipping is on or off etc.
Here are the results when Dust2 and HLTransition2 were rendered as single mesh and with Spatial Partitioning.
(Note – When loading level as single mesh Collision Detection is off because level is a single mesh and collision detection will involve testing object against each of those triangles in the scene which isn’t possible for realtime application as the triangle count is very high.)
I am still not done with this , in fact this is just the start of what needs to be done to render such large game scene with many dynamic objects. I am exploring and implementing further techniques / optimizations to further improve the performance and also working on adding more dynamic objects and some AI characters to test this in a better way.
I will also upload a video of collision detection in action on one of these maps in a couple of days.