diff options
Diffstat (limited to 'source/blender/render')
-rw-r--r-- | source/blender/render/intern/source/rendercore.c | 22 | ||||
-rw-r--r-- | source/blender/render/intern/source/vanillaRenderPipe.c | 23 |
2 files changed, 32 insertions, 13 deletions
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 0b545ed73a0..4c64af0afba 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -50,6 +50,8 @@ #include "BKE_global.h" #include "BKE_texture.h" +#include "BLI_rand.h" + /* local include */ #include "RE_callbacks.h" #include "old_zbuffer_types.h" @@ -217,15 +219,18 @@ void RE_sky(float *view, float *col) void RE_sky_char(float *view, char *col) { float f, colf[3]; + float dither_value; + + dither_value = (BLI_frand()*R.r.dither_intensity)/256.0; RE_sky(view, colf); - f= 255.0*colf[0]; + f= 255.0*(colf[0]+dither_value); 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]; + f= 255.0*(colf[1]+dither_value); 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]; + f= 255.0*(colf[2]+dither_value); 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 */ @@ -2846,12 +2851,21 @@ void shadepixel_short(float x, float y, int vlaknr, int mask, unsigned short *sh else shortcol[2]= 65535.0*colf[2]; if(colf[3]<=0.0) shortcol[3]= 0; else if(colf[3]>=1.0) shortcol[3]= 65535; else shortcol[3]= 65535.0*colf[3]; - + if(usegamtab) { shortcol[0]= igamtab2[ shortcol[0] ]; shortcol[1]= igamtab2[ shortcol[1] ]; shortcol[2]= igamtab2[ shortcol[2] ]; } + + if(R.r.dither_intensity!=0.0) { + short dither_value = (short)(BLI_frand()*R.r.dither_intensity*256.0); + /* no dither for color 254/255, is OK. intensity is <= 2.0 */ + if( shortcol[0] < 65000) shortcol[0]+= dither_value; + if( shortcol[1] < 65000) shortcol[1]+= dither_value; + if( shortcol[2] < 65000) shortcol[2]+= dither_value; + } + } PixStr *addpsmain() diff --git a/source/blender/render/intern/source/vanillaRenderPipe.c b/source/blender/render/intern/source/vanillaRenderPipe.c index 68476465da3..4e9057904de 100644 --- a/source/blender/render/intern/source/vanillaRenderPipe.c +++ b/source/blender/render/intern/source/vanillaRenderPipe.c @@ -57,6 +57,8 @@ #include "DNA_object_types.h" #include "BKE_global.h" +#include "BLI_rand.h" + /* local includes (from the render module) */ #include "RE_callbacks.h" #include "render.h" /* all kinds of stuff */ @@ -1342,27 +1344,30 @@ void zBufferFillEdge(float *vec1, float *vec2) void std_transFloatColV2CharColV( RE_COLBUFTYPE *buf, char *target) { float fval; + float dither_value; + + dither_value = (BLI_frand()*R.r.dither_intensity)/256.0; /* alpha */ - if(buf[3]<=0.0) target[3]= 0; - else if(buf[3]>1.0) target[3]= 255; - else target[3]= 255.0*buf[3]; + if((buf[3]+dither_value)<=0.0) target[3]= 0; + else if((buf[3]+dither_value)>1.0) target[3]= 255; + else target[3]= 255.0*(buf[3]+dither_value); if(R.r.postgamma==1.0) { /* r */ - fval= R.r.postmul*buf[0] + R.r.postadd; + fval= R.r.postmul*buf[0] + R.r.postadd + dither_value; if(fval<=0.0) target[0]= 0; else if(fval>1.0) target[0]= 255; else target[0]= 255.0*fval; /* g */ - fval= R.r.postmul*buf[1] + R.r.postadd; + fval= R.r.postmul*buf[1] + R.r.postadd + dither_value; if(fval<=0.0) target[1]= 0; else if(fval>1.0) target[1]= 255; else target[1]= 255.0*fval; /* b */ - fval= R.r.postmul*buf[2] + R.r.postadd; + fval= R.r.postmul*buf[2] + R.r.postadd + dither_value; if(fval<=0.0) target[2]= 0; else if(fval>1.0) target[2]= 255; else target[2]= 255.0*fval; @@ -1376,19 +1381,19 @@ void std_transFloatColV2CharColV( RE_COLBUFTYPE *buf, char *target) /* r */ - fval= pow(R.r.postmul*buf[0], R.r.postigamma) + R.r.postadd; + fval= pow(R.r.postmul*buf[0], R.r.postigamma) + R.r.postadd + dither_value; if(fval<=0.0) target[0]= 0; else if(fval>1.0) target[0]= 255; else target[0]= 255.0*fval; /* g */ - fval=pow( R.r.postmul*buf[1], R.r.postigamma) + R.r.postadd; + fval=pow( R.r.postmul*buf[1], R.r.postigamma) + R.r.postadd + dither_value; if(fval<=0.0) target[1]= 0; else if(fval>1.0) target[1]= 255; else target[1]= 255.0*fval; /* b */ - fval= pow(R.r.postmul*buf[2], R.r.postigamma) + R.r.postadd; + fval= pow(R.r.postmul*buf[2], R.r.postigamma) + R.r.postadd + dither_value; if(fval<=0.0) target[2]= 0; else if(fval>1.0) target[2]= 255; else target[2]= 255.0*fval; |