Git Product home page Git Product logo

softglrender's Introduction

SoftGLRender

Tiny C++ Software Renderer/Rasterizer, it implements the main GPU rendering pipeline, 3D models (GLTF) are loaded by assimp, and using GLM as math library.

License

CMake MacOS CMake Windows CMake Linux

Code structure:

  • renderer: the main software renderer implementation, first preparing input data (Vertexes, Indices), then binding custom shaders, and setup rendering pipeline, after the pipeline finished, graphics will draw to the result framebuffer.
  • shader: the programmable render pipeline simulation, vertex shader and fragment shader are supported, and it is easy to port real GLSL code to this project, several basic shaders are embed such as blinn-phong lighting, skybox, PBR & IBL, etc.
  • app: code for Viewer, mainly include GLTF loading (based on Assimp), camera & controller, setting panel, and render pass management.

Renderer Pipeline Features

  • Wireframe
  • View Frustum culling
  • Back-Front culling
  • Orbit Camera Controller
  • Perspective Correct Interpolation
  • Tangent Space Normal Mapping
  • Basic Lighting
  • Blinn-Phong shading
  • PBR & IBL shading
  • Skybox CubeMap & Equirectangular
  • Texture mipmaps
  • Texture tiling and swizzling (linear, tiled, morton)
  • Texture filtering and wrapping
  • Shader varying partial derivative dFdx dFdy
  • Alpha mask & blend
  • Reversed Z, Early Z

Texture

Texture Filtering

  • NEAREST
  • LINEAR
  • NEAREST_MIPMAP_NEAREST
  • LINEAR_MIPMAP_NEAREST
  • NEAREST_MIPMAP_LINEAR
  • LINEAR_MIPMAP_LINEAR

Texture Wrapping

  • REPEAT
  • MIRRORED_REPEAT
  • CLAMP_TO_EDGE
  • CLAMP_TO_BORDER
  • CLAMP_TO_ZERO

Several commonly used texture fetch parameter are Supported, such as Lod, Bias, Offset, to support texture mipmaps, the renderer pipeline has implement shader varying partial derivative function dFdx dFdy, rasterization operates on 4 pixels as a Quad, dFdx dFdy is the difference between adjacent pixel shader variables:

/**
 *   p2--p3
 *   |   |
 *   p0--p1
 */
PixelContext pixels[4];

The storage of texture supports three modes:

  • Linear: pixel values are stored line by line, commonly used as image RGBA buffer
  • Tiled: block base storage, inside the block pixels are stored as Linear
  • Morton: block base storage, inside the block pixels are stored as morton pattern (similar to zigzag)

Anti Aliasing

  • SSAA
  • FXAA
  • MSAA
  • TAA

Shading

  • Blinn-Phong
  • PBR-BRDF

Optimization

  • Multi-Threading: rasterization is block based with multi-threading support, currently the triangle traversal algorithm needs to be optimized.
  • SIMD: SIMD acceleration is used to optimize performance bottlenecks, such as barycentric coordinate calculation, shader's varying interpolation, etc.

Showcase

Render Textured

  • BoomBox (PBR)

  • Robot

  • DamagedHelmet (PBR)

  • GlassTable

  • AfricanHead

  • Brickwall

  • Cube

Render Wireframe

Check "show clip" to show the triangles created by frustum clip

Dependencies

Clone

git clone [email protected]:keith2018/SoftGLRender.git
cd SoftGLRender
git submodule update --init --recursive

Build

mkdir build
cmake -B ./build -DCMAKE_BUILD_TYPE=Release
cmake --build ./build --config Release

Run

cd bin/Release
./SoftGLRender

License

This code is licensed under the MIT License (see LICENSE).

softglrender's People

Contributors

keith2018 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.