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

Project 6 submission #18

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
4950125
Updated project to run on my laptop with cornel box.
cboots Nov 13, 2013
e3774eb
Added some debug text to command line modes.
cboots Nov 13, 2013
d775847
Added nvidia settings.
cboots Nov 13, 2013
5139a93
Minor changes.
cboots Nov 14, 2013
88ead1f
Added simple point lights.
cboots Nov 14, 2013
864fdb1
Added point light grid.
cboots Nov 14, 2013
d9f7506
Added lights for sponza scene.
cboots Nov 14, 2013
67858ff
Moved points around
cboots Nov 14, 2013
9ca052d
Added buggy textures.
cboots Nov 14, 2013
ba0b53b
Fixed diffuse textures.
cboots Nov 14, 2013
8ccdd9a
Fixed sponza file. tinyobj loader can't handle multiple materials per…
cboots Nov 14, 2013
cc8b235
Added filtered textures.
cboots Nov 14, 2013
0d6dc23
Added passthrough for bump, mask, and specular textures.
cboots Nov 15, 2013
b305d9b
Added some more debug modes.
cboots Nov 15, 2013
70f2e3c
Added more debug modes, allow disabling of different textures.
cboots Nov 15, 2013
f50bfb0
Renamed color output of passthrough shader.
cboots Nov 15, 2013
74c7c12
Added specular texture to each stage 2 shader.
cboots Nov 15, 2013
6de24a7
Added specular debug mode and sampling stubs
cboots Nov 15, 2013
c5682e9
Moved around debug shader options.
cboots Nov 16, 2013
73cf348
Added specular highlights
cboots Nov 16, 2013
ab6ce59
Added more scene lighting
cboots Nov 16, 2013
4961d2a
Added Ks to point shader
cboots Nov 16, 2013
04b0c3e
Added Tangent to pass shader.
cboots Nov 16, 2013
e4ab4b7
Added bump mapping.
cboots Nov 16, 2013
98ba267
Disabled depth test for point lights
cboots Nov 16, 2013
7746735
Attempted to implement alpha channel passthrough.
cboots Nov 16, 2013
5fe4497
Added in bloom texture to pass through separately.
cboots Nov 16, 2013
cfa3d44
Changed bloom code a bit. Still not fixed.
cboots Nov 16, 2013
e641936
Added bloom. Scaling was wrong on filter.
cboots Nov 17, 2013
108bbcf
Added ability to disable bloom at runtime.
cboots Nov 17, 2013
0acb1b7
Added toon shader.
cboots Nov 17, 2013
f7487b2
Added performance metric recording code.
cboots Nov 18, 2013
4d7b9ff
Added charts
cboots Nov 18, 2013
1ecb2c0
Update README.md
cboots Nov 18, 2013
671310b
Lion Closeup
cboots Nov 18, 2013
8adb10a
Merge branch 'master' of https://github.com/cboots/Deferred-Shading
cboots Nov 18, 2013
c821d26
Update README.md
cboots Nov 18, 2013
5bd574d
Update README.md
cboots Nov 18, 2013
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
211 changes: 95 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
-------------------------------------------------------------------------------
CIS565: Project 6: Deferred Shader
Deferred Shader
-------------------------------------------------------------------------------
Fall 2013
-------------------------------------------------------------------------------
Due Friday 11/15/2013
-------------------------------------------------------------------------------
![fullscene](/renders/FullHallAllTextures.PNG "Finished Rendering")

Youtube Video of Rendering:
<dl>
<a href="http://www.youtube.com/watch?feature=player_embedded&v=kvQ3dNG4Mdg
" target="_blank"><img src="http://img.youtube.com/vi/kvQ3dNG4Mdg/0.jpg"
alt="Youtube Video of Rendering Process" width="480" height="360" border="10" /></a>
</dl>

-------------------------------------------------------------------------------
NOTE:
-------------------------------------------------------------------------------
This project requires any graphics card with support for a modern OpenGL
Expand All @@ -17,7 +22,10 @@ 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.
This project implements a three stage deffered shader pipeline.
Stage 1 renders geometry and samples model textures.
Stage 2 performs point and ambient lighting calculations
Stage 3 does any post processing effects

-------------------------------------------------------------------------------
CONTENTS:
Expand All @@ -31,29 +39,11 @@ The Project6 root directory contains the following subdirectories:
* 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.
-------------------------------------------------------------------------------
CODE TOUR/CONTROLS
-------------------------------------------------------------------------------

Stage 1 renders the scene geometry to the G-Buffer
Stage 1 samples model textures renders the scene geometry to the G-Buffer
* pass.vert
* pass.frag

Expand All @@ -67,7 +57,8 @@ 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):
Keyboard controls
[keyboard](https://github.com/cboots/Deferred-Shading/blob/master/base/src/main.cpp#L1178):
This is a good reference for the key mappings in the program.
WASDQZ - Movement
X - Toggle scissor test
Expand All @@ -77,114 +68,102 @@ R - Reload shaders
3 - View Diffuse color
4 - View eye space positions
5 - View lighting debug mode
6 - View Specular Mapping
7 - View Only Bloomed Geometry
0 - Standard view

x - Toggle Scissor Test
r - Reload Shaders
p - Print camera position to console
j - Toggle timing measurements to console (averaged since last reset)
SPACE - Reset timing averages

Shift-L - Toggle Bloom
Shift-T - Toggle Toon Shading
Shift-D - Toggle Diffuse Mapping
Shift-S - Toggle Specular Mapping
Shift-B - Toggle Bump Mapping
Shift-M - Toggle Transparency Masking

c - Reset diffuse color to default
t - Change diffuse color to texture coordinate visualization
h - Overlay diffuse color with visualization of available textures
b - Change diffuse color to bump map visualization if available
m - Change diffuse color to white if mask texture is available

-------------------------------------------------------------------------------
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
* Renders .obj files with support for .mtl files with
* Diffuse Textures
* Specular Textures
* Height Maps (Bump Mapping)
* Texture Masking

* Bloom (Not seperable, very inefficient)
![NoBloom](/renders/LampNoBloom.PNG "Without Bloom")
![Bloom](/renders/LampWithBloom.PNG "With Bloom")

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
* "Toon" Shading (with basic silhouetting and color quantization)
![Toon](/renders/ToonShadingNoColor.PNG "Toon Shading B/W")
![Toon](/renders/FullHallToon.PNG "Toon Shading")

**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).
* Point light sources with specular

![Point Specular](/renders/PointLightSpeculars.PNG "Point Light Speculars")
-------------------------------------------------------------------------------
README
SCREENSHOTS
-------------------------------------------------------------------------------
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).
No special features enabled. Just Point lighting:
![Baseline](/renders/FullHallBaseline.PNG "Baseline")

-------------------------------------------------------------------------------
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.
Diffuse Texture:
![Diffuse Map](/renders/FullHallDiffuseOnly.PNG "Diffuse Texture")

We encourage you to get creative with your tweaks. Consider places in your code
that could be considered bottlenecks and try to improve them.
Specular Texture:
![Specular Map](/renders/FullHallSpecularOnly.PNG "Specular Texture")

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.
Bump Mapping:
![Bump Map](/renders/FullHallBumpOnly.PNG "Bump Texture")
![Bump Map](/renders/LionCloseNoBump.PNG "Without Bump")
![Bump Map](/renders/LionClose.PNG "With Bump")

-------------------------------------------------------------------------------
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.
Masking:
![Mask](/renders/FullHallMaskOnly.PNG "Mask Texture")
![No Mask](/renders/PlantsNoMask.PNG "No Mask")
![With Mask](/renders/PlantsWithMask.PNG "With Mask")


All Textures:
![All Textures Map](/renders/FullHallAllTextures.PNG "Specular Texture")

Scissor Test Specular Bug:
![ScissorNo](/renders/SpecularNoScissorTest.PNG "No Scissor Test")
![Scissor](/renders/SpecularWithScissorTest.PNG "With Scissor Test")

-------------------------------------------------------------------------------
SELF-GRADING
PERFORMANCE EVALUATION
-------------------------------------------------------------------------------
* 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.
I measured the synchronized time to complete each stage of the pipeline with various features enabled.
Two test scenes were used, a wide shot of the entire hall and a closeup of the lion sculpture (see above).
Bloom was so inefficient that I removed it from some charts for scale

Full Hall Metrics:

---
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.
![TimingFH](/renders/FullHallTiming.PNG "Full Hall")
![TimingFHB](/renders/FullHallTimingBloom.PNG "Full Hall Including Bloom")

Lion Closeup Metrics:

![TimingLC](/renders/LionCloseupTiming.PNG "Lion Closeup")
![TimingLCB](/renders/LionCloseupTimingBloom.PNG "Lion Closeup Including Bloom")

Clearly the non-seperated convolution involved in the bloom effect has a huge impact on performance.
Most of the other effects had only minimal impact on performance.
The scissor test gave a huge boost to stage 2 performance but as shown above it results in visual artifacts.
Another takeaway of this data is the second stage (lighting calculation) is the most intensive part of the process.

---
ACKNOWLEDGEMENTS
Expand Down
6 changes: 4 additions & 2 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 Down Expand Up @@ -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>..\SOIL;..\..\..\src\tiny_obj_loader;..\..\..\..\shared32\freeglut\include;..\..\..\..\shared32\glew\include;..\..\..\..\shared32\glm;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<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>
<AdditionalDependencies>SOIL.lib;freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
Expand Down
6 changes: 6 additions & 0 deletions base/PROJ_WIN/P6/P6/P6.vcxproj.collin boots.nvuser
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ProjectSettingsModel DefinitionId="a218e900-1199-4ab1-a767-7976786f04d4" DisplayName="Nexus Project User Settings" xmlns="clr-namespace:Ark.PropertyModel;assembly=Ark">
<SettingsPointModel DefinitionId="3eb7ba04-016d-475e-b0ff-daa5f0e59a08" DisplayName="Launch">
<Property Name="Arguments" Value="mesh=&quot;..\..\..\res\crytek-sponza\sponza.obj&quot;" />
<Property Name="WorkingDirectory" Value="C:\Users\Collin Boots\Documents\GIT\GitHub\Deferred-Shading\base\PROJ_WIN\P6\P6" />
</SettingsPointModel>
</ProjectSettingsModel>
6 changes: 6 additions & 0 deletions base/PROJ_WIN/P6/P6/P6.vcxproj.collin.nvuser
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<ProjectSettingsModel DefinitionId="a218e900-1199-4ab1-a767-7976786f04d4" DisplayName="Nexus Project User Settings" xmlns="clr-namespace:Ark.PropertyModel;assembly=Ark">
<SettingsPointModel DefinitionId="3eb7ba04-016d-475e-b0ff-daa5f0e59a08" DisplayName="Launch">
<Property Name="Arguments" Value="mesh=&quot;..\..\..\res\cornell\cornell_box.obj&quot;" />
<Property Name="WorkingDirectory" Value="C:\Users\Collin\Documents\GitHub\Classes\Project6-Deferred-Shading\base\PROJ_WIN\P6\P6" />
</SettingsPointModel>
</ProjectSettingsModel>
Binary file added base/PROJ_WIN/P6/P6/freeglut.dll
Binary file not shown.
Binary file added base/PROJ_WIN/P6/P6/glew32.dll
Binary file not shown.
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