forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskybox.js
More file actions
25 lines (23 loc) · 1.2 KB
/
Copy pathskybox.js
File metadata and controls
25 lines (23 loc) · 1.2 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
pc.programlib.skybox = {
generateKey: function (device, options) {
var key = "skybox" + options.rgbm + " " + options.hdr + " " + options.fixSeams + "" +
options.toneMapping + "" + options.gamma + "" + options.useIntensity + "" + options.mip;
return key;
},
createShaderDefinition: function (device, options) {
var chunks = pc.shaderChunks;
var mip2size = [128, 64, 16, 8, 4, 2];
return {
attributes: {
aPosition: pc.SEMANTIC_POSITION
},
vshader: chunks.skyboxVS,
fshader: pc.programlib.precisionCode(device) +
(options.mip ? chunks.fixCubemapSeamsStretchPS : chunks.fixCubemapSeamsNonePS) +
(options.useIntensity ? chunks.envMultiplyPS : chunks.envConstPS) +
pc.programlib.gammaCode(options.gamma) + pc.programlib.tonemapCode(options.toneMapping) + chunks.rgbmPS +
chunks.skyboxHDRPS.replace(/\$textureCubeSAMPLE/g, options.rgbm ? "textureCubeRGBM" : (options.hdr ? "textureCube" : "textureCubeSRGB"))
.replace(/\$FIXCONST/g, (1.0 - 1.0 / mip2size[options.mip]) + "")
};
}
};