Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
孙万捷 authored and 孙万捷 committed Jun 17, 2016
1 parent 017c944 commit 630e942
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions core/woodcock_tracking.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@
#include "cuda_volume.h"
#include "cuda_transfer_function.h"

#define BASE_SAMPLE_STEP_SIZE 0.5f

__inline__ __device__ float opacity_to_sigmat(float opacity)
{
opacity = fminf(opacity, 0.99f);
return -logf(1.f - opacity) * BASE_SAMPLE_STEP_SIZE;
}
#define BASE_SAMPLE_STEP_SIZE 1.f

__inline__ __device__ float sample_distance(const cudaRay& ray, const cudaVolume& volume, const cudaTransferFunction& tf, curandState& rng)
{
Expand All @@ -32,19 +26,21 @@ __inline__ __device__ float sample_distance(const cudaRay& ray, const cudaVolume
ray.tMax = tFar;
auto t = ray.tMin;

float invSigmaMax = 1.f / opacity_to_sigmat(tf.GetMaxOpacity());
float sigmaMax = tf.GetMaxOpacity();
float invSigmaMax = 1.f / sigmaMax;
float invSigmaMaxSampleInterval = 1.f / (sigmaMax * BASE_SAMPLE_STEP_SIZE);
while(true)
{
t += -logf(1.f - curand_uniform(&rng)) * invSigmaMax;
t += -logf(1.f - curand_uniform(&rng)) * invSigmaMaxSampleInterval;
if(t > ray.tMax)
return -FLT_MAX;

auto ptInWorld = ray.PointOnRay(t);
auto intensity = volume(ptInWorld);
auto color_opacity = tf(intensity);
auto sigma_t = opacity_to_sigmat(color_opacity.w);
auto sigma_t = color_opacity.w;

if(curand_uniform(&rng) < sigma_t * invSigmaMax)
if(curand_uniform(&rng) < sigma_t * invSigmaMax || t > ray.tMax)
break;
}

Expand Down

0 comments on commit 630e942

Please sign in to comment.