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

Project2 Submission!!!! #6

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
dea199a
debugged first steps of path tracer and got the most naive implementa…
uriahjb Sep 26, 2013
b0aae64
Update README.md
uriahjb Sep 26, 2013
244d85a
fixed imported images
uriahjb Sep 26, 2013
7ba772e
Merge branch 'master' of https://github.com/uriahjb/Project2-Pathtracer
uriahjb Sep 26, 2013
ff9cd9d
Update README.md
uriahjb Sep 26, 2013
59477c6
working towards error-free stream compaction, aww yeah! d(-_-)b
uriahjb Sep 27, 2013
8a69c79
debuging thrust::exclusive_scan integration, started on gpu compactio…
uriahjb Oct 1, 2013
50b2182
fixed stream compaction using thrust
uriahjb Oct 1, 2013
bd1b017
stream compaction fixed. thanks Liam
uriahjb Oct 1, 2013
5a391b1
added proper lighting accumulation to allow for multiple emissive obj…
uriahjb Oct 2, 2013
9d6b2bb
added anti-aliasing, added beginnings of depth of field
uriahjb Oct 2, 2013
5103dbc
Added refraction
uriahjb Oct 3, 2013
ba5a8a8
added some more renders
uriahjb Oct 3, 2013
c97be78
added final set of features, updated README
uriahjb Oct 3, 2013
a335a24
added renders, etc ...
uriahjb Oct 3, 2013
8c38049
Update README.md
uriahjb Oct 3, 2013
c9f4950
Update README.md
uriahjb Oct 3, 2013
c4492b5
Update README.md
uriahjb Oct 3, 2013
fc50a28
Update README.md
uriahjb Oct 3, 2013
5e83ac8
Update README.md
uriahjb Oct 3, 2013
cc40e1f
added even better image of all features :)
uriahjb Oct 3, 2013
948de96
Merge branch 'master' of https://github.com/uriahjb/Project2-Pathtracer
uriahjb Oct 3, 2013
3c9aa7d
Update README.md
uriahjb Oct 3, 2013
9ecf834
Update README.md
uriahjb Oct 3, 2013
646f977
Update README.md
uriahjb Oct 3, 2013
673bcdc
Update README.md
uriahjb Oct 3, 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
139 changes: 139 additions & 0 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# This file is NOT licensed under the GPLv3, which is the license for the rest
# of YouCompleteMe.
#
# Here's the license text for this file:
#
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
# software to the public domain. We make this dedication for the benefit
# of the public at large and to the detriment of our heirs and
# successors. We intend this dedication to be an overt act of
# relinquishment in perpetuity of all present and future rights to this
# software under copyright law.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
#
# For more information, please refer to <http://unlicense.org/>

import os
import ycm_core

# These are the compilation flags that will be used in case there's no
# compilation database set (by default, one is not set).
# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
flags = [
'-lglut',
'-lGL',
'-lGLEW',
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-DUSE_CLANG_COMPLETER',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c++',
'-I/usr/local/cuda/samples/common/inc',
'-I/usr/local/cuda/include'
]

# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
compilation_database_folder = ''

if compilation_database_folder:
database = ycm_core.CompilationDatabase( compilation_database_folder )
else:
database = None


def DirectoryOfThisScript():
return os.path.dirname( os.path.abspath( __file__ ) )


def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
if not working_directory:
return list( flags )
new_flags = []
make_next_absolute = False
path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
for flag in flags:
new_flag = flag

if make_next_absolute:
make_next_absolute = False
if not flag.startswith( '/' ):
new_flag = os.path.join( working_directory, flag )

for path_flag in path_flags:
if flag == path_flag:
make_next_absolute = True
break

if flag.startswith( path_flag ):
path = flag[ len( path_flag ): ]
new_flag = path_flag + os.path.join( working_directory, path )
break

if new_flag:
new_flags.append( new_flag )
return new_flags


def FlagsForFile( filename ):
if database:
# Bear in mind that compilation_info.compiler_flags_ does NOT return a
# python list, but a "list-like" StringVec object
compilation_info = database.GetCompilationInfoForFile( filename )
final_flags = MakeRelativePathsInFlagsAbsolute(
compilation_info.compiler_flags_,
compilation_info.compiler_working_dir_ )

# NOTE: This is just for YouCompleteMe; it's highly likely that your project
# does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
# ycm_extra_conf IF YOU'RE NOT 100% YOU NEED IT.
'''
try:
final_flags.remove( '-stdlib=libc++' )
except ValueError:
pass
'''
else:
relative_to = DirectoryOfThisScript()
final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )

return {
'flags': final_flags,
'do_cache': True
}
Binary file added PROJ2_NIX/565Pathtracer
Binary file not shown.
Binary file added PROJ2_NIX/glslUtility.o
Binary file not shown.
Binary file added PROJ2_NIX/image.o
Binary file not shown.
Binary file added PROJ2_NIX/main.o
Binary file not shown.
File renamed without changes.
Binary file added PROJ2_NIX/raytraceKernel.o
Binary file not shown.
Binary file added PROJ2_NIX/scene.o
Binary file not shown.
Binary file added PROJ2_NIX/stb_image.o
Binary file not shown.
Binary file added PROJ2_NIX/stb_image_write.o
Binary file not shown.
Binary file added PROJ2_NIX/utilities.o
Binary file not shown.
105 changes: 105 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,108 @@
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/all_features_awesome.bmp)

-------------------------------------------------------------------------------
Pathtracer:
-------------------------------------------------------------------------------
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/dof_nice.bmp)


![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/all_features.bmp)

![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/dof_refl_refr.bmp)


-------------------------------------------------------------------------------
Video:
-------------------------------------------------------------------------------
This is pretty low-res. High-res to come soon!!!
http://youtu.be/hzeRzmRnIo0

-------------------------------------------------------------------------------
Features:
-------------------------------------------------------------------------------
I implementing the requred features:

* Properly accumulating emittance and colors to generate a final image
* Supersampled antialiasing
* Parallelization by ray instead of by pixel via stream compaction
* I used thrust for the scan step and implented my own parallel scatter
* Perfect specular reflection

And:
* Fresnel-based Refraction, i.e. glass
* Depth of field

The following screenshot shows a comparison between anti-aliased and non-anti-aliased edges, its a bit hard to see because the render isn't fully converged.
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/anti_aliasing.png)

-------------------------------------------------------------------------------
Cool Bugs:
-------------------------------------------------------------------------------
In the process of implementing various features in my path tracer I ran into
a number of awesome bugs.

This one is the result of poorly seeded random number, I'm still not sure if
I can recreate it :).
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/artsy_bug.png)

While implementing refraction a missing sqrt and refractive index flip lead to this one.
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/refraction_bug.bmp)

For comparison here is the fixed pure-refraction
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/refraction_pure.png)

-------------------------------------------------------------------------------
Performance Evalutation:
-------------------------------------------------------------------------------
TileSize vs. Average Time-per-frame ( seconds ) for a 400 by 400 Image on a GEFORCE 610M 1GB.

With stream compaction:
* 2, 0.81
* 4, 0.33
* 8, 0.18
* 16, 0.25

Without stream compaction ( note: this code produces incorrect results but will be fixed ):
* 2, 0.43
* 4, 0.17
* 8, 0.08
* 16, 0.11

At the moment it looks like my non-stream compaction implementation is faster by about a factor of 2. Once I get NVVP up and running I'll evaluate more closely the difference between the two.


For a 600 by 600 image using a TileSize of 8 I acheive an average time-per-frame of 0.33 with a raydepth of 6.
This comes out to ~6480000 rays/sec.

Once I fix the thrust::dealloc error in my code ( a quick google search seems to hint at the problem being some sort of ECC problem ) I'm going to do some profiling useing NVidia Visual Profiler ( such a cool tool! ).








-------------------------------------------------------------------------------
First Steps:
-------------------------------------------------------------------------------
Moved some of my code from Project1 over and started getting the path tracer up and working.
Naive Implementation:
* Send out ray from camera, then calculate new ray direction by randomly sampling on a hemisphere
* Sample the brdf using the new direction

![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/path_tracer_first_steps.png)

I put together debug some simple debug modes:

New Ray direction ( converges to the point normal ):
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/sampled_directions.png)


BRDF ( first object intersected color ):
![screenshot](https://raw.github.com/uriahjb/Project2-PathTracer/master/renders/brdf_sampling.png)


-------------------------------------------------------------------------------
CIS565: Project 2: CUDA Pathtracer
-------------------------------------------------------------------------------
Expand Down
Binary file added renders/all_features.bmp
Binary file not shown.
Binary file added renders/all_features_awesome.bmp
Binary file not shown.
Binary file added renders/anti_aliasing.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/antialiased.bmp
Binary file not shown.
Binary file added renders/artsy_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 added renders/brdf_sampling.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/dof.bmp
Binary file not shown.
Binary file added renders/dof_highres.bmp
Binary file not shown.
Binary file added renders/dof_nice.bmp
Binary file not shown.
Binary file added renders/dof_refl_refr.bmp
Binary file not shown.
Binary file added renders/no_antialiasing.bmp
Binary file not shown.
Binary file added renders/ok_render.bmp
Binary file not shown.
Binary file added renders/path_tracer_first_steps.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/reflections.bmp
Binary file not shown.
Binary file added renders/refraction_bug.bmp
Binary file not shown.
Binary file added renders/refraction_pure.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/sampled_directions.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/second_bounce_direction.bmp
Binary file not shown.
Binary file added renders/stream_compaction.bmp
Binary file not shown.
Binary file removed renders/test.0.bmp
Binary file not shown.
Loading