Skip to content

Commit 569b677

Browse files
committed
add media demo
1 parent 164f7b8 commit 569b677

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

docs/_posts/2017-01-06-media.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
layout: post
3+
title: "Media Demo"
4+
date: 2017-01-08 04:31:13
5+
categories: joonsrenderer update
6+
---
7+
Sunflow is an open source global illumination rendering system written in Java written by [Christopher Kulla][fpsunflower]. I have recently updated to [build with maven][maven] using jdk-8 and to use the latest [janino jars][janino]. This is gem makes sunflow rendering easily available to `JRubyArt` and `propane` users using Joon Hylub Lees [joons-renderer][joons]:-
8+
9+
### media_demo.rb (JRubyArt Sketch)
10+
```ruby
11+
require 'joonsrenderer'
12+
include_package 'joons'
13+
14+
attr_reader :jr, :eye, :center, :up
15+
16+
def setup
17+
sketch_title 'Media Demo'
18+
@jr = JoonsRenderer.new(self)
19+
jr.set_sampler('ipr') # Rendering mode, either 'ipr' or 'bucket'.
20+
jr.set_size_multiplier(2) # Set size of PNG file as a multiple of Processing sketch size.
21+
jr.setAA(-2, 0) # Set anti aliasing, (aaMin, aaMax, aaSamples). aaMin & aaMax = .. -2, -1, .. , 1, 2 .. aaMin < aaMax.
22+
jr.set_caustics(10) # Set caustics. 1, 5, 10 .., affects quality of light reflected & refracted through glass.
23+
# Camera Setting.
24+
@eye = Vec3D.new(0, 0, 120)
25+
@center = Vec3D.new(0, 0, -1)
26+
@up = Vec3D.new(0, 1, 0)
27+
end
28+
29+
def draw
30+
jr.begin_record # Make sure to include things you want rendered.
31+
kamera(eye: eye, center: center, up: up)
32+
perspektiv(fov: PI / 4.0, aspect_ratio: 4 / 3.0, near_z: 5, far_z: 10_000)
33+
jr.background('gi_instant') # Global illumination.
34+
jr.background('cornell_box', 100, 100, 100) # Cornell box, width, height, depth.
35+
push_matrix
36+
translate(-40, 20, -20)
37+
push_matrix
38+
rotateY(-PI / 8)
39+
# jr.fill('light', r, g, b)
40+
jr.fill('light', 5, 5, 5)
41+
sphere(13)
42+
translate(27, 0, 0)
43+
# jr.fill('mirror', r, g, b)
44+
jr.fill('mirror', 255, 255, 255)
45+
sphere(13)
46+
translate(27, 0, 0)
47+
# jr.fill('diffuse', r, g, b)
48+
jr.fill('diffuse', 150, 255, 255)
49+
sphere(13)
50+
translate(27, 0, 0)
51+
# jr.fill('shiny', r, g, b, shininess)
52+
jr.fill('shiny', 150, 255, 255, 0.1)
53+
sphere(13)
54+
translate(27, 0, 0)
55+
pop_matrix
56+
rotateY(PI / 8)
57+
translate(-10, -27, 30)
58+
# jr.fill('ambient occlusion', bright r, g, b, dark r, g, b, maximum distance, int samples)
59+
jr.fill('ambient_occlusion', 150, 255, 255, 0, 0, 255, 50, 16)
60+
sphere(13)
61+
translate(27, 0, 0)
62+
# jr.fill('phong', r, g, b)
63+
jr.fill('phong', 150, 255, 255)
64+
sphere(13)
65+
translate(27, 0, 0)
66+
# jr.fill('glass', r, g, b)
67+
jr.fill('glass', 255, 255, 255)
68+
sphere(13)
69+
translate(27, 0, 0)
70+
# jr.fill('constant', r, g, b)
71+
jr.fill('constant', 150, 255, 255)
72+
sphere(13)
73+
pop_matrix
74+
jr.end_record # Make sure to end record.
75+
# Display rendered image if render is completed, and the argument is true.
76+
jr.display_rendered(true)
77+
end
78+
79+
def key_pressed
80+
jr.render if (key == 'r' || key == 'R') # Press 'r' key to start rendering.
81+
end
82+
83+
def settings
84+
size(800, 600, P3D)
85+
end
86+
87+
```
88+
89+
### The Processing Sketch
90+
91+
<img src="{{site.github.url}}/assets/media_captured.png" />
92+
93+
### The RayTraced Image
94+
95+
<img src="{{site.github.url}}/assets/media_rendered.png" />
96+
97+
[fpsunflower]:http://sunflow.sourceforge.net/
98+
[maven]:https://github.com/monkstone/sunflow
99+
[joons]:https://github.com/joonhyublee/joons-renderer
100+
[janino]:http://janino-compiler.github.io/janino/
101+
[github]:https://github.com/monkstone/joonsrenderer

docs/assets/media_captured.png

42.9 KB
Loading

docs/assets/media_rendered.png

2.18 MB
Loading

0 commit comments

Comments
 (0)