All Projects â†’ forkercat â†’ ForkerRenderer

forkercat / ForkerRenderer

Licence: MIT license
CPU-Based Software Forward / Deferred Rasterizer, A Tiny OpenGL (PBR, Soft Shadow, SSAO) đŸŧ

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
CMake
9771 projects

Projects that are alternatives of or similar to ForkerRenderer

Tinyrenderer
A brief computer graphics / rendering course
Stars: ✭ 11,776 (+69170.59%)
Mutual labels:  rendering, rasterizer
retro-ngon
A well-featured retro-oriented 3D software renderer for the HTML5 canvas.
Stars: ✭ 30 (+76.47%)
Mutual labels:  rendering, rasterizer
SHSoftwareRasterizer
čŊ¯å…‰æ …器įš„įŽ€å•åŽžįŽ°
Stars: ✭ 31 (+82.35%)
Mutual labels:  rendering, rasterizer
CPU-Rasterizer
A tile based cpu rasterizer
Stars: ✭ 30 (+76.47%)
Mutual labels:  rendering, rasterizer
Unity3DShaders
Simple shaders for Unity3D that I created for games, for a challenge or following tutorials.
Stars: ✭ 17 (+0%)
Mutual labels:  rendering
abeamer
frame-by-frame Web Animation framework
Stars: ✭ 49 (+188.24%)
Mutual labels:  rendering
photon mapping
minimal but extensible header only implementation of photon mapping in C++
Stars: ✭ 65 (+282.35%)
Mutual labels:  rendering
swGL
A multithreaded software implementation of OpenGL 1.3 in C++.
Stars: ✭ 50 (+194.12%)
Mutual labels:  rasterizer
safemd
Safety first markdown rendering
Stars: ✭ 77 (+352.94%)
Mutual labels:  rendering
DuEngine
An efficient interactive C++ renderer for ShaderToy-alike demos with 2D/3D/CubeMap/Video/Camera/LightField/Volume textures. (Partially used in my I3D 2018 papers)
Stars: ✭ 62 (+264.71%)
Mutual labels:  rendering
Messier87
A realtime raytracing blackhole renderer
Stars: ✭ 53 (+211.76%)
Mutual labels:  rendering
coin
Coin3D core library
Stars: ✭ 193 (+1035.29%)
Mutual labels:  rendering
mcrt
Monte Carlo Raytracer from Scratch in C++11/14
Stars: ✭ 22 (+29.41%)
Mutual labels:  rendering
f3d
Fast and minimalist 3D viewer.
Stars: ✭ 791 (+4552.94%)
Mutual labels:  rendering
evplp
Implementation of Efficient Energy-Compensated VPLs using Photon Splatting (and various rendering techniques)
Stars: ✭ 26 (+52.94%)
Mutual labels:  rendering
tech-seo-crawler
Build a small, 3 domain internet using Github pages and Wikipedia and construct a crawler to crawl, render, and index.
Stars: ✭ 57 (+235.29%)
Mutual labels:  rendering
Kuplung
OpenGL Model Viewer
Stars: ✭ 15 (-11.76%)
Mutual labels:  rendering
Squirrel-Engine
Multithreaded C/C++ Game Engine
Stars: ✭ 90 (+429.41%)
Mutual labels:  rendering
pmj-cpp
"Progressive Multi-Jittered Sample Sequences" in C++
Stars: ✭ 34 (+100%)
Mutual labels:  rendering
fluctus
An interactive OpenCL wavefront path tracer
Stars: ✭ 55 (+223.53%)
Mutual labels:  rendering

Forker Renderer: CPU-Based Forward / Deferred Rasterizer, A Tiny OpenGL đŸŧ

CMake license

Implement a CPU-based software rasterizer that simulates how OpenGL works without using any third-party libraries, but use spdlog for logging though :)

🔨 Building & Usage

# Clone
git clone https://github.com/forkercat/ForkerRenderer.git
cd ForkerRenderer 

# Compile
mkdir build && cd build
cmake .. && make

# Usage: <scene filename>
./ForkerRenderer ../scenes/test.scene

đŸĨē Future Development

  • Physically-Based Rendering (PBR)
    • Improvement
  • Global Illumination
    • Screen Space Reflection (SSR) aka. Realtime Ray Tracing

⭐ Features

  • Rasterization
    • Bresenham's Line Algorithm (used and removed)
    • Bounding Box Method (currently used)
  • Rendering Methods
    • Forward Rendering
    • Deferred Rendering
      • G-Buffers: depth, world position, normal, albedo, etc
      • Geometry Pass
      • Lighting Pass

  • Shading
    • Depth Shading
    • Geometry Shading (for deferred rendering)
    • Blinn-Phong Shading
    • PBR Material and Shading
      • Cook-Torrance reflectance equation
      • D: Trowbridge-Reitz GGX
      • F: Fresnel-Schlick approximation
      • G: Smith's method with Schlick-GGX

  • Parsing *.obj / *.mtl
    • g defines mesh name; usemtl defines m_Material name (comes in order)
    • Support Ka, Kd, Ks, Ke, map_Kd, map_Ks, map_Ke, map_Bump, map_Ao, map_Pr, map_Pm
    • Position vertex normalization
    • Auto triangulation
  • Parsing scene files *.scene
# Test Scene
screen 1280 800
# forward/deferred rendering
mode deferred
ssaa off 2
shadow on
# Light (type: point/dir, position, color)
light point 2 5 5 1 1 1
# Camera (type: persp/ortho, position, lookAt)
camera persp -1 1 1 0 0 -1
# Models (filepath, position, rotate_y, uniform scale)
model obj/plane/plane.obj false false 0 -1 -1 0 3
# Mary
model obj/mary/mary.obj true true 0.05 0 -1 -10 1
  • Geometry Template Class
    • Vector: Vector2f, Vector3f, Vector4f, Vector4i, ...
    • Matrix: Matrix3f, Matrix4f, Matrix3x4f, ...
    • Support glm-style vector swizzling, e.g. v.xyz, v.xy
  • Light: Point / Directional
    • AreaLight is defined by AREA_LIGHT_SIZE in shadow mapping)
  • Texture Mapping:
    • Diffuse / Specular / Normal / Emissive
    • Roughness / Metalness / Ambient Occlusion
  • Texture Wrapping: NoWrap / ClampToEdge / Repeat / MirroredRepeat Texture::WrapMode
  • Texture Filtering: Nearest / Linear (Bilinear) Texture::FilterMode

  • Normal Transformation: TBN Matrix
    • Generate and average m_Tangents for each vertex when loading the model
  • Camera: Orthographic / Perspective Projection
  • Perspective Correct Interpolation (PCI) #define PERSPECTIVE_CORRECT_INTERPOLATION

  • Shadow Effect
    • Hard Shadow: Shadow Mapping (set shadow on in test.scene and comment out below macros)
    • Soft Shadow:
      • Percentage-Closer Filtering (PCF) #define SOFT_SHADOW_PCF
      • Percentage-Closer Soft Shadow (PCSS) #define SOFT_SHADOW_PCSS
#ifdef SOFT_SHADOW_PCF
    // Percentage-Closer Filtering (PCF)
    visibility = PCF(uShadowBuffer, shadowCoord, bias, PCF_FILTER_SIZE);
#elif defined(SOFT_SHADOW_PCSS)
    // Percentage-Closer Soft Shadow (PCSS)
    visibility = PCSS(uShadowBuffer, shadowCoord, bias);
#else
    // Hard Shadow
    visibility = HardShadow(uShadowBuffer, shadowCoord, bias);
#endif
  • Anti-Aliasing (AA)
    • SSAA: Super Sampling Anti-Aliasing (set ssaa on in test.scene)
    • MSAA

  • Global Illuminations
    • Screen Space Ambient Occlusion (SSAO) ssao on
      • Range Check (courtesy of John Chapman)
      • Noise Reduction: simple 9x9 blur, two-pass Gaussian blur
    • Screen Space Reflection (SSR)
      • Aka. Screen Space Ray Tracing

đŸ–ŧī¸ Gallery

Apex Horizon (also Dr. Mary Somers) [Squral]

Mary [TAs from GAMES202: Real-time High Quality Rendering]

Horizon Meets Mary

Sci-Fi Welding Vehicle [Berk Gedik]

Cafe Menu Chalkboard [Naiyararahman]

Gossblade Greatsword (Monster Hunter Rise) [taj_tajima]

Backpack [Berk Gedik]

African Head [Vidar Rapp]

📁 Structure

About 5,500 lines of code:

  • Rendering: render.h/cpp (rendering functions), forkergl.h/cpp (rasterization)
  • Buffer: buffer.h/cpp (Buffer1f, Buffer3f)
  • Shader: shader.h, phongshader.h, pbrshader.h, depthshader.h, gshader.h
  • Shadow: shadow.h/cpp
  • Scene: scene.h/cpp, scenes/test.scene
  • Model: model.h/cpp, mesh.h/cpp, material.h, pbrmaterial.h, texture.h
  • Camera: camera.h/cpp
  • Light: light.h
  • Color: color.h
  • Geometry: geometry.h/cpp
  • Utility: tgaimage.h/cpp, output.h/cpp, check.h, utility.h, constant.h, stringprint.h (PBRT-v3)

📜 Console Output

$ ./ForkerRenderer scenes/test.scene
[info] Scene File: 'scenes/test.scene'
[info]   [Mode] Forward Rendering
[info]   [Screen] 1280 x 800
[info]   [Point Light] position: [ 2.00000000, 5.00000000, 5.00000000 ], color: [ 1.00000000, 1.00000000, 1.00000000 ]
[info]   [Camera] position: [ -1.00000000, 1.00000000, 1.00000000 ], lookAt: [ 0.00000000, 0.00000000, -1.00000000 ]
[info]   [Model] 'obj/diablo_pose/diablo_pose.obj'
[info]      v# 2519, f# 5022, vt# 3263, vn# 2519, tg# 2519, mesh# 1, mtl# 1 | normalized[o] generateTangent[o], flipTexCoordY[o]
[info]      [Diablo_Pose] f# 5022 | PBR[x] map_Kd[o] map_Ks[o] map_Ke[x] map_Bump[o] | Ka(0.10, 0.10, 0.10), Kd(0.81, 0.81, 0.81), Ks(0.20, 0.20, 0.20)
[info]   [Config] SSAA(x2)[off] shadow[on] SSAO[off]
[info] ------------------------------------------------------------
[info] Time Used: 0.714729 Seconds (Scene Loaded)

[info] Shadow Pass:
[info]   [Status] Enabled
[info]   [Diablo_Pose] Time Used: 0.106988 Seconds
[info] ------------------------------------------------------------
[info] Time Used: 0.858756 Seconds (Shadow Pass)

[info] Forward Pass (Blinn-Phong):
[info]   [Diablo_Pose] Time Used: 3.92819 Seconds
[info] ------------------------------------------------------------
[info] Time Used: 3.97755 Seconds (Forward Pass)

[info] Anti-Aliasing (SSAA):
[info]   [Status] Disabled
[info] ------------------------------------------------------------
[info] Time Used: 4.87400e-06 Seconds (Anti-Aliasing)

[info] Output TGA File: 'output/framebuffer.tga'
[info] Output TGA File: 'output/shadowmap.tga'
[info] Output TGA File: 'output/zbuffer.tga'

📚 Reference

Started by following the basic workflow in ssloy/TinyRenderer, improved code style (e.g. geometry.h) when referring to other great resources such as mmp/pbrt-v3 & v4, and resolved tons of issues with the help of the Internet. Thank those authors and creators who wrote the articles and built the models!

Rendering:

Model Credits:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].