SBWO/rt.jl

29 lines
742 B
Julia
Raw Normal View History

using BenchmarkTools
using LinearAlgebra
using Rotations
# using Images
using Colors
using GLMakie
##
include("SimpleRayTracer.jl")
world = SimpleRayTracer.World(RGB(.1,.5,.5))
push!(world, SimpleRayTracer.Sphere(Vec3(-2.5, 0.0, 0.0), 2.0, RGB(1, 0, 0)))
push!(world, SimpleRayTracer.Sphere(Vec3( 2.5, 0.0, 0.0), 2.0, RGB(0, 1, 0)))
push!(world, SimpleRayTracer.Sphere(Vec3( 0.0, 0.0, 2.5), 2.0, RGB(0, 0, 1)))
camera = SimpleRayTracer.OrthogonalCamera(
Vec3(0.0, 0.0, -5.0),
RotXYZ(0.0, 0.0, 0.0),
(5.0, 5.0)
)
resolution = (256, 256)
img = [SimpleRayTracer.trace_ray(world, ray).color for ray in SimpleRayTracer.get_rays(camera, resolution)];
fig = Figure(size=resolution)
ax = Axis(fig[1,1], aspect=1)
image!(ax, img)