Skip to content

hw6 submission #8

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

Open
wants to merge 13 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
167 changes: 50 additions & 117 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,142 +1,75 @@
-------------------------------------------------------------------------------
CIS565: Project 6: Deferred Shader
-------------------------------------------------------------------------------
Fall 2013
-------------------------------------------------------------------------------
Due Friday 11/15/2013
-------------------------------------------------------------------------------

-------------------------------------------------------------------------------
NOTE:
Features:
-------------------------------------------------------------------------------
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.
* Point Lights

-------------------------------------------------------------------------------
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.
![alt text](./renders/point_lights.jpg "point lights")

-------------------------------------------------------------------------------
REQUIREMENTS:
-------------------------------------------------------------------------------
* Bloom

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).
![alt text](./renders/bloom_shader.jpg "bloom")

-------------------------------------------------------------------------------
README
-------------------------------------------------------------------------------
All students must replace or augment the contents of this Readme.md in a clear
manner with the following:
For the bloom effect, I created an additional G buffer to store the materials with
bloom. Materials with Ka greater than 0 are assigned a value of 1, while materials with
a Ka of 0 and therefore doesn't glow are assigned a value of 0. I then apply a simple
Gaussian blur to the map and do an additive blend between the base color of the material
and the glow.

* Toon shading

For toon shading, I used a Sobel filter for basic edge detection. To
create cel shading effect, I simply find the dot product between the normal and the
vector from the position to the light, and shade it based on the angle between these
2 vectors.

![alt text](./renders/toon_shader.jpg "toon")

![alt text](./renders/toon_shader_2.jpg "toon")

* Screen Space Ambient Occlusion

* 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).
I based my implementation off of last year's GLSL project.

![alt text](./renders/regular_grid.jpg "grid")

![alt text](./renders/poisson_disk.jpg "poisson")

![alt text](./renders/diffuse_occlusion.jpg "diffuse with occlusion")

[Here](https://vimeo.com/79531738) is a video of my deferred shader
running.

-------------------------------------------------------------------------------
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.
Number of Lights

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.
With scissor test, nearly 3000 lights can be rendered without a major performance
hit. After 3000 lights, however, the number of texture reads becomes very high and
there is a sharp drop in performance. Without the scissor test, the scene can barely
handle 700 lights.

-------------------------------------------------------------------------------
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.
![alt text](./renders/chart_2.png "number of lights")

-------------------------------------------------------------------------------
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.
Number of neighbors sampled for bloom effect

When blurring the glow texture, FPS stays at 60 when the number of samples taken is
under 64. When the number of samples go above 64, performance decreases to about 30
FPS since the number of texture reads become very high.

---
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.
![alt text](./renders/chart_3.png "number of lights")

-------------------------------------------------------------------------------
THIRD PARTY CODE POLICY
-------------------------------------------------------------------------------
* For screen space ambient occlusion, I used the base code from project 5 of the
CIS565 fall 2012 class.

---
ACKNOWLEDGEMENTS
Expand Down
30 changes: 30 additions & 0 deletions SSAO/PROJ_NIX/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
LFLAGS := -lglut -lGL -lGLEW
CFLAGS := -Wall
IFLAGS := -I../../shared32/glm/ -I../../shared32/freeglut -I../../shared32/glew -I../src/SOIL -I../src/tiny_obj_loader

565DefferedShader: Utility.o tiny_obj_loader.o main.o image_helper.o stb_image_aug.o image_DXT.o SOIL.o
g++ *.o -o 565DefferedShader $(LFLAGS)

tiny_obj_loader.o: ../src/tiny_obj_loader/tiny_obj_loader.cc ../src/tiny_obj_loader/tiny_obj_loader.h
g++ ../src/tiny_obj_loader/tiny_obj_loader.cc -c

SOIL.o: ../src/SOIL/SOIL.c ../src/SOIL/*.h
gcc ../src/SOIL/SOIL.c -c

image_DXT.o: ../src/SOIL/image_DXT.c ../src/SOIL/*.h
gcc ../src/SOIL/image_DXT.c -c

stb_image_aug.o: ../src/SOIL/stb_image_aug.c ../src/SOIL/*.h
gcc ../src/SOIL/stb_image_aug.c -c

image_helper.o: ../src/SOIL/image_helper.c ../src/SOIL/*.h
gcc ../src/SOIL/image_helper.c -c

main.o: ../src/main.cpp ../src/main.h ../src/Utility.h
g++ -g ../src/main.cpp $(IFLAGS) -c

Utility.o: ../src/Utility.cpp ../src/Utility.h
g++ ../src/Utility.cpp $(IFLAGS) -c

clean:
rm *.o 565DefferedShader
26 changes: 26 additions & 0 deletions SSAO/PROJ_WIN/P6/P6.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5706DFE4-FA46-448C-8A11-12E132B9BC59}.Debug|Win32.ActiveCfg = Debug|Win32
{5706DFE4-FA46-448C-8A11-12E132B9BC59}.Debug|Win32.Build.0 = Debug|Win32
{5706DFE4-FA46-448C-8A11-12E132B9BC59}.Release|Win32.ActiveCfg = Release|Win32
{5706DFE4-FA46-448C-8A11-12E132B9BC59}.Release|Win32.Build.0 = Release|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Debug|Win32.ActiveCfg = Debug|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Debug|Win32.Build.0 = Debug|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Release|Win32.ActiveCfg = Release|Win32
{25544C77-3B78-405F-A15D-1231D05969F3}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
104 changes: 104 additions & 0 deletions SSAO/PROJ_WIN/P6/P6/P6.vcxproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5706DFE4-FA46-448C-8A11-12E132B9BC59}</ProjectGuid>
<RootNamespace>P6</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<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">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\..\src\SOIL;..\..\..\src\tiny_obj_loader;..\..\..\..\shared32\freeglut\include;..\..\..\..\shared32\glew\include;..\..\..\..\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>SOIL.lib;freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<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>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>..\..\..\..\shared32\glew\lib;..\..\..\..\shared32\freeglut\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>SOIL.lib;freeglut.lib;glew32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<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\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\bloom.frag" />
<None Include="..\..\..\res\shaders\diagnostic.frag" />
<None Include="..\..\..\res\shaders\directional.frag" />
<None Include="..\..\..\res\shaders\pass.frag" />
<None Include="..\..\..\res\shaders\pass.vert" />
<None Include="..\..\..\res\shaders\point.frag" />
<None Include="..\..\..\res\shaders\post.frag" />
<None Include="..\..\..\res\shaders\post.vert" />
<None Include="..\..\..\res\shaders\shade.vert" />
<None Include="..\..\..\res\shaders\ssao.frag" />
<None Include="..\..\..\res\shaders\ssao.vert" />
<None Include="..\..\..\res\shaders\toon.frag" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Loading