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
diff options
context:
space:
mode:
authorM.G. Kishalmi <lmg@kishalmi.net>2011-02-14 21:18:46 +0300
committerM.G. Kishalmi <lmg@kishalmi.net>2011-02-14 21:18:46 +0300
commit20553d4064e790f42fe707b8b6c5e6451e983eb7 (patch)
tree8453025eb4106b26ed323a16da222153f117ab81 /source/blender/gpu/intern/gpu_material.c
parent8b7482892b2ecb456be60b42fe1625156d19e954 (diff)
This commit will switch blender to use tangent space generated within
the two files mikktspace.h and mikktspace.c. These are standalone files which can be redistributed into any other application and regenerate the same tangent spaces. The implementation is independent of the ordering of faces and the vertex ordering of faces.
Diffstat (limited to 'source/blender/gpu/intern/gpu_material.c')
-rw-r--r--source/blender/gpu/intern/gpu_material.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index cb28d0dbe47..fb8c7465a4d 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -894,6 +894,7 @@ static void do_material_tex(GPUShadeInput *shi)
int tex_nr, rgbnor, talpha;
int init_done = 0, iBumpSpacePrev;
GPUNodeLink *vNorg, *vNacc, *fPrevMagnitude;
+ int iFirstTimeNMap=1;
GPU_link(mat, "set_value", GPU_uniform(&one), &stencil);
@@ -902,7 +903,7 @@ static void do_material_tex(GPUShadeInput *shi)
GPU_link(mat, "texco_object", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
GPU_builtin(GPU_INVERSE_OBJECT_MATRIX),
GPU_builtin(GPU_VIEW_POSITION), &texco_object);
- GPU_link(mat, "texco_tangent", GPU_attribute(CD_TANGENT, ""), &texco_tangent);
+ //GPU_link(mat, "texco_tangent", GPU_attribute(CD_TANGENT, ""), &texco_tangent);
GPU_link(mat, "texco_global", GPU_builtin(GPU_INVERSE_VIEW_MATRIX),
GPU_builtin(GPU_VIEW_POSITION), &texco_global);
@@ -1037,7 +1038,20 @@ static void do_material_tex(GPUShadeInput *shi)
GPU_link(mat, "mtex_negate_texnormal", tnor, &tnor);
if(mtex->normapspace == MTEX_NSPACE_TANGENT)
- GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
+ {
+ if(iFirstTimeNMap!=0)
+ {
+ // use unnormalized normal (this is how we bake it - closer to gamedev)
+ GPUNodeLink *vNegNorm;
+ GPU_link(mat, "vec_math_negate", GPU_builtin(GPU_VIEW_NORMAL), &vNegNorm);
+ GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), vNegNorm, tnor, &newnor);
+ iFirstTimeNMap = 0;
+ }
+ else // otherwise use accumulated perturbations
+ {
+ GPU_link(mat, "mtex_nspace_tangent", GPU_attribute(CD_TANGENT, ""), shi->vn, tnor, &newnor);
+ }
+ }
else
newnor = tnor;