Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2003-12-23 01:27:51 +0300
committerTon Roosendaal <ton@blender.org>2003-12-23 01:27:51 +0300
commit454166026afd52e546716a7aa33821e86d2371af (patch)
tree094dc47e4f9520efbf91a6db632cf44032b1c285 /source
parent3df84b755f3b49f8d31355135a48444413af2914 (diff)
- another fresnel improvement. :)
At last irc meeting, eeshlo pointed to an error in the code. It didn't use the IOR value correctly. This has been solved. So how it works now: - the IOR button value influences (very subtle) the fresnel effect. Only for realism diehards. - the Fresnel value (slider) now denotes the power in the function rf + (1-rf) * (1-c)^5 where rf= rf = ((ior-1)/(ior+1))^2 and c the dot-product ray/normal. - so, set the slider at '5' and you have real fresnel. Lower values for interesting artistic effects. - put back the forgotten code for gaussian corrected sampling during antialising render. Normally, each sub-pixel sample in Blender counts equally, and together make up the pixel color. With 'Gauss' option set (F10 menu) each sub-pixel sample creates a small weighted mask with variable size, which (can) affect neighbouring pixels as well. The result is smoother edges, less sensitive for gamma, and well suited to reduce motion-aliasing (when things move extreme slow). This is result of *long* period of research in NeoGeo days, and based on every scientific sampling/reconstructing theory we could find. Plus a little bit of our selves. :) - I should write once how blender constructs Jitter tables for sub-sampling. this is a very nice method, and superior to normal block filter or random jittering... time!
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenloader/intern/readfile.c10
-rw-r--r--source/blender/makesdna/DNA_scene_types.h5
-rw-r--r--source/blender/render/intern/include/rendercore.h2
-rw-r--r--source/blender/render/intern/source/initrender.c21
-rw-r--r--source/blender/render/intern/source/ray.c4
-rw-r--r--source/blender/render/intern/source/rendercore.c39
-rw-r--r--source/blender/src/buttons_scene.c15
-rw-r--r--source/blender/src/buttons_shading.c8
-rw-r--r--source/blender/src/previewrender.c6
9 files changed, 51 insertions, 59 deletions
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 068fca17726..f55d0fa78f7 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3931,13 +3931,14 @@ static void do_versions(Main *main)
}
if(main->versionfile <= 231) {
Material *ma= main->mat.first;
+ Scene *sce;
while(ma) {
if(ma->ang==0.0) {
ma->ang= 1.0;
ma->ray_depth= 2;
ma->ray_depth_tra= 2;
- ma->fresnel_tra= 1.0;
- ma->fresnel_mir= 1.0;
+ ma->fresnel_tra= 0.0;
+ ma->fresnel_mir= 0.0;
}
else if(ma->ang<1.0) { // temporal, because of IOR & fresnel change
ma-> ang= 1.0/ma->ang;
@@ -3946,6 +3947,11 @@ static void do_versions(Main *main)
}
ma= ma->id.next;
}
+ sce= main->scene.first;
+ while(sce) {
+ if(sce->r.gauss==0.0) sce->r.gauss= 1.0;
+ sce= sce->id.next;
+ }
}
/* don't forget to set version number in blender.c! */
}
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 48c448187f6..679a33ac492 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -200,12 +200,12 @@ typedef struct RenderData {
/** For unified renderer: reduce intensity on boundaries with
* identical materials with this number.*/
- short same_mat_redux, pad_3[2];
+ short same_mat_redux;
/**
* The gamma for the normal rendering. Used when doing
* oversampling, to correctly blend subpixels to pixels. */
- float gamma;
+ float gamma, gauss;
/** post-production settings. Don't really belong here */
float postmul, postgamma, postadd, postigamma;
@@ -282,6 +282,7 @@ typedef struct Scene {
#define R_MBLUR 0x4000
#define R_UNIFIED 0x8000
#define R_RAYTRACE 0x10000
+#define R_GAUSS 0x20000
/* scemode */
#define R_DOSEQ 0x0001
diff --git a/source/blender/render/intern/include/rendercore.h b/source/blender/render/intern/include/rendercore.h
index c463d9cdaae..c8ad75a4f00 100644
--- a/source/blender/render/intern/include/rendercore.h
+++ b/source/blender/render/intern/include/rendercore.h
@@ -58,7 +58,7 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
void shade_color(struct ShadeInput *shi, ShadeResult *shr);
void shade_lamp_loop(struct ShadeInput *shi, ShadeResult *shr, int mask);
-float fresnel_fac(float *view, float *vn, float fresnel);
+float fresnel_fac(float *view, float *vn, float fresnel, float fac);
void calc_R_ref(struct ShadeInput *shi);
float spec(float inp, int hard);
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 8edde6563b7..15b401d3d66 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -168,9 +168,12 @@ void RE_free_render_data()
float calc_weight(float *weight, int i, int j)
{
- float x, y, dist, totw= 0.0;
+ float x, y, dist, totw= 0.0, fac;
int a;
+ fac= R.r.gauss*R.r.gauss;
+ fac*= fac;
+
for(a=0; a<R.osa; a++) {
x= jit[a][0]-0.5+ i;
y= jit[a][1]-0.5+ j;
@@ -179,15 +182,15 @@ float calc_weight(float *weight, int i, int j)
weight[a]= 0.0;
/* gaussian weighting has been cancelled */
- //if(R.r.mode & R_GAUSS) {
- // if(dist<1.5) {
- // x = dist*1.5;
- // weight[a]= (1.0/exp(x*x) - 1.0/exp(1.5*1.5*1.5*1.5));
- // }
- //}
- //else {
+ if(R.r.mode & R_GAUSS) {
+ if(dist<R.r.gauss) {
+ x = dist*R.r.gauss;
+ weight[a]= (1.0/exp(x*x) - 1.0/exp(fac));
+ }
+ }
+ else {
if(i==0 && j==0) weight[a]= 1.0;
- //}
+ }
totw+= weight[a];
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c
index 04ca80171d5..030dbb7847b 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->fresnel_mir);
+ if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.matren->ang, shi.matren->fresnel_mir);
}
else f= 0.0;
@@ -1619,7 +1619,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->fresnel_mir);
+ i= shi->matren->ray_mirror*fresnel_fac(shi->view, shi->vn, shi->matren->ang, 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 5342fef9934..cb7fa627e3c 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -1500,46 +1500,29 @@ void calc_R_ref(ShadeInput *shi)
}
-float fresnel_fac(float *view, float *vn, float ior)
+float fresnel_fac(float *view, float *vn, float ior, float fac)
{
float rf, t1, t2;
- if(ior==1.0) return 1.0;
-
- 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(fac==0.0) return 1.0;
- t2 = t1*t1;
- t2= (ior + (1.0-ior)*t2*t2*t1);
-
- if(t2<0.0) return 0.0;
- else if(t2>1.0) return 1.0;
- return t2;
-}
-#if 0
-/* correctness fresnel, schlick approx */
-float fresnel_fac1(float *view, float *vn, float ior)
-{
- float rf, t1, t2;
-
- if(ior==1.0) return 1.0;
-
- rf = ((ior-1)/(ior+1));
+ 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;
- t2 = t1*t1;
- t2= (rf + (1.0-rf)*t2*t2*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);
if(t2<0.0) return 0.0;
else if(t2>1.0) return 1.0;
return t2;
}
-#endif
void shade_color(ShadeInput *shi, ShadeResult *shr)
{
@@ -1564,7 +1547,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->fresnel_tra);
+ ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->ang, ma->fresnel_tra);
}
shr->diff[0]= ma->r;
@@ -1896,7 +1879,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->fresnel_tra);
+ ma->alpha*= fresnel_fac(shi->view, shi->vn, ma->ang, ma->fresnel_tra);
if(ma->spectra!=0.0) {
diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c
index a9ba3f66beb..4583fd8d813 100644
--- a/source/blender/src/buttons_scene.c
+++ b/source/blender/src/buttons_scene.c
@@ -1054,16 +1054,17 @@ static void render_panel_render()
uiDefButS(block, ROW,B_DIFF,"75%", 565,90,36,20,&G.scene->r.size,1.0,75.0, 0, 0, "Set render size to 3/4 of defined size");
uiDefButS(block, ROW,B_DIFF,"50%", 604,90,40,20,&G.scene->r.size,1.0,50.0, 0, 0, "Set render size to 1/2 of defined size");
uiDefButS(block, ROW,B_DIFF,"25%", 647,90,39,20,&G.scene->r.size,1.0,25.0, 0, 0, "Set render size to 1/4 of defined size");
- uiBlockEndAlign(block);
- uiDefButI(block, TOG|BIT|6,0,"Fields", 564,42,90,31,&G.scene->r.mode, 0, 0, 0, 0, "Enables field rendering");
uiBlockBeginAlign(block);
- uiDefButI(block, TOG|BIT|13,0,"Odd", 655,57,30,16,&G.scene->r.mode, 0, 0, 0, 0, "Enables Odd field first rendering (Default: Even field)");
- uiDefButI(block, TOG|BIT|7,0,"x", 655,42,30,15,&G.scene->r.mode, 0, 0, 0, 0, "Disables time difference in field calculations");
- uiBlockEndAlign(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|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)");
- uiDefButI(block, TOG|BIT|9,REDRAWVIEWCAM, "Border", 565,11,58,24, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
- uiDefButI(block, TOG|BIT|2,0, "Gamma", 626,11,58,24, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
+ uiDefButI(block, TOG|BIT|9,REDRAWVIEWCAM, "Border", 564,10,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Render a small cut-out of the image");
+ uiDefButI(block, TOG|BIT|2,0, "Gamma", 624,10,60,20, &G.scene->r.mode, 0, 0, 0, 0, "Enable gamma correction");
}
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index e182024910b..f228bee4fde 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -2025,9 +2025,7 @@ void do_matbuts(unsigned short event)
case B_MATRAYTRANSP:
ma= G.buts->lockpoin;
if(ma) {
- // set ztra when you disable ray-tra, is nicer
- if(ma->mode & MA_RAYTRANSP) ma->mode &= ~MA_ZTRA;
- else ma->mode |= MA_ZTRA;
+ ma->mode &= ~MA_ZTRA;
allqueue(REDRAWBUTSSHADING, 0);
BIF_preview_changed(G.buts);
}
@@ -2256,7 +2254,7 @@ static void material_panel_tramir(Material *ma)
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), 1.0, 1.5, 10, 2, "Amount of Fresnel for mirror reflection");
+ 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 ");
uiBlockBeginAlign(block);
@@ -2266,7 +2264,7 @@ static void material_panel_tramir(Material *ma)
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");
- uiDefButF(block, NUMSLI, B_MATPRV, "Fresnel ", 10,90,200,19, &(ma->fresnel_tra), 1.0, 1.5, 10, 2, "Amount of Fresnel for transparency");
+ 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 ");
uiBlockBeginAlign(block);
diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c
index 1dbed2795ba..b5554dbfccd 100644
--- a/source/blender/src/previewrender.c
+++ b/source/blender/src/previewrender.c
@@ -701,7 +701,7 @@ static void refraction_prv(int *x, int *y, float *n, float index)
static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char *rect, int smooth)
{
- extern float fresnel_fac(float *view, float *vn, float fresnel);
+ extern float fresnel_fac(float *view, float *vn, float ior, float fac);
Material *mat;
float v1,inp, inprspec=0, isr=0.0, isb=0.0, isg=0.0;
float ir=0.0, ib=0.0, ig=0.0;
@@ -860,7 +860,7 @@ 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->fresnel_mir);
+ shi->refcol[0]= mat->ray_mirror*fresnel_fac(view, shi->vn, mat->ang, mat->fresnel_mir);
if(div<0.0) {
/* minus 0.5 prevents too many small tiles in distance */
@@ -907,7 +907,7 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char *
if(mat->mode & (MA_ZTRA|MA_RAYTRANSP))
if(mat->fresnel_tra!=0.0)
- alpha*= fresnel_fac(view, shi->vn, mat->fresnel_tra);
+ alpha*= fresnel_fac(view, shi->vn, mat->ang, mat->fresnel_tra);
/* ztra shade */
if(mat->spectra!=0.0) {