Skip to content

Instantly share code, notes, and snippets.

@williamsiuhang
Created February 12, 2019 20:54
Show Gist options
  • Save williamsiuhang/9e6d5060312ea8e5a9f0206379acadf3 to your computer and use it in GitHub Desktop.
Save williamsiuhang/9e6d5060312ea8e5a9f0206379acadf3 to your computer and use it in GitHub Desktop.
Uniform data types for Three js <-> shaders
switch (uniform.type)
{
case 'b':
case 'bool':
case 'boolean':
// single int value
case 'i':
case '1i'
// single float value
case 'f':
case '1f':
// Float32Array(2) or JS Arrray
case '2f':
// Float32Array(3) or JS Arrray
case '3f':
// Float32Array(4) or JS Arrray
case '4f':
// a 2D Point object
case 'v2':
// a 3D Point object
case 'v3':
// a 4D Point object
case 'v4':
// Int32Array or JS Array
case '1iv':
// Int32Array or JS Array
case '2iv':
// Int32Array or JS Array
case '3iv':
// Int32Array or JS Array
case '4iv':
// Float32Array or JS Array
case '1fv':
// Float32Array or JS Array
case '2fv':
// Float32Array or JS Array
case '3fv':
// Float32Array or JS Array
case '4fv':
// Float32Array or JS Array
case 'm2':
case 'mat2':
case 'Matrix2fv':
// Float32Array or JS Array
case 'm3':
case 'mat3':
case 'Matrix3fv':
// Float32Array or JS Array
case 'm4':
case 'mat4':
case 'Matrix4fv':
// a Color Value
case 'c':
// flat array of integers (JS or typed array)
case 'iv1':
// flat array of integers with 3 x N size (JS or typed array)
case 'iv':
// flat array of floats (JS or typed array)
case 'fv1':
// flat array of floats with 3 x N size (JS or typed array)
case 'fv':
// array of 2D Point objects
case 'v2v':
// array of 3D Point objects
case 'v3v':
// array of 4D Point objects
case 'v4v':
// PIXI.Texture
case 't':
case 'sampler2D':
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment