summaryrefslogtreecommitdiffhomepage
path: root/benchmark/ao-render.rb
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark/ao-render.rb')
-rw-r--r--benchmark/ao-render.rb42
1 files changed, 13 insertions, 29 deletions
diff --git a/benchmark/ao-render.rb b/benchmark/ao-render.rb
index 793804a7b..e7406b26b 100644
--- a/benchmark/ao-render.rb
+++ b/benchmark/ao-render.rb
@@ -6,8 +6,8 @@
# mruby version by Hideki Miura
#
-IMAGE_WIDTH = 256
-IMAGE_HEIGHT = 256
+IMAGE_WIDTH = 64
+IMAGE_HEIGHT = 64
NSUBSAMPLES = 2
NAO_SAMPLES = 8
@@ -30,19 +30,14 @@ module Rand
end
class Vec
+ attr_accessor :x, :y, :z
+
def initialize(x, y, z)
@x = x
@y = y
@z = z
end
- def x=(v); @x = v; end
- def y=(v); @y = v; end
- def z=(v); @z = v; end
- def x; @x; end
- def y; @y; end
- def z; @z; end
-
def vadd(b)
Vec.new(@x + b.x, @y + b.y, @z + b.z)
end
@@ -80,14 +75,13 @@ end
class Sphere
+ attr_reader :center, :radius
+
def initialize(center, radius)
@center = center
@radius = radius
end
- def center; @center; end
- def radius; @radius; end
-
def intersect(ray, isect)
rs = ray.org.vsub(@center)
b = rs.vdot(ray.dir)
@@ -140,33 +134,23 @@ class Plane
end
class Ray
+ attr_accessor :org, :dir
+
def initialize(org, dir)
@org = org
@dir = dir
end
-
- def org; @org; end
- def org=(v); @org = v; end
- def dir; @dir; end
- def dir=(v); @dir = v; end
end
class Isect
+ attr_accessor :t, :hit, :pl, :n
+
def initialize
@t = 10000000.0
@hit = false
@pl = Vec.new(0.0, 0.0, 0.0)
@n = Vec.new(0.0, 0.0, 0.0)
end
-
- def t; @t; end
- def t=(v); @t = v; end
- def hit; @hit; end
- def hit=(v); @hit = v; end
- def pl; @pl; end
- def pl=(v); @pl = v; end
- def n; @n; end
- def n=(v); @n = v; end
end
def clamp(f)
@@ -298,9 +282,9 @@ class Scene
r = rad.x / (nsf * nsf)
g = rad.y / (nsf * nsf)
b = rad.z / (nsf * nsf)
- printf("%c", clamp(r))
- printf("%c", clamp(g))
- printf("%c", clamp(b))
+ # printf("%c", clamp(r))
+ # printf("%c", clamp(g))
+ # printf("%c", clamp(b))
end
end
end