function uniformToVarying({vertexShader, fragmentShader}, uniformName, varyingName = uniformName) {
  const uniformRE = new RegExp(`uniform\\s+(bool|float|vec[234]|mat[34])\\s+${uniformName}\\b`)

  let type
  let hadFragmentUniform = false
  fragmentShader = fragmentShader.replace(uniformRE, ($0, $1) => {
    hadFragmentUniform = true
    return `varying ${type = $1} ${varyingName}`
  })

  let hadVertexUniform = false
  vertexShader = vertexShader.replace(uniformRE, (_, $1) => {
    hadVertexUniform = true
    return `${hadFragmentUniform ? 'varying' : ''} ${type = $1} ${varyingName}`
  })
  if (!hadVertexUniform) {
    vertexShader = `${hadFragmentUniform ? 'varying' : ''} ${type} ${varyingName};\n${vertexShader}`
  }
  return {vertexShader, fragmentShader}
}
Turn a uniform into a varying/writeable value.
- If the uniform was used in the fragment shader, it will become a varying in both shaders.
- If the uniform was only used in the vertex shader, it will become a writeable var.