From 2de4c8f2b20efe57a27804bd20d7e4882e9137d4 Mon Sep 17 00:00:00 2001 From: Robin Allen Date: Mon, 17 Aug 2009 22:17:25 +0000 Subject: Implemented multisampling for texture nodes. --- source/blender/nodes/intern/TEX_nodes/TEX_output.c | 46 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'source/blender/nodes/intern/TEX_nodes') diff --git a/source/blender/nodes/intern/TEX_nodes/TEX_output.c b/source/blender/nodes/intern/TEX_nodes/TEX_output.c index 355de796c7e..96ee5d74f66 100644 --- a/source/blender/nodes/intern/TEX_nodes/TEX_output.c +++ b/source/blender/nodes/intern/TEX_nodes/TEX_output.c @@ -35,6 +35,48 @@ static bNodeSocketType inputs[]= { { -1, 0, "" } }; +static void osa( + void (*input_fn)(float *, bNodeStack *, TexParams *, short), + float *out, + bNodeStack *in, + TexParams *p, + short thread +){ + if(!p->dxt) { + input_fn(out, in, p, thread); + } else { + float sample[4] = {0}; + float coord[3]; + TexParams sp = *p; + int i; + + sp.coord = coord; + sp.dxt = sp.dyt = 0; + + QUATCOPY(out, sample); + + for(i=0; i<5; i++) { + VECCOPY(coord, p->coord); + + if(i < 4) + { + if(i % 2) VECADD(coord, coord, p->dxt); + if(i > 1) VECADD(coord, coord, p->dyt); + } + else + { + VECADDFAC(coord, coord, p->dxt, 0.5); + VECADDFAC(coord, coord, p->dyt, 0.5); + } + + input_fn(sample, in, &sp, thread); + + QUATADDFAC(out, out, sample, 0.2); + } + } +} + + /* applies to render pipeline */ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) { @@ -52,14 +94,14 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) TexParams params; params_from_cdata(¶ms, cdata); - tex_input_rgba(&target->tr, in[0], ¶ms, cdata->thread); + osa(tex_input_rgba, &target->tr, in[0], ¶ms, cdata->thread); target->tin = (target->tr + target->tg + target->tb) / 3.0f; target->talpha = 1.0f; if(target->nor) { if(in[1]->hasinput) - tex_input_vec(target->nor, in[1], ¶ms, cdata->thread); + osa(tex_input_vec, target->nor, in[1], ¶ms, cdata->thread); else target->nor = 0; } -- cgit v1.2.3