plug-ins/Lighting/lighting_main.c applied the first of two patches

2004-04-03  Sven Neumann  <sven@gimp.org>

	* plug-ins/Lighting/lighting_main.c
	* plug-ins/Lighting/lighting_shade.c: applied the first of two
	patches attached to bug #138788 by William Skaggs.
This commit is contained in:
Sven Neumann 2004-04-02 23:45:36 +00:00 committed by Sven Neumann
parent 6531b323ef
commit df2a470e50
3 changed files with 19 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2004-04-03 Sven Neumann <sven@gimp.org>
* plug-ins/Lighting/lighting_main.c
* plug-ins/Lighting/lighting_shade.c: applied the first of two
patches attached to bug #138788 by William Skaggs.
2004-04-02 Simon Budig <simon@gimp.org>
* plug-ins/common/whirlpinch.c: set a proper pixelfetcher

View File

@ -105,7 +105,7 @@ check_drawables (void)
if (mapvals.bump_mapped)
{
if (!gimp_drawable_is_gray (mapvals.bumpmap_id) ||
if (gimp_drawable_is_indexed (mapvals.bumpmap_id) ||
(gimp_drawable_width (mapvals.drawable_id) !=
gimp_drawable_width (mapvals.bumpmap_id)) ||
(gimp_drawable_height (mapvals.drawable_id) !=

View File

@ -35,7 +35,7 @@ phong_shade (GimpVector3 *position,
{
GimpRGB ambient_color, diffuse_color, specular_color;
gdouble nl, rv, dist;
GimpVector3 l, nn, v, n;
GimpVector3 l, v, n, lnormal, h;
/* Compute ambient intensity */
/* ========================= */
@ -59,6 +59,12 @@ phong_shade (GimpVector3 *position,
nl = 2.0 * gimp_vector3_inner_product (&n, &l);
lnormal.x = l.x;
lnormal.y = l.y;
lnormal.z = l.z;
gimp_vector3_normalize (&lnormal);
if (nl >= 0.0)
{
/* Compute (R*V)^alpha term of Phong's equation */
@ -67,10 +73,12 @@ phong_shade (GimpVector3 *position,
gimp_vector3_sub (&v, viewpoint, position);
gimp_vector3_normalize (&v);
gimp_vector3_mul (&n, nl);
gimp_vector3_sub (&nn, &n, &l);
rv = gimp_vector3_inner_product (&nn, &v);
gimp_vector3_add (&h, &lnormal, &v);
gimp_vector3_normalize (&h);
rv = MAX (0., gimp_vector3_inner_product (&n, &h));
rv = pow (rv, mapvals.material.highlight);
rv *= nl;
/* Compute diffuse and specular intensity contribution */
/* =================================================== */
@ -279,8 +287,6 @@ precompute_normals (gint x1,
bpp = gimp_drawable_bpp(mapvals.bumpmap_id);
}
bpp = gimp_drawable_bpp(mapvals.bumpmap_id);
gimp_pixel_rgn_get_row (&bump_region, bumprow, x1, y, x2 - x1);
if (mapvals.bumpmaptype > 0)