SBWO/rt.jl

40 lines
919 B
Julia

using BenchmarkTools
using LinearAlgebra
using Rotations
using Images
using GeometryBasics
using Colors
using GLMakie
##
include("SimpleRayTracer.jl")
world = SimpleRayTracer.World(RGB(.1,.5,.5))
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)))
camera = SimpleRayTracer.OrthogonalCamera(
Vec3(0.0, 0.0, -5.0),
(20.0, 10.0),
RotXYZ(0.0, 0.0, 0.0),
)
camera = SimpleRayTracer.PinHoleCamera(
Vec3(0.0, 1.0, -8.0),
Vec3(0.0, 0.0, 0.0),
Vec3(0.0, 1.0, 0.0),
1.0,
(4.0, 2.0),
)
resolution = (512, 256);
img = SimpleRayTracer.render(world, camera, resolution);
# img |> size
fig = Figure(size=resolution)
ax = GLMakie.Axis(fig[1,1], aspect=2)
image!(ax, img |> rotr90)
Images.save("test.png", img)