mirror of https://github.com/GNOME/gimp.git
Bill Skaggs <weskaggs@primate.ucdavis.edu>
* plug-ins/Lighting/lighting_shade.c: Fix typo responsible for bug #300122, also revise env-mapping code to make it perform better.
This commit is contained in:
parent
02878f0e34
commit
2931f24626
|
@ -1,3 +1,9 @@
|
|||
2005-04-11 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* plug-ins/Lighting/lighting_shade.c: Fix typo responsible for
|
||||
bug #300122, also revise env-mapping code to make it perform
|
||||
better.
|
||||
|
||||
2005-04-11 DindinX <dindinx@gimp.org>
|
||||
|
||||
* plug-ins/common/convmatrix.c: small cleanups, more will come.
|
||||
|
|
|
@ -482,70 +482,76 @@ get_ray_color_ref (GimpVector3 *position)
|
|||
gdouble xf, yf;
|
||||
GimpVector3 normal, *p, v, r;
|
||||
gint k;
|
||||
gdouble tmpval;
|
||||
|
||||
pos_to_float (position->x, position->y, &xf, &yf);
|
||||
|
||||
x = RINT (xf);
|
||||
|
||||
if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
|
||||
normal = mapvals.planenormal;
|
||||
else
|
||||
normal = vertex_normals[1][(gint) RINT (xf)];
|
||||
gimp_vector3_normalize (&normal);
|
||||
|
||||
if (mapvals.transparent_background && heights[1][x] == 0)
|
||||
{
|
||||
gimp_rgb_set_alpha (&color, 0.0);
|
||||
gimp_rgb_set_alpha (&color_sum, 0.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
color = get_image_color (xf, yf, &f);
|
||||
color_sum = color;
|
||||
gimp_rgb_multiply (&color_sum, mapvals.material.ambient_int);
|
||||
|
||||
for (k = 0; k < NUM_LIGHTS; k++)
|
||||
{
|
||||
p = &mapvals.lightsource[k].direction;
|
||||
|
||||
if (!mapvals.lightsource[k].active
|
||||
|| mapvals.lightsource[k].type == NO_LIGHT)
|
||||
continue;
|
||||
else if (mapvals.lightsource[k].type == POINT_LIGHT)
|
||||
p = &mapvals.lightsource[k].position;
|
||||
else
|
||||
p = &mapvals.lightsource[k].direction;
|
||||
|
||||
color_int = mapvals.lightsource[k].color;
|
||||
gimp_rgb_multiply (&color_int, mapvals.lightsource[k].intensity);
|
||||
|
||||
if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
|
||||
{
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&mapvals.planenormal,
|
||||
p,
|
||||
&color,
|
||||
&color_int,
|
||||
mapvals.lightsource[0].type);
|
||||
}
|
||||
else
|
||||
{
|
||||
normal = vertex_normals[1][(gint) RINT (xf)];
|
||||
|
||||
gimp_vector3_sub (&v, &mapvals.viewpoint,position);
|
||||
gimp_vector3_normalize (&v);
|
||||
|
||||
r = compute_reflected_ray (&normal, &v);
|
||||
|
||||
/* Get color in the direction of r */
|
||||
/* =============================== */
|
||||
|
||||
sphere_to_image (&r, &xf, &yf);
|
||||
env_color = peek_env_map (RINT (env_width * xf),
|
||||
RINT (env_height * yf));
|
||||
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&normal,
|
||||
p,
|
||||
&env_color,
|
||||
&color_int,
|
||||
mapvals.lightsource[0].type);
|
||||
}
|
||||
|
||||
gimp_rgb_add (&color_sum, &light_color);
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&normal,
|
||||
p,
|
||||
&color,
|
||||
&color_int,
|
||||
mapvals.lightsource[0].type);
|
||||
}
|
||||
|
||||
gimp_vector3_sub (&v, &mapvals.viewpoint, position);
|
||||
gimp_vector3_normalize (&v);
|
||||
|
||||
r = compute_reflected_ray (&normal, &v);
|
||||
|
||||
/* Get color in the direction of r */
|
||||
/* =============================== */
|
||||
|
||||
sphere_to_image (&r, &xf, &yf);
|
||||
env_color = peek_env_map (RINT (env_width * xf),
|
||||
RINT (env_height * yf));
|
||||
|
||||
tmpval = mapvals.material.diffuse_int;
|
||||
mapvals.material.diffuse_int = 0.;
|
||||
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&normal,
|
||||
&r,
|
||||
&color,
|
||||
&env_color,
|
||||
DIRECTIONAL_LIGHT);
|
||||
|
||||
mapvals.material.diffuse_int = tmpval;
|
||||
|
||||
gimp_rgb_add (&color_sum, &light_color);
|
||||
}
|
||||
|
||||
gimp_rgb_clamp (&color_sum);
|
||||
|
@ -582,13 +588,13 @@ get_ray_color_no_bilinear (GimpVector3 *position)
|
|||
|
||||
for (k = 0; k < NUM_LIGHTS; k++)
|
||||
{
|
||||
p = &mapvals.lightsource[k].direction;
|
||||
|
||||
if (!mapvals.lightsource[k].active
|
||||
|| mapvals.lightsource[k].type == NO_LIGHT)
|
||||
continue;
|
||||
else if (mapvals.lightsource[k].type == POINT_LIGHT)
|
||||
p = &mapvals.lightsource[k].position;
|
||||
else
|
||||
p = &mapvals.lightsource[k].direction;
|
||||
|
||||
color_int = mapvals.lightsource[k].color;
|
||||
gimp_rgb_multiply (&color_int, mapvals.lightsource[k].intensity);
|
||||
|
@ -635,11 +641,18 @@ get_ray_color_no_bilinear_ref (GimpVector3 *position)
|
|||
gdouble xf, yf;
|
||||
GimpVector3 normal, *p, v, r;
|
||||
gint k;
|
||||
gdouble tmpval;
|
||||
|
||||
pos_to_float (position->x, position->y, &xf, &yf);
|
||||
|
||||
x = RINT (xf);
|
||||
|
||||
if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
|
||||
normal = mapvals.planenormal;
|
||||
else
|
||||
normal = vertex_normals[1][(gint) RINT (xf)];
|
||||
gimp_vector3_normalize (&normal);
|
||||
|
||||
if (mapvals.transparent_background && heights[1][x] == 0)
|
||||
{
|
||||
gimp_rgb_set_alpha (&color_sum, 0.0);
|
||||
|
@ -648,76 +661,56 @@ get_ray_color_no_bilinear_ref (GimpVector3 *position)
|
|||
{
|
||||
color = peek (RINT (xf), RINT (yf));
|
||||
color_sum = color;
|
||||
gimp_rgb_multiply (&color_sum, mapvals.material.ambient_int);
|
||||
|
||||
for (k = 0; k < NUM_LIGHTS; k++)
|
||||
{
|
||||
p = &mapvals.lightsource[k].direction;
|
||||
|
||||
if (!mapvals.lightsource[k].active
|
||||
|| mapvals.lightsource[k].type == NO_LIGHT)
|
||||
continue;
|
||||
else if (mapvals.lightsource[k].type == POINT_LIGHT)
|
||||
p = &mapvals.lightsource[k].position;
|
||||
else
|
||||
p = &mapvals.lightsource[k].direction;
|
||||
|
||||
color_int = mapvals.lightsource[k].color;
|
||||
gimp_rgb_multiply (&color_int, mapvals.lightsource[k].intensity);
|
||||
|
||||
if (mapvals.bump_mapped == FALSE || mapvals.bumpmap_id == -1)
|
||||
{
|
||||
pos_to_float (position->x, position->y, &xf, &yf);
|
||||
|
||||
color = peek (RINT (xf), RINT (yf));
|
||||
|
||||
gimp_vector3_sub (&v, &mapvals.viewpoint, position);
|
||||
gimp_vector3_normalize (&v);
|
||||
|
||||
r = compute_reflected_ray (&mapvals.planenormal, &v);
|
||||
|
||||
/* Get color in the direction of r */
|
||||
/* =============================== */
|
||||
|
||||
sphere_to_image (&r, &xf, &yf);
|
||||
env_color = peek_env_map (RINT (env_width * xf),
|
||||
RINT (env_height * yf));
|
||||
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&mapvals.planenormal,
|
||||
p,
|
||||
&env_color,
|
||||
&color_int,
|
||||
mapvals.lightsource[0].type);
|
||||
}
|
||||
else
|
||||
{
|
||||
normal = vertex_normals[1][(gint) RINT (xf)];
|
||||
|
||||
pos_to_float (position->x, position->y, &xf, &yf);
|
||||
color = peek (RINT (xf), RINT (yf));
|
||||
|
||||
gimp_vector3_sub (&v, &mapvals.viewpoint, position);
|
||||
gimp_vector3_normalize (&v);
|
||||
|
||||
r = compute_reflected_ray (&normal, &v);
|
||||
|
||||
/* Get color in the direction of r */
|
||||
/* =============================== */
|
||||
|
||||
sphere_to_image (&r, &xf, &yf);
|
||||
env_color = peek_env_map (RINT (env_width * xf),
|
||||
RINT (env_height * yf));
|
||||
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&normal,
|
||||
p,
|
||||
&env_color,
|
||||
&color,
|
||||
&color_int,
|
||||
mapvals.lightsource[0].type);
|
||||
|
||||
gimp_rgb_add (&color_sum, &light_color);
|
||||
}
|
||||
}
|
||||
|
||||
gimp_vector3_sub (&v, &mapvals.viewpoint, position);
|
||||
gimp_vector3_normalize (&v);
|
||||
|
||||
r = compute_reflected_ray (&normal, &v);
|
||||
|
||||
/* Get color in the direction of r */
|
||||
/* =============================== */
|
||||
|
||||
sphere_to_image (&r, &xf, &yf);
|
||||
env_color = peek_env_map (RINT (env_width * xf),
|
||||
RINT (env_height * yf));
|
||||
|
||||
tmpval = mapvals.material.diffuse_int;
|
||||
mapvals.material.diffuse_int = 0.;
|
||||
|
||||
light_color = phong_shade (position,
|
||||
&mapvals.viewpoint,
|
||||
&normal,
|
||||
&r,
|
||||
&color,
|
||||
&env_color,
|
||||
DIRECTIONAL_LIGHT);
|
||||
|
||||
mapvals.material.diffuse_int = tmpval;
|
||||
|
||||
gimp_rgb_add (&color_sum, &light_color);
|
||||
}
|
||||
|
||||
gimp_rgb_clamp (&color_sum);
|
||||
|
|
Loading…
Reference in New Issue