How to use the troika-three-utils.expandShaderIncludes function in troika-three-utils

To help you get started, we’ve selected a few troika-three-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github protectwise / troika / packages / troika-3d / src / facade / instancing / InstancingShaderUpgrades.js View on Github external
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) {
github protectwise / troika / packages / troika-3d / src / facade / instancing / InstancingShaderUpgrades.js View on Github external
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

troika-three-utils

Various utilities related to Three.js

MIT
Latest version published 11 days ago

Package Health Score

83 / 100
Full package analysis

Similar packages