diff options
author | Ton Roosendaal <ton@blender.org> | 2004-01-14 23:13:41 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-01-14 23:13:41 +0300 |
commit | 5190faf513e8289c68d4e40d3ea4db6260493570 (patch) | |
tree | cb2356b5ff069753acf84ba629807d5565078cc7 /source/blender | |
parent | dd714911204e101b4139cb07859579d3f16a5605 (diff) |
- fix for speedup raytracing, which gave errors in very simple scenes
(1 lamp, shadow). The 'coherence' check gets reset now for each new
pixel rendered, which remains efficient for oversampling.
- small cleanups in code, prototype added, less globals.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/render/extern/include/render_types.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/include/rendercore.h | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/ray.c | 12 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 11 |
4 files changed, 16 insertions, 13 deletions
diff --git a/source/blender/render/extern/include/render_types.h b/source/blender/render/extern/include/render_types.h index 6259d98162b..e9cefafa4c7 100644 --- a/source/blender/render/extern/include/render_types.h +++ b/source/blender/render/extern/include/render_types.h @@ -59,7 +59,9 @@ typedef struct ShadeInput float co[3]; float lo[3], gl[3], uv[3], ref[3], orn[3], winco[3], sticky[3], vcol[3], rad[3]; float vn[3], view[3], refcol[4], displace[3]; + float xs, ys; /* pixel to be rendered */ short osatex; + } ShadeInput; /* here only stuff to initalize the render itself */ diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h index 8757d99b3ec..288ff10937f 100644 --- a/source/blender/render/intern/include/rendercore.h +++ b/source/blender/render/intern/include/rendercore.h @@ -71,6 +71,10 @@ float fresnel_fac(float *view, float *vn, float fresnel, float fac); void calc_R_ref(struct ShadeInput *shi); float spec(float inp, int hard); +/* -------- ray.c ------- */ + +extern void ray_shadow(ShadeInput *, LampRen *, float *, int); +extern void ray_trace(ShadeInput *, ShadeResult *, int); /** * Apply the background (sky). Depending on the active alphamode and diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c index 25c4d0e68cb..ee966c231e1 100644 --- a/source/blender/render/intern/source/ray.c +++ b/source/blender/render/intern/source/ray.c @@ -102,6 +102,7 @@ typedef struct Node /* ******** globals ***************** */ static Octree g_oc; /* can be scene pointer or so later... */ +static int coh_test=0; /* coherence optimize */ /* just for statistics */ static int raycount, branchcount, nodecount; @@ -1060,7 +1061,6 @@ static int d3dda(Isect *is) } else { static int coh_ocx1,coh_ocx2,coh_ocy1, coh_ocy2,coh_ocz1,coh_ocz2; - static int coh_test=0; float dox, doy, doz; int coherent=1, nodecount=0; @@ -1502,11 +1502,10 @@ static float jit_cube4[4*4*4*3]={0.0}; static float jit_cube5[5*5*5*3]={0.0}; /* table around origin, -.5 to 0.5 */ -static float *jitter_plane(LampRen *lar) +static float *jitter_plane(LampRen *lar, int xs, int ys) { extern float hashvectf[]; - extern char hash[]; - extern int temp_x, temp_y; + //extern char hash[]; float dsizex, dsizey, *fp, *hv; int dit, x, y, resolx, resoly; @@ -1551,7 +1550,7 @@ static float *jitter_plane(LampRen *lar) } if(lar->ray_samp_type & LA_SAMP_DITHER) - return lar->jitter + 3*resolx*resoly*((temp_x & 1)+2*(temp_y & 1)); + return lar->jitter + 3*resolx*resoly*((xs & 1)+2*(ys & 1)); return lar->jitter; } @@ -1847,6 +1846,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac, int mask) else isec.mode= DDA_SHADOW; shadfac[3]= 1.0; // 1=full light + coh_test= 0; // reset coherence optimize if(lar->type==LA_SUN || lar->type==LA_HEMI) { lampco[0]= shi->co[0] - g_oc.ocsize*lar->vec[0]; @@ -1928,7 +1928,7 @@ void ray_shadow(ShadeInput *shi, LampRen *lar, float *shadfac, int mask) isec.vlrorig= shi->vlr; fac= 0.0; - jitlamp= jitter_plane(lar); + jitlamp= jitter_plane(lar, floor(shi->xs), floor(shi->ys)); a= lar->ray_totsamp; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index b00ca3b403b..8fa260f01da 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1907,7 +1907,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr, int mask) } else if(lar->mode & LA_SHAD_RAY) { if(R.r.mode & R_RAYTRACE) { - extern void ray_shadow(ShadeInput *, LampRen *, float *, int); + /* hurms, single sided? */ if( shi->vlr->n[0]*lv[0] + shi->vlr->n[1]*lv[1] + shi->vlr->n[2]*lv[2] > -0.01) { ray_shadow(shi, lar, shadfac, mask); @@ -2306,8 +2306,6 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i } } -int temp_x, temp_y; - /* x,y: window coordinate from 0 to rectx,y */ /* return pointer to rendered face */ void *shadepixel(float x, float y, int vlaknr, int mask, float *col) @@ -2319,8 +2317,9 @@ void *shadepixel(float x, float y, int vlaknr, int mask, float *col) if(vlaknr< 0) { /* error */ return NULL; } -temp_x= floor(x); -temp_y= floor(y); + /* currently in use for dithering soft shadow */ + shi.xs= x; + shi.ys= y; if(vlaknr==0) { /* sky */ col[0]= 0.0; col[1]= 0.0; col[2]= 0.0; col[3]= 0.0; @@ -2474,8 +2473,6 @@ temp_y= floor(y); if(R.r.mode & R_RAYTRACE) { if(shi.matren->ray_mirror!=0.0 || (shi.mat->mode & MA_RAYTRANSP && shr.alpha!=1.0)) { - extern void ray_trace(ShadeInput *shi, ShadeResult *shr, int mask); - ray_trace(&shi, &shr, mask); } } |