-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest_builtins.js
More file actions
37 lines (33 loc) · 1.98 KB
/
test_builtins.js
File metadata and controls
37 lines (33 loc) · 1.98 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
test("Test Shade builtins", function() {
var exp = {"type": "vec", guid: 227, "parents": [
{"type": "parameter", "parameterType": "float", "guid":9999, "parents": []},
{"type": "constant", "guid":9998, "parents": [], "values": [0]},
{"type": "constant", "guid":9997, "parents": [], "values": [0]},
{"type": "constant", "guid":9996, "parents": [], "values": [1]}]};
var exp2 = {"type":"cross","guid":242,"parents":[
{"type":"normalize","guid":238,"parents":[
{"type":"cross","guid":237,"parents":[
{"type":"dFdx","guid":235,"parents":[
{"type":"div","guid":234,"parents":[
{"type":"swizzle{xyz}","guid":232,"parents":[exp]},
{"type":"swizzle{w}","guid":233,"parents":[{"type":"reference","guid":227}]}]}]},
{"type":"dFdy","guid":236,"parents":[{"type":"reference","guid":234}]}]}]},
{"type":"vec","guid":241,"parents":[
{"type":"constant","guid":239,"parents":[],"values":[0]},
{"type":"constant","guid":240,"parents":[],"values":[0]},
{"type":"constant","guid":241,"parents":[],"values":[1]}]}]};
ok(Shade.Debug.fromJson(exp2).element(0));
equal(Shade.cross(Shade.vec(1,0,0),
Shade.vec(0,1,0)).element(0).constantValue(), 0);
equal(Shade.cross(Shade.vec(1,0,0),
Shade.vec(0,1,0)).element(1).constantValue(), 0);
equal(Shade.cross(Shade.vec(1,0,0),
Shade.vec(0,1,0)).element(2).constantValue(), 1);
equal(Shade.cross(Shade.vec(0,1,0),
Shade.vec(1,0,0)).element(2).constantValue(), -1);
almostEqual(Shade.atan(Shade.vec(0,0,0)).evaluate(), vec.make([0,0,0]));
equal(Shade.clamp(0.5, 0, 1).evaluate(), 0.5);
equal(Shade.clamp(-0.5, 0, 1).evaluate(), 0);
equal(Shade.clamp(1.5, 0, 1).evaluate(), 1);
almostEqual(Shade.clamp(Shade.vec(0.5, -0.5, 1.5), 0, 1).evaluate(), vec.make([0.5, 0, 1]));
});