Skip to content

rms13/Project5-WebGL-Clustered-Deferred-Forward-Plus

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebGL Clustered Deferred and Forward+ Shading

University of Pennsylvania, CIS 565: GPU Programming and Architecture, Project 5

  • Rishabh Shah
  • Tested on: Version 62.0.3202.75 (Official Build) (64-bit) on Windows 10, i7-6700HQ @ 2.6GHz 16GB, GTX 960M 4096MB (Laptop)

Live Online

Demo GIF

Overview

In this project, I worked on implementing Clustered Forward+ and Clustered Deferred renderers. Clustered Forward+ renderer works in a similar way as a Forward rendered, but with one optimization. Here, we divide the view frustum in slices in three axes and bin the lights into the clusters. So in the fragment, only the lights in the cluster of the fragment need to be iterated through. Clustered Deferred takes this one step further by changing the way the scene is rendered. A Deferred shader postpones shading until the end. So we do per-pixel shading and not per-fragment. When shading is the heaviest stage, this is highly efficient than forward methods.

Features

  • Clustered Forward+
  • Clustered Deferred
  • Blinn-Phong shading (diffuse + specular) for point lights (in Clustered Deferred)
  • Simple Toon shading (in Clustered Forward+)
  • Optimizations
    • Pack values together into vec4s
    • Use 2-component normals

Performance Analysis

Forward vs. Forward+ vs Deferred

As expected, Deferred shading is the fastest followed by Forward+ followed by Forward. The tests were performed using 100 lights in the sponza model.

3-Buffers vs 2-Buffers

Deferred shading requires passing all the data between shaders using g-buffers. For this implementation, I tried reducing the number of g-buffers by packing position, color and normals in 2 vec4s. This can be done by storing the x and y components of the normal in the 4th position of the 2 g-buffers, and computing the z in the fragment shader. This is known as screen-space normals. But the method gives low performance advantage, and causes artefacts as seen below. This happens because the sign of recomputed Z is not retained. So the deployed version does not contain that code. But it can be found in the files in comments.

Screen-space normal artefacts

Lambertian Shading

Blinn-Phong Shading

Toon Shading

Credits

About

WebGL Clustered Deferred and Forward+ Shading

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 93.9%
  • GLSL 5.5%
  • HTML 0.6%