Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2006-07-09 15:54:41 +0400
committerTon Roosendaal <ton@blender.org>2006-07-09 15:54:41 +0400
commitcf313f867d3e457ac9da21c001202650d4a8e2ce (patch)
tree982a56d8fe4e2405f8237a42bbed39e2fe6fe189 /source
parent121f13fef7e6e2652555b0fda59da282da37a2ff (diff)
Bugfix #4647
The raytracer wasn't calling node shaders yet, so results showed only shading for the base material. This now works, but there's a conflict in the internal Blender shader that makes recursive raytracing with nodes unpredictable. Basicaly the conflict is that when a ray wants to shade a point, it should be able to check the material for mirror properties, but this is undefined for node trees... Probably we need to separate raytrace entirely from material shading. Is a good topic for NodeShader 2.0, when we really split up materials in shading components. I'll add a note in the release log about this. Best results you get now when you don't include mirror/ray-transp insde a node tree, in that case a regular material mirror can render that material perfectly.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/node.c5
-rw-r--r--source/blender/blenkernel/intern/node_shaders.c2
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h2
-rw-r--r--source/blender/render/intern/source/ray.c58
-rw-r--r--source/blender/render/intern/source/rendercore.c24
5 files changed, 45 insertions, 46 deletions
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 144bac09e8c..b39b838f481 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1046,6 +1046,8 @@ void ntreeFreeTree(bNodeTree *ntree)
if(ntree==NULL) return;
+ ntreeEndExecTree(ntree); /* checks for if it is still initialized */
+
BLI_freelistN(&ntree->links); /* do first, then unlink_node goes fast */
for(node= ntree->nodes.first; node; node= next) {
@@ -1739,6 +1741,9 @@ static void group_tag_used_outputs(bNode *gnode, bNodeStack *stack)
void ntreeBeginExecTree(bNodeTree *ntree)
{
+ /* let's make it sure */
+ if(ntree->init & NTREE_EXEC_INIT)
+ return;
/* goes recursive over all groups */
ntree->stacksize= ntree_begin_exec_tree(ntree);
diff --git a/source/blender/blenkernel/intern/node_shaders.c b/source/blender/blenkernel/intern/node_shaders.c
index 25437b89a02..8b7164b9f57 100644
--- a/source/blender/blenkernel/intern/node_shaders.c
+++ b/source/blender/blenkernel/intern/node_shaders.c
@@ -259,7 +259,7 @@ static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in,
VECCOPY(shi->vn, nor);
}
- node_shader_lamp_loop(shi, &shrnode);
+ node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */
/* write to outputs */
if(node->custom1 & SH_NODE_MAT_DIFF) {
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index f9015dc1161..9fdaf8f4e62 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -105,7 +105,7 @@ typedef struct ShadeInput
short thread;
short osatex, puno;
int mask;
- int depth;
+ int depth; /* 1 or larger on raytrace shading */
unsigned int lay;
} ShadeInput;
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c
index 7d0ab78881f..671fe0c5537 100644
--- a/source/blender/render/intern/source/ray.c
+++ b/source/blender/render/intern/source/ray.c
@@ -36,8 +36,9 @@
#include "DNA_material_types.h"
#include "DNA_lamp_types.h"
-#include "BKE_utildefines.h"
#include "BKE_global.h"
+#include "BKE_node.h"
+#include "BKE_utildefines.h"
#include "BLI_arithb.h"
#include "BLI_rand.h"
@@ -1445,25 +1446,15 @@ static void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr)
shade_input_set_coords(shi, is->u, is->v, 0, 1, 2);
}
- // SWAP(int, osatex, shi->osatex); XXXXX!!!!
-
- if(is->mode==DDA_SHADOW_TRA) shade_color(shi, shr);
- else {
-
- shade_lamp_loop(shi, shr);
-
- if(shi->translucency!=0.0) {
- ShadeResult shr_t;
- VecMulf(shi->vn, -1.0);
- VecMulf(shi->facenor, -1.0);
- shade_lamp_loop(shi, &shr_t);
- shr->diff[0]+= shi->translucency*shr_t.diff[0];
- shr->diff[1]+= shi->translucency*shr_t.diff[1];
- shr->diff[2]+= shi->translucency*shr_t.diff[2];
- VecMulf(shi->vn, -1.0);
- VecMulf(shi->facenor, -1.0);
- }
+ if(is->mode==DDA_SHADOW_TRA)
+ shade_color(shi, shr);
+ else if(shi->mat->nodetree && shi->mat->use_nodes) {
+ ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
+ shi->mat= vlr->mat; /* shi->mat is being set in nodetree */
}
+ else
+ shade_material_loop(shi, shr);
+
SWAP(int, osatex, shi->osatex); // XXXXX!!!!
@@ -1549,12 +1540,13 @@ static float shade_by_transmission(Isect *is, ShadeInput *shi, ShadeResult *shr)
if (shi->mat->tx_limit <= 0.0) {
d= 1.0;
- } else {
- /* shi.co[] calculated by shade_ray() */
- dx= shi->co[0] - is->start[0];
- dy= shi->co[1] - is->start[1];
- dz= shi->co[2] - is->start[2];
- d= sqrt(dx*dx+dy*dy+dz*dz);
+ }
+ else {
+ /* shi.co[] calculated by shade_ray() */
+ dx= shi->co[0] - is->start[0];
+ dy= shi->co[1] - is->start[1];
+ dz= shi->co[2] - is->start[2];
+ d= sqrt(dx*dx+dy*dy+dz*dz);
if (d > shi->mat->tx_limit)
d= shi->mat->tx_limit;
@@ -1598,13 +1590,15 @@ static void traceray(ShadeInput *origshi, short depth, float *start, float *vec,
shi.lay= origshi->lay;
shi.do_preview= 0;
+ memset(&shr, 0, sizeof(ShadeResult));
+
shade_ray(&isec, &shi, &shr);
if (traflag & RAY_TRA)
d= shade_by_transmission(&isec, &shi, &shr);
if(depth>0) {
- if(shi.mat->mode & (MA_RAYTRANSP|MA_ZTRA) && shr.alpha < 1.0) {
+ if(shi.mat->mode_l & (MA_RAYTRANSP|MA_ZTRA) && shr.alpha < 1.0) {
float nf, f, f1, refract[3], tracol[4];
tracol[0]= shi.r;
@@ -1650,7 +1644,7 @@ static void traceray(ShadeInput *origshi, short depth, float *start, float *vec,
else
col[3]= 1.0;
- if(shi.mat->mode & MA_RAYMIRROR) {
+ if(shi.mat->mode_l & MA_RAYMIRROR) {
f= shi.ray_mirror;
if(f!=0.0) f*= fresnel_fac(shi.view, shi.vn, shi.mat->fresnel_mir_i, shi.mat->fresnel_mir);
}
@@ -1825,7 +1819,7 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr)
float i, f, f1, fr, fg, fb, vec[3], mircol[4], tracol[4];
int do_tra, do_mir;
- do_tra= ((shi->mat->mode & (MA_RAYTRANSP|MA_ZTRA)) && shr->alpha!=1.0);
+ do_tra= ((shi->mat->mode & (MA_RAYTRANSP)) && shr->alpha!=1.0);
do_mir= ((shi->mat->mode & MA_RAYMIRROR) && shi->ray_mirror!=0.0);
vlr= shi->vlr;
@@ -1834,12 +1828,8 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr)
tracol[3]= shr->alpha;
- if(shi->mat->mode & MA_RAYTRANSP) {
- refraction(refract, shi->vn, shi->view, shi->ang);
- traceray(shi, shi->mat->ray_depth_tra, shi->co, refract, tracol, shi->vlr, RAY_TRA|RAY_TRAFLIP);
- }
- else
- traceray(shi, shi->mat->ray_depth_tra, shi->co, shi->view, tracol, shi->vlr, 0);
+ refraction(refract, shi->vn, shi->view, shi->ang);
+ traceray(shi, shi->mat->ray_depth_tra, shi->co, refract, tracol, shi->vlr, RAY_TRA|RAY_TRAFLIP);
f= shr->alpha; f1= 1.0-f;
fr= 1.0+ shi->mat->filter*(shi->r-1.0);
diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 0d7d3fd1efa..c78ca424d91 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2109,6 +2109,9 @@ void shade_input_set_coords(ShadeInput *shi, float u, float v, int i1, int i2, i
shi->tang[0]= shi->tang[1]= shi->tang[2]= 0.0f;
}
+ /* used in nodes */
+ VECCOPY(shi->vno, shi->vn);
+
if(R.r.mode & R_SPEED) {
float *s1, *s2, *s3;
@@ -2365,16 +2368,18 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
VecMulf(shi->facenor, -1.0);
}
- if(R.r.mode & R_RAYTRACE) {
- if(shi->ray_mirror!=0.0 || ((shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0)) {
- ray_trace(shi, shr);
+ /* depth >= 1 when ray-shading */
+ if(shi->depth==0) {
+ if(R.r.mode & R_RAYTRACE) {
+ if(shi->ray_mirror!=0.0 || ((shi->mat->mode & MA_RAYTRANSP) && shr->alpha!=1.0)) {
+ ray_trace(shi, shr);
+ }
}
- }
- else {
- /* doesnt look 'correct', but is better for preview, plus envmaps dont raytrace this */
- if(shi->mat->mode & MA_RAYTRANSP) shr->alpha= 1.0;
- }
-
+ else {
+ /* doesnt look 'correct', but is better for preview, plus envmaps dont raytrace this */
+ if(shi->mat->mode & MA_RAYTRANSP) shr->alpha= 1.0;
+ }
+ }
}
/* x,y: window coordinate from 0 to rectx,y */
@@ -2594,7 +2599,6 @@ void *shadepixel(ShadePixelInfo *shpi, float x, float y, int z, volatile int fac
}
/* ------ main shading loop -------- */
- VECCOPY(shi.vno, shi.vn);
if(shi.mat->nodetree && shi.mat->use_nodes) {
ntreeShaderExecTree(shi.mat->nodetree, &shi, shr);