diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-12-11 17:35:08 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2007-12-11 17:35:08 +0300 |
commit | 60972ad45865682ad97202785d3cee4f48466575 (patch) | |
tree | 33ba3326632b4effd590c4accb9e9b8fdf02d3c1 /source | |
parent | 114ce86167b0000428304c5675719cfff3a771d7 (diff) |
Bugfix for SSS crash with nan's.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/render/intern/source/sss.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/source/blender/render/intern/source/sss.c b/source/blender/render/intern/source/sss.c index c4438a22ce5..09a3b9ef66d 100644 --- a/source/blender/render/intern/source/sss.c +++ b/source/blender/render/intern/source/sss.c @@ -234,11 +234,7 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd) float indexf, t, idxf; int index; - if(rr > (RD_TABLE_RANGE_2*RD_TABLE_RANGE_2)) { - rd[0]= Rd_rsquare(ss[0], rr); - rd[1]= Rd_rsquare(ss[1], rr); - rd[2]= Rd_rsquare(ss[2], rr); - } + if(rr > (RD_TABLE_RANGE_2*RD_TABLE_RANGE_2)); else if(rr > RD_TABLE_RANGE) { rr= sqrt(rr); indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE_2); @@ -246,9 +242,12 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd) idxf= (float)index; t= indexf - idxf; - rd[0]= (ss[0]->tableRd2[index]*(1-t) + ss[0]->tableRd2[index+1]*t); - rd[1]= (ss[1]->tableRd2[index]*(1-t) + ss[1]->tableRd2[index+1]*t); - rd[2]= (ss[2]->tableRd2[index]*(1-t) + ss[2]->tableRd2[index+1]*t); + if(index >= 0 && index < RD_TABLE_SIZE) { + rd[0]= (ss[0]->tableRd2[index]*(1-t) + ss[0]->tableRd2[index+1]*t); + rd[1]= (ss[1]->tableRd2[index]*(1-t) + ss[1]->tableRd2[index+1]*t); + rd[2]= (ss[2]->tableRd2[index]*(1-t) + ss[2]->tableRd2[index+1]*t); + return; + } } else { indexf= rr*(RD_TABLE_SIZE/RD_TABLE_RANGE); @@ -256,10 +255,18 @@ static void approximate_Rd_rgb(ScatterSettings **ss, float rr, float *rd) idxf= (float)index; t= indexf - idxf; - rd[0]= (ss[0]->tableRd[index]*(1-t) + ss[0]->tableRd[index+1]*t); - rd[1]= (ss[1]->tableRd[index]*(1-t) + ss[1]->tableRd[index+1]*t); - rd[2]= (ss[2]->tableRd[index]*(1-t) + ss[2]->tableRd[index+1]*t); + if(index >= 0 && index < RD_TABLE_SIZE) { + rd[0]= (ss[0]->tableRd[index]*(1-t) + ss[0]->tableRd[index+1]*t); + rd[1]= (ss[1]->tableRd[index]*(1-t) + ss[1]->tableRd[index+1]*t); + rd[2]= (ss[2]->tableRd[index]*(1-t) + ss[2]->tableRd[index+1]*t); + return; + } } + + /* fallback to slow Rd computation */ + rd[0]= Rd_rsquare(ss[0], rr); + rd[1]= Rd_rsquare(ss[1], rr); + rd[2]= Rd_rsquare(ss[2], rr); } static void build_Rd_table(ScatterSettings *ss) |