diff --git a/zenovis/xinxinoptix/DeflMatShader.cu b/zenovis/xinxinoptix/DeflMatShader.cu index 91c7ddf250..4f9787ded1 100644 --- a/zenovis/xinxinoptix/DeflMatShader.cu +++ b/zenovis/xinxinoptix/DeflMatShader.cu @@ -237,9 +237,9 @@ extern "C" __global__ void __anyhit__shadow_cutout() bv0 = meshMat * bv0; bv1 = meshMat * bv1; bv2 = meshMat * bv2; - float3 v0 = make_float3(bv0.x, bv0.y, bv0.z); - float3 v1 = make_float3(bv1.x, bv1.y, bv1.z); - float3 v2 = make_float3(bv2.x, bv2.y, bv2.z); + float3& v0 = *(float3*)&bv0; //make_float3(bv0.x, bv0.y, bv0.z); + float3& v1 = *(float3*)&bv1; //make_float3(bv1.x, bv1.y, bv1.z); + float3& v2 = *(float3*)&bv2; //make_float3(bv2.x, bv2.y, bv2.z); float3 N_0 = normalize( cross( normalize(v1-v0), normalize(v2-v0) ) ); @@ -509,9 +509,9 @@ extern "C" __global__ void __closesthit__radiance() bv0 = meshMat * bv0; bv1 = meshMat * bv1; bv2 = meshMat * bv2; - float3 v0 = make_float3(bv0.x, bv0.y, bv0.z); - float3 v1 = make_float3(bv1.x, bv1.y, bv1.z); - float3 v2 = make_float3(bv2.x, bv2.y, bv2.z); + float3& v0 = *(float3*)&bv0; //make_float3(bv0.x, bv0.y, bv0.z); + float3& v1 = *(float3*)&bv1; //make_float3(bv1.x, bv1.y, bv1.z); + float3& v2 = *(float3*)&bv2; //make_float3(bv2.x, bv2.y, bv2.z); float3 N_0 = normalize( cross( normalize(v1-v0), normalize(v2-v1) ) ); // this value has precision issue for big float diff --git a/zenovis/xinxinoptix/Light.h b/zenovis/xinxinoptix/Light.h index c0f0e452f8..3f22a211f8 100644 --- a/zenovis/xinxinoptix/Light.h +++ b/zenovis/xinxinoptix/Light.h @@ -256,7 +256,7 @@ void DirectLighting(RadiancePRD *prd, RadiancePRD& shadow_prd, const float3& sha light_attenuation = shadow_prd.shadowAttanuation; - if (length(light_attenuation) > 0.0f) { + if (lengthSquared(light_attenuation) > 0.0f) { auto bxdf_value = evalBxDF(lsr.dir, wo, scatterPDF); auto misWeight = 1.0f; diff --git a/zenovis/xinxinoptix/Shape.h b/zenovis/xinxinoptix/Shape.h index 16b8a78426..56e3e042f1 100644 --- a/zenovis/xinxinoptix/Shape.h +++ b/zenovis/xinxinoptix/Shape.h @@ -247,6 +247,8 @@ struct SphereShape { float3 f = ray_origin - center; float b2 = dot(f, ray_dir); + if (b2 >= 0) { return false; } + float r2 = radius * radius; float3 fd = f - b2 * ray_dir; @@ -264,7 +266,6 @@ struct SphereShape { lsr->dir = ray_dir; lsr->dist = fminf(c/q, q); lsr->p = ray_origin + ray_dir * lsr->dist; - // lsr->n = normalize(lsr->p - center); // lsr->p = rtgems::offset_ray(lsr->p, lsr->n); // lsr->dist = length(lsr->p - ray_origin);