diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/material.c | 6 | ||||
-rw-r--r-- | source/blender/blenloader/intern/readfile.c | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_material_types.h | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/ray.c | 19 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 26 | ||||
-rw-r--r-- | source/blender/src/buttons_scene.c | 2 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 34 | ||||
-rw-r--r-- | source/blender/src/previewrender.c | 24 |
8 files changed, 67 insertions, 50 deletions
diff --git a/source/blender/blenkernel/intern/material.c b/source/blender/blenkernel/intern/material.c index b3b13583e98..cc502b54f99 100644 --- a/source/blender/blenkernel/intern/material.c +++ b/source/blender/blenkernel/intern/material.c @@ -108,8 +108,10 @@ void init_material(Material *ma) ma->ang= 1.0; ma->ray_depth= 2; ma->ray_depth_tra= 2; - ma->fresnel_mir= 1.0; - ma->fresnel_tra= 1.0; + ma->fresnel_mir= 0.0; + ma->fresnel_tra= 0.0; + ma->fresnel_tra_i= 1.25; + ma->fresnel_mir_i= 1.25; ma->mode= MA_TRACEBLE+MA_SHADOW+MA_RADIO; } diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index f55d0fa78f7..a8abc0f0798 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3933,6 +3933,8 @@ static void do_versions(Main *main) Material *ma= main->mat.first; Scene *sce; while(ma) { + if(ma->fresnel_tra_i==0.0) ma->fresnel_tra_i= 1.25; + if(ma->fresnel_mir_i==0.0) ma->fresnel_mir_i= 1.25; if(ma->ang==0.0) { ma->ang= 1.0; ma->ray_depth= 2; diff --git a/source/blender/makesdna/DNA_material_types.h b/source/blender/makesdna/DNA_material_types.h index d75cce4e4b8..f81f79f2b25 100644 --- a/source/blender/makesdna/DNA_material_types.h +++ b/source/blender/makesdna/DNA_material_types.h @@ -57,8 +57,8 @@ typedef struct Material { float amb, emit, ang, spectra, ray_mirror; float alpha, ref, spec, zoffs, add; float translucency; - float fresnel_mir; - float fresnel_tra; + float fresnel_mir, fresnel_mir_i; + float fresnel_tra, fresnel_tra_i; short ray_depth, ray_depth_tra; short har; char seed1, seed2; diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c index 030dbb7847b..c60b679465c 100644 --- a/source/blender/render/intern/source/ray.c +++ b/source/blender/render/intern/source/ray.c @@ -1366,7 +1366,7 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen if(shi.matren->mode & MA_RAYMIRROR) { f= shi.matren->ray_mirror; - if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.matren->ang, shi.matren->fresnel_mir); + if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.matren->fresnel_mir_i, shi.matren->fresnel_mir); } else f= 0.0; @@ -1438,6 +1438,9 @@ static float jit_cube5[5*5*5*3]={0.0}; static float *jitter_plane(int resol) { extern float hashvectf[]; + extern char hash[]; + extern int temp_x, temp_y; + static int offs=0; float dsize, *jit, *fp, *hv; int x, y; @@ -1453,15 +1456,17 @@ static float *jitter_plane(int resol) case 7: jit= jit_plane7; break; default: jit= jit_plane8; break; } - if(jit[0]!=0.0) return jit; + //if(jit[0]!=0.0) return jit; + + offs++; dsize= 1.0/(resol-1.0); fp= jit; - hv= hashvectf; + hv= hashvectf+3*(hash[ (temp_x&3)+4*(temp_y&3) ]); for(x=0; x<resol; x++) { for(y=0; y<resol; y++, fp+= 3, hv+=3) { - fp[0]= -0.5 + (x+0.25*hv[0])*dsize; - fp[1]= -0.5 + (y+0.25*hv[1])*dsize; + fp[0]= -0.5 + (x+0.5*hv[0])*dsize; + fp[1]= -0.5 + (y+0.5*hv[1])*dsize; fp[2]= fp[0]*fp[0] + fp[1]*fp[1]; if(resol>2) if(fp[2]>0.3) fp[2]= 0.0; @@ -1586,7 +1591,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr, int mask) } if(div!=0.0) { - i= shi->matren->ray_mirror; + i= shi->matren->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->matren->fresnel_mir_i, shi->matren->fresnel_mir); fr= shi->matren->mirr; fg= shi->matren->mirg; fb= shi->matren->mirb; @@ -1619,7 +1624,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr, int mask) if(do_mir) { - i= shi->matren->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->matren->ang, shi->matren->fresnel_mir); + i= shi->matren->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->matren->fresnel_mir_i, shi->matren->fresnel_mir); if(i!=0.0) { fr= shi->matren->mirr; fg= shi->matren->mirg; diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index cb7fa627e3c..1406cb51380 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -1500,24 +1500,18 @@ void calc_R_ref(ShadeInput *shi) } -float fresnel_fac(float *view, float *vn, float ior, float fac) +/* mix of 'real' fresnel and allowing control. grad defines blending gradient */ +float fresnel_fac(float *view, float *vn, float grad, float fac) { - float rf, t1, t2; + float t1, t2; if(fac==0.0) return 1.0; - rf = ((ior-1.0)/(ior+1.0)); - rf*= rf; - t1= (view[0]*vn[0] + view[1]*vn[1] + view[2]*vn[2]); - if(t1>0.0) t1= 1.0-t1; - else t1 = 1.0+t1; + if(t1>0.0) t2= 1.0+t1; + else t2= 1.0-t1; - if(fac==5.0) { - t2 = t1*t1; - t2= rf + (1.0-rf)*t1*t2*t2; - } - else t2= rf + (1.0-rf)*pow(t1, fac); + t2= grad + (1.0-grad)*pow(t2, fac); if(t2<0.0) return 0.0; else if(t2>1.0) return 1.0; @@ -1547,7 +1541,7 @@ void shade_color(ShadeInput *shi, ShadeResult *shr) if(ma->mode & (MA_ZTRA|MA_RAYTRANSP)) { if(ma->fresnel_tra!=1.0) - ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->ang, ma->fresnel_tra); + ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); } shr->diff[0]= ma->r; @@ -1879,7 +1873,7 @@ void shade_lamp_loop(ShadeInput *shi, ShadeResult *shr, int mask) if(ma->mode & (MA_ZTRA|MA_RAYTRANSP)) { if(ma->fresnel_tra!=1.0) - ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->ang, ma->fresnel_tra); + ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->fresnel_tra_i, ma->fresnel_tra); if(ma->spectra!=0.0) { @@ -2182,6 +2176,8 @@ 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) @@ -2193,6 +2189,8 @@ 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); if(vlaknr==0) { /* sky */ col[0]= 0.0; col[1]= 0.0; col[2]= 0.0; col[3]= 0.0; diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index 4583fd8d813..4a66f064966 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -1058,7 +1058,7 @@ static void render_panel_render() uiBlockBeginAlign(block); uiDefButI(block, TOG|BIT|6,0,"Fields", 564,50,60,23,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering"); uiDefButI(block, TOG|BIT|13,0,"Odd", 624,50,40,23,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)"); - uiDefButI(block, TOG|BIT|7,0,"x", 655,50,20,23,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations"); + uiDefButI(block, TOG|BIT|7,0,"x", 665,50,20,23,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations"); uiDefButI(block, TOG|BIT|17,0,"Gauss", 564,30,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable Gauss sampling filter for antialiasing"); uiDefButF(block, NUM,B_DIFF,"", 624,30,60,20,&G.scene->r.gauss,0.5, 2.0, 0, 0, "Sets the Gauss filter size)"); diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index f228bee4fde..75f19245550 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -2251,30 +2251,34 @@ static void material_panel_tramir(Material *ma) uiNewPanelTabbed("Shaders", "Material"); if(uiNewPanel(curarea, block, "Mirror Transp", "Material", 640, 0, 318, 204)==0) return; + uiDefButI(block, TOG|BIT|18, B_MATPRV,"Ray Mirror",210,180,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering"); + uiBlockBeginAlign(block); - uiDefButF(block, NUMSLI, B_MATPRV, "RayMir ", 10,180,200,19, &(ma->ray_mirror), 0.0, 1.0, 100, 2, "Sets the amount mirror reflection for raytrace"); - uiDefButI(block, TOG|BIT|18, B_MATPRV,"Ray Mirror",210,180,100,19, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering"); - uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,160,200,19, &(ma->fresnel_mir), 0.0, 5.0, 100, 2, "Power of Fresnel for mirror reflection"); - uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,160,100,19, &(ma->ray_depth), 0.0, 10.0, 100, 0, "Amount of inter-reflections calculated maximal "); + uiDefButF(block, NUMSLI, B_MATPRV, "RayMir ", 10,160,200,20, &(ma->ray_mirror), 0.0, 1.0, 100, 2, "Sets the amount mirror reflection for raytrace"); + uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,160,100,20, &(ma->ray_depth), 0.0, 10.0, 100, 0, "Amount of inter-reflections calculated maximal "); + + uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,140,160,20, &(ma->fresnel_mir), 0.0, 5.0, 10, 2, "Power of Fresnel for mirror reflection"); + uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,140,140,20, &(ma->fresnel_mir_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel"); uiBlockBeginAlign(block); - uiDefButF(block, NUMSLI, B_MATPRV, "Alpha ", 10,130,200,19, &(ma->alpha), 0.0, 1.0, 0, 0, "Sets the material's opacity and transparency mix"); - uiDefButI(block, TOG|BIT|6, B_MATZTRANSP,"ZTransp", 210,130,100,19, &(ma->mode), 0, 0, 0, 0, "Enables Z-Buffering of transparent faces"); + uiDefButI(block, TOG|BIT|6, B_MATZTRANSP,"ZTransp", 110,110,100,20, &(ma->mode), 0, 0, 0, 0, "Enables Z-Buffering of transparent faces"); + uiDefButI(block, TOG|BIT|17, B_MATRAYTRANSP,"Ray Transp",210,110,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering"); - uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,110,200,19, &(ma->ang), 1.0, 3.0, 100, 2, "Sets the angular index of refraction for raytrace"); - uiDefButI(block, TOG|BIT|17, B_MATRAYTRANSP,"Ray Transp",210,110,100,19, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering"); + uiBlockBeginAlign(block); + uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,90,200,20, &(ma->ang), 1.0, 3.0, 100, 2, "Sets the angular index of refraction for raytrace"); + uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,90,100,20, &(ma->ray_depth_tra), 0.0, 10.0, 100, 0, "Amount of refractions calculated maximal "); - uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,90,200,19, &(ma->fresnel_tra), 0.0, 5.0, 100, 2, "Power of Fresnel for transparency"); - uiDefButS(block, NUM, B_MATPRV, "Depth:", 210,90,100,19, &(ma->ray_depth_tra), 0.0, 10.0, 100, 0, "Amount of refractions calculated maximal "); + uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,70,160,20, &(ma->fresnel_tra), 0.0, 5.0, 10, 2, "Power of Fresnel for transparency"); + uiDefButF(block, NUMSLI, B_MATPRV, "Fac ", 170,70,140,20, &(ma->fresnel_tra_i), 1.0, 5.0, 10, 2, "Blending factor for Fresnel"); uiBlockBeginAlign(block); - uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 10,60,150,19, &(ma->spectra), 0.0, 1.0, 0, 0, "Makes specular areas opaque on transparent materials"); - uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 160,60,150,19, &(ma->add), 0.0, 1.0, 0, 0, "Sets a glow factor for transparant materials"); + uiDefButF(block, NUMSLI, B_MATPRV, "SpecTra ", 10,40,150,20, &(ma->spectra), 0.0, 1.0, 0, 0, "Makes specular areas opaque on transparent materials"); + uiDefButF(block, NUMSLI, B_MATPRV, "Add ", 160,40,150,20, &(ma->add), 0.0, 1.0, 0, 0, "Sets a glow factor for transparant materials"); uiBlockBeginAlign(block); - uiDefButI(block, TOG|BIT|10, 0, "OnlyShadow", 10,10,100,19, &(ma->mode), 0, 0, 0, 0, "Renders shadows falling on material only"); - uiDefButI(block, TOG|BIT|14, 0, "No Mist", 110,10,100,19, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values"); - uiDefButI(block, TOG|BIT|9, 0, "Env", 210,10,100,19, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through"); + uiDefButI(block, TOG|BIT|10, 0, "OnlyShadow", 10,10,100,20, &(ma->mode), 0, 0, 0, 0, "Renders shadows falling on material only"); + uiDefButI(block, TOG|BIT|14, 0, "No Mist", 110,10,100,20, &(ma->mode), 0, 0, 0, 0, "Sets the material to ignore mist values"); + uiDefButI(block, TOG|BIT|9, 0, "Env", 210,10,100,20, &(ma->mode), 0, 0, 0, 0, "Causes faces to render with alpha zero: allows sky/backdrop to show through"); uiBlockEndAlign(block); diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c index b5554dbfccd..ef43ca66ad0 100644 --- a/source/blender/src/previewrender.c +++ b/source/blender/src/previewrender.c @@ -783,7 +783,13 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char * } } + /* set it here, because ray_mirror will affect it */ + alpha= mat->alpha; + if(mat->mode & (MA_ZTRA|MA_RAYTRANSP)) + if(mat->fresnel_tra!=0.0) + alpha*= fresnel_fac(view, shi->vn, mat->fresnel_tra_i, mat->fresnel_tra); + if(mat->mode & MA_SHLESS) { temp= 255.0*(mat->r); if(temp>255) rect[0]= 255; else if(temp<0) rect[0]= 0; else rect[0]= temp; @@ -860,8 +866,14 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char * /* scale */ div= (0.85*shi->ref[1]); - shi->refcol[0]= mat->ray_mirror*fresnel_fac(view, shi->vn, mat->ang, mat->fresnel_mir); - + shi->refcol[0]= mat->ray_mirror*fresnel_fac(view, shi->vn, mat->fresnel_mir_i, mat->fresnel_mir); + /* not real 'alpha', but mirror overriding transparency */ + if(mat->mode & MA_RAYTRANSP) { + float fac= sqrt(shi->refcol[0]); + alpha= alpha*(1.0-fac) + fac; + } + else alpha= alpha*(1.0-shi->refcol[0]) + shi->refcol[0]; + if(div<0.0) { /* minus 0.5 prevents too many small tiles in distance */ fac= (int)(shi->ref[0]/(div-0.1) ) + (int)(shi->ref[2]/(div-0.1) ); @@ -903,12 +915,6 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char * } } - alpha= mat->alpha; - - if(mat->mode & (MA_ZTRA|MA_RAYTRANSP)) - if(mat->fresnel_tra!=0.0) - alpha*= fresnel_fac(view, shi->vn, mat->ang, mat->fresnel_tra); - /* ztra shade */ if(mat->spectra!=0.0) { inp = MAX3(isr, isg, isb); @@ -916,7 +922,7 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char * if(inp>1.0) inp= 1.0; alpha= (1.0-inp)*alpha+inp; } - + if(alpha!=1.0) { if(mat->mode & MA_RAYTRANSP) { refraction_prv(&x, &y, shi->vn, mat->ang); |