summaryrefslogtreecommitdiffstats
path: root/src/display
diff options
context:
space:
mode:
authorJasper van de Gronde <jasper.vandegronde@gmail.com>2009-04-03 15:16:18 +0000
committerjaspervdg <jaspervdg@users.sourceforge.net>2009-04-03 15:16:18 +0000
commit863cc2bbd59361f196a10b08dc52f1f32ccc1e86 (patch)
treee885bbc1df3cfa943dd0f1136009e63cc9ccc7cc /src/display
parentio/crystalegg.xml: Fix a couple of textual errors. (diff)
downloadinkscape-863cc2bbd59361f196a10b08dc52f1f32ccc1e86.tar.gz
inkscape-863cc2bbd59361f196a10b08dc52f1f32ccc1e86.zip
And now gradients should be (almost) perfect... The gradient vector is set up to be a good approximation to the "true" gradient and it is used consistently throughout (I hope).
Also some other, minor, tweaks and a small bugfix. (bzr r7616)
Diffstat (limited to 'src/display')
-rw-r--r--src/display/nr-3dutils.cpp11
-rw-r--r--src/display/nr-filter-component-transfer.cpp1
-rw-r--r--src/display/nr-filter-diffuselighting.cpp13
-rw-r--r--src/display/nr-filter-displacement-map.cpp4
4 files changed, 11 insertions, 18 deletions
diff --git a/src/display/nr-3dutils.cpp b/src/display/nr-3dutils.cpp
index dd1419f2b..89c21940a 100644
--- a/src/display/nr-3dutils.cpp
+++ b/src/display/nr-3dutils.cpp
@@ -125,13 +125,14 @@ void compute_surface_normal(Fvector &N, gdouble ss, NRPixBlock *in, int i, int j
alpha_idx_y = alpha_idx + 4*(k-1)*dy*w;
for (l = START(x_carac); l <= FINISH(x_carac); l++) {
alpha = (data + alpha_idx_y + 4*dx*(l-1))[3];
- accu_x += K_X[y_carac][x_carac][k][l] * alpha / 255;
- accu_y += K_X[x_carac][y_carac][l][k] * alpha / 255;
+ accu_x += K_X[y_carac][x_carac][k][l] * alpha;
+ accu_y += K_X[x_carac][y_carac][l][k] * alpha;
}
}
- N[X_3D] = -1 * ss * FACTOR_X[y_carac][x_carac] * accu_x / dx;
- N[Y_3D] = -1 * ss * FACTOR_X[x_carac][y_carac] * accu_y / dy;
- N[Z_3D] = 1;
+ ss /= 255.0; // Correction for scale of pixel values
+ N[X_3D] = -ss * FACTOR_X[y_carac][x_carac] * accu_x / dx;
+ N[Y_3D] = -ss * FACTOR_X[x_carac][y_carac] * accu_y / dy;
+ N[Z_3D] = 1.0;
normalize_vector(N);
//std::cout << "(" << N[X_3D] << ", " << N[Y_3D] << ", " << N[Z_3D] << ")" << std::endl;
}
diff --git a/src/display/nr-filter-component-transfer.cpp b/src/display/nr-filter-component-transfer.cpp
index 6f9e2b712..bd52c071e 100644
--- a/src/display/nr-filter-component-transfer.cpp
+++ b/src/display/nr-filter-component-transfer.cpp
@@ -59,7 +59,6 @@ int FilterComponentTransfer::render(FilterSlot &slot, FilterUnits const &/*units
free_in_on_exit = true;
}
bool premultiplied = in->mode == NR_PIXBLOCK_MODE_R8G8B8A8P;
- g_message("Premultiplied=%s", premultiplied?"yes":"no");
NRPixBlock *out = new NRPixBlock;
nr_pixblock_setup_fast(out, in->mode, x0, y0, x1, y1, true);
diff --git a/src/display/nr-filter-diffuselighting.cpp b/src/display/nr-filter-diffuselighting.cpp
index 9ae231d39..bf5b97fb1 100644
--- a/src/display/nr-filter-diffuselighting.cpp
+++ b/src/display/nr-filter-diffuselighting.cpp
@@ -43,13 +43,6 @@ FilterPrimitive * FilterDiffuseLighting::create() {
FilterDiffuseLighting::~FilterDiffuseLighting()
{}
-#define COMPUTE_INTER(inter, N, L, kd) \
-do {\
- (inter) = (kd) * NR::scalar_product((N), (L)); \
- if ((inter) < 0) (inter) = 0; \
-}while(0)
-
-
int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) {
NRPixBlock *in = slot.get(_input);
if (!in) {
@@ -92,7 +85,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) {
//finish the work
for (i = 0, j = 0; i < w*h; i++) {
NR::compute_surface_normal(N, ss, in, i / w, i % w, dx, dy);
- COMPUTE_INTER(inter, N, L, kd);
+ inter = kd * NR::scalar_product(N, L);
data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]);
data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]);
@@ -118,7 +111,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) {
i % w + x0,
i / w + y0,
ss * (double) data_i[4*i+3]/ 255);
- COMPUTE_INTER(inter, N, L, kd);
+ inter = kd * NR::scalar_product(N, L);
data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]);
data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]);
@@ -144,7 +137,7 @@ int FilterDiffuseLighting::render(FilterSlot &slot, FilterUnits const &units) {
i / w + y0,
ss * (double) data_i[4*i+3]/ 255);
sl->light_components(LC, L);
- COMPUTE_INTER(inter, N, L, kd);
+ inter = kd * NR::scalar_product(N, L);
data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_RED]);
data_o[j++] = CLAMP_D_TO_U8(inter * LC[LIGHT_GREEN]);
diff --git a/src/display/nr-filter-displacement-map.cpp b/src/display/nr-filter-displacement-map.cpp
index 31d562f21..29815abbb 100644
--- a/src/display/nr-filter-displacement-map.cpp
+++ b/src/display/nr-filter-displacement-map.cpp
@@ -114,10 +114,10 @@ static void performDisplacement(NRPixBlock const* texture, NRPixBlock const* map
pixel_t mapValue = pixelValue(map, xmap, ymap);
double xtex = xout + (Xneedsdemul ?
(mapValue[3]==0?0:(scalex * (mapValue[Xchannel] - mapValue[3]*0.5) / mapValue[3])) :
- scalex * (mapValue[Xchannel] - 127.5));
+ (scalex * (mapValue[Xchannel] - 127.5)));
double ytex = yout + (Yneedsdemul ?
(mapValue[3]==0?0:(scaley * (mapValue[Ychannel] - mapValue[3]*0.5) / mapValue[3])) :
- scaley * (mapValue[Ychannel] - 127.5));
+ (scaley * (mapValue[Ychannel] - 127.5)));
out_data[(xout-out->area.x0) + (out->area.x1-out->area.x0)*(yout-out->area.y0)] = interpolatePixels<DATA_PREMULTIPLIED>(texture, xtex, ytex);
}