threejs built-in variables
vertex shader
- highp vec4 gl_PointSize point size
- mediump float gl_Position Needless to say
fragment shader
- mediump vec4 gl_FragCoord screen coordinate system
- bool gl_FrontFacing
- mediump vec4 gl_FragColor most important
- mediump vec4 gl_FragData[gl_MaxDrawBuffers] cache data
- mediump vec2 gl_PointCoord The coordinate system used when using textures for points
constant
- const mediump int gl_MaxVertexAttribs = 8;
- const mediump int gl_MaxVertexUniformVectors = 128;
- const mediump int gl_MaxVaryingVectors = 8;
- const mediump int gl_MaxVertexTextureImageUnits = 0;
- const mediump int gl_MaxCombinedTextureImageUnits = 8;
- const mediump int gl_MaxTextureImageUnits = 8;
- const mediump int gl_MaxFragmentUniformVectors = 16;
- const mediump int gl_MaxDrawBuffers = 1;
built-in functions
If you don’t understand the function well, you can check it out on this website , the effect is more intuitive. I won’t post pictures, after all, it’s better to do it yourself.
Trigonometric functions
- radians angle to radians
- degree angle of rotation in radians
- sin
- cos
- tan
- asin
- acos
- for the purpose
exponential function
- pow
- exp
- log
- exp2
- log2
- sqrt
- inversesqrt = 1/sqrt
Commonly used functions
- abs
- sign
- floor
- ceil
- fract = x - floor(x)
- mod
- min
- max
- clamp
- mix
- step
- smoothstep
Geometric functions
- length
- distance
- dot
- cross
- normalize
- faceforward
- reflect
- refract
matrix function
- matrixCompMult
vector correlation function
- lessThan
- lessThanEqual
- greaterThan
- greaterThanEqual
- equal
- notEqual
- any
- all
- not
Texture related functions
- texture2D
- texture2DProj
- texture2DLod
- texture2DProjLod
- textureCube
- textureCubeLod