diff options
author | Anthony LaTorre <tlatorre9@gmail.com> | 2011-09-10 14:35:30 -0400 |
---|---|---|
committer | Anthony LaTorre <tlatorre9@gmail.com> | 2011-09-10 14:35:30 -0400 |
commit | 254a0713a85c869e96425522df4ae182f3ab8e13 (patch) | |
tree | aa7a7e04258acd627b1d2fd250e9e29478c94626 | |
parent | 1e192ba2349bc70efb1090c72f318470d8920970 (diff) | |
download | chroma-254a0713a85c869e96425522df4ae182f3ab8e13.tar.gz chroma-254a0713a85c869e96425522df4ae182f3ab8e13.tar.bz2 chroma-254a0713a85c869e96425522df4ae182f3ab8e13.zip |
new alpha rendering scheme.
-rw-r--r-- | solids/pmts.py | 2 | ||||
-rw-r--r-- | src/render.cu | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/solids/pmts.py b/solids/pmts.py index 4bcf276..43aed3f 100644 --- a/solids/pmts.py +++ b/solids/pmts.py @@ -38,7 +38,7 @@ def build_pmt_shell(filename, outer_material=water, nsteps=16): # convert mm -> m profile /= 1000.0 - return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xccffffff) + return Solid(rotate_extrude(profile[:,0], profile[:,1], nsteps), glass, outer_material, color=0xeeffffff) def build_pmt(filename, glass_thickness, outer_material=water, nsteps=16): profile = read_csv(filename) diff --git a/src/render.cu b/src/render.cu index c1e8ea1..d9ce1b1 100644 --- a/src/render.cu +++ b/src/render.cu @@ -142,11 +142,7 @@ render(int nthreads, float3 *_origin, float3 *_direction, Geometry *geometry, float fg = 0.0f; float fb = 0.0f; for (i=0; i < n; i++) { - float alpha; - if (i < alpha_depth-1) - alpha = color_a[i].w; - else - alpha = 1.0; + float alpha = color_a[i].w; fr += scale*color_a[i].x*alpha; fg += scale*color_a[i].y*alpha; @@ -158,10 +154,10 @@ render(int nthreads, float3 *_origin, float3 *_direction, Geometry *geometry, if (n < alpha_depth) a = floorf(255*(1.0f-scale)); else - a = 255; - unsigned int r = floorf(fr); - unsigned int g = floorf(fg); - unsigned int b = floorf(fb); + a = 255; + unsigned int r = floorf(fr/(1.0f-scale)); + unsigned int g = floorf(fg/(1.0f-scale)); + unsigned int b = floorf(fb/(1.0f-scale)); pixels[id] = a << 24 | r << 16 | g << 8 | b; } |