After investigations, i've found what's going wrong.
the scene.pixels[] array is getting refreshed on booth x and y at the same pixel's increment.
I've found out by using printnl(x + " " + y)
Quote:x y
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
. .
. .
. .
639 479
This is wrong for an image with a 1:1.33 ratio.
I'm trying now to modify this part of the code to float, to maintain the proper pixel's refresh speed.
Quote:void draw() {
int x, y, u, bu;
int newpix;
float mX, mY, du;
newpix = 0;
u = 0;
bu= 0;
mX = 0;
mY = 0;
for(int i = WIDTHSEG+1; i < WHSEG-WIDTHSEG-1; i++) {
bump[i] = (vel[i-1]
+ vel[i+1]
+ vel[i+WIDTHSEG]
+ vel[i-WIDTHSEG]
+ vel[i-WIDTHSEG-1]/1
+ vel[i-WIDTHSEG+1]/2
+ vel[i+WIDTHSEG-1]/2
+ vel[i+WIDTHSEG+1]/1)/4 - bump[i];
bump[i] *= 0.90;
}
for(int i = 0; i < WHSEG; i++) {
t[i] = vel[i];
vel[i] = bump[i];
bump[i] = t[i];
}
for(int i = 1; i < WH; i++)
{
x = i%WIDTH; // x should be equal to 1.3333... when y is 1
y = i/HEIGHT; // y should be equal to 1 when x is 1.3333...
// println(x + " " + y );
newpix = 0;
if(x > SEG && x < WIDTH-SEG && y > SEG && y < HEIGHT-SEG)
{
bu = (int)(x/SEG+((y/SEG)*WIDTHSEG));
mX = (float)((bump[bu] - bump[bu-1]) + (bump[bu+1] - bump[bu]))*32;
mY = (float)((bump[bu] - bump[bu-WIDTHSEG]) + (bump[bu+WIDTHSEG] - bump[bu]))/32;
mX = constrain(mX,-8,1);
mY = constrain(mY,-8,1);
u = (int)(x+mX+(y+mY)*WIDTH);
if(u < WH && u > 0)
{
newpix=scene.pixels[u];
}
}
loadPixels();
pixels[i] = newpix;
updatePixels();
}
Any help is warmly welcome ;)
Studying code and trying to understand it, my new hobby now :P
(Processing is really addictive when you dive into..)