From 9a5f98576a42d6af90be3ffcf5642c7b5110f90f Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Mon, 1 Nov 2004 18:04:18 +0000 Subject: [PATCH] Small tweak in dithering; the noise varies around 0.0 now. Value 'dithering' in buttons can go to '2', for extra noise. 1.0 defaults to exact 1.0/256.0 noise. --- source/blender/render/intern/source/rendercore.c | 12 ++++++------ .../blender/render/intern/source/vanillaRenderPipe.c | 2 +- source/blender/src/buttons_scene.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c index 4c64af0afba..418a33ab00f 100644 --- a/source/blender/render/intern/source/rendercore.c +++ b/source/blender/render/intern/source/rendercore.c @@ -221,7 +221,7 @@ 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; + dither_value = ( (BLI_frand()-0.5)*R.r.dither_intensity)/256.0; RE_sky(view, colf); f= 255.0*(colf[0]+dither_value); @@ -2859,11 +2859,11 @@ void shadepixel_short(float x, float y, int vlaknr, int mask, unsigned short *sh } 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; + short dither_value = (short)((BLI_frand() -.5)*R.r.dither_intensity*256.0); + /* no dither for color 0 or 255, is OK. intensity is <= 2.0 */ + if(shortcol[0]>255 || shortcol[0] < 65280) shortcol[0]+= dither_value; + if(shortcol[1]>255 || shortcol[1] < 65280) shortcol[1]+= dither_value; + if(shortcol[2]>255 || shortcol[2] < 65280) shortcol[2]+= dither_value; } } diff --git a/source/blender/render/intern/source/vanillaRenderPipe.c b/source/blender/render/intern/source/vanillaRenderPipe.c index 4e9057904de..6a384b270c9 100644 --- a/source/blender/render/intern/source/vanillaRenderPipe.c +++ b/source/blender/render/intern/source/vanillaRenderPipe.c @@ -1346,7 +1346,7 @@ void std_transFloatColV2CharColV( RE_COLBUFTYPE *buf, char *target) float fval; float dither_value; - dither_value = (BLI_frand()*R.r.dither_intensity)/256.0; + dither_value = ((BLI_frand()-0.5)*R.r.dither_intensity)/256.0; /* alpha */ if((buf[3]+dither_value)<=0.0) target[3]= 0; diff --git a/source/blender/src/buttons_scene.c b/source/blender/src/buttons_scene.c index b727064f767..0ae1a347896 100644 --- a/source/blender/src/buttons_scene.c +++ b/source/blender/src/buttons_scene.c @@ -1040,7 +1040,7 @@ static void render_panel_output(void) uiDefButS(block, TOG|BIT|4, 0, "Extensions", 250, 10, 60, 20, &G.scene->r.scemode, 0.0, 0.0, 0, 0, "Adds extensions to the output when rendering animations"); /* Dither control */ - uiDefButF(block, NUM,B_DIFF, "Dither:", 205,31,105,19, &G.scene->r.dither_intensity, 0.0, 1.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)"); + uiDefButF(block, NUM,B_DIFF, "Dither:", 205,31,105,19, &G.scene->r.dither_intensity, 0.0, 2.0, 0, 0, "The amount of dithering noise present in the output image (0.0 = no dithering)"); /* Toon shading buttons */ uiBlockBeginAlign(block);