forked from ingowald/optix7course
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
1,837 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# ====================================================================================== | ||
# Copyright (c) 2019 NVIDIA Corporation. All rights reserved. | ||
# | ||
# NVIDIA Corporation and its licensors retain all intellectual property and proprietary | ||
# rights in and to this software, related documentation and any modifications thereto. | ||
# Any use, reproduction, disclosure or distribution of this software and related | ||
# documentation without an express license agreement from NVIDIA Corporation is strictly | ||
# prohibited. | ||
# | ||
# TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* | ||
# AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, | ||
# INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
# PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY | ||
# SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT | ||
# LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF | ||
# BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR | ||
# INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
# SUCH DAMAGES | ||
# ====================================================================================== | ||
|
||
find_package(OpenGL REQUIRED) | ||
|
||
include_directories(${OptiX_INCLUDE}) | ||
|
||
cuda_compile_and_embed(embedded_ptx_code devicePrograms.cu) | ||
|
||
add_executable(ex10_softShadows | ||
${embedded_ptx_code} | ||
optix7.h | ||
CUDABuffer.h | ||
SampleRenderer.h | ||
SampleRenderer.cpp | ||
Model.cpp | ||
main.cpp | ||
) | ||
|
||
target_link_libraries(ex10_softShadows | ||
gdt | ||
# optix dependencies, for rendering | ||
${optix_LIBRARY} | ||
${CUDA_LIBRARIES} | ||
${CUDA_CUDA_LIBRARY} | ||
# glfw and opengl, for display | ||
glfWindow | ||
glfw | ||
${OPENGL_gl_LIBRARY} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// ====================================================================================== | ||
// Copyright (c) 2019 NVIDIA Corporation. All rights reserved. | ||
// | ||
// NVIDIA Corporation and its licensors retain all intellectual property and proprietary | ||
// rights in and to this software, related documentation and any modifications thereto. | ||
// Any use, reproduction, disclosure or distribution of this software and related | ||
// documentation without an express license agreement from NVIDIA Corporation is strictly | ||
// prohibited. | ||
// | ||
// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* | ||
// AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, | ||
// INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
// PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY | ||
// SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT | ||
// LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF | ||
// BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR | ||
// INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
// SUCH DAMAGES | ||
// ====================================================================================== | ||
|
||
#pragma once | ||
|
||
#include "optix7.h" | ||
// common std stuff | ||
#include <vector> | ||
#include <assert.h> | ||
|
||
/*! \namespace osc - Optix Siggraph Course */ | ||
namespace osc { | ||
|
||
/*! simple wrapper for creating, and managing a device-side CUDA | ||
buffer */ | ||
struct CUDABuffer { | ||
inline CUdeviceptr d_pointer() const | ||
{ return (CUdeviceptr)d_ptr; } | ||
|
||
//! re-size buffer to given number of bytes | ||
void resize(size_t size) | ||
{ | ||
if (d_ptr) free(); | ||
alloc(size); | ||
} | ||
|
||
//! allocate to given number of bytes | ||
void alloc(size_t size) | ||
{ | ||
assert(d_ptr == nullptr); | ||
this->sizeInBytes = size; | ||
CUDA_CHECK(Malloc( (void**)&d_ptr, sizeInBytes)); | ||
} | ||
|
||
//! free allocated memory | ||
void free() | ||
{ | ||
CUDA_CHECK(Free(d_ptr)); | ||
d_ptr = nullptr; | ||
sizeInBytes = 0; | ||
} | ||
|
||
template<typename T> | ||
void alloc_and_upload(const std::vector<T> &vt) | ||
{ | ||
alloc(vt.size()*sizeof(T)); | ||
upload((const T*)vt.data(),vt.size()); | ||
} | ||
|
||
template<typename T> | ||
void upload(const T *t, size_t count) | ||
{ | ||
assert(d_ptr != nullptr); | ||
assert(sizeInBytes == count*sizeof(T)); | ||
CUDA_CHECK(Memcpy(d_ptr, (void *)t, | ||
count*sizeof(T), cudaMemcpyHostToDevice)); | ||
} | ||
|
||
template<typename T> | ||
void download(T *t, size_t count) | ||
{ | ||
assert(d_ptr != nullptr); | ||
assert(sizeInBytes == count*sizeof(T)); | ||
CUDA_CHECK(Memcpy((void *)t, d_ptr, | ||
count*sizeof(T), cudaMemcpyDeviceToHost)); | ||
} | ||
|
||
size_t sizeInBytes { 0 }; | ||
void *d_ptr { nullptr }; | ||
}; | ||
|
||
} // ::osc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// ====================================================================================== | ||
// Copyright (c) 2019 NVIDIA Corporation. All rights reserved. | ||
// | ||
// NVIDIA Corporation and its licensors retain all intellectual property and proprietary | ||
// rights in and to this software, related documentation and any modifications thereto. | ||
// Any use, reproduction, disclosure or distribution of this software and related | ||
// documentation without an express license agreement from NVIDIA Corporation is strictly | ||
// prohibited. | ||
// | ||
// TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED *AS IS* | ||
// AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, | ||
// INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
// PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS BE LIABLE FOR ANY | ||
// SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT | ||
// LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF | ||
// BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR | ||
// INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF | ||
// SUCH DAMAGES | ||
// ====================================================================================== | ||
|
||
#pragma once | ||
|
||
#include "gdt/math/vec.h" | ||
#include "optix7.h" | ||
|
||
namespace osc { | ||
using namespace gdt; | ||
|
||
// for this simple example, we have a single ray type | ||
enum { RADIANCE_RAY_TYPE=0, SHADOW_RAY_TYPE, RAY_TYPE_COUNT }; | ||
|
||
struct TriangleMeshSBTData { | ||
vec3f color; | ||
vec3f *vertex; | ||
vec3f *normal; | ||
vec2f *texcoord; | ||
vec3i *index; | ||
bool hasTexture; | ||
cudaTextureObject_t texture; | ||
}; | ||
|
||
struct LaunchParams | ||
{ | ||
struct { | ||
uint32_t *colorBuffer; | ||
vec2i size; | ||
int accumID { 0 }; | ||
} frame; | ||
|
||
struct { | ||
vec3f position; | ||
vec3f direction; | ||
vec3f horizontal; | ||
vec3f vertical; | ||
} camera; | ||
|
||
struct { | ||
vec3f origin, du, dv, power; | ||
} light; | ||
|
||
OptixTraversableHandle traversable; | ||
}; | ||
|
||
} // ::osc |
Oops, something went wrong.