Summary Files Commits Branches @commit @diff @stats
diff options
context:
space:
mode:
Commitce3ddd0ac87e9642851759a92fc99b24339533f6 (patch)
Author
 Syndamia <kamen@syndamia.com>
2023-08-28 12:09:33 +0300
Committer
 Syndamia <kamen@syndamia.com>
2023-08-28 12:09:33 +0300
Filesb8c53d88a38a331bef56d89b8addb430f0dc3b90
uni-projects-ce3ddd0ac87e9642851759a92fc99b24339533f6.tar
uni-projects-ce3ddd0ac87e9642851759a92fc99b24339533f6.tar.gz
uni-projects-ce3ddd0ac87e9642851759a92fc99b24339533f6.zip
Parentbaade692399d125001e00d08afc68c1e253eaae4 (diff)
[WGL/P] Added a setting for disabling ray marching
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);
}
`;