[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13602] trunk/blender/source/blender/ render/intern: FSA: tweaked merging samples with filter to correctly map edges of the
Ton Roosendaal
ton at blender.org
Thu Feb 7 13:14:58 CET 2008
Revision: 13602
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13602
Author: ton
Date: 2008-02-07 13:14:58 +0100 (Thu, 07 Feb 2008)
Log Message:
-----------
FSA: tweaked merging samples with filter to correctly map edges of the
images. Found method that doesn't require image to be rendered larger.
Note: assembling pre-rendered parts that are result of FSA renders might
still give minor visible artefacts on edges; however, we should include
such render methods in the render pipeline, so multiple computers can
each render parts, save all samples, and have 1 computer assembling and
compositing all. This is for another project... :)
Modified Paths:
--------------
trunk/blender/source/blender/render/intern/include/pixelblending.h
trunk/blender/source/blender/render/intern/source/pipeline.c
trunk/blender/source/blender/render/intern/source/pixelblending.c
Modified: trunk/blender/source/blender/render/intern/include/pixelblending.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/pixelblending.h 2008-02-07 06:00:08 UTC (rev 13601)
+++ trunk/blender/source/blender/render/intern/include/pixelblending.h 2008-02-07 12:14:58 UTC (rev 13602)
@@ -35,6 +35,8 @@
*/
void add_filt_fmask(unsigned int mask, float *col, float *rowbuf, int row_w);
void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize);
+void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, int col_h, int x, int y);
+void mask_array(unsigned int mask, float filt[][3]);
/**
* Alpha-over blending for floats.
Modified: trunk/blender/source/blender/render/intern/source/pipeline.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pipeline.c 2008-02-07 06:00:08 UTC (rev 13601)
+++ trunk/blender/source/blender/render/intern/source/pipeline.c 2008-02-07 12:14:58 UTC (rev 13602)
@@ -2016,7 +2016,7 @@
/* reads all buffers, calls optional composite, merges in first result->rectf */
static void do_merge_fullsample(Render *re, bNodeTree *ntree)
{
- float *rectf;
+ float *rectf, filt[3][3];
int sample;
/* filtmask needs it */
@@ -2055,16 +2055,18 @@
/* accumulate with filter, and clip */
mask= (1<<sample);
- for(y=1; y<re->recty-1; y++) {
- float *rf= rectf + 4*y*re->rectx + 4;
- float *col= rres.rectf + 4*y*re->rectx + 4;
+ mask_array(mask, filt);
+
+ for(y=0; y<re->recty; y++) {
+ float *rf= rectf + 4*y*re->rectx;
+ float *col= rres.rectf + 4*y*re->rectx;
- for(x=1; x<re->rectx-1; x++, rf+=4, col+=4) {
+ for(x=0; x<re->rectx; x++, rf+=4, col+=4) {
if(col[0]<0.0f) col[0]=0.0f; else if(col[0] > 1.0f) col[0]= 1.0f;
if(col[1]<0.0f) col[1]=0.0f; else if(col[1] > 1.0f) col[1]= 1.0f;
if(col[2]<0.0f) col[2]=0.0f; else if(col[2] > 1.0f) col[2]= 1.0f;
- add_filt_fmask(mask, col, rf, re->rectx);
+ add_filt_fmask_coord(filt, col, rf, re->rectx, re->recty, x, y);
}
}
@@ -2396,7 +2398,6 @@
/* evaluating scene options for general Blender render */
static int render_initialize_from_scene(Render *re, Scene *scene)
{
- Scene *sce;
int winx, winy;
rcti disprect;
Modified: trunk/blender/source/blender/render/intern/source/pixelblending.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/pixelblending.c 2008-02-07 06:00:08 UTC (rev 13601)
+++ trunk/blender/source/blender/render/intern/source/pixelblending.c 2008-02-07 12:14:58 UTC (rev 13602)
@@ -31,6 +31,7 @@
*/
#include <math.h>
+#include <string.h>
/* global includes */
#include "BLI_arithb.h"
@@ -203,6 +204,121 @@
}
}
+
+void mask_array(unsigned int mask, float filt[][3])
+{
+ float **fmask1= R.samples->fmask1, **fmask2=R.samples->fmask2;
+ unsigned int maskand= (mask & 255);
+ unsigned int maskshift= (mask >>8);
+ int a, j;
+
+ for(j=2; j>=0; j--) {
+
+ a= j;
+
+ filt[2][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
+
+ a+=3;
+
+ filt[1][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
+
+ a+=3;
+
+ filt[0][2-j]= *(fmask1[a] +maskand) + *(fmask2[a] +maskshift);
+ }
+}
+
+
+/*
+
+index ordering, scanline based:
+
+ --- --- ---
+| 2,0 | 2,1 | 2,2 |
+ --- --- ---
+| 1,0 | 1,1 | 1,2 |
+ --- --- ---
+| 0,0 | 0,1 | 0,2 |
+ --- --- ---
+*/
+
+void add_filt_fmask_coord(float filt[][3], float *col, float *rowbuf, int row_w, int col_h, int x, int y)
+{
+ float *fpoin[3][3];
+ float val, r, g, b, al, lfilt[3][3];
+
+ r= col[0];
+ g= col[1];
+ b= col[2];
+ al= col[3];
+
+ memcpy(lfilt, filt, sizeof(lfilt));
+
+ fpoin[0][1]= rowbuf-4*row_w;
+ fpoin[1][1]= rowbuf;
+ fpoin[2][1]= rowbuf+4*row_w;
+
+ fpoin[0][0]= fpoin[0][1] - 4;
+ fpoin[1][0]= fpoin[1][1] - 4;
+ fpoin[2][0]= fpoin[2][1] - 4;
+
+ fpoin[0][2]= fpoin[0][1] + 4;
+ fpoin[1][2]= fpoin[1][1] + 4;
+ fpoin[2][2]= fpoin[2][1] + 4;
+
+ if(y==0) {
+ fpoin[0][0]= fpoin[1][0];
+ fpoin[0][1]= fpoin[1][1];
+ fpoin[0][2]= fpoin[1][2];
+ /* filter needs the opposite value yes! */
+ lfilt[0][0]= filt[2][0];
+ lfilt[0][1]= filt[2][1];
+ lfilt[0][2]= filt[2][2];
+ }
+ else if(y==col_h-1) {
+ fpoin[2][0]= fpoin[1][0];
+ fpoin[2][1]= fpoin[1][1];
+ fpoin[2][2]= fpoin[1][2];
+
+ lfilt[2][0]= filt[0][0];
+ lfilt[2][1]= filt[0][1];
+ lfilt[2][2]= filt[0][2];
+ }
+
+ if(x==0) {
+ fpoin[2][0]= fpoin[2][1];
+ fpoin[1][0]= fpoin[1][1];
+ fpoin[0][0]= fpoin[0][1];
+
+ lfilt[2][0]= filt[2][2];
+ lfilt[1][0]= filt[1][2];
+ lfilt[0][0]= filt[0][2];
+ }
+ else if(x==row_w-1) {
+ fpoin[2][2]= fpoin[2][1];
+ fpoin[1][2]= fpoin[1][1];
+ fpoin[0][2]= fpoin[0][1];
+
+ lfilt[2][2]= filt[2][0];
+ lfilt[1][2]= filt[1][0];
+ lfilt[0][2]= filt[0][0];
+ }
+
+
+ /* loop unroll */
+#define MASKFILT(i, j) val= lfilt[i][j]; if(val!=0.0f) {float *fp= fpoin[i][j]; fp[0]+= val*r; fp[1]+= val*g; fp[2]+= val*b; fp[3]+= val*al; }
+
+ MASKFILT(0, 0)
+ MASKFILT(0, 1)
+ MASKFILT(0, 2)
+ MASKFILT(1, 0)
+ MASKFILT(1, 1)
+ MASKFILT(1, 2)
+ MASKFILT(2, 0)
+ MASKFILT(2, 1)
+ MASKFILT(2, 2)
+}
+
void add_filt_fmask_pixsize(unsigned int mask, float *in, float *rowbuf, int row_w, int pixsize)
{
/* calc the value of mask */
More information about the Bf-blender-cvs
mailing list