Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
84addc6
fixed linker error
mchen15 Nov 12, 2013
f4bfde1
adding some comments
mchen15 Nov 13, 2013
587f53d
temp disabled post process
mchen15 Nov 13, 2013
0cc2e23
updated shader for point lights
mchen15 Nov 13, 2013
f2e5361
ambient and pointlight toon shading
mchen15 Nov 14, 2013
a680f73
toon shader with outline
mchen15 Nov 15, 2013
1b8ac4d
better silhouette for toon shading
mchen15 Nov 15, 2013
52dd580
light will still be effect even if the camera rotates away
mchen15 Nov 15, 2013
7f26f59
prelim bloom (simple blur). Need to enhance further
mchen15 Nov 15, 2013
8225718
anti-aliasing along edges
mchen15 Nov 15, 2013
86f92fc
multiple light sources
mchen15 Nov 15, 2013
506b9a2
attempting to add specular texture
mchen15 Nov 15, 2013
da254b5
commit before bloom update
mchen15 Nov 15, 2013
76b778b
bloommap texture and bug fix
mchen15 Nov 16, 2013
eb369d4
bloom
mchen15 Nov 16, 2013
02fac68
2 pass bloom almost complete
mchen15 Nov 16, 2013
a760abb
2 pass bloom complete.
mchen15 Nov 16, 2013
1d365f9
screenshots
mchen15 Nov 16, 2013
a579541
perf analysis chart
mchen15 Nov 16, 2013
23d84e8
read me update 1
mchen15 Nov 16, 2013
566c7a5
read me update 2
mchen15 Nov 16, 2013
32c7de3
read me update 3
mchen15 Nov 16, 2013
c0d9fbc
read me update 4
mchen15 Nov 16, 2013
9e1ad03
read me update 5
mchen15 Nov 16, 2013
978a75a
set up multiple lights
mchen15 Jan 17, 2014
a0403e0
adding minimal number of lights needed
mchen15 Jan 17, 2014
a8e9479
removing duplicated lights
mchen15 Jan 17, 2014
d2c961d
light animation and comments regarding bloom
mchen15 Jan 18, 2014
4f8ffa4
animated bloom
mchen15 Jan 18, 2014
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
177 changes: 34 additions & 143 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,27 @@
-------------------------------------------------------------------------------
CIS565: Project 6: Deferred Shader
-------------------------------------------------------------------------------
Fall 2013
-------------------------------------------------------------------------------
Due Friday 11/15/2013
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
NOTE:
RESULTS:
-------------------------------------------------------------------------------
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.

![result](screenshots/cornell_box_normals.png)
![result](screenshots/cornell_box_depth.png)
![result](screenshots/cornell_box_toon.png)
![result](screenshots/cornell_box_bloom.png)
![result](screenshots/cornell_box_aa_diffuse.png)
![result](screenshots/cornell_box_specular.png)
![result](screenshots/cornell_box_diffuse_specular.png)
![result](screenshots/sponza_light.png)
![result](screenshots/sponza_normal.png)
![result](screenshots/sponza_toon.png)
![result](screenshots/sponza_bloom.png)
![result](screenshots/sponza_diffuse_specular.png)
-------------------------------------------------------------------------------
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.

-------------------------------------------------------------------------------
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.

---
BASE CODE TOUR
---

Most of your edits will be confined to the various fragment shader programs and main.cpp.

Some methods worth exploring are:

[initShader](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L223):
This method initializes each shader program from specified source files. Note that the source name is declared inside a `#ifdef WIN32` guard block. This is done to reflect the relative directory structure between the linux and windows versions of the code.

[initFBO](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L360):
This method initializes the framebuffer objects used as render targets for the first and second stage of the pipeline. When you go to add another slot to the G buffer you will need to modify to first FBO accordingly. Try finding all the places where `colorTexture` is used (ctrl+F in windows will be helpful) and look at how textures are created, freed, added to the FBO, and assigned to the appropriate shader programs before adding your own. Also keep in mind that textures can be reused as inputs in other pipeline stages, for instance you might want access to the normals both in the lighting stage and in the post process stage.

[draw_mesh](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L574),
[draw_quad](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L647),
[draw_light](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L657):
These methods render the scene geometry, viewing quad, and point light quad to the screen. The draw_light method in particular is interesting because it will set up the scissor window for efficient rendering of point lights.

[display](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L742):
This is where the graphical work of your program is done. The method is separated into three stages with the majority of work being done in stage 2.
In this project, I worked on implementing the basics of deferred shading. This is implemented with GLSL and OpenGL where various tasks such as
creating and writing to the G-Buffer were performed.

Stage 1 renders the scene geometry to the G-Buffer
* pass.vert
Expand All @@ -67,124 +37,45 @@ Stage 3 renders the post processing
* post.vert
* post.frag

[keyboard](https://github.com/CIS565-Fall-2013/Project6-DeferredShader/blob/master/base/src/main.cpp#L870):
This is a good reference for the key mappings in the program.
Key binding overview:
WASDQZ - Movement
X - Toggle scissor test
R - Reload shaders
1 - View depth
2 - View eye space normals
3 - View Diffuse color
4 - View eye space positions
5 - View lighting debug mode
5 - View lighting
6 - View toon shading with silhouettes
7 - View scene with bloom effect
8 - View scene with anti-aliasing and diffuse lighting
9 - View specular map
0 - Standard view

-------------------------------------------------------------------------------
REQUIREMENTS:
FEATURES:
-------------------------------------------------------------------------------

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
In this project, I have implemented the following features:

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).
* Bloom effect with one pass and two pass convolution
* Toon shading with silhouettes
* Displaying point light sources
* Additional G buffer slot to store specular map
* Anti-aliasing via averaging on contours

-------------------------------------------------------------------------------
PERFORMANCE EVALUATION
PERFORMANCE ANALYSIS
-------------------------------------------------------------------------------
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.
I made a run time comparison between the one pass and two pass convolution techniques. Below is the chart that displays
the results.

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.
![result](screenshots/perf_analysis.png)

-------------------------------------------------------------------------------
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,
liamboone@gmail.com, 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
As seen from above, when the size of the gaussian kernel is small, simply performing a one pass convolution is sufficient. However,
once the size increases past a certain point, the advantage of the two pass convolution technique becomes apparent.

* 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
Expand Down
30 changes: 0 additions & 30 deletions base/PROJ_NIX/makefile

This file was deleted.

12 changes: 9 additions & 3 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 @@ -49,7 +51,7 @@
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(SolutionDir)$(Configuration);..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>$(SolutionDir)$(Configuration);..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;..\debug\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>SOIL.lib;freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
Expand All @@ -66,23 +68,27 @@
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>$(SolutionDir)$(Configuration);..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(SolutionDir)$(Configuration);..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;..\release\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;glew32.lib;SOIL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\src\light.cpp" />
<ClCompile Include="..\..\..\src\main.cpp" />
<ClCompile Include="..\..\..\src\tiny_obj_loader\tiny_obj_loader.cc" />
<ClCompile Include="..\..\..\src\Utility.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\light.h" />
<ClInclude Include="..\..\..\src\main.h" />
<ClInclude Include="..\..\..\src\tiny_obj_loader\tiny_obj_loader.h" />
<ClInclude Include="..\..\..\src\Utility.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\res\shaders\ambient.frag" />
<None Include="..\..\..\res\shaders\bloomPass1.frag" />
<None Include="..\..\..\res\shaders\bloomPass1.vert" />
<None Include="..\..\..\res\shaders\diagnostic.frag" />
<None Include="..\..\..\res\shaders\directional.frag" />
<None Include="..\..\..\res\shaders\pass.frag" />
Expand Down
12 changes: 12 additions & 0 deletions base/PROJ_WIN/P6/P6/P6.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<ClCompile Include="..\..\..\src\tiny_obj_loader\tiny_obj_loader.cc">
<Filter>tinyobjloader</Filter>
</ClCompile>
<ClCompile Include="..\..\..\src\light.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\src\tiny_obj_loader\tiny_obj_loader.h">
Expand All @@ -38,6 +41,9 @@
<ClInclude Include="..\..\..\src\Utility.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\src\light.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\res\shaders\ambient.frag">
Expand Down Expand Up @@ -67,5 +73,11 @@
<None Include="..\..\..\res\shaders\shade.vert">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\bloomPass1.vert">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\..\res\shaders\bloomPass1.frag">
<Filter>Resource Files</Filter>
</None>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions base/PROJ_WIN/P6/SOIL/SOIL.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
Expand Down
Loading