Skip to content

GLSL

Type Qualifier (GLSL) - OpenGL Wiki > Shader - OpenGL Wiki

  • 渲染管线中可编程的部分

    • 顶点着色器 -> 片元着色器
  • precision
  • uniform

    • uniform 作为顶点和片元着色器的输入
    • 所有线程的输入值必须统一且只读
  • vec4 gl_Position
    • 顶点着色器中顶点位置输出
  • vec4 gl_FragColor
    • 片元着色器中颜色输出
  • vec4 gl_FragCoord
    • 存储了活动线程正在处理的像素或屏幕碎片的坐标

For WebGL

The Study of Shaders with React Three Fiber - Maxime Heckel's Blog > Introduction to Shaders > p5.js/contributor_docs/webgl_mode_architecture.md at main · processing/p5.js · GitHub

  • attribute
    • deprecated since GLSL 1.30 (OpenGL 3.0)
    • input in vertex shaders, 输入不同的数据到各顶点
    • attribute 只用于顶点着色器
  • varying
    • deprecated since GLSL 1.30 (OpenGL 3.0)
    • the input of a fragment shader or the output of a vertex shader

[!NOTE] p5 中的坐标转换

vec4 viewModelPosition = uModelViewMatrix * vec4(aPosition, 1.0);
gl_Position = uProjectionMatrix * viewModelPosition;