Skip to content
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
17,326 changes: 2 additions & 17,324 deletions optix-sys/cuda_wrapper.rs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions optix-sys/optix_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRACE_DEPTH_EXCEEDED:
OptixExceptionCodes = -2;
pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRAVERSAL_DEPTH_EXCEEDED:
OptixExceptionCodes = -3;
pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRAVERSAL_INVALID_TRAVERSABLE : OptixExceptionCodes = -5 ;
pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRAVERSAL_INVALID_MISS_SBT : OptixExceptionCodes = -6 ;
pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRAVERSAL_INVALID_TRAVERSABLE : OptixExceptionCodes = - 5 ;
pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRAVERSAL_INVALID_MISS_SBT : OptixExceptionCodes = - 6 ;
pub const OptixExceptionCodes_OPTIX_EXCEPTION_CODE_TRAVERSAL_INVALID_HIT_SBT:
OptixExceptionCodes = -7;
pub type OptixExceptionCodes = i32;
Expand Down
25 changes: 13 additions & 12 deletions optix/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,25 @@ edition = "2018"

[dependencies]
optix-sys = {path="../optix-sys"}
bitflags = "1.1.0"
gl = "0.13.0"
imath = {path="../../imath-rs", optional=true}
cfg-if = "0.1.10"
nalgebra-glm = {version = "0.5.0", optional=true}
nalgebra = {version = "0.19.0", optional=true}
log = "0.4.8"
bitflags = "1.3.2"
gl = "0.14.0"
imath = {version = "0.1.0", optional=true}
cfg-if = "1.0.0"
nalgebra-glm = {version = "0.16.0", optional=true} # features=["cuda"],
nalgebra = {version = "0.30.1", optional=true}
#ultraviolet = {version = "0.9.0", optional=true}
log = "0.4.14"
thiserror = "1.0"
bitfield = "0.13.2"
ustr = "0.2"
ustr = "0.8.1"

[dev-dependencies]
optix-derive = {path="../optix-derive"}
glfw = "0.32.0"
tobj = "0.1.10"
image = "0.22.2"
glfw = "0.44.0"
tobj = "3.2.0"
image = "0.24.1"
enum_primitive = "0.1.1"
num = "0.2.0"
num = "0.4.0"

[features]
default=["math-nalgebra"]
Expand Down
2 changes: 1 addition & 1 deletion optix/examples/02_pipeline/LaunchParams.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef unsigned int uint32_t;
struct LaunchParams {
int frameID{0};
uint32_t* colorBuffer;
V2i32 fbSize;
i32x2 fbSize;
};

} // namespace osc
4 changes: 3 additions & 1 deletion optix/examples/07_obj/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ use optix::cuda::TaggedMallocator;
use optix::math::*;

fn load_model(path: &std::path::Path) -> Model {
let (models, materials) = tobj::load_obj(path).unwrap();
let (models, materials) = tobj::load_obj(path,
&tobj::LoadOptions::default()).unwrap();

let mut bounds = Box3f32::make_empty();
let materials = materials.expect("Failed to load MTL file");
let meshes = models
.into_iter()
.map(|model| {
Expand Down
6 changes: 4 additions & 2 deletions optix/examples/08_texture/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {

fn load_texture(path: &std::path::Path) -> Option<Rc<Texture>> {
let im = match image::open(path) {
Ok(im) => im.to_rgba(),
Ok(im) => im.to_rgba8(),
Err(e) => {
println!("{}", e);
return None;
Expand All @@ -131,11 +131,13 @@ fn load_texture(path: &std::path::Path) -> Option<Rc<Texture>> {
}

fn load_model(path: &std::path::Path) -> Model {
let (models, materials) = tobj::load_obj(path).unwrap();
let (models, materials) = tobj::load_obj(path,
&tobj::LoadOptions::default()).unwrap();

let mut bounds = Box3f32::make_empty();
let mut loaded_texture_ids = std::collections::HashMap::new();
let mut textures = Vec::new();
let materials = materials.expect("Failed to load MTL file");
let meshes = models
.into_iter()
.map(|model| {
Expand Down
51 changes: 26 additions & 25 deletions optix/examples/09_shadow/devicePrograms.cu
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,27 @@ extern "C" __global__ void __closesthit__radiance() {
// gather some basic hit information
// ------------------------------------------------------------------
const int primID = optixGetPrimitiveIndex();
const V3i32 index = sbtData.index[primID];
const i32x3 index = sbtData.index[primID];
const f32 u = optixGetTriangleBarycentrics().x;
const f32 v = optixGetTriangleBarycentrics().y;

// ------------------------------------------------------------------
// compute normal, using either shading normal (if avail), or
// geometry normal (fallback)
// ------------------------------------------------------------------
const V3f32& A = sbtData.vertex[index.x];
const V3f32& B = sbtData.vertex[index.y];
const V3f32& C = sbtData.vertex[index.z];
V3f32 Ng = cross(B - A, C - A);
V3f32 Ns = (!sbtData.normal.is_null())
const f32x3& A = sbtData.vertex[index.x];
const f32x3& B = sbtData.vertex[index.y];
const f32x3& C = sbtData.vertex[index.z];
f32x3 Ng = cross(B - A, C - A);
f32x3 Ns = (!sbtData.normal.is_null())
? ((1.f - u - v) * sbtData.normal[index.x] +
u * sbtData.normal[index.y] + v * sbtData.normal[index.z])
: Ng;

// ------------------------------------------------------------------
// face-forward and normalize normals
// ------------------------------------------------------------------
const V3f32 rayDir = optixGetWorldRayDirection();
const f32x3 rayDir = optixGetWorldRayDirection();

if (dot(rayDir, Ng) > 0.f)
Ng = -Ng;
Expand All @@ -106,27 +106,28 @@ extern "C" __global__ void __closesthit__radiance() {
// compute diffuse material color, including diffuse texture, if
// available
// ------------------------------------------------------------------
V3f32 diffuseColor = sbtData.color;
f32x3 diffuseColor = sbtData.color;
if (sbtData.has_texture && !sbtData.texcoord.is_null()) {
const V2f32 tc = (1.f - u - v) * sbtData.texcoord[index.x] +
const f32x2 tc = (1.f - u - v) * sbtData.texcoord[index.x] +
u * sbtData.texcoord[index.y] +
v * sbtData.texcoord[index.z];

V4f32 fromTexture = tex2D<float4>(sbtData.texture, tc.x, tc.y);
diffuseColor = diffuseColor * fromTexture.xyz();
f32x4 fromTexture = tex2D<float4>(sbtData.texture, tc.x, tc.y);
//diffuseColor = diffuseColor * fromTexture.xyz();
diffuseColor = diffuseColor * make_f32x3(fromTexture);
}

// ------------------------------------------------------------------
// compute shadow
// ------------------------------------------------------------------
const V3f32 surfPos = (1.f - u - v) * sbtData.vertex[index.x] +
const f32x3 surfPos = (1.f - u - v) * sbtData.vertex[index.x] +
u * sbtData.vertex[index.y] +
v * sbtData.vertex[index.z];
const V3f32 lightPos(-907.108f, 2205.875f, -400.0267f);
const V3f32 lightDir = lightPos - surfPos;
const f32x3 lightPos = make_f32x3(-907.108f, 2205.875f, -400.0267f);
const f32x3 lightDir = lightPos - surfPos;

// trace shadow ray:
V3f32 lightVisibility(1.f);
f32x3 lightVisibility=make_f32x3(1.f,1.f,1.f);
// the values we store the PRD pointer in:
u32 u0, u1;
packPointer(&lightVisibility, u0, u1);
Expand All @@ -148,7 +149,7 @@ extern "C" __global__ void __closesthit__radiance() {
// ------------------------------------------------------------------
const float cosDN = 0.1f + .8f * fabsf(dot(rayDir, Ns));

V3f32& prd = *(V3f32*)getPRD<V3f32>();
f32x3& prd = *(f32x3*)getPRD<f32x3>();
prd = (.1f + (.2f + .8f * lightVisibility) * cosDN) * diffuseColor;
}

Expand All @@ -158,8 +159,8 @@ __anyhit__radiance() { /*! for this simple example, this will remain empty */

extern "C" __global__ void __anyhit__shadow() {
// in this simple example, we terminate on ANY hit
V3f32& prd = *(V3f32*)getPRD<V3f32>();
prd = V3f32(0.f);
f32x3& prd = *(f32x3*)getPRD<f32x3>();
prd = make_f32x3(0.f,0.f,0.f);
optixTerminateRay();
}

Expand All @@ -172,9 +173,9 @@ extern "C" __global__ void __anyhit__shadow() {
// ------------------------------------------------------------------------------

extern "C" __global__ void __miss__radiance() {
V3f32& prd = *(V3f32*)getPRD<V3f32>();
f32x3& prd = *(f32x3*)getPRD<f32x3>();
// set to constant white as background color
prd = V3f32(1.f);
prd = make_f32x3(1.f,1.f,1.f);
}

extern "C" __global__ void __miss__shadow() {
Expand All @@ -194,19 +195,19 @@ extern "C" __global__ void __raygen__renderFrame() {
// our per-ray data for this example. what we initialize it to
// won't matter, since this value will be overwritten by either
// the miss or hit program, anyway
V3f32 pixelColorPRD = V3f32(0.f, 0.0f, 0.0f);
f32x3 pixelColorPRD = make_f32x3(0.f, 0.0f, 0.0f);

// the values we store the PRD pointer in:
u32 u0, u1;
packPointer(&pixelColorPRD, u0, u1);

// normalized screen plane position, in [0,1]^2
const V2f32 screen =
V2f32(f32(ix) + .5f, f32(iy) + .5f) /
V2f32(optixLaunchParams.frame.size.x, optixLaunchParams.frame.size.y);
const f32x2 screen =
make_f32x2(f32(ix) + .5f, f32(iy) + .5f) /
make_f32x2(optixLaunchParams.frame.size.x, optixLaunchParams.frame.size.y);

// generate ray direction
V3f32 rayDir =
f32x3 rayDir =
normalize(camera.direction + (screen.x - 0.5f) * camera.horizontal +
(screen.y - 0.5f) * camera.vertical);

Expand Down
10 changes: 7 additions & 3 deletions optix/examples/09_shadow/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ fn main() {
up: v3f32(0.0, 1.0, 0.0),
};

let alloc = TaggedMallocator::new();
let mut sample =
SampleRenderer::new(v2i32(width as i32, height as i32), camera, model)
SampleRenderer::new(v2i32(width as i32, height as i32), camera, model,
&alloc)
.unwrap();

let (mut window, events) = glfw
Expand Down Expand Up @@ -110,7 +112,7 @@ fn handle_window_event(window: &mut glfw::Window, event: glfw::WindowEvent) {

fn load_texture(path: &std::path::Path) -> Option<Rc<Texture>> {
let im = match image::open(path) {
Ok(im) => im.to_rgba(),
Ok(im) => im.to_rgba8(),
Err(e) => {
println!("{}", e);
return None;
Expand All @@ -126,11 +128,13 @@ fn load_texture(path: &std::path::Path) -> Option<Rc<Texture>> {
}

fn load_model(path: &std::path::Path) -> Model {
let (models, materials) = tobj::load_obj(path).unwrap();
let (models, materials) = tobj::load_obj(path,
&tobj::LoadOptions::default()).unwrap();

let mut bounds = Box3f32::make_empty();
let mut loaded_texture_ids = std::collections::HashMap::new();
let mut textures = Vec::new();
let materials = materials.expect("Failed to load MTL file");
let meshes = models
.into_iter()
.map(|model| {
Expand Down
Loading