forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram-lib.js
More file actions
71 lines (62 loc) · 2.17 KB
/
program-lib.js
File metadata and controls
71 lines (62 loc) · 2.17 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
63
64
65
66
67
68
69
70
pc.programlib = {
gammaCode: function (value) {
if (value === pc.GAMMA_SRGB || value === pc.GAMMA_SRGBFAST) {
return pc.shaderChunks.gamma2_2PS;
} else if (value === pc.GAMMA_SRGBHDR) {
return "#define HDR\n" + pc.shaderChunks.gamma2_2PS;
}
return pc.shaderChunks.gamma1_0PS;
},
tonemapCode: function (value) {
if (value === pc.TONEMAP_FILMIC) {
return pc.shaderChunks.tonemappingFilmicPS;
} else if (value === pc.TONEMAP_LINEAR) {
return pc.shaderChunks.tonemappingLinearPS;
} else if (value === pc.TONEMAP_HEJL) {
return pc.shaderChunks.tonemappingHejlPS;
} else if (value === pc.TONEMAP_ACES) {
return pc.shaderChunks.tonemappingAcesPS;
} else if (value === pc.TONEMAP_ACES2) {
return pc.shaderChunks.tonemappingAces2PS;
}
return pc.shaderChunks.tonemappingNonePS;
},
fogCode: function(value) {
if (value === 'linear') {
return pc.shaderChunks.fogLinearPS;
} else if (value === 'exp') {
return pc.shaderChunks.fogExpPS;
} else if (value === 'exp2') {
return pc.shaderChunks.fogExp2PS;
} else {
return pc.shaderChunks.fogNonePS;
}
},
skinCode: function(device, chunks) {
if (!chunks) chunks = pc.shaderChunks;
if (device.supportsBoneTextures) {
return chunks.skinTexVS;
} else {
return "#define BONE_LIMIT " + device.getBoneLimit() + "\n" + chunks.skinConstVS;
}
},
precisionCode: function(device) {
var pcode = 'precision ' + device.precision + ' float;\n';
if (device.webgl2) {
pcode += '#ifdef GL2\nprecision ' + device.precision + ' sampler2DShadow;\n#endif\n';
}
return pcode;
},
versionCode: function(device) {
return device.webgl2 ? "#version 300 es\n" : "";
},
dummyFragmentCode: function() {
return "void main(void) {gl_FragColor = vec4(0.0);}";
},
begin: function() {
return 'void main(void)\n{\n';
},
end: function() {
return '}\n';
}
};