diff options
author | Ton Roosendaal <ton@blender.org> | 2011-02-19 19:24:14 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2011-02-19 19:24:14 +0300 |
commit | e86b787bcc8248b94583b1a78ed883150ea2884b (patch) | |
tree | ac3af7d53b056d95191154e389e96d09ade0fb71 /source | |
parent | 6481921b9ad3d6e50a2aaa2f4a03e2fefcb14a94 (diff) |
Bugfix #25967
Shader nodes: option "backface" failed for materials using
full oversampling.
The usage of shi->flippednorm in render code is heavily messed
up... also flipping vertexnormals themselves feels wrong.
Marked it in code with XXX for future fixups.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index 38ed5a0a42c..e4f0de688be 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -840,6 +840,36 @@ void shade_input_set_normals(ShadeInput *shi) shade_input_flip_normals(shi); } +/* XXX shi->flippednor messes up otherwise */ +static void shade_input_set_vertex_normals(ShadeInput *shi) +{ + float u= shi->u, v= shi->v; + float l= 1.0f+u+v; + + /* calculate vertexnormals */ + if(shi->vlr->flag & R_SMOOTH) { + float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3; + + shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0]; + shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1]; + shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2]; + + // use unnormalized normal (closer to games) + VECCOPY(shi->nmapnorm, shi->vn); + + normalize_v3(shi->vn); + } + else + { + VECCOPY(shi->vn, shi->facenor); + VECCOPY(shi->nmapnorm, shi->vn); + } + + /* used in nodes */ + VECCOPY(shi->vno, shi->vn); +} + + /* use by raytrace, sss, bake to flip into the right direction */ void shade_input_flip_normals(ShadeInput *shi) { @@ -1379,7 +1409,10 @@ void shade_samples_fill_with_ps(ShadeSample *ssamp, PixStr *ps, int x, int y) shi->samplenr= R.shadowsamplenr[shi->thread]++; /* this counter is not being reset per pixel */ shade_input_set_viewco(shi, x, y, xs, ys, (float)ps->z); shade_input_set_uv(shi); - shade_input_set_normals(shi); + if(shi_cp==0) + shade_input_set_normals(shi); + else /* XXX shi->flippednor messes up otherwise */ + shade_input_set_vertex_normals(shi); shi_cp= 1; shi++; |