Bugfix #18801
authorTon Roosendaal <ton@blender.org>
Tue, 26 May 2009 13:46:08 +0000 (13:46 +0000)
committerTon Roosendaal <ton@blender.org>
Tue, 26 May 2009 13:46:08 +0000 (13:46 +0000)
Third transparent shadow bug... this time it's a Material Node, which
has mirror + transp-shadow on, and when it traces its own material it
enters an eternal loop...

Raytracing + shading + materialnode combo really needs work!

source/blender/nodes/intern/SHD_nodes/SHD_material.c
source/blender/render/extern/include/RE_shader_ext.h
source/blender/render/intern/source/rayshade.c

index c0a2534ac4a361845905b3ea4950016b948258a2..69c2c0a345ca5db5e0476345135ca0eb8f60d765 100644 (file)
@@ -130,7 +130,9 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
                                nodestack_get_vec(&shi->translucency, SOCK_VALUE, in[MAT_IN_TRANSLUCENCY]);                     
                }
                
+               shi->nodes= 1; /* temp hack to prevent trashadow recursion */
                node_shader_lamp_loop(shi, &shrnode);   /* clears shrnode */
+               shi->nodes= 0;
                
                /* write to outputs */
                if(node->custom1 & SH_NODE_MAT_DIFF) {
index 2cee2673a269f8591b4fea9f78e36b7ff2bbfead..0ad48fe97a970328733c1e0e60f492bb75f90f78 100644 (file)
@@ -171,6 +171,7 @@ typedef struct ShadeInput
        /* from initialize, part or renderlayer */
        short do_preview;               /* for nodes, in previewrender */
        short thread, sample;   /* sample: ShadeSample array index */
+       short nodes;                    /* indicate node shading, temp hack to prevent recursion */
        
        unsigned int lay;
        int layflag, passflag, combinedflag;
index f4dcbe9e1869c3a1271356ea4fc14e85befa51c9..75b9557f3374fbe6ce142cb57152d817c704a155 100644 (file)
@@ -263,7 +263,8 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
        shade_input_set_shade_texco(shi);
        
        if(is->mode==RE_RAY_SHADOW_TRA) {
-               if(shi->mat->nodetree && shi->mat->use_nodes) {
+               /* temp hack to prevent recursion */
+               if(shi->nodes==0 && shi->mat->nodetree && shi->mat->use_nodes) {
                        ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
                        shi->mat= vlr->mat;             /* shi->mat is being set in nodetree */
                }
@@ -1299,6 +1300,7 @@ static void ray_trace_shadow_tra(Isect *is, ShadeInput *origshi, int depth, int
                shi.xs= origshi->xs;
                shi.ys= origshi->ys;
                shi.lay= origshi->lay;
+               shi.nodes= origshi->nodes;
                
                shade_ray(is, &shi, &shr);
                if (traflag & RAY_TRA)