Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/components/plots/SphereBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/components/plots/plotarea/PlotPoints.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
22 changes: 17 additions & 5 deletions src/components/textures/shaders/sphereBlocksVert.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ 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);
Expand Down Expand Up @@ -65,11 +74,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;

Expand Down
Loading