Sha256: 45542d5d8fcd85cf7d87c81acac0a2c6f2e78ff673d8431f1362eaf7372a5dce

Contents?: true

Size: 443 Bytes

Versions: 1

Compression:

Stored size: 443 Bytes

Contents

module Rubytracer
  class Camera
    def initialize(view, scene)
      @view = view
      @scene = scene
    end

    def colour_of_pixel(row, col)
      ray = @view.eye_ray(row, col)
      obj, t = @scene.intersect(ray)
      if t == Float::INFINITY
        Colour.new(0.6,0.6,0.6)
      else
        pos = ray.pos(t)
        normal = obj.normal(pos)
        obj.material.lit_colour(@scene, normal, -ray.dir, pos)
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubytracer-0.1.0 lib/rubytracer/camera.rb