GithubHelp home page GithubHelp logo

zoom-2x / software_renderer Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 0.0 154.38 MB

Software renderer.

License: GNU General Public License v3.0

C 55.12% CMake 0.45% Objective-C 0.23% Batchfile 0.13% C++ 43.94% Makefile 0.05% Python 0.07% Cython 0.01% M4 0.02%
3d multithreaded pbr renderer software-rasterizer software-renderer

software_renderer's Introduction

Software Renderer

Software Renderer

Software renderer written in c/c++ (SDL) for Windows that started from Casey Muratori's Handmade Hero Project https://handmadehero.org/.

Preview: https://www.deviantart.com/zoom-2x

Features

  • multithreading
  • SSE vectorization
  • tiled rendering
  • perspective correct texture mapping
  • texture filtering
  • mipmapping + trilinear filtering
  • tangent space normal mapping
  • cubemapping
  • depth buffer
  • backface culling
  • homogeneous clipping
  • gamma correction
  • tonemapping (clamp, reinhard, filmic (Uncharted 2), aproximated ACES)
  • post processing (tint, saturation)
  • directional light shadows (basic, linear, pcf3x3, pcf5x5)
  • point light shadows (basic, linear, pcf (slower))
  • transparency (separate buffer which holds up to 5 transparent samples per pixel)
  • custom shader programs
  • blinn-phong model
  • physically based rendering + image based lighting model
  • asset packing (bmp format with 4 channels, hdr equirectangular format (ibl), 3d gltf format)
  • rudimentary custom memory management system

Running the program

First of all you have to build the asset packages by running run-asset-builder-msvc.bat (select the "all" option). This will take a few minutes depending on your cpu. On mine (I5-2400) it takes between 5 to 10 minutes, the hdr texture packing is the biggest time comsumer. The packing step needs to be done once.

To change the level you want to run open the file data/settings.json and "uncomment" the desired level (remove the "1" in "level1"). Run run-msvc.bat.

Building the program

First, you have to open the shell.bat and change the path to the MSVC vcvarsall.bat file and the path to the software_renderer/shell directory. Open a console and navigate to the software_renderer directory and run shell then build (the shell command needs to be run only once to setup the directories). This should generate the executables and the dll inside the bin directory.

The file shell/build.bat can be configured if needed.

The number of threads used can be changed in the file src/gcsr_settings.h, now the program uses 4 threads #define GC_PIPE_NUM_THREADS 4. On a I5-2400 3.1Ghz, a complex pbr hdr level runs at 5-20 fps on a 1280x800 resolution. I believe that on a newer processor, with more cores, the performance will be higher than this. You can also run a scene at a lower scaled resolution - this can be done by changing the res_scaling option inside the file data/settings.json, up to 4. This will boost the performance but the image will be pixelated, no filtering is being done when rescaling.

Adding new assets

The input textures are in 32bit BMP format, 4 channels and the size needs to be a power of 2. The meshes need to be exported from Blender in gltf binary (.glb) format:

  • the first file (name.glb) will contain the base triangle mesh and has the following "Geometry" settings checked: Apply Modifiers, UVs, Normals, Tangents, Vertex Colors (for now this is not used)
  • the second file (name.gen.glb) is used to extract the line and point meshes and has the following "Geometry" settings checked "Apply modifiers

The new assets need to be added in the file data/package/asset_builder_config.json - there are separate sections for each the textures and the meshes. Finally, run run-asset-builder-msvc and build only the packages corresponding to the new assets. Read the existing level files to see how they can be loaded.

Dependencies

Assets used

Skybox textures and HDR textures:

software_renderer's People

Contributors

zoom-2x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.