Grafikprogrammierung I
Reflexionen
Thorsten Thormählen
10. Februar 2020
Teil 11, Kapitel 3
Thorsten Thormählen
10. Februar 2020
Teil 11, Kapitel 3
Dies ist die Druck-Ansicht.
Weiterschalten der Folien durch die → Taste oder
durch das Klicken auf den rechten Folienrand.
Das Weiterschalten der Folien kann ebenfalls durch das Klicken auf den rechten bzw. linken Folienrand erfolgen.
| Typ | Schriftart | Beispiele |
|---|---|---|
| Variablen (Skalare) | kursiv | $a, b, x, y$ |
| Funktionen | aufrecht | $\mathrm{f}, \mathrm{g}(x), \mathrm{max}(x)$ |
| Vektoren | fett, Elemente zeilenweise | $\mathbf{a}, \mathbf{b}= \begin{pmatrix}x\\y\end{pmatrix} = (x, y)^\top,$ $\mathbf{B}=(x, y, z)^\top$ |
| Matrizen | Schreibmaschine | $\mathtt{A}, \mathtt{B}= \begin{bmatrix}a & b\\c & d\end{bmatrix}$ |
| Mengen | kalligrafisch | $\mathcal{A}, \{a, b\} \in \mathcal{B}$ |
| Zahlenbereiche, Koordinatenräume | doppelt gestrichen | $\mathbb{N}, \mathbb{Z}, \mathbb{R}^2, \mathbb{R}^3$ |
$\mathbf{\omega}_r = 2 (\mathbf{\omega}_i^{\top} \mathbf{n}) \mathbf{n} - \mathbf{\omega}_i$
GL_TEXTURE_CUBE_MAP gekennzeichnet wird:
GLuint textureID; glGenTextures( 1, &textureID); glBindTexture(GL_TEXTURE_CUBE_MAP, textureID);
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, ..., imgData1); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, ..., imgData2); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, ..., imgData3); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, ..., imgData4); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, ..., imgData5); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, ..., imgData6);
![]() GL_TEXTURE_CUBE_MAP_POSITIVE_X |
![]() GL_TEXTURE_CUBE_MAP_NEGATIVE_X |
![]() GL_TEXTURE_CUBE_MAP_POSITIVE_Y |
![]() GL_TEXTURE_CUBE_MAP_NEGATIVE_Y |
![]() GL_TEXTURE_CUBE_MAP_POSITIVE_Z |
![]() GL_TEXTURE_CUBE_MAP_NEGATIVE_Z |
#version 140
in vec3 inputPosition;
in vec2 inputTexCoord;
in vec3 inputNormal;
uniform mat4 projection, view, modelTrans, normalMat;
out vec3 normalInterp;
out vec3 vertPos;
void main(){
gl_Position = projection * view * modelTrans *
vec4(inputPosition, 1.0);
vec4 vertPos4 = modelTrans * vec4(inputPosition, 1.0);
vertPos = vec3(vertPos4) / vertPos4.w;
normalInterp = vec3(normalMat * vec4(inputNormal, 0.0));
}
#version 140
in vec3 normalInterp;
in vec3 vertPos;
out vec4 outputColor;
uniform samplerCube myTexture;
uniform int mode;
uniform vec3 eyePos;
const vec3 baseColor = vec3(0.4, 0.4, 0.4);
void main() {
vec3 normal = normalize(normalInterp);
vec3 diffuseColor = vec3(textureLod(myTexture, normal, 5));
vec3 viewDir = vertPos - eyePos;
vec3 r = reflect(viewDir, normal);
// also try the following to generate refraction
// vec3 r = refract(viewDir, normal,0.95);
vec3 specColor = vec3(texture(myTexture,normalize(r)));
float diffuseMix = 0.7;
float specMix = 0.5;
// no diffuse, no spec
if(mode == 2) {
diffuseMix = 0.0;
specMix = 0.0;
}
// only diffuse
if(mode == 3) {
diffuseMix = 1.0;
specMix = 0.0;
}
// only specular
if(mode == 4) {
diffuseMix = 0.0;
specMix = 1.0;
}
vec3 color = mix(baseColor,diffuseColor*baseColor,diffuseMix);
color = mix(color, specColor + color, specMix);
outputColor = vec4(color, 1.0);
}
Anregungen oder Verbesserungsvorschläge können auch gerne per E-mail an mich gesendet werden: Kontakt