Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function upgradeShaders(vertexShader, fragmentShader, instanceUniforms=[]) {
// Pre-expand includes
vertexShader = expandShaderIncludes(vertexShader)
fragmentShader = expandShaderIncludes(fragmentShader)
// See what gets used
let usesModelMatrix = modelMatrixRefRE.test(vertexShader)
let usesModelViewMatrix = modelViewMatrixRefRE.test(vertexShader)
let usesNormalMatrix = normalMatrixRefRE.test(vertexShader)
// Find what uniforms are declared in which shader and their types
let vertexUniforms = getShaderUniformTypes(vertexShader)
let fragmentUniforms = getShaderUniformTypes(fragmentShader)
let vertexDeclarations = [modelMatrixRowAttrs]
let vertexAssignments = []
let fragmentDeclarations = []
// Add variable assignments for, and rewrite references to, builtin matrices
if (usesModelMatrix || usesModelViewMatrix || usesNormalMatrix) {
export function upgradeShaders(vertexShader, fragmentShader, instanceUniforms=[]) {
// Pre-expand includes
vertexShader = expandShaderIncludes(vertexShader)
fragmentShader = expandShaderIncludes(fragmentShader)
// See what gets used
let usesModelMatrix = modelMatrixRefRE.test(vertexShader)
let usesModelViewMatrix = modelViewMatrixRefRE.test(vertexShader)
let usesNormalMatrix = normalMatrixRefRE.test(vertexShader)
// Find what uniforms are declared in which shader and their types
let vertexUniforms = getShaderUniformTypes(vertexShader)
let fragmentUniforms = getShaderUniformTypes(fragmentShader)
let vertexDeclarations = [modelMatrixRowAttrs]
let vertexAssignments = []
let fragmentDeclarations = []
// Add variable assignments for, and rewrite references to, builtin matrices