2024-01-20 14:56:37 +01:00
|
|
|
using BenchmarkTools
|
|
|
|
using LinearAlgebra
|
|
|
|
using Rotations
|
|
|
|
|
2024-01-20 22:53:43 +01:00
|
|
|
using Images
|
|
|
|
using GeometryBasics
|
2024-01-20 14:56:37 +01:00
|
|
|
using Colors
|
|
|
|
using GLMakie
|
|
|
|
|
|
|
|
##
|
|
|
|
include("SimpleRayTracer.jl")
|
|
|
|
|
|
|
|
world = SimpleRayTracer.World(RGB(.1,.5,.5))
|
2024-01-23 22:51:29 +01:00
|
|
|
push!(
|
|
|
|
world,
|
|
|
|
SimpleRayTracer.Plane(
|
|
|
|
Vec3(0.0, -2.0, 0.0),
|
|
|
|
Vec3(0.0, 1.0, 0.0),
|
|
|
|
RGB(.5, .5, .5)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2024-01-20 22:53:43 +01:00
|
|
|
push!(world, SimpleRayTracer.Sphere(Vec3(-4.0, 0.0, 0.0), 2.0, RGB(1, 0, 0)))
|
|
|
|
push!(world, SimpleRayTracer.Sphere(Vec3( 4.0, 0.0, 0.0), 2.0, RGB(0, 1, 0)))
|
|
|
|
push!(world, SimpleRayTracer.Sphere(Vec3( 0.0, 0.0, 3.0), 2.0, RGB(0, 0, 1)))
|
2024-01-20 14:56:37 +01:00
|
|
|
|
2024-01-20 22:53:43 +01:00
|
|
|
camera = SimpleRayTracer.PinHoleCamera(
|
2024-01-24 09:34:24 +01:00
|
|
|
Vec3(0.0, 4.0, -8.0),
|
2024-01-20 22:53:43 +01:00
|
|
|
Vec3(0.0, 0.0, 0.0),
|
|
|
|
Vec3(0.0, 1.0, 0.0),
|
2024-01-24 09:34:24 +01:00
|
|
|
0.005,
|
|
|
|
(0.02, 0.01),
|
2024-01-20 22:53:43 +01:00
|
|
|
)
|
2024-01-20 14:56:37 +01:00
|
|
|
|
2024-01-20 22:53:43 +01:00
|
|
|
resolution = (512, 256);
|
|
|
|
img = SimpleRayTracer.render(world, camera, resolution);
|
|
|
|
|
2024-01-23 22:51:29 +01:00
|
|
|
# fig = Figure(size=resolution)
|
|
|
|
# ax = GLMakie.Axis(fig[1,1], aspect=2)
|
|
|
|
# image!(ax, img |> rotr90)
|
2024-01-20 22:53:43 +01:00
|
|
|
Images.save("test.png", img)
|