|
|
|
@ -3,6 +3,7 @@ package eu.jonahbauer.raytracing;
|
|
|
|
|
import eu.jonahbauer.raytracing.material.DielectricMaterial;
|
|
|
|
|
import eu.jonahbauer.raytracing.material.LambertianMaterial;
|
|
|
|
|
import eu.jonahbauer.raytracing.material.MetallicMaterial;
|
|
|
|
|
import eu.jonahbauer.raytracing.math.Vec3;
|
|
|
|
|
import eu.jonahbauer.raytracing.render.Camera;
|
|
|
|
|
import eu.jonahbauer.raytracing.render.Color;
|
|
|
|
|
import eu.jonahbauer.raytracing.render.ImageFormat;
|
|
|
|
@ -15,12 +16,17 @@ import java.nio.file.Path;
|
|
|
|
|
public class Main {
|
|
|
|
|
public static void main(String[] args) throws IOException {
|
|
|
|
|
var scene = new Scene(
|
|
|
|
|
new Sphere(0, -100.5, 1, 100, new LambertianMaterial(new Color(0.8, 0.8, 0.0))),
|
|
|
|
|
new Sphere(0, 0, 1.2, 0.5, new LambertianMaterial(new Color(0.1, 0.2, 0.5))),
|
|
|
|
|
new Sphere(-1, 0, 1, 0.5, new DielectricMaterial(0.75)),
|
|
|
|
|
new Sphere(1, 0, 1, 0.5, new MetallicMaterial(new Color(0.8, 0.6, 0.2), 1.0))
|
|
|
|
|
new Sphere(0, -100.5, - 1, 100, new LambertianMaterial(new Color(0.8, 0.8, 0.0))),
|
|
|
|
|
new Sphere(0, 0, - 1.2, 0.5, new LambertianMaterial(new Color(0.1, 0.2, 0.5))),
|
|
|
|
|
new Sphere(-1, 0, - 1, 0.5, new DielectricMaterial(1.5)),
|
|
|
|
|
new Sphere(-1, 0, - 1, 0.4, new DielectricMaterial(1 / 1.5)),
|
|
|
|
|
new Sphere(1, 0, - 1, 0.5, new MetallicMaterial(new Color(0.8, 0.6, 0.2), 1.0))
|
|
|
|
|
);
|
|
|
|
|
var camera = new Camera(
|
|
|
|
|
800, 450,
|
|
|
|
|
16d / 9 * 2, 2d,
|
|
|
|
|
Vec3.ZERO.plus(Vec3.UNIT_Z).plus(Vec3.UNIT_Y).minus(Vec3.UNIT_X), new Vec3(0.25, -0.5, - 1)
|
|
|
|
|
);
|
|
|
|
|
var camera = new Camera(512, 2, 16 / 9d);
|
|
|
|
|
|
|
|
|
|
var image = camera.render(scene);
|
|
|
|
|
ImageFormat.PNG.write(image, Path.of("scene-" + System.currentTimeMillis() + ".png"));
|
|
|
|
|