muerwre.github.io/content/Frontend/WebGL/Fragment Shaders.md
2022-11-27 19:44:07 +06:00

710 B

Fragment shaders describe ==how polygons are painted== (or textured). Read Basics of WebGL (Drawing a Cube) first.

Sample fragment vertex

Parameters could be passed here as written at Vertex Shaders.

precision highp float;

// parameter from Vertex Shader
varying vec4 v_positionWithOffset;
// parameters passed from Javascript loop
uniform float slide;
uniform float aspect;

void main(void){
  // color, attached to current verticle {r,g,b,alpha}
  // same a[
  //   v_positionWithOffset.x,
  //   v_positionWithOffset.y, 
  //   v_positionWithOffset.z, 
  //   1
  //  ]
  gl_FragColor=vec4(v_positionWithOffset.xyz,1);
}```