diff options
author | Ton Roosendaal <ton@blender.org> | 2004-04-25 00:27:29 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2004-04-25 00:27:29 +0400 |
commit | 5bbd35ff054cf79b29ccdba3a85ff35ea6825611 (patch) | |
tree | 6c6190ef892987d02cba867ed826f6578484c8fb | |
parent | 382297b68753b1d17d6e57846206d086fde251b0 (diff) |
Turned Sky render code in Blender to become fully float, it still returned
bytes for RGB.
This to allow very bright contrasted images to be used for AO as well. As
a first start also the Texture->Colors panel now allows contrast setting
up to 5.0 (was 2.0).
-rw-r--r-- | source/blender/blenkernel/BKE_utildefines.h | 6 | ||||
-rw-r--r-- | source/blender/render/extern/include/render.h | 3 | ||||
-rw-r--r-- | source/blender/render/intern/source/ray.c | 16 | ||||
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 41 | ||||
-rw-r--r-- | source/blender/src/buttons_shading.c | 2 | ||||
-rw-r--r-- | source/blender/src/previewrender.c | 13 | ||||
-rw-r--r-- | source/blender/src/renderwin.c | 5 |
7 files changed, 46 insertions, 40 deletions
diff --git a/source/blender/blenkernel/BKE_utildefines.h b/source/blender/blenkernel/BKE_utildefines.h index 92b29a59f1f..75b70d9e090 100644 --- a/source/blender/blenkernel/BKE_utildefines.h +++ b/source/blender/blenkernel/BKE_utildefines.h @@ -274,11 +274,11 @@ if(Tin<0.0) Tin= 0.0; else if(Tin>1.0) Tin= 1.0; #define BRICONRGB Tr= tex->rfac*((Tr-0.5)*tex->contrast+tex->bright-0.5); \ - if(Tr<0.0) Tr= 0.0; else if(Tr>1.0) Tr= 1.0; \ + if(Tr<0.0) Tr= 0.0; \ Tg= tex->gfac*((Tg-0.5)*tex->contrast+tex->bright-0.5); \ - if(Tg<0.0) Tg= 0.0; else if(Tg>1.0) Tg= 1.0; \ + if(Tg<0.0) Tg= 0.0; \ Tb= tex->bfac*((Tb-0.5)*tex->contrast+tex->bright-0.5); \ - if(Tb<0.0) Tb= 0.0; else if(Tb>1.0) Tb= 1.0; + if(Tb<0.0) Tb= 0.0; /* mystifying stuff from blendef... */ #define SELECT 1 diff --git a/source/blender/render/extern/include/render.h b/source/blender/render/extern/include/render.h index 7d039349e73..c27e35fd1cf 100644 --- a/source/blender/render/extern/include/render.h +++ b/source/blender/render/extern/include/render.h @@ -252,7 +252,8 @@ struct EnvMap *RE_copy_envmap(struct EnvMap *env); /* patch for the external if, to support the split for the ui */ void RE_addalphaAddfac(char *doel, char *bron, char addfac); - void RE_sky(float *view, char *col); + void RE_sky_char(float *view, char *col); + void RE_sky(float *view, float *col); void RE_renderflare(struct HaloRen *har); /** * Shade the pixel at xn, yn for halo har, and write the result to col. diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c index 495d8b52c12..950b1334cf5 100644 --- a/source/blender/render/intern/source/ray.c +++ b/source/blender/render/intern/source/ray.c @@ -1544,17 +1544,11 @@ static void traceray(short depth, float *start, float *vec, float *col, VlakRen } else { /* sky */ - char skycol[4]; VECCOPY(shi.view, vec); Normalise(shi.view); - RE_sky(shi.view, skycol); - - col[0]= skycol[0]/255.0; - col[1]= skycol[1]/255.0; - col[2]= skycol[2]/255.0; - + RE_sky(shi.view, col); } } @@ -2121,7 +2115,7 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac) else sh+= 1.0; } else if(wrld->aocolor!=WO_AOPLAIN) { - char skycol[4]; + float skycol[4]; float fac, view[3]; view[0]= -vec[0]; @@ -2137,9 +2131,9 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac) } else { RE_sky(view, skycol); - shadfac[0]+= skycol[0]/255.0; - shadfac[1]+= skycol[1]/255.0; - shadfac[2]+= skycol[2]/255.0; + shadfac[0]+= skycol[0]; + shadfac[1]+= skycol[1]; + shadfac[2]+= skycol[2]; } } } diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 2a202815bbe..9a2bac82c98 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -163,9 +163,9 @@ float mistfactor(float *co) /* dist en height, return alpha */ return (1.0-fac)* (1-R.wrld.misi); } -void RE_sky(float *view, char *col) +void RE_sky(float *view, float *col) { - float lo[3], rf, gf, bf; + float lo[3]; if((R.wrld.skytype & (WO_SKYBLEND+WO_SKYTEX))==0) { *( (unsigned int *)col)= R.wrld.fastcol; @@ -206,22 +206,31 @@ void RE_sky(float *view, char *col) R.inprh= 1.0-R.inprz; if(R.wrld.skytype & WO_SKYBLEND) { - rf= 255.0*(R.inprh*R.wrld.horr + R.inprz*R.wrld.zenr); - gf= 255.0*(R.inprh*R.wrld.horg + R.inprz*R.wrld.zeng); - bf= 255.0*(R.inprh*R.wrld.horb + R.inprz*R.wrld.zenb); - - if (rf>255.0) col[0]= 255; - else col[0]= (char)rf; - if (gf>255.0) col[1]= 255; - else col[1]= (char)gf; - if (bf>255.0) col[2]= 255; - else col[2]= (char)bf; + col[0]= (R.inprh*R.wrld.horr + R.inprz*R.wrld.zenr); + col[1]= (R.inprh*R.wrld.horg + R.inprz*R.wrld.zeng); + col[2]= (R.inprh*R.wrld.horb + R.inprz*R.wrld.zenb); } else { - col[0]= 255.0*R.wrld.horr; - col[1]= 255.0*R.wrld.horg; - col[2]= 255.0*R.wrld.horb; + col[0]= R.wrld.horr; + col[1]= R.wrld.horg; + col[2]= R.wrld.horb; } +} + +void RE_sky_char(float *view, char *col) +{ + float f, colf[3]; + + RE_sky(view, colf); + f= 255.0*colf[0]; + if(f<=0.0) col[0]= 0; else if(f>255.0) col[0]= 255; + else col[0]= (char)f; + f= 255.0*colf[1]; + if(f<=0.0) col[1]= 0; else if(f>255.0) col[1]= 255; + else col[1]= (char)f; + f= 255.0*colf[2]; + if(f<=0.0) col[2]= 0; else if(f>255.0) col[2]= 255; + else col[2]= (char)f; col[3]= 1; /* to prevent wrong optimalisation alphaover of flares */ } @@ -372,7 +381,7 @@ void scanlinesky(char *rect, int y) view[2]= -panosi*u + panoco*v; } - RE_sky(view, (char *)&col); + RE_sky_char(view, (char *)&col); if(rect[3]==0) *((unsigned int *)rect)= col; else alphafunc(rect, &col); diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c index dfcbfe50e78..8efc58b0049 100644 --- a/source/blender/src/buttons_shading.c +++ b/source/blender/src/buttons_shading.c @@ -1172,7 +1172,7 @@ static void texture_panel_colors(Tex *tex) uiBlockBeginAlign(block); uiDefButF(block, NUMSLI, B_TEXPRV, "Bright", 10,10,150,20, &tex->bright, 0.0, 2.0, 0, 0, "Changes the brightness of the colour or intensity of a texture"); - uiDefButF(block, NUMSLI, B_TEXPRV, "Contr", 160,10,150,20, &tex->contrast, 0.01, 2.0, 0, 0, "Changes the contrast of the colour or intensity of a texture"); + uiDefButF(block, NUMSLI, B_TEXPRV, "Contr", 160,10,150,20, &tex->contrast, 0.01, 5.0, 0, 0, "Changes the contrast of the colour or intensity of a texture"); } diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c index 4bfe5265f27..214161e53fd 100644 --- a/source/blender/src/previewrender.c +++ b/source/blender/src/previewrender.c @@ -88,6 +88,8 @@ #include "RE_renderconverter.h" +#include "blendef.h" /* CLAMP */ + #define PR_RECTX 141 #define PR_RECTY 141 #define PR_XMIN 10 @@ -385,7 +387,7 @@ static void sky_preview_pixel(float lens, int x, int y, char *rect) view[2]= -lens*PR_RECTX/32.0; Normalise(view); } - RE_sky(view, rect); + RE_sky_char(view, rect); } static void lamp_preview_pixel(ShadeInput *shi, LampRen *la, int x, int y, char *rect) @@ -642,9 +644,12 @@ static void texture_preview_pixel(Tex *tex, int x, int y, char *rect) if(rgbnor & 1) { - rect[0]= 255.0*Tr; - rect[1]= 255.0*Tg; - rect[2]= 255.0*Tb; + v1= 255.0*Tr; + rect[0]= CLAMPIS(v1, 0, 255); + v1= 255.0*Tg; + rect[1]= CLAMPIS(v1, 0, 255); + v1= 255.0*Tb; + rect[2]= CLAMPIS(v1, 0, 255); if(Ta!=1.0) { tracol= 64+100*(abs(x)>abs(y)); diff --git a/source/blender/src/renderwin.c b/source/blender/src/renderwin.c index 1d2db07f05a..66bd70dd57f 100644 --- a/source/blender/src/renderwin.c +++ b/source/blender/src/renderwin.c @@ -666,7 +666,7 @@ static void renderview_progress_display_cb(int y1, int y2, int w, int h, unsigne /* callback for print info in top header in interface */ -static void printrenderinfo_cb(double time, int sample, int blur) +static void printrenderinfo_cb(double time, int sample) { extern int mem_in_use; float megs_used_memory= mem_in_use/(1024.0*1024.0); @@ -679,9 +679,6 @@ static void printrenderinfo_cb(double time, int sample, int blur) if (R.r.mode & R_FIELDS) { spos+= sprintf(spos, "Field %c ", (R.flag&R_SEC_FIELD)?'B':'A'); } - if (blur!=-1) { - spos+= sprintf(spos, "Blur: %d ", blur); - } if (sample!=-1) { spos+= sprintf(spos, "Sample: %d ", sample); } |