48 lines
1.2 KiB
Java
48 lines
1.2 KiB
Java
package renderer;
|
|
|
|
import basics.math.algebra.Vector;
|
|
import renderer.canvas.ContributionBuffer;
|
|
|
|
import java.util.concurrent.Callable;
|
|
|
|
public class TileProcessor implements Callable<Void> {
|
|
|
|
private final ContributionBuffer buffer;
|
|
|
|
private FragmentProgram program;
|
|
|
|
private int width;
|
|
private int height;
|
|
private int x0;
|
|
private int y0;
|
|
private int x1;
|
|
private int y1;
|
|
|
|
public TileProcessor(ContributionBuffer buffer, int x0, int y0, int x1, int y1, int width, int height, FragmentProgram program) {
|
|
this.buffer = buffer;
|
|
this.width = width;
|
|
this.height = height;
|
|
this.x0 = x0;
|
|
this.y0 = y0;
|
|
this.x1 = x1;
|
|
this.y1 = y1;
|
|
this.program = program;
|
|
}
|
|
|
|
@Override
|
|
public Void call() throws Exception {
|
|
|
|
for (int x = this.x0; x < x1; x++) {
|
|
double u = (x + Math.random()) / (double) this.width * 2.0 - 1.0;
|
|
|
|
for (int y = this.y0; y < y1; y++) {
|
|
double v = (y + Math.random()) / (double) this.height * 2.0 - 1.0;
|
|
|
|
this.buffer.contribute(x, y, this.program.fragment(u, v));
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|