Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit... finally.... #14

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
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
Binary file added 32b_ao.jpg
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 32b_ao_smooth.jpg
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 32b_ao_unsmooth.jpg
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 32b_color.jpg
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 32b_depth.jpg
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 32b_mv_effect.jpg
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 32b_normal.jpg
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 32b_shading_ao_mb.jpg
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 32b_toon.jpg
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 8b_ao.jpg
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 8b_depth.jpg
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 8b_normal.jpg
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 8b_shading_ao_mb.jpg
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 8b_toon.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
240 changes: 101 additions & 139 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,144 +1,106 @@
-------------------------------------------------------------------------------
CIS565: Project 6: Deferred Shader
-------------------------------------------------------------------------------
Fall 2013
-------------------------------------------------------------------------------
Due Friday 11/15/2013
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
NOTE:
-------------------------------------------------------------------------------
This project requires any graphics card with support for a modern OpenGL
pipeline. Any AMD, NVIDIA, or Intel card from the past few years should work
fine, and every machine in the SIG Lab and Moore 100 is capable of running
this project.

-------------------------------------------------------------------------------
INTRODUCTION:
-------------------------------------------------------------------------------
In this project, you will get introduced to the basics of deferred shading. You will write GLSL and OpenGL code to perform various tasks in a deferred lighting pipeline such as creating and writing to a G-Buffer.
Deferred Renderer
-------------------------------------------------------------------------------

Deferred shading is a mulit-pass rendering approach. The scene primitives are usually rendered once per frame (or per material), and the information needed for shading (position, normal, depth, albedo, etc.) are output to multiple render targets, a
group of image buffers that have the same size as the output screen.
Then in the subequent passes, a screen-sized quad is rendered and shading is performed using information provided by the buffers obtained from the primitive-rendering pass.
Unlike traditional forward rendering approach, which has to render the same primitives multiple times when multiple lights are present,
deferred shading can reuse the shading information without rendering the scene over and over again.
Thus the shading complexity is decoupled from scene complexity.

This project implements deferred renderer using OpenGL's Framebuffer Objects; it demonstrates the following effects:
* Diffuse material shading
* Toon shading with silhouette
* Scren space ambient occlusion (SSAO)
* Motion blur

by using the following buffers generated in the primitive-rendering pass:
* Depth
* Surface normal
* Albedo
* Velocity field

Mutiple post-processing passes are performed:
* SSAO calculation
* SSAO smoothing
* Motion blurring
* Toon shading silhouette (using Sobel filter on both depth and normal)

Keyboard usage
--------------------------------------------------------------------------------
* 1: show depth
* 2: show screen space normal
* 3: show albedo
* 4: show screen space position
* 5: show light influence (press 'x' to toggle scissor)
* 6: show Toon shading
* 0: show diffuse shading (plus SSAO)
* mouse to look around
* W,S,A,D to move


Rendering result
---------------------------------------------------------------------------------
Diffuse shading+SSAO:
![all](32b_shading_ao_mb.jpg)


Motion blur effect:
![mv](32b_mv_effect.jpg)

Toon Shading:
![toon](32b_toon.jpg)

Depth buffer:
![depth](32b_depth.jpg)

Normal buffer:
![normal](32b_normal.jpg)

Ambient Occlusion before smoothing:
![ao](32b_ao_unsmooth.jpg)

Ambient ccclusion after smoothing:
![ao2](32b_ao_smooth.jpg)


Performance Evaluation:
----------------------------------------------------------------------------------
Three kinds of render targets layouts were tested:


* 4 X RGBA32F floating point textures + 32bit depth buffer:

![4 RBGA32F](buffer1.jpg)

* 2 X RGBA32F floating point textures + 32bit depth buffer:
(Positions are reconstructed on the fly from detph values)

![2 RGBA32F](buffer2.jpg)

* 2 X RGBA8 UCHAR textures + 32bit depth buffer:
(Positions are reconstructed on the fly from detph values)

![2 RGBA32F](buffer2.jpg)



The following chart shows how size and precision of render targets affect performance:

![Comparison between MRT layouts](chart.jpg)

The chart shows how FPS changes when rendering using different amounts of render targets and precision.
The tests were run on a nVidia GTX660M laptop.

Although 8-bit precision textures yields better performance, error arises when using them for shading.

The following images are the rendering results using 8-bit depth textures.

![8b normal](8b_normal.jpg)
![8b all](8b_shading_ao_mb.jpg)
![8b toon](8b_toon.jpg)

-------------------------------------------------------------------------------
CONTENTS:
-------------------------------------------------------------------------------
The Project6 root directory contains the following subdirectories:

* base/
* PROJ_WIN/ contains the vs2010 project files
* PROJ_NIX/ contains makefile for building (tested on ubuntu 12.04 LTS)
* res/ contains resources including shader source and obj files
* src/ contains the c++ code for the project along with SOIL and tiny_obj_loader
* shared32/ contains freeglut, glm, and glew.

-------------------------------------------------------------------------------
REQUIREMENTS:
-------------------------------------------------------------------------------

In this project, you are given code for:
* Loading .obj files
* Rendering to a minimal G buffer:
* Depth
* Normal
* Color
* Eye space position
* Rendering simple ambient and directional lighting to texture
* Example post process shader to add a vignette

You are required to implement:
* Either of the following effects
* Bloom (feel free to use [GPU Gems](http://http.developer.nvidia.com/GPUGems/gpugems_ch21.html) as a rough guide)
* "Toon" Shading (with basic silhouetting)
* Point light sources
* An additional G buffer slot and some effect showing it off

**NOTE**: Implementing separable convolution will require another link in your pipeline and will count as an extra feature if you do performance analysis with a standard one-pass 2D convolution. The overhead of rendering and reading from a texture _may_ offset the extra computations for smaller 2D kernels.

You must implement two of the following extras:
* The effect you did not choose above
* Screen space ambient occlusion
* Compare performance to a normal forward renderer with
* No optimizations
* Coarse sort geometry front-to-back for early-z
* Z-prepass for early-z
* Optimize g-buffer format, e.g., pack things together, quantize, reconstruct z from normal x and y (because it is normalized), etc.
* Must be accompanied with a performance analysis to count
* Additional lighting and pre/post processing effects! (email first please, if they are good you may add multiple).

-------------------------------------------------------------------------------
README
-------------------------------------------------------------------------------
All students must replace or augment the contents of this Readme.md in a clear
manner with the following:

* A brief description of the project and the specific features you implemented.
* At least one screenshot of your project running.
* A 30 second or longer video of your project running. To create the video you
can use http://www.microsoft.com/expression/products/Encoder4_Overview.aspx
* A performance evaluation (described in detail below).

-------------------------------------------------------------------------------
PERFORMANCE EVALUATION
-------------------------------------------------------------------------------
The performance evaluation is where you will investigate how to make your
program more efficient using the skills you've learned in class. You must have
performed at least one experiment on your code to investigate the positive or
negative effects on performance.

We encourage you to get creative with your tweaks. Consider places in your code
that could be considered bottlenecks and try to improve them.

Each student should provide no more than a one page summary of their
optimizations along with tables and or graphs to visually explain any
performance differences.

-------------------------------------------------------------------------------
THIRD PARTY CODE POLICY
-------------------------------------------------------------------------------
* Use of any third-party code must be approved by asking on the Google groups.
If it is approved, all students are welcome to use it. Generally, we approve
use of third-party code that is not a core part of the project. For example,
for the ray tracer, we would approve using a third-party library for loading
models, but would not approve copying and pasting a CUDA function for doing
refraction.
* Third-party code must be credited in README.md.
* Using third-party code without its approval, including using another
student's code, is an academic integrity violation, and will result in you
receiving an F for the semester.

-------------------------------------------------------------------------------
SELF-GRADING
-------------------------------------------------------------------------------
* On the submission date, email your grade, on a scale of 0 to 100, to Liam,
[email protected], with a one paragraph explanation. Be concise and
realistic. Recall that we reserve 30 points as a sanity check to adjust your
grade. Your actual grade will be (0.7 * your grade) + (0.3 * our grade). We
hope to only use this in extreme cases when your grade does not realistically
reflect your work - it is either too high or too low. In most cases, we plan
to give you the exact grade you suggest.
* Projects are not weighted evenly, e.g., Project 0 doesn't count as much as
the path tracer. We will determine the weighting at the end of the semester
based on the size of each project.


---
SUBMISSION
---
As with the previous projects, you should fork this project and work inside of
your fork. Upon completion, commit your finished project back to your fork, and
make a pull request to the master repository. You should include a README.md
file in the root directory detailing the following

* A brief description of the project and specific features you implemented
* At least one screenshot of your project running.
* A link to a video of your project running.
* Instructions for building and running your project if they differ from the
base code.
* A performance writeup as detailed above.
* A list of all third-party code used.
* This Readme file edited as described above in the README section.

---
ACKNOWLEDGEMENTS
---
This project makes use of [tinyobjloader](http://syoyo.github.io/tinyobjloader/) and [SOIL](http://lonesock.net/soil.html)
7 changes: 5 additions & 2 deletions base/PROJ_WIN/P6/P6.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "P6", "P6\P6.vcxproj", "{5706DFE4-FA46-448C-8A11-12E132B9BC59}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SOIL", "..\..\src\SOIL\SOIL.vcxproj", "{25544C77-3B78-405F-A15D-1231D05969F3}"
Expand All @@ -23,4 +23,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal
19 changes: 13 additions & 6 deletions base/PROJ_WIN/P6/P6/P6.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand All @@ -44,13 +46,13 @@
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\src\SOIL;..\..\..\src\tiny_obj_loader;..\..\..\..\shared32\freeglut\include;..\..\..\..\shared32\glew\include;..\..\..\..\shared32\glm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\shared32\freeglut\include;..\..\..\..\shared32\glew\include;..\..\..\src\SOIL;..\..\..\src\tiny_obj_loader;..\..\..\..\shared32\glm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\..\shared32\freeglut\lib;..\..\..\..\shared32\glew\lib;..\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;SOIL.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
Expand All @@ -60,14 +62,14 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\..\..\src\SOIL;..\..\..\src\tiny_obj_loader;..\..\..\..\shared32\freeglut\include;..\..\..\..\shared32\glew\include;..\..\..\..\shared32\glm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\..\..\..\shared32\freeglut\include;..\..\..\src\SOIL;..\..\..\src\tiny_obj_loader;..\..\..\..\shared32\glew\include;..\..\..\..\shared32\glm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>..\..\..\..\shared32\freeglut\lib;..\..\..\..\shared32\glew\lib;..\Release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;SOIL.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
Expand All @@ -85,9 +87,14 @@
<None Include="..\..\..\res\shaders\ambient.frag" />
<None Include="..\..\..\res\shaders\diagnostic.frag" />
<None Include="..\..\..\res\shaders\directional.frag" />
<None Include="..\..\..\res\shaders\outline.geom" />
<None Include="..\..\..\res\shaders\pass.frag" />
<None Include="..\..\..\res\shaders\pass.vert" />
<None Include="..\..\..\res\shaders\point.frag" />
<None Include="..\..\..\res\shaders\post-ao.frag" />
<None Include="..\..\..\res\shaders\post-blur.frag" />
<None Include="..\..\..\res\shaders\post-smooth.frag" />
<None Include="..\..\..\res\shaders\post-toon.frag" />
<None Include="..\..\..\res\shaders\post.frag" />
<None Include="..\..\..\res\shaders\post.vert" />
<None Include="..\..\..\res\shaders\shade.vert" />
Expand Down
15 changes: 15 additions & 0 deletions base/PROJ_WIN/P6/P6/P6.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,20 @@
<None Include="..\..\..\res\shaders\shade.vert">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\post-blur.frag">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\post-smooth.frag">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\post-ao.frag">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\outline.geom">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\post-toon.frag">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
24 changes: 24 additions & 0 deletions base/PROJ_WIN/P6/P6/cornell_box.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
newmtl white
Ka 0 0 0
Kd 0.9 0.9 0.9
Ks 0 0 0

newmtl red
Ka 0 0 0
Kd 1 0 0
Ks 0 0 0

newmtl green
Ka 0 0 0
Kd 0 1 0
Ks 0 0 0

newmtl blue
Ka 0 0 0
Kd 0 0 1
Ks 0 0 0

newmtl light
Ka 20 20 20
Kd 1 1 1
Ks 0 0 0
Loading