Hi!
I'd like to present the library I have been working on roughly last two month. It is DirectX 11 forward renderer. The library is written in C++11 using VS2013 Express and Windows SDK 8.1. The library is targeting DX11 hardware with SM 5.0 and higher. No deprecated stuff from DXSDK is used.
What the library has and what it can do:
What it can't do (yet)
Using the library I've written several demos. Each of the demo presents group of the concepts from the library. Currently there are 3 projects.
Controls common to all projects:
Two camera modes, default one is orbital, press F2 to select first person camera, press F1 to select orbital camera. In orbital mode press left button and move the mouse to rotate, use wheel for zooming. In first person mode, use WASD to walk/strafe, Q and E to fly up/down, hold right mouse button and move to change look direction. Press F to go fullscreen, press G to go into window mode. Press Esc to exit the program.
Basics
[IMG:http://s7.postimg.org/ze30x2ilz/Basics.jpg]
Concepts shown: opaque/transparent sorting, raster/blend states, render to render target, dynamic meshes, multiple lights, texture transform, mesh transform, computing AABB on the fly, object/camera, object/light flags.
Specific controls for Basics scene: arrows to move the ball, z/x/c - change render target resolution, v - kill render target. 1/2/3/4 - change sample filtering to point/bilinear/trilinear/anisotropic filtering accordingly, 5/6/7/8 change anisotropy to 1/2/4/8 samples accordingly (only works if anisotropic filtering mode is on). 'I' - make rotating wireframe sphere immutable (will no longer animate)
Geometry Shader
[IMG:http://s7.postimg.org/sqb0o7ohj/Geometry_Shader.jpg]
Concepts shown: geometry shaders (trees are points, actual quads are constructed on the gpu), billboarding, dynamic hlsl linking (outer ring of trees use oriented billboards, inner ring - screen aligned billboards, but there is only one compiled shader), alpha cutouts (trees are rendered in opaque queue), alpha-to-coverage (to smooth trees), texture arrays (actual dds file is constructed using DirectXTex lib).
Instancing
[IMG:http://s7.postimg.org/6pq2tugfr/Instancing.jpg]
Concepts shown: mostly hardware instancing (there are roughly 10000 spheres), working with various parameters of the mesh class (start/offset/count for vertices/indices/instances), number of instances is animated as well as each sphere indices (you can see that if you zoom in close), overall it renders several million triangles via single draw call.
That's it folks! I have never thought that it would be so hard to write rendering library, there are tons of little details which you can't even predict. Additionally I haven't used DirectX11 before, so this is my first experience using this API which adds more efforts for learning.
I will develop the library further as my free time allows me. Ideally in the end this would be the module for the GCC engine, however there is lot of work to be done yet!
Share your thoughts and comments, if you want to see some certain functionality in the library also let me know. Thanks for reading this!
P.S. You can download demo binaries by the following link dropbox.com/s/nv0zbxwql65bsr6/bin.zip. Archive contains several textures, 3 executable, compiled shaders and dll for shader reflection.
I'd like to present the library I have been working on roughly last two month. It is DirectX 11 forward renderer. The library is written in C++11 using VS2013 Express and Windows SDK 8.1. The library is targeting DX11 hardware with SM 5.0 and higher. No deprecated stuff from DXSDK is used.
What the library has and what it can do:
- Classes for shaders, materials, material properties, meshes, shader resources, samplers
- Control over almost all pipeline functionality (rasterizer, depthstencil, blend, sampler states)
- Cameras, ability to render into separate render target
- Simple lighting manager (dir and point lights; amount of lights is configurable and associated with shaders)
- Ability to set flags for object-camera, object-light relationship (e.g. you can render certain objects with certain cameras and lit certain objects with certain lights)
- Automatic sorting of submitted items (camera -> opaque/transparent queues ->rendering order -> materials -> material properties); this allows to minimize state changes thus gain more performance
- Material properties allow you to interface with shaders. You can specify constants for material constant buffer, set shader resources and samplers (Effects framework is not used); setting shader data is done using strings names (shader reflection is used for that)
- Support for vertex, pixel and geometry shaders
- Dynamic hlsl shader linking which allows you to make your shaders to behave like uber-shader without having to recompile the hlsl code
- Flexible mesh class which contains mesh buffer classes for vertices, indices and instances (i.e. support for HW instancing); you can choose usage for your mesh buffers (default, immutable, dynamic, but no staging), update them at runtime, change usage as required, control all aspects of DirectX Draw*** commands (start, count parameter for all buffers etc); mesh buffers can also keep copy of the data in the system memory (e.g. for calculating bounding box)
- Flexible vertex layout creation (you can cache the layouts); materials control and set appropriate input layout for IA pipeline stage
- You can specify MSAA for the swap chain
- Texture loading is done via DirectXTex library
- DirectXMath simd library is used under the hood
- Public interfaces does not contain any dx specific types
- For convenience pod vector types are added similar to hlsl types (e.g. bool2, float3), although they are mostly for passing data rather than for calculations
- And many other little details
What it can't do (yet)
- No support for tesselation and compute shaders as those are huge topic on itself
- Still no animation support (very high on the priority list)
- Not able to load meshes from the file, but I'm thinking about that
- No post-effects
- No multipass materials
- No runtime shader compilation, you must compile shaders beforehand into *.cso objects load those cso files at runtime
- Several raster state bits describing depth options are not presented
- And many many more features which I'd like to add but unfortunately have no time to read about and implement; one of them is making the code to work with GCC engine and what's even more difficult - with the editor (this thing will bite me sooner or later I'm sure)
Using the library I've written several demos. Each of the demo presents group of the concepts from the library. Currently there are 3 projects.
Controls common to all projects:
Two camera modes, default one is orbital, press F2 to select first person camera, press F1 to select orbital camera. In orbital mode press left button and move the mouse to rotate, use wheel for zooming. In first person mode, use WASD to walk/strafe, Q and E to fly up/down, hold right mouse button and move to change look direction. Press F to go fullscreen, press G to go into window mode. Press Esc to exit the program.
Basics
[IMG:http://s7.postimg.org/ze30x2ilz/Basics.jpg]
Concepts shown: opaque/transparent sorting, raster/blend states, render to render target, dynamic meshes, multiple lights, texture transform, mesh transform, computing AABB on the fly, object/camera, object/light flags.
Specific controls for Basics scene: arrows to move the ball, z/x/c - change render target resolution, v - kill render target. 1/2/3/4 - change sample filtering to point/bilinear/trilinear/anisotropic filtering accordingly, 5/6/7/8 change anisotropy to 1/2/4/8 samples accordingly (only works if anisotropic filtering mode is on). 'I' - make rotating wireframe sphere immutable (will no longer animate)
Geometry Shader
[IMG:http://s7.postimg.org/sqb0o7ohj/Geometry_Shader.jpg]
Concepts shown: geometry shaders (trees are points, actual quads are constructed on the gpu), billboarding, dynamic hlsl linking (outer ring of trees use oriented billboards, inner ring - screen aligned billboards, but there is only one compiled shader), alpha cutouts (trees are rendered in opaque queue), alpha-to-coverage (to smooth trees), texture arrays (actual dds file is constructed using DirectXTex lib).
Instancing
[IMG:http://s7.postimg.org/6pq2tugfr/Instancing.jpg]
Concepts shown: mostly hardware instancing (there are roughly 10000 spheres), working with various parameters of the mesh class (start/offset/count for vertices/indices/instances), number of instances is animated as well as each sphere indices (you can see that if you zoom in close), overall it renders several million triangles via single draw call.
That's it folks! I have never thought that it would be so hard to write rendering library, there are tons of little details which you can't even predict. Additionally I haven't used DirectX11 before, so this is my first experience using this API which adds more efforts for learning.
I will develop the library further as my free time allows me. Ideally in the end this would be the module for the GCC engine, however there is lot of work to be done yet!
Share your thoughts and comments, if you want to see some certain functionality in the library also let me know. Thanks for reading this!
P.S. You can download demo binaries by the following link dropbox.com/s/nv0zbxwql65bsr6/bin.zip. Archive contains several textures, 3 executable, compiled shaders and dll for shader reflection.
Looking for a job!
My LinkedIn Profile
My LinkedIn Profile