Working ambient light in Abgabe 4
This commit is contained in:
parent
ff748e7326
commit
97888b6a17
BIN
Abgabe_4/ICG_Hausaufgabe_4.pdf
Normal file
BIN
Abgabe_4/ICG_Hausaufgabe_4.pdf
Normal file
Binary file not shown.
@ -74,7 +74,7 @@ class Object3D {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
asd;
|
|
||||||
class Island extends Object3D {
|
class Island extends Object3D {
|
||||||
constructor() {
|
constructor() {
|
||||||
// DONE: Setze Material für Insel
|
// DONE: Setze Material für Insel
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>WebGL Example</title>
|
<title>WebGL Example</title>
|
||||||
|
|
||||||
<script id="vertex-shader" type="x-shader/x-vertex">
|
<script id="vertex-shader" type="x-shader/x-vertex">#version 300 es
|
||||||
#version 300 es
|
|
||||||
|
|
||||||
in vec4 vPosition;
|
in vec4 vPosition;
|
||||||
// TODO: Nimm Normalen als Attribut entgegen
|
// TODO: Nimm Normalen als Attribut entgegen
|
||||||
@ -20,6 +19,10 @@
|
|||||||
// TODO: Nimm alle Koeffizienten und Intensitäten, sowie den Exponenten als Uniform-Variablen entgegen
|
// TODO: Nimm alle Koeffizienten und Intensitäten, sowie den Exponenten als Uniform-Variablen entgegen
|
||||||
uniform vec3 Ia;
|
uniform vec3 Ia;
|
||||||
uniform vec3 ka;
|
uniform vec3 ka;
|
||||||
|
uniform vec3 Id;
|
||||||
|
uniform vec3 kd;
|
||||||
|
uniform vec3 Is;
|
||||||
|
uniform vec3 ks;
|
||||||
uniform float specExp;
|
uniform float specExp;
|
||||||
|
|
||||||
// TODO: Definiere alle Konstanten c_1, c_2, c_3
|
// TODO: Definiere alle Konstanten c_1, c_2, c_3
|
||||||
@ -62,8 +65,7 @@
|
|||||||
gl_Position = projectionMatrix * position;
|
gl_Position = projectionMatrix * position;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<script id="fragment-shader" type="x-shader/x-fragment">
|
<script id="fragment-shader" type="x-shader/x-fragment">#version 300 es
|
||||||
#version 300 es
|
|
||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
in vec3 vfColor;
|
in vec3 vfColor;
|
||||||
|
@ -47,12 +47,12 @@ function main() {
|
|||||||
normalLoc = gl.getAttribLocation(program, "vNormal");
|
normalLoc = gl.getAttribLocation(program, "vNormal");
|
||||||
lightPositionLoc = gl.getUniformLocation(program, "lightPosition");
|
lightPositionLoc = gl.getUniformLocation(program, "lightPosition");
|
||||||
IaLoc = gl.getUniformLocation(program, "Ia");
|
IaLoc = gl.getUniformLocation(program, "Ia");
|
||||||
IdLoc = gl.getUniformLocation(program, "Id");
|
|
||||||
IsLoc = gl.getUniformLocation(program, "Is");
|
|
||||||
kaLoc = gl.getUniformLocation(program, "ka");
|
kaLoc = gl.getUniformLocation(program, "ka");
|
||||||
|
IdLoc = gl.getUniformLocation(program, "Id");
|
||||||
kdLoc = gl.getUniformLocation(program, "kd");
|
kdLoc = gl.getUniformLocation(program, "kd");
|
||||||
|
IsLoc = gl.getUniformLocation(program, "Is");
|
||||||
ksLoc = gl.getUniformLocation(program, "ks");
|
ksLoc = gl.getUniformLocation(program, "ks");
|
||||||
specularExponentLoc = gl.getUniformLocation(program, "specExp");
|
specularExpLoc = gl.getUniformLocation(program, "specExp");
|
||||||
|
|
||||||
eye = vec3.fromValues(0.0, 0.3, 4.0);
|
eye = vec3.fromValues(0.0, 0.3, 4.0);
|
||||||
target = vec3.fromValues(0.0, 0.3, 0.0);
|
target = vec3.fromValues(0.0, 0.3, 0.0);
|
||||||
@ -69,6 +69,11 @@ function main() {
|
|||||||
gl.uniform3fv(IdLoc, [0.8, 0.8, 0.8]);
|
gl.uniform3fv(IdLoc, [0.8, 0.8, 0.8]);
|
||||||
gl.uniform3fv(IsLoc, [0.7, 0.7, 0.7]);
|
gl.uniform3fv(IsLoc, [0.7, 0.7, 0.7]);
|
||||||
|
|
||||||
|
gl.uniform3fv(kaLoc, [0.5, 0.5, 0.5]);
|
||||||
|
gl.uniform3fv(kdLoc, [0.5, 0.5, 0.5]);
|
||||||
|
gl.uniform3fv(ksLoc, [0.5, 0.5, 0.5]);
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("keydown", keydown);
|
document.addEventListener("keydown", keydown);
|
||||||
document.addEventListener("keyup", keyup);
|
document.addEventListener("keyup", keyup);
|
||||||
document.addEventListener("mousemove", changeView);
|
document.addEventListener("mousemove", changeView);
|
||||||
|
Loading…
Reference in New Issue
Block a user