From 81adcd396de6f33865551ae5ec6b258c8674f206 Mon Sep 17 00:00:00 2001 From: Patrick Schroen Date: Mon, 27 May 2024 05:52:38 -0400 Subject: [PATCH] chore: examples house cleaning (#215) * chore: remove unused time uniforms * chore: examples house cleaning --- examples/gpgpu-particles.html | 6 +++--- examples/load-json.html | 4 ++-- examples/mouse-flowmap.html | 4 ++-- examples/normal-maps.html | 1 - examples/orbit-controls.html | 4 ++-- examples/skinning.html | 2 +- examples/textures.html | 2 +- examples/wireframe.html | 4 ++-- 8 files changed, 13 insertions(+), 14 deletions(-) diff --git a/examples/gpgpu-particles.html b/examples/gpgpu-particles.html index 57bcebf6..44878163 100644 --- a/examples/gpgpu-particles.html +++ b/examples/gpgpu-particles.html @@ -156,8 +156,8 @@ for (let i = 0; i < numParticles; i++) { initialPositionData.set( [ - (Math.random() - 0.5) * 2.0, - (Math.random() - 0.5) * 2.0, + (Math.random() - 0.5) * 2, + (Math.random() - 0.5) * 2, 0, // the Green and Alpha channels go unused in this example, however I set 1, // unused Alpha to 1 so that texture is visible in WebGL debuggers ], @@ -230,7 +230,7 @@ } // Get mouse value in -1 to 1 range, with y flipped - mouse.value.set((e.x / gl.renderer.width) * 2 - 1, (1.0 - e.y / gl.renderer.height) * 2 - 1); + mouse.value.set((e.x / gl.renderer.width) * 2 - 1, (1 - e.y / gl.renderer.height) * 2 - 1); } requestAnimationFrame(update); diff --git a/examples/load-json.html b/examples/load-json.html index 667cb4f9..50cda856 100644 --- a/examples/load-json.html +++ b/examples/load-json.html @@ -40,18 +40,18 @@ const fragment = /* glsl */ ` precision highp float; - uniform float uTime; uniform sampler2D tMap; varying vec2 vUv; varying vec3 vNormal; void main() { - vec3 normal = normalize(vNormal); vec3 tex = texture2D(tMap, vUv).rgb; + vec3 normal = normalize(vNormal); vec3 light = normalize(vec3(0.5, 1.0, -0.3)); float shading = dot(normal, light) * 0.15; + gl_FragColor.rgb = tex + shading; gl_FragColor.a = 1.0; } diff --git a/examples/mouse-flowmap.html b/examples/mouse-flowmap.html index ae5415c4..3739a62c 100644 --- a/examples/mouse-flowmap.html +++ b/examples/mouse-flowmap.html @@ -53,7 +53,7 @@ vec3 tex = texture2D(tWater, uv).rgb; // Oscillate between raw values and the affected texture above - tex = mix(tex, flow * 0.5 + 0.5, smoothstep( -0.3, 0.7, sin(uTime))); + tex = mix(tex, flow * 0.5 + 0.5, smoothstep(-0.3, 0.7, sin(uTime))); gl_FragColor.rgb = tex; gl_FragColor.a = 1.0; @@ -125,7 +125,7 @@ } // Get mouse value in 0 to 1 range, with y flipped - mouse.set(e.x / gl.renderer.width, 1.0 - e.y / gl.renderer.height); + mouse.set(e.x / gl.renderer.width, 1 - e.y / gl.renderer.height); // Calculate velocity if (!lastTime) { diff --git a/examples/normal-maps.html b/examples/normal-maps.html index e040743a..e6e6b22b 100644 --- a/examples/normal-maps.html +++ b/examples/normal-maps.html @@ -77,7 +77,6 @@ void main() { vec3 tex = texture2D(tDiffuse, vUv).rgb; - vec3 normal = getNormal(); vec3 light = normalize(vec3(sin(uTime), 1.0, cos(uTime))); diff --git a/examples/orbit-controls.html b/examples/orbit-controls.html index f9f39fb1..77a6117c 100644 --- a/examples/orbit-controls.html +++ b/examples/orbit-controls.html @@ -50,18 +50,18 @@ const fragment = /* glsl */ ` precision highp float; - uniform float uTime; uniform sampler2D tMap; varying vec2 vUv; varying vec3 vNormal; void main() { - vec3 normal = normalize(vNormal); vec3 tex = texture2D(tMap, vUv).rgb; + vec3 normal = normalize(vNormal); vec3 light = normalize(vec3(0.5, 1.0, -0.3)); float shading = dot(normal, light) * 0.15; + gl_FragColor.rgb = tex + shading; gl_FragColor.a = 1.0; } diff --git a/examples/skinning.html b/examples/skinning.html index 0fedb23d..07ab1222 100644 --- a/examples/skinning.html +++ b/examples/skinning.html @@ -95,8 +95,8 @@ void main() { vec3 tex = texture2D(tMap, vUv).rgb; - vec3 normal = normalize(vNormal); + vec3 light = vec3(0.0, 1.0, 0.0); float shading = min(0.0, dot(normal, light) * 0.2); diff --git a/examples/textures.html b/examples/textures.html index 4ed386a2..c34c58c5 100644 --- a/examples/textures.html +++ b/examples/textures.html @@ -46,8 +46,8 @@ varying vec3 vNormal; void main() { - vec3 normal = normalize(vNormal); vec3 tex = texture2D(tMap, vUv).rgb; + vec3 normal = normalize(vNormal); vec3 light = normalize(vec3(0.5, 1.0, -0.3)); float shading = dot(normal, light) * 0.15; diff --git a/examples/wireframe.html b/examples/wireframe.html index aad4d29c..c5d32d00 100644 --- a/examples/wireframe.html +++ b/examples/wireframe.html @@ -40,18 +40,18 @@ const fragment = /* glsl */ ` precision highp float; - uniform float uTime; uniform sampler2D tMap; varying vec2 vUv; varying vec3 vNormal; void main() { - vec3 normal = normalize(vNormal); vec3 tex = texture2D(tMap, vUv).rgb; + vec3 normal = normalize(vNormal); vec3 light = normalize(vec3(0.5, 1.0, -0.3)); float shading = dot(normal, light) * 0.15; + gl_FragColor.rgb = tex + shading; gl_FragColor.a = 1.0; }