A Software Renderer Using The LightSky Framework.
SoftLight started as a research project into software rendering and shader technology which mimicked modern hardware rendering APIs. By looking at other software rendering projects like tinyrenderer and Mesa3D, SoftLight began to take shape.
SoftLight has been built from the ground-up to run on Windows (Win32 & GDI), Linux (X11 or XCB, optionally with XSHM-MIT), and OS X (Cocoa & Quartz) using C++. For window creation, only the Win32 API and Xlib development libraries are used. Direct framebuffer access is available which can allow for other implementations to be created as well, or you can simply use the window handles to embed an internal, native context into other applications which support it.
SoftLight uses CPU-based SIMD acceleration (AVX2 on x86 and NEON/VFPv4 on ARM) to increase performance. There are also multithreaded work queues which can take advantage of as many cores as a system has available. The number of cores can be configured at runtime to help increase flexibility.
Technically, any C++11-compliant compiler should be able to build the project. To build the project, you'll need GCC, Clang, Microsoft Visual Studio 2017, or MSVC 2019. Softlight should work on any modern architecture (tested on i686, x64, ARM, AARCH64, and PowerPC-EL64), the project has been tested on the following compilers:
GCC | Clang* | MSVC** | MinGW-W64** |
---|---|---|---|
4.8.2 | 3.5 | 2017 | 5.1.0 |
5.0.0 | 3.6 | 2019 | 7.4.0 |
7.3.0 | 6.0 | 2022 | 8.4.0 |
9.3.0 | 10.0 | 11.0.0 | |
11.1.0 | 12.0 |
* Benchmarking has consistently shown Clang generates and builds the most optimized code.
**Windows builds typically run the slowest. MSVC is the worst performer and using MinGW-w64 can lead to better performance.
3rd-party development dependencies listed here will either be detected from the local system or downloaded and built from source:
Dependency | Platform | Required? | Use/Application |
---|---|---|---|
cmake | All | Yes | Generate build files |
x11-utils | Linux | Yes | Required for X11 & XCB |
libx11-dev | Linux | Yes | Required for X11 & XCB |
libx11-xcb-dev | Linux | Yes | Enable X11 Shared Memory |
libxext-dev | Linux | No | Required for X11 & XCB |
libxcb1-dev | Linux | Yes | Required for X11 & XCB |
libxcb-image0-dev | Linux | Yes | Required for X11 & XCB |
libxcb-shm0-dev | Linux | No | Enable XCB Shared Memory |
*libxkbcommon | OS X + Homebrew | No | Enable X11/XQuartz on OSX |
TortoiseSVN | Windows | Yes | Checkout 3rd-party libs |
* The X11 backend can be used on OS X with XQuartz but XSHM-MIT optimizations will be unavailable due to limitations of shared memory.
Linux targets currently require both X11 and XCB development libraries to
compile. However the backend can be chosen at compile time by passing the
-DPREFER_XCB=TRUE
build flag to CMake. Similarly on OSX, the X11 backend can
also be chosen by setting the -DPREFER_COCOA=FALSE
flag. The X-Shared Memory
(XSHM-MIT) will be checked and enabled at compile-time for better performance.
All other dependencies will be downloaded from their source repositories and
compiled.
Dependency | Use/Application |
---|---|
ASSIMP | For loading various 3D asset file formats |
FreeImage | To load textures and image files. |
ENet | Dependency of LightUtils. Used for UDP Networking. |
GLM | Dependency of LightMath. For unit testing and validation only. |
FreeType | Used for loading TTF fonts. |
It is recommended to install the 3rd-party development packages onto the system to speed up build times.
SoftLight uses the following submodules:
Cloning the repository should be done recursively, using the following steps:
git clone --recursive https://github.com/hamsham/SoftLight.git
cd SoftLight
git submodule foreach git checkout master
git submodule foreach git pull origin master
SoftLight is a very flexible software rasterizer. Compiling the code will generate a set of tests you can use to play around with. Some interesting examples include:
- Parallel Mesh Instancing (
sl_instancing_test.cpp
): Toggle threaded instancing by pressing theF2
key. - Skinning and animation (
sl_animation_test.cpp
). - Large indoor environment rendering (
sl_large_scene_test.cpp
): Press theF1
Key to capture the mouse and explore the environment using the WASD keys. You can also toggle PBR-based rendering with theF2
key as well as change the number of threads used for rendering by using the up/down arrow keys. - Full-screen quad rendering (
sl_fullscreen_quad.cpp
). Render to an offscreen Compact YCoCg Framebuffer then reconstruct the image in a second render pass. - Volumetric voxel rendering (
sl_volume_rendering_test.cpp
).
Check out the below screenshots to see what else it can do!
To see how to build a sample application using either SoftLight or the LightSky frameworks, explore the "tests" subdirectories within each project. You will find plenty of examples on how to load a 3D model, create a shader, render, and manipulate a 3D scene in real-time.
- Provide support for mip-mapping.
- Migrate shader system to use modern "pipeline" syntax (similar to Metal & Vulkan).
- Migrate framebuffer system to render passes (similar to Metal & Vulkan).
- Finish support for render state objects (including depth-stencil states).
- Complete Doxygen-based documentation for the software rendering module.
- Additional Unit Tests.
- Create additional examples.
- Wrap the rendering module in a C API for project portability.
- Migrate high-level scene graph constructs into LightGame.
- Add SDL2 backend support.
For any inquiries or pull requests, please email mileslacey@gmail.com. Bugs and other issues can be added here on GitHub. Finally, all source code is available under the MIT License.