Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@luma.gl/shadertools

Package Overview
Dependencies
Maintainers
8
Versions
249
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@luma.gl/shadertools - npm Package Compare versions

Comparing version 8.0.0-alpha.5 to 8.0.0-alpha.6

dist/es5/modules/adjust-filters/brightnesscontrast.js

58

dist/es5/index.js
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -9,10 +7,3 @@ value: true

var _exportNames = {
MODULAR_SHADERS: true,
registerShaderModules: true,
setDefaultShaderModules: true,
getDefaultShaderModules: true,
assembleShaders: true,
createShaderHook: true,
createModuleInjection: true,
resetGlobalShaderHooks: true,
combineInjects: true,

@@ -26,20 +17,2 @@ normalizeShaderModule: true,

};
Object.defineProperty(exports, "registerShaderModules", {
enumerable: true,
get: function get() {
return _resolveModules.registerShaderModules;
}
});
Object.defineProperty(exports, "setDefaultShaderModules", {
enumerable: true,
get: function get() {
return _resolveModules.setDefaultShaderModules;
}
});
Object.defineProperty(exports, "getDefaultShaderModules", {
enumerable: true,
get: function get() {
return _resolveModules.getDefaultShaderModules;
}
});
Object.defineProperty(exports, "assembleShaders", {

@@ -51,20 +24,2 @@ enumerable: true,

});
Object.defineProperty(exports, "createShaderHook", {
enumerable: true,
get: function get() {
return _assembleShaders.createShaderHook;
}
});
Object.defineProperty(exports, "createModuleInjection", {
enumerable: true,
get: function get() {
return _assembleShaders.createModuleInjection;
}
});
Object.defineProperty(exports, "resetGlobalShaderHooks", {
enumerable: true,
get: function get() {
return _assembleShaders.resetGlobalShaderHooks;
}
});
Object.defineProperty(exports, "combineInjects", {

@@ -112,10 +67,3 @@ enumerable: true,

});
exports.MODULAR_SHADERS = void 0;
var _modularVertex = _interopRequireDefault(require("./shaders/modular-vertex.glsl"));
var _modularFragment = _interopRequireDefault(require("./shaders/modular-fragment.glsl"));
var _resolveModules = require("./lib/resolve-modules");
var _assembleShaders = require("./lib/assemble-shaders");

@@ -141,8 +89,2 @@

});
var MODULAR_SHADERS = {
vs: _modularVertex["default"],
fs: _modularFragment["default"],
uniforms: {}
};
exports.MODULAR_SHADERS = MODULAR_SHADERS;
//# sourceMappingURL=index.js.map

216

dist/es5/lib/assemble-shaders.js

@@ -10,5 +10,2 @@ "use strict";

});
exports.createShaderHook = createShaderHook;
exports.createModuleInjection = createModuleInjection;
exports.resetGlobalShaderHooks = resetGlobalShaderHooks;
exports.assembleShaders = assembleShaders;

@@ -30,47 +27,8 @@

var _SHADER_TYPE, _HOOK_FUNCTIONS, _MODULE_INJECTIONS;
var _SHADER_TYPE;
var INJECT_SHADER_DECLARATIONS = "\n\n".concat(_injectShader.DECLARATION_INJECT_MARKER, "\n\n");
var SHADER_TYPE = (_SHADER_TYPE = {}, (0, _defineProperty2["default"])(_SHADER_TYPE, _constants.VERTEX_SHADER, 'vertex'), (0, _defineProperty2["default"])(_SHADER_TYPE, _constants.FRAGMENT_SHADER, 'fragment'), _SHADER_TYPE);
var HOOK_FUNCTIONS = (_HOOK_FUNCTIONS = {}, (0, _defineProperty2["default"])(_HOOK_FUNCTIONS, _constants.VERTEX_SHADER, {}), (0, _defineProperty2["default"])(_HOOK_FUNCTIONS, _constants.FRAGMENT_SHADER, {}), _HOOK_FUNCTIONS);
var MODULE_INJECTIONS = (_MODULE_INJECTIONS = {}, (0, _defineProperty2["default"])(_MODULE_INJECTIONS, _constants.VERTEX_SHADER, {}), (0, _defineProperty2["default"])(_MODULE_INJECTIONS, _constants.FRAGMENT_SHADER, {}), _MODULE_INJECTIONS);
var FRAGMENT_SHADER_PROLOGUE = "precision highp float;\n\n";
function createShaderHook(hook) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
hook = hook.trim();
var _hook$split = hook.split(':'),
_hook$split2 = (0, _slicedToArray2["default"])(_hook$split, 2),
stage = _hook$split2[0],
signature = _hook$split2[1];
var name = hook.replace(/\(.+/, '');
HOOK_FUNCTIONS[stage][name] = Object.assign(opts, {
signature: signature
});
}
function createModuleInjection(moduleName, opts) {
var hook = opts.hook,
injection = opts.injection,
_opts$order = opts.order,
order = _opts$order === void 0 ? 0 : _opts$order;
var shaderStage = hook.slice(0, 2);
var moduleInjections = MODULE_INJECTIONS[shaderStage];
moduleInjections[moduleName] = moduleInjections[moduleName] || {};
(0, _utils.assert)(!moduleInjections[moduleName][hook], 'Module injection already created');
moduleInjections[moduleName][hook] = {
injection: injection,
order: order
};
}
function resetGlobalShaderHooks() {
HOOK_FUNCTIONS[_constants.VERTEX_SHADER] = {};
HOOK_FUNCTIONS[_constants.FRAGMENT_SHADER] = {};
MODULE_INJECTIONS[_constants.VERTEX_SHADER] = {};
MODULE_INJECTIONS[_constants.FRAGMENT_SHADER] = {};
}
function assembleShaders(gl, opts) {

@@ -92,4 +50,3 @@ var vs = opts.vs,

})),
getUniforms: assembleGetUniforms(modules),
modules: assembleModuleMap(modules)
getUniforms: assembleGetUniforms(modules)
};

@@ -106,5 +63,5 @@ }

_ref$hookFunctions = _ref.hookFunctions,
hookFunctions = _ref$hookFunctions === void 0 ? HOOK_FUNCTIONS : _ref$hookFunctions,
hookFunctions = _ref$hookFunctions === void 0 ? [] : _ref$hookFunctions,
_ref$moduleInjections = _ref.moduleInjections,
moduleInjections = _ref$moduleInjections === void 0 ? MODULE_INJECTIONS : _ref$moduleInjections,
moduleInjections = _ref$moduleInjections === void 0 ? {} : _ref$moduleInjections,
_ref$inject = _ref.inject,

@@ -116,15 +73,2 @@ inject = _ref$inject === void 0 ? {} : _ref$inject,

(0, _utils.assert)(typeof source === 'string', 'shader source must be a string');
if (hookFunctions !== HOOK_FUNCTIONS) {
var _hookFunctions;
hookFunctions = (_hookFunctions = {}, (0, _defineProperty2["default"])(_hookFunctions, _constants.VERTEX_SHADER, Object.assign({}, HOOK_FUNCTIONS[_constants.VERTEX_SHADER], hookFunctions[_constants.VERTEX_SHADER])), (0, _defineProperty2["default"])(_hookFunctions, _constants.FRAGMENT_SHADER, Object.assign({}, HOOK_FUNCTIONS[_constants.FRAGMENT_SHADER], hookFunctions[_constants.FRAGMENT_SHADER])), _hookFunctions);
}
if (moduleInjections !== MODULE_INJECTIONS) {
var _moduleInjections;
moduleInjections = (_moduleInjections = {}, (0, _defineProperty2["default"])(_moduleInjections, _constants.VERTEX_SHADER, Object.assign({}, MODULE_INJECTIONS[_constants.VERTEX_SHADER], moduleInjections[_constants.VERTEX_SHADER])), (0, _defineProperty2["default"])(_moduleInjections, _constants.FRAGMENT_SHADER, Object.assign({}, MODULE_INJECTIONS[_constants.FRAGMENT_SHADER], moduleInjections[_constants.FRAGMENT_SHADER])), _moduleInjections);
}
var isVertex = type === _constants.VERTEX_SHADER;

@@ -156,3 +100,4 @@ var sourceLines = source.split('\n');

}), "\n").concat((0, _platformDefines.getPlatformShaderDefines)(gl), "\n").concat((0, _platformDefines.getVersionDefines)(gl, glslVersion, !isVertex), "\n").concat(getApplicationDefines(allDefines), "\n").concat(isVertex ? '' : FRAGMENT_SHADER_PROLOGUE, "\n") : "".concat(versionLine, "\n");
var injectStandardStubs = false;
hookFunctions = normalizeHookFunctions(hookFunctions);
moduleInjections = normalizeModuleInjections(moduleInjections);
var hookInjections = {};

@@ -186,31 +131,23 @@ var mainInjections = {};

switch (module.name) {
case 'inject':
injectStandardStubs = true;
break;
if (log) {
module.checkDeprecations(coreSource, log);
}
default:
if (log) {
module.checkDeprecations(coreSource, log);
}
var moduleSource = module.getModuleSource(type, glslVersion);
assembledSource += moduleSource;
var moduleSource = module.getModuleSource(type, glslVersion);
assembledSource += moduleSource;
if (moduleInjections[type][module.name]) {
var injections = moduleInjections[type][module.name];
if (moduleInjections[type][module.name]) {
var injections = moduleInjections[type][module.name];
for (var _key in injections) {
if (_key.match(/^(v|f)s:#/)) {
mainInjections[_key] = mainInjections[_key] || [];
for (var _key in injections) {
if (_key.match(/^(v|f)s:#/)) {
mainInjections[_key] = mainInjections[_key] || [];
mainInjections[_key].push(injections[_key]);
} else {
hookInjections[_key] = hookInjections[_key] || [];
mainInjections[_key].push(injections[_key]);
} else {
hookInjections[_key] = hookInjections[_key] || [];
hookInjections[_key].push(injections[_key]);
}
}
hookInjections[_key].push(injections[_key]);
}
}
}

@@ -236,3 +173,3 @@ }

assembledSource += coreSource;
assembledSource = (0, _injectShader["default"])(assembledSource, type, mainInjections, injectStandardStubs);
assembledSource = (0, _injectShader["default"])(assembledSource, type, mainInjections);
return assembledSource;

@@ -273,32 +210,2 @@ }

function assembleModuleMap(modules) {
var result = {};
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = modules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var moduleName = _step3.value;
var shaderModule = (0, _resolveModules.getShaderModule)(moduleName);
result[moduleName] = shaderModule;
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return result;
}
function getShaderType(_ref2) {

@@ -358,22 +265,22 @@ var type = _ref2.type;

});
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator4 = injections[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var injection = _step4.value;
for (var _iterator3 = injections[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var injection = _step3.value;
result += " ".concat(injection.injection, "\n");
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
_iterator4["return"]();
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
if (_didIteratorError3) {
throw _iteratorError3;
}

@@ -393,2 +300,59 @@ }

}
function normalizeHookFunctions(hookFunctions) {
var result = {
vs: {},
fs: {}
};
hookFunctions.forEach(function (hook) {
var opts;
if (typeof hook !== 'string') {
opts = hook;
hook = opts.hook;
} else {
opts = {};
}
hook = hook.trim();
var _hook$split = hook.split(':'),
_hook$split2 = (0, _slicedToArray2["default"])(_hook$split, 2),
stage = _hook$split2[0],
signature = _hook$split2[1];
var name = hook.replace(/\(.+/, '');
result[stage][name] = Object.assign(opts, {
signature: signature
});
});
return result;
}
function normalizeModuleInjections(moduleInjections) {
var result = {
vs: {},
fs: {}
};
for (var moduleName in moduleInjections) {
var injections = moduleInjections[moduleName];
for (var hook in injections) {
var injection = injections[hook];
var stage = hook.slice(0, 2);
if (typeof injection === 'string') {
injection = {
injection: injection
};
}
result[stage][moduleName] = result[stage][moduleName] || {};
result[stage][moduleName][hook] = injection;
}
}
return result;
}
//# sourceMappingURL=assemble-shaders.js.map

@@ -8,41 +8,13 @@ "use strict";

});
exports.setDefaultShaderModules = setDefaultShaderModules;
exports.getDefaultShaderModules = getDefaultShaderModules;
exports.registerShaderModules = registerShaderModules;
exports.resolveModules = resolveModules;
exports.getShaderModule = getShaderModule;
exports.TEST_EXPORTS = void 0;
var _shaderModuleRegistry = _interopRequireDefault(require("./shader-module-registry"));
var _shaderModule = _interopRequireDefault(require("./shader-module"));
var shaderModuleRegistry = new _shaderModuleRegistry["default"]();
var _utils = require("../utils");
function setDefaultShaderModules(modules) {
shaderModuleRegistry.setDefaultShaderModules(modules);
}
function getDefaultShaderModules() {
return shaderModuleRegistry.getDefaultShaderModules();
}
function registerShaderModules(shaderModuleList) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$ignoreMultipleRe = _ref.ignoreMultipleRegistrations,
ignoreMultipleRegistrations = _ref$ignoreMultipleRe === void 0 ? false : _ref$ignoreMultipleRe;
shaderModuleRegistry.registerShaderModules(shaderModuleList, {
ignoreMultipleRegistrations: ignoreMultipleRegistrations
});
}
function resolveModules(modules) {
modules = modules.concat(shaderModuleRegistry.defaultShaderModules);
modules = shaderModuleRegistry.resolveModules(modules);
return getShaderDependencies(modules);
return getShaderDependencies(instantiateModules(modules));
}
function getShaderModule(moduleOrName) {
return shaderModuleRegistry.getShaderModule(moduleOrName);
}
function getShaderDependencies(modules) {

@@ -64,7 +36,7 @@ var moduleMap = {};

function getDependencyGraph(_ref2) {
var modules = _ref2.modules,
level = _ref2.level,
moduleMap = _ref2.moduleMap,
moduleDepth = _ref2.moduleDepth;
function getDependencyGraph(_ref) {
var modules = _ref.modules,
level = _ref.level,
moduleMap = _ref.moduleMap,
moduleDepth = _ref.moduleDepth;

@@ -136,2 +108,15 @@ if (level >= 5) {

function instantiateModules(modules, seen) {
return modules.map(function (module) {
if (module instanceof _shaderModule["default"]) {
return module;
}
(0, _utils.assert)(module.name, 'shader module has no name');
module = new _shaderModule["default"](module);
module.dependencies = instantiateModules(module.dependencies);
return module;
});
}
var TEST_EXPORTS = {

@@ -138,0 +123,0 @@ getShaderDependencies: getShaderDependencies,

@@ -26,8 +26,2 @@ "use strict";

});
Object.defineProperty(exports, "fog", {
enumerable: true,
get: function get() {
return _fog["default"];
}
});
Object.defineProperty(exports, "lights", {

@@ -51,8 +45,2 @@ enumerable: true,

});
Object.defineProperty(exports, "diffuse", {
enumerable: true,
get: function get() {
return _diffuse["default"];
}
});
Object.defineProperty(exports, "gouraudLighting", {

@@ -76,2 +64,110 @@ enumerable: true,

});
Object.defineProperty(exports, "brightnessContrast", {
enumerable: true,
get: function get() {
return _brightnesscontrast["default"];
}
});
Object.defineProperty(exports, "denoise", {
enumerable: true,
get: function get() {
return _denoise["default"];
}
});
Object.defineProperty(exports, "hueSaturation", {
enumerable: true,
get: function get() {
return _huesaturation["default"];
}
});
Object.defineProperty(exports, "noise", {
enumerable: true,
get: function get() {
return _noise["default"];
}
});
Object.defineProperty(exports, "sepia", {
enumerable: true,
get: function get() {
return _sepia["default"];
}
});
Object.defineProperty(exports, "vibrance", {
enumerable: true,
get: function get() {
return _vibrance["default"];
}
});
Object.defineProperty(exports, "vignette", {
enumerable: true,
get: function get() {
return _vignette["default"];
}
});
Object.defineProperty(exports, "tiltShift", {
enumerable: true,
get: function get() {
return _tiltshift["default"];
}
});
Object.defineProperty(exports, "triangleBlur", {
enumerable: true,
get: function get() {
return _triangleblur["default"];
}
});
Object.defineProperty(exports, "zoomBlur", {
enumerable: true,
get: function get() {
return _zoomblur["default"];
}
});
Object.defineProperty(exports, "colorHalftone", {
enumerable: true,
get: function get() {
return _colorhalftone["default"];
}
});
Object.defineProperty(exports, "dotScreen", {
enumerable: true,
get: function get() {
return _dotscreen["default"];
}
});
Object.defineProperty(exports, "edgeWork", {
enumerable: true,
get: function get() {
return _edgework["default"];
}
});
Object.defineProperty(exports, "hexagonalPixelate", {
enumerable: true,
get: function get() {
return _hexagonalpixelate["default"];
}
});
Object.defineProperty(exports, "ink", {
enumerable: true,
get: function get() {
return _ink["default"];
}
});
Object.defineProperty(exports, "bulgePinch", {
enumerable: true,
get: function get() {
return _bulgepinch["default"];
}
});
Object.defineProperty(exports, "swirl", {
enumerable: true,
get: function get() {
return _swirl["default"];
}
});
Object.defineProperty(exports, "fxaa", {
enumerable: true,
get: function get() {
return _fxaa["default"];
}
});
Object.defineProperty(exports, "_transform", {

@@ -90,4 +186,2 @@ enumerable: true,

var _fog = _interopRequireDefault(require("./fog/fog"));
var _lights = _interopRequireDefault(require("./lights/lights"));

@@ -99,4 +193,2 @@

var _diffuse = _interopRequireDefault(require("./diffuse/diffuse"));
var _phongLighting = require("./phong-lighting/phong-lighting");

@@ -106,3 +198,39 @@

var _brightnesscontrast = _interopRequireDefault(require("./adjust-filters/brightnesscontrast"));
var _denoise = _interopRequireDefault(require("./adjust-filters/denoise"));
var _huesaturation = _interopRequireDefault(require("./adjust-filters/huesaturation"));
var _noise = _interopRequireDefault(require("./adjust-filters/noise"));
var _sepia = _interopRequireDefault(require("./adjust-filters/sepia"));
var _vibrance = _interopRequireDefault(require("./adjust-filters/vibrance"));
var _vignette = _interopRequireDefault(require("./adjust-filters/vignette"));
var _tiltshift = _interopRequireDefault(require("./blur-filters/tiltshift"));
var _triangleblur = _interopRequireDefault(require("./blur-filters/triangleblur"));
var _zoomblur = _interopRequireDefault(require("./blur-filters/zoomblur"));
var _colorhalftone = _interopRequireDefault(require("./fun-filters/colorhalftone"));
var _dotscreen = _interopRequireDefault(require("./fun-filters/dotscreen"));
var _edgework = _interopRequireDefault(require("./fun-filters/edgework"));
var _hexagonalpixelate = _interopRequireDefault(require("./fun-filters/hexagonalpixelate"));
var _ink = _interopRequireDefault(require("./fun-filters/ink"));
var _bulgepinch = _interopRequireDefault(require("./warp-filters/bulgepinch"));
var _swirl = _interopRequireDefault(require("./warp-filters/swirl"));
var _fxaa = _interopRequireDefault(require("./fxaa/fxaa"));
var _transform = _interopRequireDefault(require("./transform/transform"));
//# sourceMappingURL=index.js.map

@@ -7,4 +7,4 @@ "use strict";

exports["default"] = void 0;
var _default = "varying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
var _default = "uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
exports["default"] = _default;
//# sourceMappingURL=pbr-vertex.glsl.js.map

@@ -10,4 +10,2 @@ "use strict";

var _project = _interopRequireDefault(require("../project2/project2"));
var _lights = _interopRequireDefault(require("../lights/lights"));

@@ -26,5 +24,5 @@

},
dependencies: [_project["default"], _lights["default"]]
dependencies: [_lights["default"]]
};
exports["default"] = _default;
//# sourceMappingURL=pbr.js.map

@@ -1,5 +0,2 @@

import MODULAR_VS from './shaders/modular-vertex.glsl';
import MODULAR_FS from './shaders/modular-fragment.glsl';
export { registerShaderModules, setDefaultShaderModules, getDefaultShaderModules } from './lib/resolve-modules';
export { assembleShaders, createShaderHook, createModuleInjection, resetGlobalShaderHooks } from './lib/assemble-shaders';
export { assembleShaders } from './lib/assemble-shaders';
export { combineInjects } from './lib/inject-shader';

@@ -9,7 +6,2 @@ export { normalizeShaderModule } from './lib/shader-module';

export * from './modules';
export const MODULAR_SHADERS = {
vs: MODULAR_VS,
fs: MODULAR_FS,
uniforms: {}
};
//# sourceMappingURL=index.js.map
import { VERTEX_SHADER, FRAGMENT_SHADER } from './constants';
import { resolveModules, getShaderModule } from './resolve-modules';
import { resolveModules } from './resolve-modules';
import { getPlatformShaderDefines, getVersionDefines } from './platform-defines';

@@ -11,40 +11,3 @@ import injectShader, { DECLARATION_INJECT_MARKER } from './inject-shader';

};
const HOOK_FUNCTIONS = {
[VERTEX_SHADER]: {},
[FRAGMENT_SHADER]: {}
};
const MODULE_INJECTIONS = {
[VERTEX_SHADER]: {},
[FRAGMENT_SHADER]: {}
};
const FRAGMENT_SHADER_PROLOGUE = "precision highp float;\n\n";
export function createShaderHook(hook, opts = {}) {
hook = hook.trim();
const [stage, signature] = hook.split(':');
const name = hook.replace(/\(.+/, '');
HOOK_FUNCTIONS[stage][name] = Object.assign(opts, {
signature
});
}
export function createModuleInjection(moduleName, opts) {
const {
hook,
injection,
order = 0
} = opts;
const shaderStage = hook.slice(0, 2);
const moduleInjections = MODULE_INJECTIONS[shaderStage];
moduleInjections[moduleName] = moduleInjections[moduleName] || {};
assert(!moduleInjections[moduleName][hook], 'Module injection already created');
moduleInjections[moduleName][hook] = {
injection,
order
};
}
export function resetGlobalShaderHooks() {
HOOK_FUNCTIONS[VERTEX_SHADER] = {};
HOOK_FUNCTIONS[FRAGMENT_SHADER] = {};
MODULE_INJECTIONS[VERTEX_SHADER] = {};
MODULE_INJECTIONS[FRAGMENT_SHADER] = {};
}
export function assembleShaders(gl, opts) {

@@ -68,4 +31,3 @@ const {

})),
getUniforms: assembleGetUniforms(modules),
modules: assembleModuleMap(modules)
getUniforms: assembleGetUniforms(modules)
};

@@ -80,4 +42,4 @@ }

defines = {},
hookFunctions = HOOK_FUNCTIONS,
moduleInjections = MODULE_INJECTIONS,
hookFunctions = [],
moduleInjections = {},
inject = {},

@@ -88,17 +50,2 @@ prologue = true,

assert(typeof source === 'string', 'shader source must be a string');
if (hookFunctions !== HOOK_FUNCTIONS) {
hookFunctions = {
[VERTEX_SHADER]: Object.assign({}, HOOK_FUNCTIONS[VERTEX_SHADER], hookFunctions[VERTEX_SHADER]),
[FRAGMENT_SHADER]: Object.assign({}, HOOK_FUNCTIONS[FRAGMENT_SHADER], hookFunctions[FRAGMENT_SHADER])
};
}
if (moduleInjections !== MODULE_INJECTIONS) {
moduleInjections = {
[VERTEX_SHADER]: Object.assign({}, MODULE_INJECTIONS[VERTEX_SHADER], moduleInjections[VERTEX_SHADER]),
[FRAGMENT_SHADER]: Object.assign({}, MODULE_INJECTIONS[FRAGMENT_SHADER], moduleInjections[FRAGMENT_SHADER])
};
}
const isVertex = type === VERTEX_SHADER;

@@ -130,3 +77,4 @@ const sourceLines = source.split('\n');

}), "\n").concat(getPlatformShaderDefines(gl), "\n").concat(getVersionDefines(gl, glslVersion, !isVertex), "\n").concat(getApplicationDefines(allDefines), "\n").concat(isVertex ? '' : FRAGMENT_SHADER_PROLOGUE, "\n") : "".concat(versionLine, "\n");
let injectStandardStubs = false;
hookFunctions = normalizeHookFunctions(hookFunctions);
moduleInjections = normalizeModuleInjections(moduleInjections);
const hookInjections = {};

@@ -153,29 +101,21 @@ const mainInjections = {};

for (const module of modules) {
switch (module.name) {
case 'inject':
injectStandardStubs = true;
break;
if (log) {
module.checkDeprecations(coreSource, log);
}
default:
if (log) {
module.checkDeprecations(coreSource, log);
}
const moduleSource = module.getModuleSource(type, glslVersion);
assembledSource += moduleSource;
const moduleSource = module.getModuleSource(type, glslVersion);
assembledSource += moduleSource;
if (moduleInjections[type][module.name]) {
const injections = moduleInjections[type][module.name];
if (moduleInjections[type][module.name]) {
const injections = moduleInjections[type][module.name];
for (const key in injections) {
if (key.match(/^(v|f)s:#/)) {
mainInjections[key] = mainInjections[key] || [];
mainInjections[key].push(injections[key]);
} else {
hookInjections[key] = hookInjections[key] || [];
hookInjections[key].push(injections[key]);
}
}
for (const key in injections) {
if (key.match(/^(v|f)s:#/)) {
mainInjections[key] = mainInjections[key] || [];
mainInjections[key].push(injections[key]);
} else {
hookInjections[key] = hookInjections[key] || [];
hookInjections[key].push(injections[key]);
}
}
}

@@ -187,3 +127,3 @@ }

assembledSource += coreSource;
assembledSource = injectShader(assembledSource, type, mainInjections, injectStandardStubs);
assembledSource = injectShader(assembledSource, type, mainInjections);
return assembledSource;

@@ -205,13 +145,2 @@ }

function assembleModuleMap(modules) {
const result = {};
for (const moduleName of modules) {
const shaderModule = getShaderModule(moduleName);
result[moduleName] = shaderModule;
}
return result;
}
function getShaderType({

@@ -285,2 +214,54 @@ type

}
function normalizeHookFunctions(hookFunctions) {
const result = {
vs: {},
fs: {}
};
hookFunctions.forEach(hook => {
let opts;
if (typeof hook !== 'string') {
opts = hook;
hook = opts.hook;
} else {
opts = {};
}
hook = hook.trim();
const [stage, signature] = hook.split(':');
const name = hook.replace(/\(.+/, '');
result[stage][name] = Object.assign(opts, {
signature
});
});
return result;
}
function normalizeModuleInjections(moduleInjections) {
const result = {
vs: {},
fs: {}
};
for (const moduleName in moduleInjections) {
const injections = moduleInjections[moduleName];
for (const hook in injections) {
let injection = injections[hook];
const stage = hook.slice(0, 2);
if (typeof injection === 'string') {
injection = {
injection
};
}
result[stage][moduleName] = result[stage][moduleName] || {};
result[stage][moduleName][hook] = injection;
}
}
return result;
}
//# sourceMappingURL=assemble-shaders.js.map

@@ -1,24 +0,6 @@

import ShaderModuleRegistry from './shader-module-registry';
const shaderModuleRegistry = new ShaderModuleRegistry();
export function setDefaultShaderModules(modules) {
shaderModuleRegistry.setDefaultShaderModules(modules);
}
export function getDefaultShaderModules() {
return shaderModuleRegistry.getDefaultShaderModules();
}
export function registerShaderModules(shaderModuleList, {
ignoreMultipleRegistrations = false
} = {}) {
shaderModuleRegistry.registerShaderModules(shaderModuleList, {
ignoreMultipleRegistrations
});
}
import ShaderModule from './shader-module';
import { assert } from '../utils';
export function resolveModules(modules) {
modules = modules.concat(shaderModuleRegistry.defaultShaderModules);
modules = shaderModuleRegistry.resolveModules(modules);
return getShaderDependencies(modules);
return getShaderDependencies(instantiateModules(modules));
}
export function getShaderModule(moduleOrName) {
return shaderModuleRegistry.getShaderModule(moduleOrName);
}

@@ -67,2 +49,15 @@ function getShaderDependencies(modules) {

function instantiateModules(modules, seen) {
return modules.map(module => {
if (module instanceof ShaderModule) {
return module;
}
assert(module.name, 'shader module has no name');
module = new ShaderModule(module);
module.dependencies = instantiateModules(module.dependencies);
return module;
});
}
export const TEST_EXPORTS = {

@@ -69,0 +64,0 @@ getShaderDependencies,

export { default as fp32 } from './fp32/fp32';
export { default as fp64 } from './fp64/fp64';
export { default as project } from './project/project';
export { default as fog } from './fog/fog';
export { default as lights } from './lights/lights';
export { default as dirlight } from './dirlight/dirlight';
export { default as picking } from './picking/picking';
export { default as diffuse } from './diffuse/diffuse';
export { gouraudLighting, phongLighting } from './phong-lighting/phong-lighting';
export { default as pbr } from './pbr/pbr';
export { default as brightnessContrast } from './adjust-filters/brightnesscontrast';
export { default as denoise } from './adjust-filters/denoise';
export { default as hueSaturation } from './adjust-filters/huesaturation';
export { default as noise } from './adjust-filters/noise';
export { default as sepia } from './adjust-filters/sepia';
export { default as vibrance } from './adjust-filters/vibrance';
export { default as vignette } from './adjust-filters/vignette';
export { default as tiltShift } from './blur-filters/tiltshift';
export { default as triangleBlur } from './blur-filters/triangleblur';
export { default as zoomBlur } from './blur-filters/zoomblur';
export { default as colorHalftone } from './fun-filters/colorhalftone';
export { default as dotScreen } from './fun-filters/dotscreen';
export { default as edgeWork } from './fun-filters/edgework';
export { default as hexagonalPixelate } from './fun-filters/hexagonalpixelate';
export { default as ink } from './fun-filters/ink';
export { default as bulgePinch } from './warp-filters/bulgepinch';
export { default as swirl } from './warp-filters/swirl';
export { default as fxaa } from './fxaa/fxaa';
export { default as _transform } from './transform/transform';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export default "varying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
export default "uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
//# sourceMappingURL=pbr-vertex.glsl.js.map

@@ -1,2 +0,1 @@

import project2 from '../project2/project2';
import lights from '../lights/lights';

@@ -12,4 +11,4 @@ import vs from './pbr-vertex.glsl';

},
dependencies: [project2, lights]
dependencies: [lights]
};
//# sourceMappingURL=pbr.js.map

@@ -1,5 +0,2 @@

import MODULAR_VS from './shaders/modular-vertex.glsl';
import MODULAR_FS from './shaders/modular-fragment.glsl';
export { registerShaderModules, setDefaultShaderModules, getDefaultShaderModules } from './lib/resolve-modules';
export { assembleShaders, createShaderHook, createModuleInjection, resetGlobalShaderHooks } from './lib/assemble-shaders';
export { assembleShaders } from './lib/assemble-shaders';
export { combineInjects } from './lib/inject-shader';

@@ -9,7 +6,2 @@ export { normalizeShaderModule } from './lib/shader-module';

export * from './modules';
export var MODULAR_SHADERS = {
vs: MODULAR_VS,
fs: MODULAR_FS,
uniforms: {}
};
//# sourceMappingURL=index.js.map
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
var _SHADER_TYPE, _HOOK_FUNCTIONS, _MODULE_INJECTIONS;
var _SHADER_TYPE;
import { VERTEX_SHADER, FRAGMENT_SHADER } from './constants';
import { resolveModules, getShaderModule } from './resolve-modules';
import { resolveModules } from './resolve-modules';
import { getPlatformShaderDefines, getVersionDefines } from './platform-defines';

@@ -13,39 +13,3 @@ import injectShader, { DECLARATION_INJECT_MARKER } from './inject-shader';

var SHADER_TYPE = (_SHADER_TYPE = {}, _defineProperty(_SHADER_TYPE, VERTEX_SHADER, 'vertex'), _defineProperty(_SHADER_TYPE, FRAGMENT_SHADER, 'fragment'), _SHADER_TYPE);
var HOOK_FUNCTIONS = (_HOOK_FUNCTIONS = {}, _defineProperty(_HOOK_FUNCTIONS, VERTEX_SHADER, {}), _defineProperty(_HOOK_FUNCTIONS, FRAGMENT_SHADER, {}), _HOOK_FUNCTIONS);
var MODULE_INJECTIONS = (_MODULE_INJECTIONS = {}, _defineProperty(_MODULE_INJECTIONS, VERTEX_SHADER, {}), _defineProperty(_MODULE_INJECTIONS, FRAGMENT_SHADER, {}), _MODULE_INJECTIONS);
var FRAGMENT_SHADER_PROLOGUE = "precision highp float;\n\n";
export function createShaderHook(hook) {
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
hook = hook.trim();
var _hook$split = hook.split(':'),
_hook$split2 = _slicedToArray(_hook$split, 2),
stage = _hook$split2[0],
signature = _hook$split2[1];
var name = hook.replace(/\(.+/, '');
HOOK_FUNCTIONS[stage][name] = Object.assign(opts, {
signature: signature
});
}
export function createModuleInjection(moduleName, opts) {
var hook = opts.hook,
injection = opts.injection,
_opts$order = opts.order,
order = _opts$order === void 0 ? 0 : _opts$order;
var shaderStage = hook.slice(0, 2);
var moduleInjections = MODULE_INJECTIONS[shaderStage];
moduleInjections[moduleName] = moduleInjections[moduleName] || {};
assert(!moduleInjections[moduleName][hook], 'Module injection already created');
moduleInjections[moduleName][hook] = {
injection: injection,
order: order
};
}
export function resetGlobalShaderHooks() {
HOOK_FUNCTIONS[VERTEX_SHADER] = {};
HOOK_FUNCTIONS[FRAGMENT_SHADER] = {};
MODULE_INJECTIONS[VERTEX_SHADER] = {};
MODULE_INJECTIONS[FRAGMENT_SHADER] = {};
}
export function assembleShaders(gl, opts) {

@@ -67,4 +31,3 @@ var vs = opts.vs,

})),
getUniforms: assembleGetUniforms(modules),
modules: assembleModuleMap(modules)
getUniforms: assembleGetUniforms(modules)
};

@@ -81,5 +44,5 @@ }

_ref$hookFunctions = _ref.hookFunctions,
hookFunctions = _ref$hookFunctions === void 0 ? HOOK_FUNCTIONS : _ref$hookFunctions,
hookFunctions = _ref$hookFunctions === void 0 ? [] : _ref$hookFunctions,
_ref$moduleInjections = _ref.moduleInjections,
moduleInjections = _ref$moduleInjections === void 0 ? MODULE_INJECTIONS : _ref$moduleInjections,
moduleInjections = _ref$moduleInjections === void 0 ? {} : _ref$moduleInjections,
_ref$inject = _ref.inject,

@@ -91,15 +54,2 @@ inject = _ref$inject === void 0 ? {} : _ref$inject,

assert(typeof source === 'string', 'shader source must be a string');
if (hookFunctions !== HOOK_FUNCTIONS) {
var _hookFunctions;
hookFunctions = (_hookFunctions = {}, _defineProperty(_hookFunctions, VERTEX_SHADER, Object.assign({}, HOOK_FUNCTIONS[VERTEX_SHADER], hookFunctions[VERTEX_SHADER])), _defineProperty(_hookFunctions, FRAGMENT_SHADER, Object.assign({}, HOOK_FUNCTIONS[FRAGMENT_SHADER], hookFunctions[FRAGMENT_SHADER])), _hookFunctions);
}
if (moduleInjections !== MODULE_INJECTIONS) {
var _moduleInjections;
moduleInjections = (_moduleInjections = {}, _defineProperty(_moduleInjections, VERTEX_SHADER, Object.assign({}, MODULE_INJECTIONS[VERTEX_SHADER], moduleInjections[VERTEX_SHADER])), _defineProperty(_moduleInjections, FRAGMENT_SHADER, Object.assign({}, MODULE_INJECTIONS[FRAGMENT_SHADER], moduleInjections[FRAGMENT_SHADER])), _moduleInjections);
}
var isVertex = type === VERTEX_SHADER;

@@ -131,3 +81,4 @@ var sourceLines = source.split('\n');

}), "\n").concat(getPlatformShaderDefines(gl), "\n").concat(getVersionDefines(gl, glslVersion, !isVertex), "\n").concat(getApplicationDefines(allDefines), "\n").concat(isVertex ? '' : FRAGMENT_SHADER_PROLOGUE, "\n") : "".concat(versionLine, "\n");
var injectStandardStubs = false;
hookFunctions = normalizeHookFunctions(hookFunctions);
moduleInjections = normalizeModuleInjections(moduleInjections);
var hookInjections = {};

@@ -161,31 +112,23 @@ var mainInjections = {};

switch (module.name) {
case 'inject':
injectStandardStubs = true;
break;
if (log) {
module.checkDeprecations(coreSource, log);
}
default:
if (log) {
module.checkDeprecations(coreSource, log);
}
var moduleSource = module.getModuleSource(type, glslVersion);
assembledSource += moduleSource;
var moduleSource = module.getModuleSource(type, glslVersion);
assembledSource += moduleSource;
if (moduleInjections[type][module.name]) {
var injections = moduleInjections[type][module.name];
if (moduleInjections[type][module.name]) {
var injections = moduleInjections[type][module.name];
for (var _key in injections) {
if (_key.match(/^(v|f)s:#/)) {
mainInjections[_key] = mainInjections[_key] || [];
for (var _key in injections) {
if (_key.match(/^(v|f)s:#/)) {
mainInjections[_key] = mainInjections[_key] || [];
mainInjections[_key].push(injections[_key]);
} else {
hookInjections[_key] = hookInjections[_key] || [];
mainInjections[_key].push(injections[_key]);
} else {
hookInjections[_key] = hookInjections[_key] || [];
hookInjections[_key].push(injections[_key]);
}
}
hookInjections[_key].push(injections[_key]);
}
}
}

@@ -211,3 +154,3 @@ }

assembledSource += coreSource;
assembledSource = injectShader(assembledSource, type, mainInjections, injectStandardStubs);
assembledSource = injectShader(assembledSource, type, mainInjections);
return assembledSource;

@@ -248,32 +191,2 @@ }

function assembleModuleMap(modules) {
var result = {};
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = modules[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var moduleName = _step3.value;
var shaderModule = getShaderModule(moduleName);
result[moduleName] = shaderModule;
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return result;
}
function getShaderType(_ref2) {

@@ -333,22 +246,22 @@ var type = _ref2.type;

});
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator4 = injections[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
var injection = _step4.value;
for (var _iterator3 = injections[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var injection = _step3.value;
result += " ".concat(injection.injection, "\n");
}
} catch (err) {
_didIteratorError4 = true;
_iteratorError4 = err;
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) {
_iterator4["return"]();
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
}
} finally {
if (_didIteratorError4) {
throw _iteratorError4;
if (_didIteratorError3) {
throw _iteratorError3;
}

@@ -368,2 +281,59 @@ }

}
function normalizeHookFunctions(hookFunctions) {
var result = {
vs: {},
fs: {}
};
hookFunctions.forEach(function (hook) {
var opts;
if (typeof hook !== 'string') {
opts = hook;
hook = opts.hook;
} else {
opts = {};
}
hook = hook.trim();
var _hook$split = hook.split(':'),
_hook$split2 = _slicedToArray(_hook$split, 2),
stage = _hook$split2[0],
signature = _hook$split2[1];
var name = hook.replace(/\(.+/, '');
result[stage][name] = Object.assign(opts, {
signature: signature
});
});
return result;
}
function normalizeModuleInjections(moduleInjections) {
var result = {
vs: {},
fs: {}
};
for (var moduleName in moduleInjections) {
var injections = moduleInjections[moduleName];
for (var hook in injections) {
var injection = injections[hook];
var stage = hook.slice(0, 2);
if (typeof injection === 'string') {
injection = {
injection: injection
};
}
result[stage][moduleName] = result[stage][moduleName] || {};
result[stage][moduleName][hook] = injection;
}
}
return result;
}
//# sourceMappingURL=assemble-shaders.js.map

@@ -1,26 +0,6 @@

import ShaderModuleRegistry from './shader-module-registry';
var shaderModuleRegistry = new ShaderModuleRegistry();
export function setDefaultShaderModules(modules) {
shaderModuleRegistry.setDefaultShaderModules(modules);
}
export function getDefaultShaderModules() {
return shaderModuleRegistry.getDefaultShaderModules();
}
export function registerShaderModules(shaderModuleList) {
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
_ref$ignoreMultipleRe = _ref.ignoreMultipleRegistrations,
ignoreMultipleRegistrations = _ref$ignoreMultipleRe === void 0 ? false : _ref$ignoreMultipleRe;
shaderModuleRegistry.registerShaderModules(shaderModuleList, {
ignoreMultipleRegistrations: ignoreMultipleRegistrations
});
}
import ShaderModule from './shader-module';
import { assert } from '../utils';
export function resolveModules(modules) {
modules = modules.concat(shaderModuleRegistry.defaultShaderModules);
modules = shaderModuleRegistry.resolveModules(modules);
return getShaderDependencies(modules);
return getShaderDependencies(instantiateModules(modules));
}
export function getShaderModule(moduleOrName) {
return shaderModuleRegistry.getShaderModule(moduleOrName);
}

@@ -43,7 +23,7 @@ function getShaderDependencies(modules) {

function getDependencyGraph(_ref2) {
var modules = _ref2.modules,
level = _ref2.level,
moduleMap = _ref2.moduleMap,
moduleDepth = _ref2.moduleDepth;
function getDependencyGraph(_ref) {
var modules = _ref.modules,
level = _ref.level,
moduleMap = _ref.moduleMap,
moduleDepth = _ref.moduleDepth;

@@ -115,2 +95,15 @@ if (level >= 5) {

function instantiateModules(modules, seen) {
return modules.map(function (module) {
if (module instanceof ShaderModule) {
return module;
}
assert(module.name, 'shader module has no name');
module = new ShaderModule(module);
module.dependencies = instantiateModules(module.dependencies);
return module;
});
}
export var TEST_EXPORTS = {

@@ -117,0 +110,0 @@ getShaderDependencies: getShaderDependencies,

export { default as fp32 } from './fp32/fp32';
export { default as fp64 } from './fp64/fp64';
export { default as project } from './project/project';
export { default as fog } from './fog/fog';
export { default as lights } from './lights/lights';
export { default as dirlight } from './dirlight/dirlight';
export { default as picking } from './picking/picking';
export { default as diffuse } from './diffuse/diffuse';
export { gouraudLighting, phongLighting } from './phong-lighting/phong-lighting';
export { default as pbr } from './pbr/pbr';
export { default as brightnessContrast } from './adjust-filters/brightnesscontrast';
export { default as denoise } from './adjust-filters/denoise';
export { default as hueSaturation } from './adjust-filters/huesaturation';
export { default as noise } from './adjust-filters/noise';
export { default as sepia } from './adjust-filters/sepia';
export { default as vibrance } from './adjust-filters/vibrance';
export { default as vignette } from './adjust-filters/vignette';
export { default as tiltShift } from './blur-filters/tiltshift';
export { default as triangleBlur } from './blur-filters/triangleblur';
export { default as zoomBlur } from './blur-filters/zoomblur';
export { default as colorHalftone } from './fun-filters/colorhalftone';
export { default as dotScreen } from './fun-filters/dotscreen';
export { default as edgeWork } from './fun-filters/edgework';
export { default as hexagonalPixelate } from './fun-filters/hexagonalpixelate';
export { default as ink } from './fun-filters/ink';
export { default as bulgePinch } from './warp-filters/bulgepinch';
export { default as swirl } from './warp-filters/swirl';
export { default as fxaa } from './fxaa/fxaa';
export { default as _transform } from './transform/transform';
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

export default "varying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
export default "uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\n\nvarying vec3 pbr_vPosition;\nvarying vec2 pbr_vUV;\n\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nvarying mat3 pbr_vTBN;\n# else\nvarying vec3 pbr_vNormal;\n# endif\n#endif\n\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\n vec4 pos = u_ModelMatrix * position;\n pbr_vPosition = vec3(pos.xyz) / pos.w;\n\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\n vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\n vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\n vec3 bitangentW = cross(normalW, tangentW) * tangent.w;\n pbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\n pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n\n#ifdef HAS_UV\n pbr_vUV = uv;\n#else\n pbr_vUV = vec2(0.,0.);\n#endif\n}\n";
//# sourceMappingURL=pbr-vertex.glsl.js.map

@@ -1,2 +0,1 @@

import project2 from '../project2/project2';
import lights from '../lights/lights';

@@ -12,4 +11,4 @@ import vs from './pbr-vertex.glsl';

},
dependencies: [project2, lights]
dependencies: [lights]
};
//# sourceMappingURL=pbr.js.map
{
"name": "@luma.gl/shadertools",
"version": "8.0.0-alpha.5",
"version": "8.0.0-alpha.6",
"description": "Shader module system for luma.gl",

@@ -42,3 +42,3 @@ "license": "MIT",

},
"gitHead": "07f5ea0576cd58ec3ff355c1ac493059c863dd51"
"gitHead": "5176c2192744847c87fd282ddf41ea7c8b68c983"
}
// shadertools exports
// DEFAULT SHADERS
// A set of base shaders that leverage the shader module system,
// dynamically enabling features depending on which modules are included
import MODULAR_VS from './shaders/modular-vertex.glsl';
import MODULAR_FS from './shaders/modular-fragment.glsl';
// DOCUMENTED APIS
export {
registerShaderModules,
setDefaultShaderModules,
getDefaultShaderModules
} from './lib/resolve-modules';
export {
assembleShaders,
createShaderHook,
createModuleInjection,
resetGlobalShaderHooks
} from './lib/assemble-shaders';
export {assembleShaders} from './lib/assemble-shaders';

@@ -37,7 +21,1 @@ // HELPERS

export * from './modules';
export const MODULAR_SHADERS = {
vs: MODULAR_VS,
fs: MODULAR_FS,
uniforms: {}
};
import {VERTEX_SHADER, FRAGMENT_SHADER} from './constants';
import {resolveModules, getShaderModule} from './resolve-modules';
import {resolveModules} from './resolve-modules';
import {getPlatformShaderDefines, getVersionDefines} from './platform-defines';

@@ -15,12 +15,2 @@ import injectShader, {DECLARATION_INJECT_MARKER} from './inject-shader';

const HOOK_FUNCTIONS = {
[VERTEX_SHADER]: {},
[FRAGMENT_SHADER]: {}
};
const MODULE_INJECTIONS = {
[VERTEX_SHADER]: {},
[FRAGMENT_SHADER]: {}
};
// Precision prologue to inject before functions are injected in shader

@@ -33,33 +23,2 @@ // TODO - extract any existing prologue in the fragment source and move it up...

export function createShaderHook(hook, opts = {}) {
hook = hook.trim();
const [stage, signature] = hook.split(':');
const name = hook.replace(/\(.+/, '');
HOOK_FUNCTIONS[stage][name] = Object.assign(opts, {signature});
}
export function createModuleInjection(moduleName, opts) {
const {hook, injection, order = 0} = opts;
const shaderStage = hook.slice(0, 2);
const moduleInjections = MODULE_INJECTIONS[shaderStage];
moduleInjections[moduleName] = moduleInjections[moduleName] || {};
assert(!moduleInjections[moduleName][hook], 'Module injection already created');
moduleInjections[moduleName][hook] = {
injection,
order
};
}
// Helpful for tests
export function resetGlobalShaderHooks() {
HOOK_FUNCTIONS[VERTEX_SHADER] = {};
HOOK_FUNCTIONS[FRAGMENT_SHADER] = {};
MODULE_INJECTIONS[VERTEX_SHADER] = {};
MODULE_INJECTIONS[FRAGMENT_SHADER] = {};
}
// Inject a list of modules

@@ -73,4 +32,3 @@ export function assembleShaders(gl, opts) {

fs: assembleShader(gl, Object.assign({}, opts, {source: fs, type: FRAGMENT_SHADER, modules})),
getUniforms: assembleGetUniforms(modules),
modules: assembleModuleMap(modules)
getUniforms: assembleGetUniforms(modules)
};

@@ -89,4 +47,4 @@ }

defines = {},
hookFunctions = HOOK_FUNCTIONS,
moduleInjections = MODULE_INJECTIONS,
hookFunctions = [],
moduleInjections = {},
inject = {},

@@ -99,33 +57,2 @@ prologue = true,

// TODO(Tarek): Supporting global hooks, remove when they're removed.
if (hookFunctions !== HOOK_FUNCTIONS) {
hookFunctions = {
[VERTEX_SHADER]: Object.assign(
{},
HOOK_FUNCTIONS[VERTEX_SHADER],
hookFunctions[VERTEX_SHADER]
),
[FRAGMENT_SHADER]: Object.assign(
{},
HOOK_FUNCTIONS[FRAGMENT_SHADER],
hookFunctions[FRAGMENT_SHADER]
)
};
}
if (moduleInjections !== MODULE_INJECTIONS) {
moduleInjections = {
[VERTEX_SHADER]: Object.assign(
{},
MODULE_INJECTIONS[VERTEX_SHADER],
moduleInjections[VERTEX_SHADER]
),
[FRAGMENT_SHADER]: Object.assign(
{},
MODULE_INJECTIONS[FRAGMENT_SHADER],
moduleInjections[FRAGMENT_SHADER]
)
};
}
const isVertex = type === VERTEX_SHADER;

@@ -170,4 +97,6 @@

hookFunctions = normalizeHookFunctions(hookFunctions);
moduleInjections = normalizeModuleInjections(moduleInjections);
// Add source of dependent modules in resolved order
let injectStandardStubs = false;
const hookInjections = {};

@@ -192,27 +121,20 @@ const mainInjections = {};

for (const module of modules) {
switch (module.name) {
case 'inject':
injectStandardStubs = true;
break;
if (log) {
module.checkDeprecations(coreSource, log);
}
const moduleSource = module.getModuleSource(type, glslVersion);
// Add the module source, and a #define that declares it presence
assembledSource += moduleSource;
default:
if (log) {
module.checkDeprecations(coreSource, log);
if (moduleInjections[type][module.name]) {
const injections = moduleInjections[type][module.name];
for (const key in injections) {
if (key.match(/^(v|f)s:#/)) {
mainInjections[key] = mainInjections[key] || [];
mainInjections[key].push(injections[key]);
} else {
hookInjections[key] = hookInjections[key] || [];
hookInjections[key].push(injections[key]);
}
const moduleSource = module.getModuleSource(type, glslVersion);
// Add the module source, and a #define that declares it presence
assembledSource += moduleSource;
if (moduleInjections[type][module.name]) {
const injections = moduleInjections[type][module.name];
for (const key in injections) {
if (key.match(/^(v|f)s:#/)) {
mainInjections[key] = mainInjections[key] || [];
mainInjections[key].push(injections[key]);
} else {
hookInjections[key] = hookInjections[key] || [];
hookInjections[key].push(injections[key]);
}
}
}
}
}

@@ -230,3 +152,3 @@ }

// Apply any requested shader injections
assembledSource = injectShader(assembledSource, type, mainInjections, injectStandardStubs);
assembledSource = injectShader(assembledSource, type, mainInjections);

@@ -253,14 +175,2 @@ return assembledSource;

// Returns a map with module names as keys, resolving to their module definitions
// The presence of a key indicates that the module is available in this program,
// whether directly included, or through a dependency of some other module
function assembleModuleMap(modules) {
const result = {};
for (const moduleName of modules) {
const shaderModule = getShaderModule(moduleName);
result[moduleName] = shaderModule;
}
return result;
}
function getShaderType({type}) {

@@ -329,1 +239,50 @@ return `

}
function normalizeHookFunctions(hookFunctions) {
const result = {
vs: {},
fs: {}
};
hookFunctions.forEach(hook => {
let opts;
if (typeof hook !== 'string') {
opts = hook;
hook = opts.hook;
} else {
opts = {};
}
hook = hook.trim();
const [stage, signature] = hook.split(':');
const name = hook.replace(/\(.+/, '');
result[stage][name] = Object.assign(opts, {signature});
});
return result;
}
function normalizeModuleInjections(moduleInjections) {
const result = {
vs: {},
fs: {}
};
for (const moduleName in moduleInjections) {
const injections = moduleInjections[moduleName];
for (const hook in injections) {
let injection = injections[hook];
const stage = hook.slice(0, 2);
if (typeof injection === 'string') {
injection = {
injection
};
}
result[stage][moduleName] = result[stage][moduleName] || {};
result[stage][moduleName][hook] = injection;
}
}
return result;
}

@@ -1,43 +0,9 @@

import ShaderModuleRegistry from './shader-module-registry';
import ShaderModule from './shader-module';
import {assert} from '../utils';
const shaderModuleRegistry = new ShaderModuleRegistry();
/**
* Registers an array of default shader modules. These will be concatenated
* automatically at the end of any shader module list passed to
* `assembleShaders` (plus `resolveModules` and `getShaderDependencies`)
* @param {Object[]} modules - Array of shader modules
*/
export function setDefaultShaderModules(modules) {
shaderModuleRegistry.setDefaultShaderModules(modules);
}
export function getDefaultShaderModules() {
return shaderModuleRegistry.getDefaultShaderModules();
}
/**
* Registers an array of shader modules
* @param {Object[]} shaderModuleList - Array of shader modules
*/
export function registerShaderModules(
shaderModuleList,
{ignoreMultipleRegistrations = false} = {}
) {
shaderModuleRegistry.registerShaderModules(shaderModuleList, {ignoreMultipleRegistrations});
}
// registers any supplied modules and returns a list of module names
// Instantiate shader modules and any dependencies resolve dependencies
export function resolveModules(modules) {
modules = modules.concat(shaderModuleRegistry.defaultShaderModules);
modules = shaderModuleRegistry.resolveModules(modules);
return getShaderDependencies(modules);
return getShaderDependencies(instantiateModules(modules));
}
// Looks up a moduleName among registered modules and returns definition.
// If "inline" module, returns it directly
export function getShaderModule(moduleOrName) {
return shaderModuleRegistry.getShaderModule(moduleOrName);
}
/**

@@ -96,2 +62,19 @@ * Takes a list of shader module names and returns a new list of

// registers any supplied modules, resolves any names into modules
// returns a list of modules
function instantiateModules(modules, seen) {
return modules.map(module => {
if (module instanceof ShaderModule) {
return module;
}
assert(module.name, 'shader module has no name');
module = new ShaderModule(module);
module.dependencies = instantiateModules(module.dependencies);
return module;
});
}
export const TEST_EXPORTS = {

@@ -98,0 +81,0 @@ getShaderDependencies,

export {default as fp32} from './fp32/fp32';
export {default as fp64} from './fp64/fp64';
export {default as project} from './project/project';
export {default as fog} from './fog/fog';
export {default as lights} from './lights/lights';
export {default as dirlight} from './dirlight/dirlight';
export {default as picking} from './picking/picking';
export {default as diffuse} from './diffuse/diffuse';
export {gouraudLighting, phongLighting} from './phong-lighting/phong-lighting';
export {default as pbr} from './pbr/pbr';
export {default as brightnessContrast} from './adjust-filters/brightnesscontrast';
export {default as denoise} from './adjust-filters/denoise';
export {default as hueSaturation} from './adjust-filters/huesaturation';
export {default as noise} from './adjust-filters/noise';
export {default as sepia} from './adjust-filters/sepia';
export {default as vibrance} from './adjust-filters/vibrance';
export {default as vignette} from './adjust-filters/vignette';
// glfx BLUR shader modules
export {default as tiltShift} from './blur-filters/tiltshift';
export {default as triangleBlur} from './blur-filters/triangleblur';
export {default as zoomBlur} from './blur-filters/zoomblur';
// glfx FUN shader modules
export {default as colorHalftone} from './fun-filters/colorhalftone';
export {default as dotScreen} from './fun-filters/dotscreen';
export {default as edgeWork} from './fun-filters/edgework';
export {default as hexagonalPixelate} from './fun-filters/hexagonalpixelate';
export {default as ink} from './fun-filters/ink';
// glfx WARP shader modules
export {default as bulgePinch} from './warp-filters/bulgepinch';
export {default as swirl} from './warp-filters/swirl';
// Postprocessing
export {default as fxaa} from './fxaa/fxaa';
// experimental
export {default as _transform} from './transform/transform';
export default `\
uniform mat4 u_MVPMatrix;
uniform mat4 u_ModelMatrix;
uniform mat4 u_NormalMatrix;
varying vec3 pbr_vPosition;

@@ -3,0 +7,0 @@ varying vec2 pbr_vUV;

@@ -1,2 +0,1 @@

import project2 from '../project2/project2';
import lights from '../lights/lights';

@@ -14,3 +13,3 @@

},
dependencies: [project2, lights]
dependencies: [lights]
};

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc