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:
authorTon Roosendaal <ton@blender.org>2004-12-06 00:49:13 +0300
committerTon Roosendaal <ton@blender.org>2004-12-06 00:49:13 +0300
commit1e811c7886bef99ff81f6990f4337f526c3676bd (patch)
treeb5eed0d27d35c0d5d9c4d3356b3277537a5e6674 /source/blender/src/previewrender.c
parent0b24f20a79c946d9dca7b67e48d7a578d373d789 (diff)
Bugfix: normal mapping for textures wasn't rotated back to view space,
causing weird results on camera moves or object rotations. Added: support for "normal maps". See for example: http://members.shaw.ca/jimht03/normal.html The Image panel in Texture buttons has new option "Normal Map" for it. When this is used, normals are read straight from RGB values, and blended with the current normal.
Diffstat (limited to 'source/blender/src/previewrender.c')
-rw-r--r--source/blender/src/previewrender.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/src/previewrender.c b/source/blender/src/previewrender.c
index b36483837d3..7bc19a87821 100644
--- a/source/blender/src/previewrender.c
+++ b/source/blender/src/previewrender.c
@@ -803,12 +803,12 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y,char *
shi->displace[0]= shi->displace[1]= shi->displace[2]= 0.0;
/* normals flipped in render for smooth... */
- if(smooth && (mat->mapto & MAP_NORM)) VecMulf(shi->vn, -1.0);
+ if( (mat->mapto & MAP_NORM)) VecMulf(shi->vn, -1.0);
do_material_tex(shi);
/* normals flipped in render... */
- if(smooth && (mat->mapto & MAP_NORM)) VecMulf(shi->vn, -1.0);
+ if( (mat->mapto & MAP_NORM)) VecMulf(shi->vn, -1.0);
if(mat->texco & TEXCO_REFL) {
/* normals in render are pointing different... rhm */
@@ -1075,7 +1075,7 @@ void BIF_previewrender(SpaceButs *sbuts)
init_render_world();
init_render_material(mat);
- /* clear imats */
+ /* clear imats, flip normal... (hack because everything is inverted here) */
for(x=0; x<MAX_MTEX; x++) {
if(mat->mtex[x]) {
if(mat->mtex[x]->tex) {
@@ -1083,6 +1083,8 @@ void BIF_previewrender(SpaceButs *sbuts)
if(mat->mtex[x]->tex->env && mat->mtex[x]->tex->env->object)
MTC_Mat4One(mat->mtex[x]->tex->env->object->imat);
+
+ mat->mtex[x]->maptoneg ^= MAP_NORM;
}
if(mat->mtex[x]->object) MTC_Mat4One(mat->mtex[x]->object->imat);
if(mat->mtex[x]->object) MTC_Mat4One(mat->mtex[x]->object->imat);
@@ -1280,8 +1282,11 @@ void BIF_previewrender(SpaceButs *sbuts)
if(mat) {
end_render_material(mat);
for(x=0; x<MAX_MTEX; x++) {
- if(mat->mtex[x] && mat->mtex[x]->tex) end_render_texture(mat->mtex[x]->tex);
- }
+ if(mat->mtex[x] && mat->mtex[x]->tex) {
+ end_render_texture(mat->mtex[x]->tex);
+ mat->mtex[x]->maptoneg ^= MAP_NORM;
+ }
+ }
}
else if(tex) {
end_render_texture(tex);