From ce3ddd0ac87e9642851759a92fc99b24339533f6 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Mon, 28 Aug 2023 12:09:33 +0300 Subject: [WGL/P] Added a setting for disabling ray marching --- Year 2/Computer Graphics with WebGL/Project/Project.html | 2 ++ Year 2/Computer Graphics with WebGL/Project/menu.js | 7 +++++++ Year 2/Computer Graphics with WebGL/Project/shaders.js | 3 ++- 3 files changed, 11 insertions(+), 1 deletion(-) 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:
Toggle coordinates:
Toggle fps:
+ Disable ray marching:
Only horizontal mouse movement:
Only vertical mouse movement:

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); } `; -- cgit v1.3.1-26-gb76a