GithubHelp home page GithubHelp logo

kosua20 / ptahrenderer Goto Github PK

View Code? Open in Web Editor NEW
87.0 9.0 8.0 38.94 MB

A small software graphics renderer

License: MIT License

Swift 100.00%
rasterization graphics-rendering computer-graphics swift software-rendering

ptahrenderer's Introduction

PtahRenderer

A small software graphics renderer. Offline and online demos available on macOS and Linux (tested on Ubuntu). See Programs for requirements and build instructions. Associated blog post here.

Written with the help of (among other resources) :

  • Interactive Computer Graphics - A Top-Down Approach, 2012, E. Angel & D.Shreiner
  • Introduction to Computer Graphics course, M. Pauly, EPFL 2015
  • How OpenGL works, D. V. Sokolov, available at github.com/ssloy/tinyrenderer
  • Triangle rasterization in practice and the following posts, F. Giesen, available here
  • Rasterization: a Practical Implementation, , available at scratchapixel.com
  • How to write a (software) 3d polygon pipeline, C. Bloom, available here

Image produced with the software renderer

Programs

The project is composed of two library modules, and three programs:

  • PtahRenderer contains the internal logic to perform transformation, rasterization and clipping,... along with primitive types.
  • PtahRendererDemo contains the scene, the objects and shaders, and handles camera movements and animations.
  • PtahRendererDemoOffline is a command-line utility that renders one frame of the scene and saves it to a .tga file in the renders/ directory
  • PtahRendererDemoOnline is a macOS Cocoa application (that can only be built using Xcode), performing real-time rendering with mouse interactions (scroll to zoom, drag to rotate around the scene).
  • PtahRendererDemoOpenGL performs the same tasks as PtahRendererDemoOnline but relies on OpenGL 3 and GLFW 3 to display the output of the renderer in real-time.

Apart from PtahRendererDemoOnline, everything can be compiled using the Swift Package Manager on both macOS (tested on macOS 10.12) and Linux (tested on Ubuntu 16.04).

swift build -c release -Xlinker -L/usr/local/lib

For PtahRendererDemoOpenGL, GLFW 3 needs to be installed in /usr/local and is accessed through a thin wrapper (macOS and Linux versions). OpenGL is also used through a wrapper, SGLOpenGL, that mainly provides platform independance and types simplification (because of Swift handling of GLenum among other things). If you want to compile the OpenGL demo in Xcode, do a first compilation with the Package Manager so the dependencies are downloaded and setup.

Done

  • General setup
  • Mesh loading (OBJ with vertices, normals, texture coordinates, faces)
  • Texture loading (PNG, 1-3-4 channels, supports wrapping and clamping)
  • Line drawing (using Bresenham’s line drawing algorithm)
  • Wireframe drawing for triangular faces
  • Triangles rasterization
  • Z-buffer
  • View and world matrices
  • Back faces culling
  • Projection matrix
  • Primitives clipping
  • Shaders (vertex, fragment)
  • Multi pass (for AO (SSAO or pre-computation), shadow maps, deferred shading)
  • Offline demo (both platforms)
  • Real-time demo (both platforms)

To do

  • Optimizations...

ptahrenderer's People

Contributors

kosua20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ptahrenderer's Issues

TGALoader.writeTGA does not seem to work(Linux)

When I run PtahRendererDemoOffline, I see the following output but the rendered files are nowhere to be found:

./.build/debug/PtahRendererDemoOffline
Starting Ptah Renderer...
Done!

I'm running swift-3.1 on Arch Linux:

swift -v
Swift version 3.1 (swift-3.1-RELEASE)
Target: x86_64-unknown-linux-gnu

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.