Preview Render:

* Fixes for texture and material nodes.
* Texture node previews now work more like materials.
This commit is contained in:
Brecht Van Lommel 2009-10-07 14:48:29 +00:00
parent 17c083a38f
commit cf4f00b2fa
33 changed files with 127 additions and 162 deletions

View File

@ -64,21 +64,19 @@ typedef struct RenderInfo {
/* Render the preview
pr_method:
- PR_DRAW_RENDER: preview is rendered and drawn, as indicated by called context (buttons panel)
- PR_ICON_RENDER: the preview is not drawn and the function is not dynamic,
so no events are processed. Hopefully fast enough for at least 32x32
- PR_DO_RENDER: preview is rendered, not drawn, but events are processed for afterqueue,
in use for node editor now.
- PR_BUTS_RENDER: preview is rendered for buttons window
- PR_ICON_RENDER: preview is rendered for icons. hopefully fast enough for at least 32x32
- PR_NODE_RENDER: preview is rendered for node editor.
*/
#define PR_DRAW_RENDER 0
#define PR_BUTS_RENDER 0
#define PR_ICON_RENDER 1
#define PR_DO_RENDER 2
#define PR_NODE_RENDER 2
void ED_preview_init_dbase(void);
void ED_preview_free_dbase(void);
void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey);
void ED_preview_shader_job(const struct bContext *C, void *owner, struct ID *id, struct ID *parent, struct MTex *slot, int sizex, int sizey, int method);
void ED_preview_icon_job(const struct bContext *C, void *owner, struct ID *id, unsigned int *rect, int sizex, int sizey);
void ED_preview_draw(const struct bContext *C, void *idp, void *parentp, void *slot, rcti *rect);

View File

@ -359,7 +359,7 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
else {
sce->lay= 1<<mat->pr_type;
if(mat->nodetree)
if(mat->nodetree && sp->pr_method==PR_NODE_RENDER)
ntreeInitPreview(mat->nodetree, sp->sizex, sp->sizey);
}
}
@ -408,6 +408,9 @@ static Scene *preview_prepare_scene(Scene *scene, ID *id, int id_type, ShaderPre
}
}
}
if(tex && tex->nodetree && sp->pr_method==PR_NODE_RENDER)
ntreeInitPreview(tex->nodetree, sp->sizex, sp->sizey);
}
else if(id_type==ID_LA) {
Lamp *la= (Lamp *)id;
@ -529,7 +532,7 @@ void ED_preview_draw(const bContext *C, void *idp, void *parentp, void *slotp, r
}
if(ok==0) {
ED_preview_shader_job(C, sa, id, parent, slot, newx, newy);
ED_preview_shader_job(C, sa, id, parent, slot, newx, newy, PR_BUTS_RENDER);
}
}
}
@ -880,11 +883,12 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
Render *re;
Scene *sce;
float oldlens;
short idtype= GS(id->name);
char name[32];
int sizex;
/* get the stuff from the builtin preview dbase */
sce= preview_prepare_scene(sp->scene, id, GS(id->name), sp); // XXX sizex
sce= preview_prepare_scene(sp->scene, id, idtype, sp); // XXX sizex
if(sce==NULL) return;
if(!split || first) sprintf(name, "Preview %p", sp->owner);
@ -896,14 +900,19 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
re= RE_NewRender(name);
/* sce->r gets copied in RE_InitState! */
if(sp->pr_method==PR_DO_RENDER) {
sce->r.scemode |= R_NODE_PREVIEW;
sce->r.scemode &= ~R_NO_IMAGE_LOAD;
sce->r.scemode &= ~(R_MATNODE_PREVIEW|R_TEXNODE_PREVIEW);
sce->r.scemode &= ~R_NO_IMAGE_LOAD;
if(sp->pr_method==PR_ICON_RENDER) {
sce->r.scemode |= R_NO_IMAGE_LOAD;
}
else if(sp->pr_method==PR_NODE_RENDER) {
if(idtype == ID_MA) sce->r.scemode |= R_MATNODE_PREVIEW;
else if(idtype == ID_TE) sce->r.scemode |= R_TEXNODE_PREVIEW;
sce->r.mode |= R_OSA;
}
else { /* PR_ICON_RENDER */
sce->r.scemode &= ~R_NODE_PREVIEW;
sce->r.scemode |= R_NO_IMAGE_LOAD;
else { /* PR_BUTS_RENDER */
sce->r.mode |= R_OSA;
}
/* in case of split preview, use border render */
@ -917,7 +926,7 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs
RE_InitState(re, NULL, &sce->r, sizex, sp->sizey, NULL);
/* callbacs are cleared on GetRender() */
if(sp->pr_method==PR_DO_RENDER) {
if(sp->pr_method==PR_BUTS_RENDER) {
RE_display_draw_cb(re, sp, shader_preview_draw);
RE_test_break_cb(re, sp, shader_preview_break);
}
@ -1125,7 +1134,7 @@ void ED_preview_icon_job(const bContext *C, void *owner, ID *id, unsigned int *r
WM_jobs_start(CTX_wm_manager(C), steve);
}
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey)
void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, MTex *slot, int sizex, int sizey, int method)
{
wmJob *steve;
ShaderPreview *sp;
@ -1138,7 +1147,7 @@ void ED_preview_shader_job(const bContext *C, void *owner, ID *id, ID *parent, M
sp->owner= owner;
sp->sizex= sizex;
sp->sizey= sizey;
sp->pr_method= PR_DO_RENDER;
sp->pr_method= method;
sp->id = id;
sp->parent= parent;
sp->slot= slot;

View File

@ -54,6 +54,7 @@
#include "MEM_guardedalloc.h"
#include "BKE_context.h"
#include "BKE_depsgraph.h"
#include "BKE_global.h"
#include "BKE_image.h"
#include "BKE_library.h"
@ -102,6 +103,7 @@ void ED_node_changed_update(bContext *C, bNode *node)
return;
if(snode->treetype==NTREE_SHADER) {
DAG_id_flush_update(snode->id, 0);
WM_event_add_notifier(C, NC_MATERIAL|ND_SHADING, snode->id);
}
else if(snode->treetype==NTREE_COMPOSIT) {
@ -127,6 +129,7 @@ void ED_node_changed_update(bContext *C, bNode *node)
WM_event_add_notifier(C, NC_SCENE|ND_NODES, CTX_data_scene(C));
}
else if(snode->treetype==NTREE_TEXTURE) {
DAG_id_flush_update(snode->id, 0);
WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, snode->id);
}

View File

@ -179,12 +179,14 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa)
{
/* default now: refresh node is starting preview */
SpaceNode *snode= sa->spacedata.first;
snode_set_context(snode, CTX_data_scene(C));
if(snode->nodetree) {
if(snode->treetype==NTREE_SHADER) {
Material *ma= (Material *)snode->id;
if(ma->use_nodes)
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100);
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
}
else if(snode->treetype==NTREE_COMPOSIT) {
Scene *scene= (Scene *)snode->id;
@ -194,7 +196,7 @@ static void node_area_refresh(const struct bContext *C, struct ScrArea *sa)
else if(snode->treetype==NTREE_TEXTURE) {
Tex *tex= (Tex *)snode->id;
if(tex->use_nodes) {
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100);
ED_preview_shader_job(C, sa, snode->id, NULL, NULL, 100, 100, PR_NODE_RENDER);
}
}
}

View File

@ -840,7 +840,7 @@ typedef struct Scene {
#define R_PASSEPARTOUT 0x0004
#define R_PREVIEWBUTS 0x0008
#define R_EXTENSION 0x0010
#define R_NODE_PREVIEW 0x0020
#define R_MATNODE_PREVIEW 0x0020
#define R_DOCOMP 0x0040
#define R_COMP_CROP 0x0080
#define R_FREE_IMAGE 0x0100
@ -852,7 +852,8 @@ typedef struct Scene {
#define R_STAMP_INFO 0x4000 /* deprecated */
#define R_FULL_SAMPLE 0x8000
#define R_COMP_RERENDER 0x10000
#define R_RECURS_PROTECTION 0x20000
#define R_RECURS_PROTECTION 0x20000
#define R_TEXNODE_PREVIEW 0x40000
/* r->stamp */
#define R_STAMP_TIME 0x0001

View File

@ -1716,7 +1716,7 @@ void RNA_def_material(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
RNA_def_property_boolean_funcs(prop, NULL, "rna_Material_use_nodes_set");
RNA_def_property_ui_text(prop, "Use Nodes", "Use shader nodes to render the material.");
RNA_def_property_update(prop, NC_MATERIAL, NULL);
RNA_def_property_update(prop, 0, "rna_Material_update");
prop= RNA_def_property(srna, "active_node_material", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "Material");

View File

@ -107,6 +107,14 @@ static void rna_Texture_update(bContext *C, PointerRNA *ptr)
WM_event_add_notifier(C, NC_TEXTURE, tex);
}
static void rna_Texture_nodes_update(bContext *C, PointerRNA *ptr)
{
Tex *tex= ptr->id.data;
DAG_id_flush_update(&tex->id, 0);
WM_event_add_notifier(C, NC_TEXTURE|ND_NODES, tex);
}
static void rna_Texture_type_set(PointerRNA *ptr, int value)
{
Tex *tex= (Tex*)ptr->data;
@ -1678,12 +1686,12 @@ static void rna_def_texture(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "use_nodes", 1);
RNA_def_property_boolean_funcs(prop, NULL, "rna_Texture_use_nodes_set");
RNA_def_property_ui_text(prop, "Use Nodes", "Make this a node-based texture");
RNA_def_property_update(prop, 0, "rna_Texture_update");
RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
prop= RNA_def_property(srna, "node_tree", PROP_POINTER, PROP_NONE);
RNA_def_property_pointer_sdna(prop, NULL, "nodetree");
RNA_def_property_ui_text(prop, "Node Tree", "Node tree for node-based textures");
RNA_def_property_update(prop, 0, "rna_Texture_update");
RNA_def_property_update(prop, 0, "rna_Texture_nodes_update");
rna_def_animdata_common(srna);

View File

@ -50,7 +50,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_at = {

View File

@ -109,9 +109,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_bricks= {

View File

@ -61,9 +61,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_checker= {

View File

@ -49,7 +49,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_compose= {

View File

@ -42,9 +42,7 @@ static void vectorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, sho
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &vectorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &vectorfn, data);
}
bNodeType tex_node_coord= {

View File

@ -50,7 +50,7 @@ static void time_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in,
static void time_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &time_colorfn);
tex_output(node, in, out[0], &time_colorfn, data);
}
@ -100,7 +100,7 @@ static void rgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in,
static void rgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &rgb_colorfn);
tex_output(node, in, out[0], &rgb_colorfn, data);
}
static void rgb_init(bNode *node)

View File

@ -67,10 +67,10 @@ static void valuefn_a(float *out, TexParams *p, bNode *node, bNodeStack **in, sh
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &valuefn_r);
tex_output(node, in, out[1], &valuefn_g);
tex_output(node, in, out[2], &valuefn_b);
tex_output(node, in, out[3], &valuefn_a);
tex_output(node, in, out[0], &valuefn_r, data);
tex_output(node, in, out[1], &valuefn_g, data);
tex_output(node, in, out[2], &valuefn_b, data);
tex_output(node, in, out[3], &valuefn_a, data);
}
bNodeType tex_node_decompose= {

View File

@ -53,9 +53,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &valuefn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &valuefn, data);
}
bNodeType tex_node_distance= {

View File

@ -84,7 +84,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_hue_sat= {

View File

@ -73,9 +73,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &colorfn, data);
}
static void init(bNode* node)

View File

@ -55,9 +55,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_invert= {

View File

@ -171,9 +171,7 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &valuefn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &valuefn, data);
}
bNodeType tex_node_math= {

View File

@ -57,9 +57,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_mix_rgb= {

View File

@ -83,28 +83,30 @@ static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
TexCallData *cdata = (TexCallData *)data;
TexResult *target = cdata->target;
if(in[1]->hasinput && !in[0]->hasinput)
tex_do_preview(node, in[1], data);
else
tex_do_preview(node, in[0], data);
if(cdata->do_preview) {
TexParams params;
params_from_cdata(&params, cdata);
if(in[1]->hasinput && !in[0]->hasinput)
tex_input_rgba(&target->tr, in[1], &params, cdata->thread);
else
tex_input_rgba(&target->tr, in[0], &params, cdata->thread);
tex_do_preview(node, params.coord, &target->tr);
}
else if(cdata->which_output == node->custom1) {
TexParams params;
params_from_cdata(&params, cdata);
osa(tex_input_rgba, &target->tr, in[0], &params, cdata->thread);
if(!cdata->do_preview) {
if(cdata->which_output == node->custom1)
{
TexParams params;
params_from_cdata(&params, cdata);
osa(tex_input_rgba, &target->tr, in[0], &params, cdata->thread);
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
target->talpha = 1.0f;
if(target->nor) {
if(in[1]->hasinput)
osa(tex_input_vec, target->nor, in[1], &params, cdata->thread);
else
target->nor = 0;
}
target->tin = (target->tr + target->tg + target->tb) / 3.0f;
target->talpha = 1.0f;
if(target->nor) {
if(in[1]->hasinput)
osa(tex_input_vec, target->nor, in[1], &params, cdata->thread);
else
target->nor = 0;
}
}
}

View File

@ -125,9 +125,8 @@ static int count_outputs(bNode *node)
static void name##_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out) \
{ \
int outs = count_outputs(node); \
if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn); \
if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn); \
if(outs >= 1) tex_do_preview(node, out[0], data); \
if(outs >= 1) tex_output(node, in, out[0], &name##_colorfn, data); \
if(outs >= 2) tex_output(node, in, out[1], &name##_normalfn, data); \
}

View File

@ -95,7 +95,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_rotate= {

View File

@ -56,7 +56,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_scale = {

View File

@ -79,9 +79,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_texture= {

View File

@ -56,7 +56,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &colorfn);
tex_output(node, in, out[0], &colorfn, data);
}
bNodeType tex_node_translate = {

View File

@ -72,9 +72,7 @@ static void normalfn(float *out, TexParams *p, bNode *node, bNodeStack **in, sho
}
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &normalfn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &normalfn, data);
}
bNodeType tex_node_valtonor = {

View File

@ -50,7 +50,7 @@ static void valtorgb_colorfn(float *out, TexParams *p, bNode *node, bNodeStack *
static void valtorgb_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &valtorgb_colorfn);
tex_output(node, in, out[0], &valtorgb_colorfn, data);
}
static void valtorgb_init(bNode *node)
@ -97,9 +97,7 @@ static void rgbtobw_valuefn(float *out, TexParams *p, bNode *node, bNodeStack **
static void rgbtobw_exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_output(node, in, out[0], &rgbtobw_valuefn);
tex_do_preview(node, out[0], data);
tex_output(node, in, out[0], &rgbtobw_valuefn, data);
}
bNodeType tex_node_rgbtobw= {

View File

@ -39,7 +39,16 @@ static bNodeSocketType outputs[]= {
static void exec(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
tex_do_preview(node, in[0], data);
TexCallData *cdata = (TexCallData *)data;
if(cdata->do_preview) {
TexParams params;
float col[4];
params_from_cdata(&params, cdata);
tex_input_rgba(col, in[0], &params, cdata->thread);
tex_do_preview(node, params.coord, col);
}
}
bNodeType tex_node_viewer = {

View File

@ -49,8 +49,12 @@
void tex_call_delegate(TexDelegate *dg, float *out, TexParams *params, short thread)
{
if(dg->node->need_exec)
if(dg->node->need_exec) {
dg->fn(out, params, dg->node, dg->in, thread);
if(dg->cdata->do_preview)
tex_do_preview(dg->node, params->coord, out);
}
}
void tex_input(float *out, int sz, bNodeStack *in, TexParams *params, short thread)
@ -95,26 +99,6 @@ float tex_input_value(bNodeStack *in, TexParams *params, short thread)
return out[0];
}
static void init_preview(bNode *node)
{
int xsize = (int)(node->prvr.xmax - node->prvr.xmin);
int ysize = (int)(node->prvr.ymax - node->prvr.ymin);
if(xsize == 0) {
xsize = PREV_RES;
ysize = PREV_RES;
}
if(node->preview==NULL)
node->preview= MEM_callocN(sizeof(bNodePreview), "node preview");
if(node->preview->rect==NULL) {
node->preview->rect= MEM_callocN(4*xsize + xsize*ysize*sizeof(float)*4, "node preview rect");
node->preview->xsize= xsize;
node->preview->ysize= ysize;
}
}
void params_from_cdata(TexParams *out, TexCallData *in)
{
out->coord = in->coord;
@ -123,48 +107,19 @@ void params_from_cdata(TexParams *out, TexCallData *in)
out->cfra = in->cfra;
}
void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata)
void tex_do_preview(bNode *node, float *coord, float *col)
{
int x, y;
float *result;
bNodePreview *preview;
float coord[3] = {0, 0, 0};
TexParams params;
int resolution;
int xsize, ysize;
if(!cdata->do_preview)
return;
if(!(node->typeinfo->flag & NODE_PREVIEW))
return;
init_preview(node);
preview = node->preview;
xsize = preview->xsize;
ysize = preview->ysize;
params.dxt = 0;
params.dyt = 0;
params.cfra = cdata->cfra;
params.coord = coord;
resolution = (xsize < ysize) ? xsize : ysize;
for(x=0; x<xsize; x++)
for(y=0; y<ysize; y++)
{
params.coord[0] = ((float) x / resolution) * 2 - 1;
params.coord[1] = ((float) y / resolution) * 2 - 1;
result = preview->rect + 4 * (xsize*y + x);
tex_input_rgba(result, ns, &params, cdata->thread);
bNodePreview *preview= node->preview;
if(preview) {
int xs= ((coord[0] + 1.0f)*0.5f)*preview->xsize;
int ys= ((coord[1] + 1.0f)*0.5f)*preview->ysize;
nodeAddToPreview(node, col, xs, ys);
}
}
void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn)
void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *cdata)
{
TexDelegate *dg;
if(!out->data)
@ -173,7 +128,7 @@ void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn)
else
dg = out->data;
dg->cdata= cdata;
dg->fn = texfn;
dg->node = node;
memcpy(dg->in, in, MAX_SOCKET * sizeof(bNodeStack*));

View File

@ -87,6 +87,7 @@ typedef struct TexParams {
typedef void(*TexFn) (float *out, TexParams *params, bNode *node, bNodeStack **in, short thread);
typedef struct TexDelegate {
TexCallData *cdata;
TexFn fn;
bNode *node;
bNodeStack *in[MAX_SOCKET];
@ -99,8 +100,8 @@ void tex_input_rgba(float *out, bNodeStack *in, TexParams *params, short thread)
void tex_input_vec(float *out, bNodeStack *in, TexParams *params, short thread);
float tex_input_value(bNodeStack *in, TexParams *params, short thread);
void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn);
void tex_do_preview(bNode *node, bNodeStack *ns, TexCallData *cdata);
void tex_output(bNode *node, bNodeStack **in, bNodeStack *out, TexFn texfn, TexCallData *data);
void tex_do_preview(bNode *node, float *coord, float *col);
void params_from_cdata(TexParams *out, TexCallData *in);

View File

@ -1306,7 +1306,7 @@ void shade_input_initialize(ShadeInput *shi, RenderPart *pa, RenderLayer *rl, in
shi->sample= sample;
shi->thread= pa->thread;
shi->do_preview= R.r.scemode & R_NODE_PREVIEW;
shi->do_preview= (R.r.scemode & R_MATNODE_PREVIEW) != 0;
shi->lay= rl->lay;
shi->layflag= rl->layflag;
shi->passflag= rl->passflag;

View File

@ -721,7 +721,7 @@ static int evalnodes(Tex *tex, float *texvec, float *dxt, float *dyt, TexResult
short rv = TEX_INT;
bNodeTree *nodes = tex->nodetree;
ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, thread, tex, which_output, R.r.cfra, (R.r.scemode & R_NODE_PREVIEW));
ntreeTexExecTree(nodes, texres, texvec, dxt, dyt, thread, tex, which_output, R.r.cfra, (R.r.scemode & R_TEXNODE_PREVIEW) != 0);
if(texres->nor) rv |= TEX_NOR;
rv |= TEX_RGB;