Shader-Sprache¶
Einführung¶
Godot verwendet eine Shader-Sprache ähnlich GLSL ES 3.0. Die meisten Datentypen und Funktionen werden unterstützt, und die wenigen verbleibenden werden wahrscheinlich im Laufe der Zeit hinzugefügt.
If you are already familiar with GLSL, the Godot Shader Migration Guide is a resource that will help you transition from regular GLSL to Godot's shading language.
Datentypen¶
Die meisten GLSL ES 3.0 Datentypen werden unterstützt:
Art |
Beschreibung |
---|---|
void |
Void Datentyp, nur nützlich für Funktionen die nichts zurück übergeben. |
bool |
Boolesche Datentyp, kann nur |
bvec2 |
Zweikomponentenvektor von Booleschen Werten. |
bvec3 |
Drei-Komponenten Vektor mit Booleschen. |
bvec4 |
Vier-Komponenten Vektor mit Booleschen. |
int |
vorzeichenbehaftete skalare Ganzzahl. |
ivec2 |
Zwei-Komponenten Vektor mit vorzeichenbehafteten Ganzzahlen. |
ivec3 |
Drei-Komponenten Vektor mit vorzeichenbehafteten Ganzzahlen. |
ivec4 |
Vier-Komponenten Vektor mit vorzeichenbehafteten Ganzzahlen. |
uint |
Skalare Ganzzahl ohne Vorzeichen, kann keine negativen Zahlen enthalten. |
uvec2 |
Zwei-Komponenten Vektor mit Ganzzahl ohne Vorzeichen. |
uvec3 |
Drei-Komponenten Vektor mit Ganzzahl ohne Vorzeichen. |
uvec4 |
Vier-Komponenten Vektor mit Ganzzahl ohne Vorzeichen. |
float |
Gleitkomma-Skalar. |
vec2 |
Zwei-Komponenten Vektor mit Fließkomma-Werten. |
vec3 |
Drei-Komponenten Vektor mit Fließkomma-Werten. |
vec4 |
Vier-Komponenten Vektor mit Fließkomma-Werten. |
mat2 |
2x2 Matrix, in spaltenweiser Anordnung. |
mat3 |
3x3 Matrix, in spaltenweiser Anordnung. |
mat4 |
4x4 Matrix, in spaltenweiser Anordnung. |
sampler2D |
Sampler Typ um 2D Texturen zu binden, welche als Fließkommazahl gelesen werden. |
isampler2D |
Sampler Typ um 2D Texturen zu binden, welche als vorzeichenbehaftete Ganzzahlen gelesen werden. |
usampler2D |
Sampler Typ um 2D Texturen zu binden, welche als Ganzzahlen ohne Vorzeichen gelesen werden. |
sampler2DArray |
Sampler Typ um 2D Texturfelder zu binden, welche als Fließkommazahl gelesen werden. |
isampler2DArray |
Sampler Typ um 2D Textur-Arrays zu binden, welche als vorzeichenbehaftete Ganzzahlen gelesen werden. |
usampler2DArray |
Sampler Typ um 2D Texturfelder zu binden, welche als Ganzzahlen ohne Vorzeichen gelesen werden. |
sampler3D |
Sampler Typ um 3D Texturen zu binden, welche als Fließkommazahl gelesen werden. |
isampler3D |
Sampler Typ um 3D Texturen zu binden, welche als vorzeichenbehaftete Ganzzahlen gelesen werden. |
usampler3D |
Sampler Typ um 3D Texturen zu binden, welche als Ganzzahlen ohne Vorzeichen gelesen werden. |
samplerCube |
Sampler Typ um Würfelformen zu binden, welche als Fließkommazahl gelesen werden. |
Casting (Typumwandlung)¶
Genau wie bei GLSL ES 3.0 ist implizites Casting zwischen Skalaren und Vektoren gleicher Größe, aber unterschiedlichen Typs nicht zulässig. Casting von Typen unterschiedlicher Größe ist ebenfalls nicht zulässig. Die Konvertierung muss explizit über Konstruktoren erfolgen.
Beispiel:
float a = 2; // invalid
float a = 2.0; // valid
float a = float(2); // valid
Standard-Ganzzahlkonstanten sind vorzeichenbehaftet, daher ist immer eine Umwandlung erforderlich um in vorzeichenlose zu konvertieren:
int a = 2; // valid
uint a = 2; // invalid
uint a = uint(2); // valid
Mitglieder¶
Individual scalar members of vector types are accessed via the "x", "y", "z" and "w" members. Alternatively, using "r", "g", "b" and "a" also works and is equivalent. Use whatever fits best for your needs.
For matrices, use the m[column][row]
indexing syntax to access each scalar,
or m[idx]
to access a vector by row index. For example, for accessing the y
position of an object in a mat4 you use m[3][1]
.
Konstruieren¶
Die Konstruktion von Vektortypen muss immer bestehen aus:
// The required amount of scalars
vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
// Complementary vectors and/or scalars
vec4 a = vec4(vec2(0.0, 1.0), vec2(2.0, 3.0));
vec4 a = vec4(vec3(0.0, 1.0, 2.0), 3.0);
// A single scalar for the whole vector
vec4 a = vec4(0.0);
Construction of matrix types requires vectors of the same dimension as the matrix. You can
also build a diagonal matrix using matx(float)
syntax. Accordingly, mat4(1.0)
is
an identity matrix.
mat2 m2 = mat2(vec2(1.0, 0.0), vec2(0.0, 1.0));
mat3 m3 = mat3(vec3(1.0, 0.0, 0.0), vec3(0.0, 1.0, 0.0), vec3(0.0, 0.0, 1.0));
mat4 identity = mat4(1.0);
Matrices can also be built from a matrix of another dimension. There are two rules : If a larger matrix is constructed from a smaller matrix, the additional rows and columns are set to the values they would have in an identity matrix. If a smaller matrix is constructed from a larger matrix, the top, left submatrix of the larger matrix is used.
mat3 basis = mat3(WORLD_MATRIX);
mat4 m4 = mat4(basis);
mat2 m2 = mat2(m4);
Swizzling (Elemente eines Vektors neu anordnen)¶
It is possible to obtain any combination of components in any order, as long as the result is another vector type (or scalar). This is easier shown than explained:
vec4 a = vec4(0.0, 1.0, 2.0, 3.0);
vec3 b = a.rgb; // Creates a vec3 with vec4 components.
vec3 b = a.ggg; // Also valid; creates a vec3 and fills it with a single vec4 component.
vec3 b = a.bgr; // "b" will be vec3(2.0, 1.0, 0.0).
vec3 b = a.xyz; // Also rgba, xyzw are equivalent.
vec3 b = a.stp; // And stpq (for texture coordinates).
float c = b.w; // Invalid, because "w" is not present in vec3 b.
vec3 c = b.xrt; // Invalid, mixing different styles is forbidden.
b.rrr = a.rgb; // Invalid, assignment with duplication.
b.bgr = a.rgb; // Valid assignment. "b"'s "blue" component will be "a"'s "red" and vice versa.
Präzision¶
Es ist möglich Datentypen Präzisionsmodifikatoren hinzuzufügen. Verwenden Sie diese für Uniforms, Variablen, Argumente und Variationen:
lowp vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // low precision, usually 8 bits per component mapped to 0-1
mediump vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // medium precision, usually 16 bits or half float
highp vec4 a = vec4(0.0, 1.0, 2.0, 3.0); // high precision, uses full float or integer range (default)
Die Verwendung einer geringeren Genauigkeit für einige Operationen kann den Rechenaufwand beschleunigen (auf Kosten einer geringeren Genauigkeit). Dies wird in der Vertex-Prozessorfunktion selten benötigt (wo die meiste Zeit volle Präzision erforderlich ist), wird jedoch im Fragmentprozessor häufig nützlich.
Einige Architekturen (hauptsächlich mobile) können stark davon profitieren, aber es gibt auch Nachteile, beispielsweise den Mehraufwand zur Konvertierung zwischen Werten unterschiedlicher Genauigkeit. Bitte lesen Sie die entsprechende Dokumentation zur Zielarchitektur, um mehr zu erfahren. In vielen Fällen verursachen mobile Treiber inkonsistentes oder unerwartetes Verhalten. Es ist deshalb am besten, keine Präzision anzugeben, wenn es nicht unbedingt erforderlich ist.
Arrays (Felder)¶
Arrays are containers for multiple variables of a similar type. Note: As of Godot 3.2, only local and varying arrays have been implemented.
Lokale Arrays¶
Local arrays are declared in functions. They can use all of the allowed datatypes, except samplers.
The array declaration follows a C-style syntax: [const] + [precision] + typename + identifier + [array size]
.
void fragment() {
float arr[3];
}
Sie können zu Beginn wie folgt initialisiert werden:
float float_arr[3] = float[3] (1.0, 0.5, 0.0); // first constructor
int int_arr[3] = int[] (2, 1, 0); // second constructor
vec2 vec2_arr[3] = { vec2(1.0, 1.0), vec2(0.5, 0.5), vec2(0.0, 0.0) }; // third constructor
bool bool_arr[] = { true, true, false }; // fourth constructor - size is defined automatically from the element count
Sie können mehrere Arrays (auch mit unterschiedlichen Größen) in einem Ausdruck deklarieren:
float a[3] = float[3] (1.0, 0.5, 0.0),
b[2] = { 1.0, 0.5 },
c[] = { 0.7 },
d = 0.0,
e[5];
Verwenden Sie die Indizierungssyntax, um auf ein Array-Element zuzugreifen:
float arr[3];
arr[0] = 1.0; // setter
COLOR.r = arr[0]; // getter
Arrays also have a built-in function .length()
(not to be confused with the built-in length()
function). It doesn't accept any parameters and will return the array's size.
float arr[] = { 0.0, 1.0, 0.5, -1.0 };
for (int i = 0; i < arr.length(); i++) {
// ...
}
Bemerkung
If you use an index below 0 or greater than array size - the shader will crash and break rendering. To prevent this, use length()
, if
, or clamp()
functions to ensure the index is between 0 and the array's length. Always carefully test and check your code. If you pass a constant expression or a simple number, the editor will check its bounds to prevent this crash.
Konstanten¶
Use the const
keyword before the variable declaration to make that variable immutable, which means that it cannot be modified. All basic types, except samplers can be declared as constants. Accessing and using a constant value is slightly faster than using a uniform. Constants must be initialized at their declaration.
const vec2 a = vec2(0.0, 1.0);
vec2 b;
a = b; // invalid
b = a; // valid
Constants cannot be modified and additionally cannot have hints, but multiple of them (if they have the same type) can be declared in a single expression e.g
const vec2 V1 = vec2(1, 1), V2 = vec2(2, 2);
Ähnlich wie Variablen können Arrays auch mit const
deklariert werden.
const float arr[] = { 1.0, 0.5, 0.0 };
arr[0] = 1.0; // invalid
COLOR.r = arr[0]; // valid
Constants can be declared both globally (outside of any function) or locally (inside a function). Global constants are useful when you want to have access to a value throughout your shader that does not need to be modified. Like uniforms, global constants are shared between all shader stages, but they are not accessible outside of the shader.
shader_type spatial;
const float PI = 3.14159265358979323846;
Operatoren¶
Die Godot Shader-Sprache unterstützt dieselben Operatoren wie GLSL ES 3.0. Unten ist die Liste von ihnen in der Rangfolge:
Priorität |
Klasse |
Operator |
1 (höchste) |
Gruppierung in Klammern |
() |
2 |
einstellig (unär) |
+, -, !, ~ |
3 |
multiplikativ |
/, *, % |
4 |
additiv |
+, - |
5 |
bitweise schieben |
<<, >> |
6 |
relational |
<, >, <=, >= |
7 |
Gleichheit |
==, != |
8 |
bitweises UND |
& |
9 |
bitweises Exklusiv-ODER |
^ |
10 |
bitweises Inklusiv-ODER |
| |
11 |
logisches UND |
&& |
12 (niedrigste) |
logisches inklusiv ODER |
|| |
Flußkontrolle¶
Godot's Shader-Sprache unterstützt die gebräuchlichsten Typen von Flußkontrollen:
// if and else
if (cond) {
} else {
}
// switch
switch(i) { // signed integer expression
case -1:
break;
case 0:
return; // break or return
case 1: // pass-through
case 2:
break;
//...
default: // optional
break;
}
// for loops
for (int i = 0; i < 10; i++) {
}
// while
while (true) {
}
// do while
do {
} while(true);
Beachten Sie, dass in modernen GPUs eine Endlosschleife existieren und Ihre Anwendung (einschließlich Editor) einfrieren kann. Godot kann Sie nicht davor schützen, also passen Sie auf, dass Sie diesen Fehler nicht machen!
Warnung
Beim Exportieren eines GLES2-Projekts nach HTML5 wird WebGL 1.0 verwendet. WebGL 1.0 unterstützt keine dynamischen Schleifen, daher funktionieren dort keine Shader, die diese verwenden.
Verwerfen¶
Fragment- und Beleuchtungsfunktionen können das Schlüsselwort discard verwenden. Bei Verwendung wird das Fragment verworfen und nichts geschrieben.
Funktionen¶
Es ist möglich, Funktionen in einem Godot-Shader zu definieren. Sie verwenden die folgende Syntax:
ret_type func_name(args) {
return ret_type; // if returning a value
}
// a more specific example:
int sum2(int a, int b) {
return a + b;
}
Sie können nur Funktionen verwenden, die oben (höher im Editor) definiert wurden, als die Funktion von der aus Sie sie aufrufen.
Funktionsargumente können spezielle Kennzeichnungsmerkmale haben:
in: bedeutet dass Argument kann nur gelesen werden (Standard).
out: bedeutet dass Argument kann nur geschrieben werden.
inout: bedeutet dass Argument wird komplett als Referenz übergeben.
Hier ein Beispiel:
void sum2(int a, int b, inout int result) {
result = a + b;
}
Variiert¶
To send data from the vertex to the fragment (or light) processor function, varyings are used. They are set for every primitive vertex in the vertex processor, and the value is interpolated for every pixel in the fragment processor.
shader_type spatial;
varying vec3 some_color;
void vertex() {
some_color = NORMAL; // Make the normal the color.
}
void fragment() {
ALBEDO = some_color;
}
void light() {
DIFFUSE_LIGHT = some_color * 100; // optionally
}
Eine Variation kann auch ein Array sein:
shader_type spatial;
varying float var_arr[3];
void vertex() {
var_arr[0] = 1.0;
var_arr[1] = 0.0;
}
void fragment() {
ALBEDO = vec3(var_arr[0], var_arr[1], var_arr[2]); // red color
}
It's also possible to send data from fragment to light processors using varying keyword. To do so you can assign it in the fragment and later use it in the light function.
shader_type spatial;
varying vec3 some_light;
void fragment() {
some_light = ALBEDO * 100.0; // Make a shining light.
}
void light() {
DIFFUSE_LIGHT = some_light;
}
Note that varying may not be assigned in custom functions or a light processor function like:
shader_type spatial;
varying float test;
void foo() {
test = 0.0; // Error.
}
void vertex() {
test = 0.0;
}
void light() {
test = 0.0; // Error too.
}
This limitation was introduced to prevent incorrect usage before initialization.
Interpolations-Kennzeichnungsmerkmale¶
Bestimmte Werte werden während der Shading-Pipeline interpoliert. Sie können die Ausführung dieser Interpolationen mithilfe von Interpolationsqualifizierern ändern.
shader_type spatial;
varying flat vec3 our_color;
void vertex() {
our_color = COLOR.rgb;
}
void fragment() {
ALBEDO = our_color;
}
Es gibt zwei mögliche Interpolations-Kennzeichnungsmerkmale:
Merkmal |
Beschreibung |
---|---|
flat |
Der Wert ist nicht interpoliert. |
smooth |
Der Wert ist interpoliert in einer perspektivisch korrekten Art. Dies ist der Standard. |
Uniforms¶
Das Übergeben von Werten an Shader ist möglich. Diese sind für den gesamten Shader global und werden als Uniforms bezeichnet. Wenn ein Shader später einem Material zugewiesen wird, werden die Uniforms als bearbeitbare Parameter darin angezeigt. Uniforms können nicht aus dem Shader heraus geschrieben werden.
shader_type spatial;
uniform float some_value;
Sie können Uniforms im Editor im Material festlegen. Oder Sie können sie über GDScript erstellen:
material.set_shader_param("some_value", some_value)
Bemerkung
Das erste Argument für set_shader_param
ist der Name des Uniform im Shader. Es muss genau mit dem Namen des Uniform im Shader übereinstimmen, sonst wird es nicht erkannt.
Any GLSL type except for void can be a uniform. Additionally, Godot provides optional shader hints to make the compiler understand for what the uniform is used, and how the editor should allow users to modify it.
shader_type spatial;
uniform vec4 color : hint_color;
uniform float amount : hint_range(0, 1);
uniform vec4 other_color : hint_color = vec4(1.0);
Es ist wichtig zu verstehen, dass Texturen die als Farbe geliefert werden, Hinweise für eine ordnungsgemäße sRGB-> lineare Konvertierung erfordern (z.B. hint_albedo
), da die 3D-Engine von Godot im linearen Farbraum gerendert wird.
Hier eine komplette Liste von Hinweisen:
Art |
Hinweis |
Beschreibung |
---|---|---|
vec4 |
hint_color |
Genutzt als Farbe. |
int, float |
hint_range(min, max[, step]) |
Beschränkt auf Werte in einem Bereich (mit Min/Max/Schritt). |
sampler2D |
hint_albedo |
genutzt als Albedofarbe, Standard ist weiß. |
sampler2D |
hint_black_albedo |
genutzt als Albedofarbe, Standard ist schwarz. |
sampler2D |
hint_normal |
Als NormalMap verwendet. |
sampler2D |
hint_white |
Als Wert, Standard ist weiß. |
sampler2D |
hint_black |
als Wert, Standard ist schwarz |
sampler2D |
hint_aniso |
Als FlowMap, standardmäßig nach rechts. |
GDScript verwendet andere Variablentypen als GLSL. Wenn Sie also Variablen von GDScript an Shader übergeben, konvertiert Godot den Typ automatisch. Unten finden Sie eine Tabelle der entsprechenden Typen:
GDScript-Typ |
GLSL Typ |
---|---|
bool |
bool |
int |
int |
float |
float |
Vector2 |
vec2 |
Vector3 |
vec3 |
Color |
vec4 |
Transform |
mat4 |
Transform2D |
mat4 |
Bemerkung
Seien Sie vorsichtig, wenn Sie Shader-Uniforms aus GDScript festlegen. Wenn der Typ nicht übereinstimmt wird kein Fehler ausgegeben. Ihr Shader zeigt nur undefiniertes Verhalten.
Uniforms können auch Standardwerte zugewiesen werden:
shader_type spatial;
uniform vec4 some_vector = vec4(0.0);
uniform vec4 some_color : hint_color = vec4(1.0);
Built-in variables¶
A large number of built-in variables are available, like UV
, COLOR
and VERTEX
. What variables are available depends on the type of shader (spatial
, canvas_item
or particle
) and the function used (vertex
, fragment
or light
).
For a list of the build-in variables that are available, please see the corresponding pages:
Eingebaute Funktionen¶
Es wird eine große Anzahl integrierter Funktionen unterstützt, die GLSL ES 3.0 entsprechen. Wenn die Nomenklatur vec_type (float), vec_int_type, vec_uint_type, vec_bool_type verwendet wird, kann sie ein Skalar oder Vektor sein.
Bemerkung
Eine Liste der Funktionen, die im GLES2-Backend nicht verfügbar sind, finden Sie im Unterschiede zwischen GLES2- und GLES3-Dokument.
Funktion |
Beschreibung |
---|---|
vec_type radians (vec_type degrees) |
konvertiert Grad nach Radiant |
vec_type degrees (vec_type radians) |
konvertiert Radiant nach Grad |
vec_type sin (vec_type x) |
Sinus |
vec_type cos (vec_type x) |
Kosinus |
vec_type tan (vec_type x) |
Tangens |
vec_type asin (vec_type x) |
Arkussinus |
vec_type acos (vec_type x) |
Arkuskosinus |
vec_type atan (vec_type y_over_x) |
Arkustangens |
vec_type atan (vec_type y, vec_type x) |
Arkustangens um einen Vektor in einem Winkel zu konvertieren |
vec_type sinh (vec_type x) |
Hyperbolischer Sinus |
vec_type cosh (vec_type x) |
Hyperbolischer Kosinus |
vec_type tanh (vec_type x) |
Hyperbolischer Tangens |
vec_type asinh (vec_type x) |
Inverser Hyperbolischer Sinus |
vec_type acosh (vec_type x) |
Inverser Hyperbolischer Kosinus |
vec_type atanh (vec_type x) |
Inverser Hyperbolischer Tangens |
vec_type pow (vec_type x, vec_type y) |
Potenz (undefiniert falls |
vec_type exp (vec_type x) |
Basis-e exponentiell |
vec_type exp2 (vec_type x) |
Basis-2 exponentiell |
vec_type log (vec_type x) |
natürlicher Logarithmus |
vec_type log2 (vec_type x) |
Basis-2 Logarithmus |
vec_type sqrt (vec_type x) |
Quadratwurzel |
vec_type inversesqrt (vec_type x) |
inverse Quadratwurzel |
vec_type abs (vec_type x) |
Absolut |
ivec_type abs (ivec_type x) |
Absolut |
vec_type sign (vec_type x) |
Vorzeichen |
ivec_type sign (ivec_type x) |
Vorzeichen |
vec_type floor (vec_type x) |
Abrundungsfunktion (Gauß-Klammer) |
vec_type round (vec_type x) |
runden |
vec_type roundEven (vec_type x) |
runden auf die nächste gerade Zahl |
vec_type trunc (vec_type x) |
kürzen |
vec_type ceil (vec_type x) |
Aufrundungsfunktion |
vec_type fract (vec_type x) |
Bruchteil |
vec_type mod (vec_type x, vec_type y) |
Rest |
vec_type mod (vec_type x , float y) |
Rest |
vec_type modf (vec_type x, out vec_type i) |
Bruch von |
vec_type min (vec_type a, vec_type b) |
Minimum |
vec_type max (vec_type a, vec_type b) |
Maximum |
vec_type clamp (vec_type x, vec_type min, vec_type max) |
Beschränken auf |
float mix (float a, float b, float c) |
Lineare Interpolation |
vec_type mix (vec_type a, vec_type b, float c) |
lineare Interpolation (Skalar Koeffizient) |
vec_type mix (vec_type a, vec_type b, vec_type c) |
Lineare Interpolation (Vector Koeffizient) |
vec_type mix (vec_type a, vec_type b, bvec_type c) |
Lineare Interpolation (Boolesche-Vector Selektion) |
vec_type step (vec_type a, vec_type b) |
|
vec_type step (float a, vec_type b) |
|
vec_type smoothstep (vec_type a, vec_type b, vec_type c) |
Hermiteinterpolation |
vec_type smoothstep (float a, float b, vec_type c) |
Hermiteinterpolation |
bvec_type isnan (vec_type x) |
Liefert |
bvec_type isinf (vec_type x) |
Liefert |
ivec_type floatBitsToInt (vec_type x) |
Fließkomma->Ganzzahl - Bitweise-Kopieren, keine Konvertierung |
uvec_type floatBitsToUint (vec_type x) |
Fließkomma->vorzeichenlose Ganzzahl - Bitweise-Kopieren, keine Konvertierung |
vec_type intBitsToFloat (ivec_type x) |
Ganzzahl->Fließkomma - Bitweise-Kopieren, keine Konvertierung |
vec_type uintBitsToFloat (uvec_type x) |
vorzeichenlose Ganzzahl->Fließkomma - Bitweise-Kopieren, keine Konvertierung |
float length (vec_type x) |
Vektorlänge |
float distance (vec_type a, vec_type b) |
Abstand zwischen Vektoren, also |
float dot (vec_type a, vec_type b) |
Skalarprodukt (Punktprodukt) |
vec3 cross (vec3 a, vec3 b) |
Kreuzprodukt |
vec_type normalize (vec_type x) |
normalisieren auf die Einheitslänge |
vec3 reflect (vec3 I, vec3 N) |
Reflektieren |
vec3 refract (vec3 I, vec3 N, float eta) |
Ablenken |
vec_type faceforward (vec_type N, vec_type I, vec_type Nref) |
Falls |
mat_type matrixCompMult (mat_type x, mat_type y) |
Matrizenmultiplikation |
mat_type outerProduct (vec_type column, vec_type row) |
Matrix-Außenprodukt |
mat_type transpose (mat_type m) |
Matrix transponieren |
float determinant (mat_type m) |
Matrix-Determinante |
mat_type inverse (mat_type m) |
Matrix invertieren |
bvec_type lessThan (vec_type x, vec_type y) |
Boolescher-Vektorvergleich für < int/uint/float-Vektoren |
bvec_type greaterThan (vec_type x, vec_type y) |
Boolescher-Vektorvergleich für > int/uint/float-Vektoren |
bvec_type lessThanEqual (vec_type x, vec_type y) |
Boolescher-Vektorvergleich für <= int/uint/float-Vektoren |
bvec_type greaterThanEqual (vec_type x, vec_type y) |
Boolescher-Vektorvergleich für >= int/uint/float-Vektoren |
bvec_type equal (vec_type x, vec_type y) |
Boolescher-Vektorvergleich für == int/uint/float-Vektoren |
bvec_type notEqual (vec_type x, vec_type y) |
Boolescher-Vektorvergleich für != int/uint/float-Vektoren |
bool any (bvec_type x) |
Irgendeine Komponente ist |
bool all (bvec_type x) |
Alle Komponenten sind |
bvec_type not (bvec_type x) |
Booleschen Vektor invertieren |
ivec2 textureSize (sampler2D_type s, int lod) |
Größe einer 2D Textur holen |
ivec3 textureSize (sampler2DArray_type s, int lod) |
Größe eines 2D-Textur-Arrays ermitteln |
ivec3 textureSize (sampler3D s, int lod) |
Größe einer 3D-Textur ermitteln |
ivec2 textureSize (samplerCube s, int lod) |
Größe einer CubeMap-Textur ermitteln |
vec4_type texture (sampler2D_type s, vec2 uv [, float bias]) |
2D-Texturlesung durchführen |
vec4_type texture (sampler2DArray_type s, vec3 uv [, float bias]) |
2D-Textur-Arraylesung durchführen |
vec4_type texture (sampler3D_type s, vec3 uv [, float bias]) |
Liest eine 3D Textur ein |
vec4 texture (samplerCube s, vec3 uv [, float bias]) |
CubeMap-Texturlesung durchführen |
vec4_type textureProj (sampler2D_type s, vec3 uv [, float bias]) |
2D-Texturlesung mit Projektion durchführen |
vec4_type textureProj (sampler2D_type s, vec4 uv [, float bias]) |
2D-Texturlesung mit Projektion durchführen |
vec4_type textureProj (sampler3D_type s, vec4 uv [, float bias]) |
3D-Texturlesung mit Projektion durchführen |
vec4_type textureLod (sampler2D_type s, vec2 uv, float lod) |
2D-Texturlesung in einer benutzerdefinierten MipMap durchführen |
vec4_type textureLod (sampler2DArray_type s, vec3 uv, float lod) |
2D-Textur-Arraylesung in einer benutzerdefinierten MipMap durchführen |
vec4_type textureLod (sampler3D_type s, vec3 uv, float lod) |
Liest eine 3D Textur aus einer benutzerdefinierten Mipmap |
vec4 textureLod (samplerCube s, vec3 uv, float lod) |
Liest eine 3D Textur aus einer benutzerdefinierten Mipmap |
vec4_type textureProjLod (sampler2D_type s, vec3 uv, float lod) |
Liest eine 2D Textur mit Projektion/LOD |
vec4_type textureProjLod (sampler2D_type s, vec4 uv, float lod) |
Liest eine 2D Textur mit Projektion/LOD |
vec4_type textureProjLod (sampler3D_type s, vec4 uv, float lod) |
Liest eine 3D Textur mit Projektion/LOD |
vec4_type texelFetch (sampler2D_type s, ivec2 uv, int lod) |
Ein einzelnes Texel mit ganzzahligen Koordinaten ermitteln |
vec4_type texelFetch (sampler2DArray_type s, ivec3 uv, int lod) |
Ein einzelnes Texel mit ganzzahligen Koordinaten ermitteln |
vec4_type texelFetch (sampler3D_type s, ivec3 uv, int lod) |
Ein einzelnes Texel mit ganzzahligen Koordinaten ermitteln |
vec_type dFdx (vec_type p) |
Ableitung in |
vec_type dFdy (vec_type p) |
Ableitung in |
vec_type fwidth (vec_type p) |
Summe der absoluten Ableitung in |