Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / Project
diff options
context:
space:
mode:
diff --git a/Year 2/Computer Graphics with WebGL/Project/Project.html b/Year 2/Computer Graphics with WebGL/Project/Project.html
index e010a1c..5aa4252 100644
--- a/Year 2/Computer Graphics with WebGL/Project/Project.html
+++ b/Year 2/Computer Graphics with WebGL/Project/Project.html
@@ -113,6 +113,7 @@ body > div {
gl.uniform4f(uBlack, 0,0,0,1);
gl.uniform4f(uBHBlack, 0,0,0,1);
+ gl.uniform1i(uDisableRayMarching, false);
skybox = new Skybox(10000, [0,0,0], undefined);
createLevels();
@@ -188,6 +189,7 @@ body > div {
Debugging colors: <input type="checkbox" id="debug-mode"><br>
Toggle coordinates: <input type="checkbox" id="coordinates-cb"><br>
Toggle fps: <input type="checkbox" id="fps-cb"><br>
+ Disable ray marching: <input type="checkbox" id="disable-ray-marching"><br>
Only horizontal mouse movement: <input type="checkbox" id="only-horizontal"><br>
Only vertical mouse movement: <input type="checkbox" id="only-vertical">
</p>
diff --git a/Year 2/Computer Graphics with WebGL/Project/menu.js b/Year 2/Computer Graphics with WebGL/Project/menu.js
index db3ee42..10cac05 100644
--- a/Year 2/Computer Graphics with WebGL/Project/menu.js
+++ b/Year 2/Computer Graphics with WebGL/Project/menu.js
@@ -1,6 +1,7 @@
function initMenu() {
initLevels();
debugChange.call(debugModeCB);
+ toggleRayMarching.call(disableRayMarching);
}
/* Level items */
@@ -64,6 +65,12 @@ function fpsCBChange() {
fpsCBChange.call(fpsCB);
fpsCB.addEventListener('change', fpsCBChange);
+const disableRayMarching = document.getElementById('disable-ray-marching');
+function toggleRayMarching() {
+ gl.uniform1i(uDisableRayMarching, this.checked);
+}
+disableRayMarching.addEventListener('change', toggleRayMarching);
+
const onlyHorizontalCB = document.getElementById('only-horizontal');
function horChange() {
onlyHorizontal = this.checked;
diff --git a/Year 2/Computer Graphics with WebGL/Project/shaders.js b/Year 2/Computer Graphics with WebGL/Project/shaders.js
index 4027c6d..a77e9b3 100644
--- a/Year 2/Computer Graphics with WebGL/Project/shaders.js
+++ b/Year 2/Computer Graphics with WebGL/Project/shaders.js
@@ -45,6 +45,7 @@ var fShader = `
varying vec3 vXYZ;
// Settings
+ uniform bool uDisableRayMarching;
uniform vec4 uBlack;
uniform vec4 uBHBlack;
@@ -166,6 +167,6 @@ var fShader = `
void main()
{
vec3 step = normalize(vXYZ - uEye);
- gl_FragColor = rayMarch(uEye, step);
+ gl_FragColor = (uDisableRayMarching) ? vec4(vColor, 1.0) : rayMarch(uEye, step);
}
`;