r/GraphicsProgramming • u/noiv • Feb 10 '26
Source Code Built a WebGPU 4D Weather Globe - some shader tricks I learned along the way
Hey all,
Been working on a weather visualization project for a while now. It's a globe that shows current and forecast temperature, wind, and pressure data using WebGPU. Wanted to share some of the graphics challenges I ran into and how I solved them - figured this crowd might find it interesting (or tell me I'm doing it wrong).
Live: https://zero.hypatia.earth
Code: https://github.com/hypatia-earth/zero
Temporal interpolation of isobars
Weather data comes in hourly chunks, but I wanted smooth scrubbing through time. So the pressure contours actually morph between timesteps - the isobars aren't just popping from one position to another, they're interpolating.
Same deal with wind - particles blend their direction and speed between hours, so you can scrub to any minute and it looks smooth.
Haven't seen this done much in web weather apps. Most just show discrete hourly frames.
Wind particles that stay on the sphere
This one was fun. Needed particles to trace wind paths on the globe surface without drifting off or requiring constant reprojection.
Solution: Rodrigues rotation formula. Instead of moving in cartesian coords and projecting back, I rotate the position around an axis perpendicular to both the current position and wind direction:
axis = cross(position, windDirection)
newPos = normalize(rodrigues(position, axis, stepAngle))Keeps everything on the unit sphere automatically. Pretty happy with how clean and fast this turned out.
Pressure contours entirely on GPU
The whole pipeline runs in compute shaders:
Regrid irregular weather data to regular grid
Marching squares for contour extraction
Prefix sum for output offsets
Chaikin subdivision for smoothing
Final render
No CPU round-trips during animation. The tricky part was Chaikin on a sphere - after each subdivision pass, vertices need to be re-normalized to stay on the surface. Otherwise the contours slowly drift inward. There is still a bug: Sometimes NE pointing lines are missing :(
WebGPU in production
Still feels early for WebGPU on the web. Had to add float16 fallbacks for Safari on iPad (no float32-filterable support). Chrome's been solid though. The compute shader workflow is so much nicer than trying to do this stuff with WebGL hacks.
Anyway, curious if anyone else has worked on globe-based visualizations or weather data rendering. Always looking to learn better approaches.
7
u/blackrack Feb 10 '26
lol bro
2
u/Parking-Pick-759 Feb 12 '26
I cannot understate how hilarious seeing you specifically post this here is
EDIT: Not accusing you of ai slop. Just the cloud connection lol. Enjoying the mod btw
2
u/blackrack Feb 12 '26
Besides all the AI stuff, OP's framing of a basic axis rotation formula as a revelation is what made me chuckle
1
u/Zealousideal_Low1287 Feb 10 '26
Don’t let the negative comments get you down OP. Hope you enjoyed the process and learnt some things along the way.
-4
2
1
1
0
Feb 10 '26
[deleted]
17
u/TreyDogg72 Feb 10 '26
Looks like someone didn’t read the CODEOFCONDUCT.md file, you can’t discriminate based on level of experience in this project buddy.
11
u/NeKon69 Feb 10 '26
For some reason the moment I got a look at the screenshot from his project I instantly wanted to start screaming "ai slop". So I guess I wasn't wrong lol
3
u/[deleted] Feb 11 '26
I think this is really cool, so what if OP used AI to make it? Unless you can point out an actual technical problem with the code, you are just hating.