diff --git a/.vscode/launch.json b/.vscode/launch.json
index 908785a..2f969a4 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -29,6 +29,13 @@
"request": "launch",
"reAttach": true,
"file": "${workspaceFolder}/RotatingCube/RotatingCube.html"
+ },
+ {
+ "name": "BivariateFunction",
+ "type": "firefox",
+ "request": "launch",
+ "reAttach": true,
+ "file": "${workspaceFolder}/BivariateFunction/BivariateFunction.html"
}
]
}
\ No newline at end of file
diff --git a/BivariateFunction/BivariateFunction.html b/BivariateFunction/BivariateFunction.html
new file mode 100644
index 0000000..8daab74
--- /dev/null
+++ b/BivariateFunction/BivariateFunction.html
@@ -0,0 +1,20 @@
+
+
+
+
+ Point lighted graph of bivariate function (Per fragment)
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BivariateFunction/BivariateFunction.js b/BivariateFunction/BivariateFunction.js
new file mode 100644
index 0000000..f43f538
--- /dev/null
+++ b/BivariateFunction/BivariateFunction.js
@@ -0,0 +1,280 @@
+// PointLightedCube_perFragment.js (c) 2012 matsuda, 2022 Jonathon Doran
+
+const vertex_shader = `
+ attribute vec4 a_Position;
+ attribute vec4 a_Color;
+ attribute vec4 a_Normal;
+ uniform mat4 u_MvpMatrix;
+ uniform mat4 u_ModelMatrix; // Model matrix
+ uniform mat4 u_NormalMatrix; // Transformation matrix of the normal
+ varying vec4 v_Color;
+ varying vec3 v_Normal;
+ varying vec3 v_Position;
+
+ void main()
+ {
+ gl_Position = u_MvpMatrix * a_Position;
+
+ // Calculate the vertex position in the world coordinate
+ v_Position = vec3(u_ModelMatrix * a_Position);
+ v_Normal = normalize(vec3(u_NormalMatrix * a_Normal));
+ v_Color = a_Color;
+ } `;
+
+
+const fragment_shader = `
+ #ifdef GL_ES
+ precision mediump float;
+ #endif
+
+ uniform vec3 u_LightColor; // Light color
+ uniform vec3 u_LightPosition; // Position of the light source
+ uniform vec3 u_AmbientLight; // Ambient light color
+ varying vec3 v_Normal;
+ varying vec3 v_Position;
+ varying vec4 v_Color;
+ void main()
+ {
+ // Normalize the normal because it is interpolated and not 1.0 in length any more
+ vec3 normal = normalize(v_Normal);
+
+ // Calculate the light direction and make its length 1.
+ vec3 lightDirection = normalize(u_LightPosition - v_Position);
+
+ // The dot product of the light direction and the orientation of a surface (the normal)
+ float nDotL = max(dot(lightDirection, normal), 0.0);
+
+ // Calculate the final color from diffuse reflection and ambient reflection
+ vec3 diffuse = u_LightColor * v_Color.rgb * nDotL;
+
+ vec3 ambient = u_AmbientLight * v_Color.rgb;
+ gl_FragColor = vec4(diffuse + ambient, v_Color.a);
+ } `;
+
+var scale = 192
+function f(x, y) {
+ var u = 80 * x - 40, v = 90 * y - 45;
+ var norm = Math.sqrt(u * u + v * v);
+ return (1 / 2) * Math.pow(Math.E, -0.04 * norm) * Math.cos(0.15 * norm)
+}
+
+function main() {
+ // Retrieve