最終更新:2015-03-31 (火) 02:37:10 (3307d)  

GLSL
Top / GLSL

OpenGL Shading Language

http://www.opengl.org/documentation/oglsl.html

メモ

  • OpenGL 1.5?の拡張機能として実装され,OpenGL 2.0で標準機能

シェーダ

GLSL/バージョン

  • GLSL 1.20GLSL ES 1.00のベース
    GLSL VersionOpenGL VersionDateShader Preprocessor
    GLSL 1.10?.59OpenGL 2.0April 2004#version 110
    GLSL 1.20.8OpenGL 2.1September 2006#version 120
    GLSL 1.30.10OpenGL 3.0?August 2008#version 130
    GLSL 1.40?.08OpenGL 3.1?March 2009#version 140
    GLSL 1.50?.11OpenGL 3.2?August 2009#version 150
    GLSL 3.30?.6OpenGL 3.3?February 2010#version 330
    GLSL 4.00?.9OpenGL 4.0?March 2010#version 400
    GLSL 4.10?.6OpenGL 4.1?July 2010#version 410
    GLSL 4.20?.11OpenGL 4.2?August 2011#version 420
    GLSL 4.30?.8OpenGL 4.3August 2012#version 430
    GLSL 4.40?OpenGL 4.4July 2013#version 440

GLSL/データ型

変数の修飾子

attribute?

  • 頂点単位のデータ読み込み用。(頂点シェーダでのみ使用可能)

uniform

  • シェーダが呼び出され実行される時に変化しない定数で、CPUから渡されてくるもの。
  • the value does not change between multiple executions of a shader during the rendering of a primitive (ie: during a glDraw* call).
  • These values are set by the user from the OpenGL API.
  • They are constant, but not compile-time constant (so not const​).

varyng?

  • 頂点シェーダの出力を意味する。フラグメントシェーダでは補間された入力値となっている。

const

  • コンパイル時に定数として処理される
  • シェーダの中で変数の値を変更することはできない

精度修飾子

  • 修飾子説明使用例
    lowp?低精度precision lowp float;
    mediump中精度precision mediump float;
    highp高精度(デフォルト)precision highp float;

パラメータ修飾子?

  • 修飾子説明
    inパラメーターが値で渡され、関数で変更されない事を示す(デフォルト値)
    inout変数が参照で関数に渡され、その値が変更される場合は、関数終了後に行われる事を示す
    out変数の値は関数に渡されず、関数から戻るときに変更される事を示す

GLSL/組み込み変数

オンラインプログラミング

Wikibooks

関連

参考