diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-07-20 18:12:22 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-07-20 18:12:22 -0400 |
commit | 6965233876421b43acac15c03cc3e6c858b0b6b0 (patch) | |
tree | 43a0662882cfddfacb82b30607eef8689a7842e6 /src | |
parent | 46011a8e4ffa31f4b057b20b84e5b45b447902b7 (diff) | |
download | chroma-6965233876421b43acac15c03cc3e6c858b0b6b0.tar.gz chroma-6965233876421b43acac15c03cc3e6c858b0b6b0.tar.bz2 chroma-6965233876421b43acac15c03cc3e6c858b0b6b0.zip |
in the previous commit i wrongly edited the code to reflect/transmit across a boundary
Diffstat (limited to 'src')
-rw-r--r-- | src/photon.h | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/photon.h b/src/photon.h index da866bc..69ecd34 100644 --- a/src/photon.h +++ b/src/photon.h @@ -16,39 +16,28 @@ struct Photon float wavelength; float time; - //bool alive; - //unsigned int last_process; unsigned int history; int last_hit_triangle; - //int photon_state; - curandState rng; }; struct State { float3 surface_normal; - //Material material1, material2; - //Surface surface; float refractive_index1, refractive_index2; float absorption_length; float scattering_length; - //float absorption_distance; - //float scattering_distance; int surface_index; - //int last_hit_triangle; float distance_to_boundary; }; enum { - //DEBUG = -2, - //INIT = -1, NO_HIT = 0x1 << 0, BULK_ABSORB = 0x1 << 1, SURFACE_DETECT = 0x1 << 2, @@ -191,27 +180,38 @@ __device__ void propagate_at_boundary(Photon &p, State &s) { reflection_coefficient = -sinf(incident_angle-refracted_angle)/sinf(incident_angle+refracted_angle); + if ((curand_uniform(&p.rng) < reflection_coefficient*reflection_coefficient) || isnan(refracted_angle)) + { + p.direction = rotate(s.surface_normal, incident_angle, incident_plane_normal); + + p.history |= REFLECT_SPECULAR; + } + else + { + p.direction = rotate(s.surface_normal, PI-refracted_angle, incident_plane_normal); + } + p.polarization = incident_plane_normal; } // photon polarization normal to plane of incidence else { reflection_coefficient = tanf(incident_angle-refracted_angle)/tanf(incident_angle+refracted_angle); + if ((curand_uniform(&p.rng) < reflection_coefficient*reflection_coefficient) || isnan(refracted_angle)) + { + p.direction = rotate(s.surface_normal, incident_angle, incident_plane_normal); + + p.history |= REFLECT_SPECULAR; + } + else + { + p.direction = rotate(s.surface_normal, PI-refracted_angle, incident_plane_normal); + } + p.polarization = cross(incident_plane_normal, p.direction); p.polarization /= norm(p.polarization); } // photon polarization parallel to plane of incidence - if ((curand_uniform(&p.rng) < reflection_coefficient*reflection_coefficient) || isnan(refracted_angle)) - { - p.direction = rotate(s.surface_normal, incident_angle, incident_plane_normal); - - p.history |= REFLECT_SPECULAR; - } - else - { - p.direction = rotate(s.surface_normal, PI-refracted_angle, incident_plane_normal); - } - } // propagate_at_boundary __device__ int propagate_at_surface(Photon &p, State &s) |