Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 52 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,69 @@

WebGL Forward+ and Clustered Deferred Shading
======================

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

* (TODO) YOUR NAME HERE
* Tested on: (TODO) **Google Chrome 222.2** on
Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* Shubham Sharma
* [LinkedIn](www.linkedin.com/in/codeshubham), [personal website](https://shubhvr.com/).
* Tested on: Windows 10, i7-9750H @ 2.26GHz, 16GB, GTX 1660ti 6GB (Personal Computer).
*GPU Compute Capability: 7.5

### Live Online

[![](img/thumb.png)](http://TODO.github.io/Project5-WebGL-Forward-Plus-and-Clustered-Deferred)
[Live Link](http://codeplay9800.github.io/Project5-WebGL-Forward-Plus-and-Clustered-Deferred)

### Demo Video/GIF

[![](img/video.png)](TODO)
[![](img/WebGL2.gif)](TODO)


**Buffer Images**
- Position
[![](img/Position.png)](TODO)

- Normal
[![](img/Normal.png)](TODO)

- Albedo
[![](img/albedo.png)](TODO)

### Overview

This project highlights the performance differences between Forward, Forward+ clustered and Deferred clustered shading schemes.
- Forward : Implementation of Forward shading in this project has been updated to calculate the visible object Mesh once and iterating through all the lights in the scene to shade the visible mesh or vertices.
- Forward+ : The Scene is divided into tiled frustum clusters, which expand along the X, Y and Z axes. The Scene objects are shaded only iterating through the lights which affect them or the lights which affect the clusters in which the object lies in.
- Deferred Clustered : This required multiple passes of the OpenGL draw pipeline. Scene information is stored as G Buffers in the first pass and the scene is shaded using the same cluster methodology as Forward+ Shading.

### Performance Analysis
In Theory Expected Performance : Deferred Clustered > Forward+ > Forward

- **Forward+ > Forward** : This is attributed towards the number of lights calculation that finally affects a vertex. In Forward we are calculating the resultant color of an object vertex due to every light in the scene regardless of weather the light affects the object vertex. Where as i Forward+ we take into account the number of light affecting the object vertex so overall the lighting computation decreases.
- **Deferred Clustered > Forward+** : This is also attributed towards the number of light calculations that finally affects the vertex. But the difference comes into play due to multiple passes in Deferred Clustered. Since we store the position attributes in a Texture buffer once, the second pass of the fragment shader doesn't have to do light calculation for multiple fragment for the same pixel as we are left with only one fragment per pixel. Only the smallest depth fragments is left and all the others gets deleted off during the first pass. Whereas in the Forward+ lighting calculation is done for all the fragments for a particular pixel, the lowest one is kept while the others are discarded after the fragment shader stage. The downside is that we can't have transparence in our scene.

### Performance Charts
I have to used debug mode in order to get substantial analyses. To analyze this data, I used Google Chrome's built-in performance tools, which allows me to view the function calls in a tick() of the program.
For some reason my the numbers for time between each cycle of tick() call didn't make any sense for forward shading so i am using (Frames Per Second) FPS as the metric for my performance analysis.

**Parameters**
- Resolution - 1920 X 912 (Width X Height )
- Cluster Size - ( 20 X 20 X 20 ) ( X * Y * Z) (OpenGL Length metric Units)
- Light Radius - 1 (OpenGL Length metric Units)


### (TODO: Your README)
**Forward, Forward+ and Deferred Clustered (Optimised)**
![Forward, Forward+ and Deferred Clustered](img/ForwardForward+andClusteredDeferred.png)
As expected, the Clustered Deferred performs the best followed by Forward+ and the Forward. However as the number of lights Forward+ and Forward converge to about a similar performance as the most of the clusters are filled with a large number of lights and similar therefore similar computation. Deferred Clustered still performs the best due to multiple passes as explained above.

*DO NOT* leave the README to the last minute! It is a crucial part of the
project, and we will not be able to grade you without a good README.
**Deferred Clustered and Deferred Clustered (Optimised)**
![Forward, Forward+ and Deferred Clustered](img/ClusteredDeferredandClusteredDeferred(Optimised).png)
GBuffers are stored as Texture Images of Float32Byte arrrays. For Simple Deferred Clustered we are using three GBuffers to store Position, Normals and Color for each pixel Data.
I have optimised by using 2 GBuffers as compared to three which provides faster less memory storage and faster access rate. Which attributes to performance increasee. This can be further optimised by storing depths only which is a single float value and recreating positions using viewProjectionMatrix and Texture Coordinates.
I wasn't able to finish my implementation, but i believe it would greatly increase the performance.

This assignment has a considerable amount of performance analysis compared
to implementation work. Complete the implementation early to leave time!

### Blinn Phong Shading
[![](img/BlinnSpecular.gif)](TODO)

### Credits

Expand All @@ -31,3 +72,4 @@ to implementation work. Complete the implementation early to leave time!
* [webgl-debug](https://github.com/KhronosGroup/WebGLDeveloperTools) by Khronos Group Inc.
* [glMatrix](https://github.com/toji/gl-matrix) by [@toji](https://github.com/toji) and contributors
* [minimal-gltf-loader](https://github.com/shrekshao/minimal-gltf-loader) by [@shrekshao](https://github.com/shrekshao)
* [oct-encoding normals] http://jcgt.org/published/0003/02/01/paper.pdf
Binary file added img/BlinnSpecular.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/ForwardForward+andClusteredDeferred.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Performance.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Performance.PNG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/Position.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/WebGL2.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/albedo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions npm-debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 silly lifecycle @~prestart: no script for prestart, continuing
7 info lifecycle @~start: @
8 verbose lifecycle @~start: unsafe-perm in lifecycle true
9 verbose lifecycle @~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\sshubh_CGGT\Documents\GitHub\Project5-WebGL-Forward-Plus-and-Clustered-Deferred\node_modules\.bin;C:\VulkanSDK\1.1.85.0\Bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\libnvvp;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\SIG\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\nodejs\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\SMI\iViewNG-HMD\SDK\libs\x86;C:\Program Files (x86)\SMI\iViewNG-HMD\SDK\libs\x64;C:\Program Files (x86)\SMI\iViewNG-HMD\SDK\3rdParty;C:\Program Files\TortoiseSVN\bin;C:\Program Files\Autodesk\Maya2017\bin;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\WINDOWS\system32;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files (x86)\QuickTime\QTSystem\;C:\Program Files\Microsoft VS Code\bin;D:\Android AVD\platform-tools;D:\Android AVD\tools;C:\Program Files\dotnet\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\libnvvp;C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.1\bin;C:\Program Files (x86)\GitExtensions\;C:\Users\SIG Student\Anaconda3\python.exe;;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\Nsight Compute 2021.2.2\;C:\Users\sshubh_CGGT\AppData\Local\Microsoft\WindowsApps;C:\Users\sshubh_CGGT\AppData\Local\GitHubDesktop\bin
10 verbose lifecycle @~start: CWD: C:\Users\sshubh_CGGT\Documents\GitHub\Project5-WebGL-Forward-Plus-and-Clustered-Deferred
11 silly lifecycle @~start: Args: [ '/d /s /c', 'webpack-dev-server --mode development' ]
12 silly lifecycle @~start: Returned: code: 1 signal: null
13 info lifecycle @~start: Failed to exec start script
14 verbose stack Error: @ start: `webpack-dev-server --mode development`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:877:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid @
16 verbose cwd C:\Users\sshubh_CGGT\Documents\GitHub\Project5-WebGL-Forward-Plus-and-Clustered-Deferred
17 error Windows_NT 10.0.19041
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 error node v6.9.5
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error @ start: `webpack-dev-server --mode development`
22 error Exit status 1
23 error Failed at the @ start script 'webpack-dev-server --mode development'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack-dev-server --mode development
23 error You can get information on how to open an issue for this project with:
23 error npm bugs
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
Loading