GLSL Functions Explained

UPDATE: Actually, you don’t need to read further, instead go here: http://thebookofshaders.com/glossary/

 

Disclaimer: I’m in no way an expert on GLSL, graphics programing, or anything else in the world, really…

However, I’m finding it difficult to find good docs on WebGL functions, that explain in layman’s terms what the hell they do. So I’m starting a list here and updating it as I learn more. Also, if I’m wrong, tell me, I don’t want to give out bad information.

 

float step(float a, float b)

  • returns a float value of either 0.0 or 1.0 depending on if “b” is higher or lower than “a”
  • “a” represents the limit or threshold to cross
  • “b” represents the number to test against the threshold

float smoothstep(float a, float b, float c)

  • returns a float value of anywhere from 0.0 to 1.0. 0.0 for any “c” value below “a” and 1.0 for any “c” value above “b”. The “c” values in between the “a” and “b” range are interpolated
  • “a” represents the start of the range (threshold)
  • “b” represents the end of the range (threshold)
  • “c” represents the value to test against the range

float fract(float a)

  • returns only the fraction portion of a value. So given the value 3.14159265358979, it will return .14159265358979