[Bf-committers] Bump mapping computation issue
Stephane SOPPERA
stephane.soppera at wanadoo.fr
Sat Dec 4 21:40:55 CET 2004
Hi,
Since I felt that bumpmapping in blender was behaving strangly, I
decided to setup a simple test:
http://perso.wanadoo.fr/stephane.soppera/blender/bump_bug/bug_bump.blend
This test scene is made of:
* two textured planes: these planes have a material with a texture
for bumpmapping. The texture is a simple bitmap. The material has
no specular, only diffuse. Diffuse function is lambert one.
* a parallel light (sun light in blender)
* an orthographic camera
For the animation, the light and the planes are parented to an empty
that simply rotates around the Z axis.
Since the material diffuse function is lambert one and since the light
is parented to the same empty as the planes, the colors of pixels of the
planes should always be the same during the whole animation. (with
lambert, colors of pixels only depends of point normal and light direction).
But that's not what is happening, see the result of that animation in
the following video:
http://perso.wanadoo.fr/stephane.soppera/blender/bump_bug/videos/bug_bump_235.avi
To illustrate the result I excpected, I made an equivalent test scene in
3DSMax:
http://perso.wanadoo.fr/stephane.soppera/blender/bump_bug/videos/bug_bump_3ds.avi
It seems to me that the problem comes from perturbated normal
computation made by blender.
The formula for normal computation should be:
perturbated_normal=initial_normal+dI/du*dP/du+dI/dv*dP/dv
where dI/du and dI/dv are the partial derivates of the texture color in
texture plane (these are scalars), and where dP/du and dP/dv are the
partial derivates of the position against texture coordinates (vector
dP/du "points" in the direction of greater "u").
But in void do_material_tex(ShadeInput *shi) function (texture.c),
normal is computed with:
shi->vn[0]+= Tnor*tex->norfac*tex->nor[0];
shi->vn[1]+= Tnor*tex->norfac*tex->nor[1];
shi->vn[2]+= Tnor*tex->norfac*tex->nor[2];
instead of dP/du and dP/dv, the x and y vectors of the space where
shi->vn is expressed are used.
I thinks that's where the problem is coming from. Am I right?
About, shi->vn, In which space is it expressed?
Thanks,
Stephane
--
Stephane SOPPERA
http://perso.wanadoo.fr/stephane.soppera
More information about the Bf-committers
mailing list