-
Notifications
You must be signed in to change notification settings - Fork 12
/
$
62 lines (59 loc) · 1.79 KB
/
$
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
scene = {
root: 'scene',
simple: 'simple.shader',
city: 'city.vbo',
//city: 'cityscape.vbo',
init: function(glee, params){
var self = this;
this.sky = params.sky;
var samples = [];
while(samples.length < 16){
var x = (Math.random()-0.5)*2.0;
var y = (Math.random()-0.5)*2.0;
var z = (Math.random()-0.5)*2.0;
var l = Math.sqrt(x*x+y*y+z*z);
if(l < 1.0 && l > 0.1){
samples.push(x, y, z);
}
}
this.processor = new glee.Processor({
clear: {
depth: 1,
},
shader: this.simple,
uniforms: {
view: params.view.matrix,
view_rot: params.view.rot,
proj: params.proj.matrix,
lightdir: new glee.Vec3(0.5, 1.0, 0.2).normalize(),
near: params.proj.near,
far: params.proj.far,
shadow_near: params.shadow.proj.near,
shadow_far: params.shadow.proj.far,
shadow_view: shadow.view,
shadow_proj: params.shadow.proj.matrix,
},
uniform3f: {
samples: samples,
},
samplers: {
diffuse: params.sky.diffuse.result,
occlusionmap: params.occlusion,
shadowmap: params.shadow.result,
},
draw: function(){
self.city.draw();
},
depth: {
test: 'Less',
write: true,
}
});
},
set_occlusion: function(occlusion){
this.processor.samplers.occlusionmap = occlusion;
},
render: function(){
this.processor.render();
}
}