From c07d161a65e559bab7c0d1feda6ee75989fb0e7b Mon Sep 17 00:00:00 2001 From: Jeran Date: Thu, 15 Jan 2026 15:42:34 +0100 Subject: [PATCH 1/2] fix sphere blocks --- src/components/plots/SphereBlocks.tsx | 1 - src/components/plots/plotarea/PlotPoints.tsx | 1 - .../textures/shaders/sphereBlocksVert.glsl | 25 +++++++++++++++---- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/components/plots/SphereBlocks.tsx b/src/components/plots/SphereBlocks.tsx index b2cc16e6..7149f3ec 100644 --- a/src/components/plots/SphereBlocks.tsx +++ b/src/components/plots/SphereBlocks.tsx @@ -77,7 +77,6 @@ const SphereBlocks = ({textures} : {textures: THREE.Data3DTexture[] | THREE.Data const newLatBounds = [Math.max(latExtent[0]-newLatStep, -90), Math.min(latExtent[1]+newLatStep, 90)] return [newLonBounds, newLatBounds] },[latExtent, lonExtent, lonResolution, latResolution]) - const shaderMaterial = useMemo(()=>{ const shader = new THREE.ShaderMaterial({ glslVersion: THREE.GLSL3, diff --git a/src/components/plots/plotarea/PlotPoints.tsx b/src/components/plots/plotarea/PlotPoints.tsx index aadbb0bd..0b58ffb7 100644 --- a/src/components/plots/plotarea/PlotPoints.tsx +++ b/src/components/plots/plotarea/PlotPoints.tsx @@ -31,7 +31,6 @@ function PlotPoints({ points, tsID, pointSetters, scalers }: { points: THREE.Vec const geometry = useMemo(() => new THREE.SphereGeometry(pointSize), [pointSize]) const material = useMemo(()=> new THREE.MeshBasicMaterial({color: new THREE.Color().setRGB(r/300, g/300, b/300).convertSRGBToLinear()}),[pointColor, useCustomPointColor, timeSeries]) // It was converting to sRGB colorspace while the line shader uses linear - useEffect(() => { if (ref.current){ const dummy = new THREE.Object3D() diff --git a/src/components/textures/shaders/sphereBlocksVert.glsl b/src/components/textures/shaders/sphereBlocksVert.glsl index c4c75b48..6b419be3 100644 --- a/src/components/textures/shaders/sphereBlocksVert.glsl +++ b/src/components/textures/shaders/sphereBlocksVert.glsl @@ -14,11 +14,23 @@ uniform float fillValue; #define PI 3.1415926535 -vec3 givePosition(vec2 uv) { + + + +vec2 giveLonLat(vec2 uv) { // Reverse the normalization using the bounds - float longitude = ((1.0 - uv.x) * (lonBounds.y - lonBounds.x) + lonBounds.x); + float longitude = uv.x * (lonBounds.y - lonBounds.x) + lonBounds.x; float latitude = uv.y * (latBounds.y - latBounds.x) + latBounds.x; + longitude = -longitude; + + return vec2(longitude, latitude); +} + +vec3 givePosition(vec2 lonlat) { + float longitude = lonlat.x; + float latitude = lonlat.y; + // Convert to Cartesian coordinates float x = cos(latitude) * cos(longitude); float y = sin(latitude); @@ -65,11 +77,14 @@ void main() { gl_Position = vec4(2.0, 2.0, 2.0, 1.0); } else { vec2 centeredUV = (instanceUV - vec2(0.5, 0.5)) * vec2(2.0, 2.0); - vec3 spherePosition = givePosition(instanceUV); - float latitudeFactor = cos(centeredUV.y * 3.14159 * 0.5); // Maps -1..1 to proper latitude + vec2 lonlat = giveLonLat(instanceUV); + vec3 spherePosition = givePosition(lonlat); + float latitudeFactor = cos(lonlat.y); // Maps -1..1 to proper latitude + float widthFactor = abs(lonBounds.y-lonBounds.x)/PI; float heightFactor = (dispStrength - displaceZero) * displacement; vec3 scaledPosition = position; - scaledPosition.x *= latitudeFactor; + scaledPosition.x *= latitudeFactor * widthFactor; + scaledPosition.z *= widthFactor; scaledPosition.y += 0.025; scaledPosition.y *= heightFactor; From 8967247356f772dfe21391fc3c920c077f3b098d Mon Sep 17 00:00:00 2001 From: Jeran Date: Thu, 15 Jan 2026 15:44:50 +0100 Subject: [PATCH 2/2] less whitespace --- src/components/textures/shaders/sphereBlocksVert.glsl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/textures/shaders/sphereBlocksVert.glsl b/src/components/textures/shaders/sphereBlocksVert.glsl index 6b419be3..7b1711fc 100644 --- a/src/components/textures/shaders/sphereBlocksVert.glsl +++ b/src/components/textures/shaders/sphereBlocksVert.glsl @@ -14,9 +14,6 @@ uniform float fillValue; #define PI 3.1415926535 - - - vec2 giveLonLat(vec2 uv) { // Reverse the normalization using the bounds float longitude = uv.x * (lonBounds.y - lonBounds.x) + lonBounds.x;