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 4: Daniel Krupka #18

Open
wants to merge 6 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
7 changes: 6 additions & 1 deletion .cproject
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<folderInfo id="com.nvidia.cuda.ide.toolchain.on_path.1673801701.1152097236" name="/" resourcePath="">
<toolChain id="com.nvidia.cuda.ide.toolchain.on_path.1386955599" name="CUDA Toolkit on the path" superClass="com.nvidia.cuda.ide.toolchain.on_path">
<targetPlatform archList="all" binaryParser="com.nvidia.cuda.ide.elf;com.nvidia.cuda.ide.macho;com.nvidia.cuda.ide.cubin" id="com.nvidia.cuda.ide.targetPlatform.853269530" isAbstract="false" name="Debug Platform" osList="linux,macosx" superClass="com.nvidia.cuda.ide.targetPlatform"/>
<builder id="com.nvidia.cuda.ide.builder.1635905474" incrementalBuildTarget="${ConfigName}" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="CUDA Toolkit 7.5 Builder" superClass="com.nvidia.cuda.ide.builder"/>
<builder buildPath="${workspace_loc:/Project4-CUDA-Rasterizer}/build/" id="com.nvidia.cuda.ide.builder.1635905474" incrementalBuildTarget="${ConfigName}" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="CUDA Toolkit 7.5 Builder" superClass="com.nvidia.cuda.ide.builder"/>
<tool id="nvcc.compiler.base.854769442" name="NVCC Compiler" superClass="nvcc.compiler.base">
<option id="nvcc.compiler.pic.1870261830" name="Position Independent Code (-fPIC)" superClass="nvcc.compiler.pic"/>
<inputType id="nvcc.compiler.input.cu.943232565" superClass="nvcc.compiler.input.cu"/>
Expand Down Expand Up @@ -186,9 +186,14 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="DebugFast"/>
<configuration configurationName="DebugNDEBUG"/>
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/Project4-CUDA-Rasterizer"/>
</configuration>
<configuration configurationName="Debug"/>
<configuration configurationName="Release"/>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
</cproject>
50 changes: 38 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,46 @@
CUDA Rasterizer
===============

[CLICK ME FOR INSTRUCTION OF THIS PROJECT](./INSTRUCTION.md)
CUDA Rasterization Pipeline
======================

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

* (TODO) YOUR NAME HERE
* Tested on: (TODO) Windows 22, i7-2222 @ 2.22GHz 22GB, GTX 222 222MB (Moore 2222 Lab)
* Daniel Krupka
* Tested on: Debian testing (stretch), Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz 8GB, GTX 850M


# About
This is a CUDA rasterization pipeline made for UPenn's CIS565. It features
* GLTF model loading
* Perspective correct diffuse PNG textures
* Screen space ambient occlusion (SSAO)
The pipeline utilizes deferred shading - the `depthPass` kernel performs depth testing and
assembles the G-buffer prior to shading and SSAO.

# Screenshots
Video of the rasterizer in action can be found [here](https://youtu.be/_Y-9eAgICrI).
![Normals](renders/duck-normals.png "Duck Normals")
![Lambert](renders/duck-lambert.png "Duck Lambert")


### (TODO: Your README)
# Textures
I implemented perspective-correct UV texturing for diffuse coloring, using CUDA's texture memory functionality.
![DuckTex](renders/duck-texture.png "Duck Texture")
![Truck](renders/truck-nossao.png "truck texture")

*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.
# SSAO
I also implemented SSAO, both using shared memory and without.
![Truck SSAO only](renders/truck-ssao-only.png "Truck SSAO only")
![Truck SSAO](renders/truck-ssao.png "Truck with ssao")

# Performance
![notex nosm](renders/plt_loc_notex.png "Duck Texture")
![tex nosm](renders/plt_loc_tex.png "Duck Texture")
![tex sm](renders/plt_sm_tex.png "Duck Texture")
The textureless pipeline was substantially faster for the models with textures (duck, milk truck), particulary when omitting the truck's
fairly large texture, due to having far fewer memory accesses. However, the small textureless models did experience a small slowdown, possibly due to having
fewer calculations to mask latency, as barycentric texture coordinate interpolation was skipped. This could be fairly easily extended to include textures for
bump mapping, specular shading, etc.

### Credits
For SSAO, shared memory did make a small improvement in all cases, but particularly the cow and duck, which both possessed large overhangs. The `ssaoBlur` kernel
could have used shared memory as well, but the handling for cross-block contributions was necessary somewhat complicated. Depth testing could also benefit, but
would require a tiling scheme, also introducing more complication.

* [tinygltfloader](https://github.com/syoyo/tinygltfloader) by [@soyoyo](https://github.com/syoyo)
* [glTF Sample Models](https://github.com/KhronosGroup/glTF/blob/master/sampleModels/README.md)
12 changes: 10 additions & 2 deletions cis565_rasterizer.launch
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.cdt.launch.applicationLaunchType">
<stringAttribute key="bad_container_name" value="/Project4-CUDA-Rasterize"/>
<booleanAttribute key="nvvp.apiTraceProfiling" value="true"/>
<booleanAttribute key="nvvp.appReplay" value="false"/>
<booleanAttribute key="nvvp.concurrentProfiling" value="true"/>
<booleanAttribute key="nvvp.environmentProfiling" value="false"/>
<intAttribute key="nvvp.multiProcess" value="0"/>
<booleanAttribute key="nvvp.startProfiling" value="true"/>
<intAttribute key="nvvp.timeout" value="0"/>
<booleanAttribute key="nvvp.uvmProfiling" value="true"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.DEBUG_NAME" value="${cuda_tk_bin:/Project4-CUDA-Rasterizer}/cuda-gdb"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.GDB_INIT" value=".cuda-gdbinit"/>
<stringAttribute key="org.eclipse.cdt.debug.mi.core.protocol" value="mi"/>
<intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_ID" value="com.nvidia.cuda.ide.debug.cudagdb"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="objs/tri.obj"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_ARGUMENTS" value="gltfs/box/box.gltf"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/cis565_rasterizer"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="Project4-CUDA-Rasterizer"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="com.nvidia.cuda.ide.toolchain.on_path.1673801701.1348522543"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/Project4-CUDA-Rasterizer"/>
</listAttribute>
Expand Down
Binary file modified gltfs/flower/flower.gltf
Binary file not shown.
Binary file removed renders/2-cylinder-engine-load-correct.png
Binary file not shown.
Binary file added renders/box-shared-bug.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 removed renders/duck-diffuse-texture.png
Binary file not shown.
Binary file added renders/duck-lambert.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 renders/duck-normals.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 renders/duck-texture.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 renders/plt_loc_notex.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 renders/plt_loc_tex.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 renders/plt_sm_tex.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 removed renders/triangle.png
Binary file not shown.
Binary file added renders/truck-no-ssao.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 renders/truck-ssao-only.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 renders/truck-ssao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ set(SOURCE_FILES

cuda_add_library(src
${SOURCE_FILES}
OPTIONS -arch=sm_20
OPTIONS -arch=sm_50 -std=c++11 -lineinfo
)
4 changes: 2 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void runCuda() {
glm::mat4 MVP = P * MV;

cudaGLMapBufferObject((void **)&dptr, pbo);
rasterize(dptr, MVP, MV, MV_normal);
rasterize(dptr, MVP, MV, MV_normal, P);
cudaGLUnmapBufferObject(pbo);

frame++;
Expand Down Expand Up @@ -332,7 +332,7 @@ void keyCallback(GLFWwindow *window, int key, int scancode, int action, int mods
//----------------------------
//----- util -----------------
//----------------------------
static std::string getFilePathExtension(const std::string &FileName) {
std::string getFilePathExtension(const std::string &FileName) {
if (FileName.find_last_of(".") != std::string::npos)
return FileName.substr(FileName.find_last_of(".") + 1);
return "";
Expand Down
2 changes: 1 addition & 1 deletion src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ std::string getFilePathExtension(const std::string &FileName);

void mouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
void mouseMotionCallback(GLFWwindow* window, double xpos, double ypos);
void mouseWheelCallback(GLFWwindow* window, double xoffset, double yoffset);
void mouseWheelCallback(GLFWwindow* window, double xoffset, double yoffset);
Loading