diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-21 17:46:49 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-07-21 17:46:49 +0400 |
commit | 0b49dc77deaa5e4bf148be4e17ae73119e6aa769 (patch) | |
tree | eff1000f20029183267b7d086adcfd44e90af07e /source/blender/blenlib | |
parent | d19bb6ffcf1364340cdb87b7bd6559ff90de8c0e (diff) |
2.5: Bump Mapping
Patch by Alfredo de Greef. Considerably improves the quality of bump
mapping, and texture filtering for displacement and warp too. Mainly
this is achieved by getting the texture derivatives just right in
various cases, many thanks to Alfredo for figuring this one out, works
great.
This is enabled by default now, but disabled still for existing
textures to preserve backwards compatibility. Can be enabled with
the "New Bump" option in the material texture slot in the outliner.
Also, I made the range for the normal factor a bit smaller since this
gives stronger effects, but note that you can still type in larger
values than the slider allows.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 03be10dd0b1..f7313c8b37a 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2197,25 +2197,23 @@ void VecNegf(float *v1) void VecOrthoBasisf(float *v, float *v1, float *v2) { - float f = (float)sqrt(v[0]*v[0] + v[1]*v[1]); + const float f = (float)sqrt(v[0]*v[0] + v[1]*v[1]); if (f < 1e-35f) { // degenerate case - v1[0] = 0.0f; v1[1] = 1.0f; v1[2] = 0.0f; - if (v[2] > 0.0f) { - v2[0] = 1.0f; v2[1] = v2[2] = 0.0f; - } - else { - v2[0] = -1.0f; v2[1] = v2[2] = 0.0f; - } + v1[0] = (v[2] < 0.0f) ? -1.0f : 1.0f; + v1[1] = v1[2] = v2[0] = v2[2] = 0.0f; + v2[1] = 1.0f; } else { - f = 1.0f/f; - v1[0] = v[1]*f; - v1[1] = -v[0]*f; - v1[2] = 0.0f; + const float d= 1.0f/f; - Crossf(v2, v, v1); + v1[0] = v[1]*d; + v1[1] = -v[0]*d; + v1[2] = 0.0f; + v2[0] = -v[2]*v1[1]; + v2[1] = v[2]*v1[0]; + v2[2] = v[0]*v1[1] - v[1]*v1[0]; } } |