Sha256: 5dd7f2b9d5f054c3a269590312d2fefef7f1136f83466cb27bf778d6ac2905e6
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
module Rubytracer class Material def initialize(options) @d_colour = options[:diffuse_colour] @s_colour = options[:specular_colour] @shininess = options[:shininess] end def diffuse_colour(point, normal) @d_colour || Colour.new(0,0,0) end def specular_colour(point, normal) @s_colour || Colour.new(0,0,0) end def lit_colour(scene, normal, view_vector, point, n=0) reflection = Colour.new(0,0,0) #reflection += self.reflection( #reflection += self.refraction( scene.lighting.each do |light| reflection += self.diffuse(point, normal, scene, light) reflection += self.specular(point, normal, scene, view_vector, light) end return reflection end def diffuse(point, normal, scene, light) self.diffuse_colour(point, normal) * light.diffuse(normal, point, scene) end def specular(point, normal, scene, view_vector, light) if @shininess self.specular_colour(point, normal) * (light.specular(normal, view_vector, point, scene) ** @shininess) else Colour.new(0,0,0) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubytracer-0.1.0 | lib/rubytracer/material.rb |