Write your own Einstein@home screensaver

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6534
Credit: 284710168
RAC: 110462

Crikey this rendering rabbit

Crikey this rendering rabbit hole goes deep.

I tripped over an Earth bump map while cruising around the web. It's a file ( public domain ) which contains, in array form of longitude by latitude, the heights above sea level for each spot on Earth to some resolution. It's an array of unsigned bytes where zero is sea level and Mt Everest is 255. So, after some suitable preparation from jpeg to bmp then through my bmp2raw utility, you can suck this map in as a resource to be used inside the starsphere program via Oliver's handy ResourceCompiler class.

Then it get's interesting. Now typically this data is used in a fragment shader to work out new/altered surface normals per model location ( 'bumping' the existing vectors ), and then use those altered normals to render while doing lighting calculations. So the surface remains flat/smooth but looks like it has raised features not unlike embossing. However what I've done though is to use the data to offset points in the radial direction of the mesh model that is the spherical Earth before a texture is aplied. This means the mesh model actually has bumps on it eg. the Rocky Mountains in North America or the Andes in South America. It's not true scale but exaggerated for the look of it.

The upshot is TEST09 in Windows and Linux versions ( TEST08 was segfaulting ). It looked a bit jaggy initially but I upped the mesh resolution. Plus the interferometers have been buried by the radial offsets.

I've also worked out how to set the orientation of the Earth with respect to the celestial sphere according to the system clock and timezone ( ie. UTC ). In theory that means you could use it to predict what constellations you would see in the sky at your location in real time ! :-)

Alas I haven't worked out the shared memory area business so the upper right only has placeholders for information.

All in all alot of coding fun.

Cheers, Mike.

( edit ) The windows TEST09 will crash. I've just been 'Valgrinding' in memcheck mode and it leaks like a sieve ... . sorry ;-(

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Holmis
Joined: 4 Jan 05
Posts: 1118
Credit: 1055935564
RAC: 0

Sorry to be the bearer of bad

Sorry to be the bearer of bad news but the Windows version crashes when I try to run it, I found this error in the stderrgfx.txt file:

Unhandled Exception Detected...

- Unhandled Exception Record -
Reason: Stack Overflow (0xc00000fd) at address 0x004326a3

Engaging BOINC Windows Runtime Debugger...

Do you want / need the whole file?
Email or PM?

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6534
Credit: 284710168
RAC: 110462

Thanks. I've already met the

Thanks. I've already met the error and am working on it just now. It's an array size issue vs parameter passing methods. This is why passing by reference was invented .... 

Cheers, Mike.

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

cecht
cecht
Joined: 7 Mar 18
Posts: 1421
Credit: 2445179647
RAC: 1500054

TEST09 Linux launches with

TEST09 Linux launches with the H toggle (rotation) off. Bumpy earth is neat.

Ideas are not fixed, nor should they be; we live in model-dependent reality.

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6534
Credit: 284710168
RAC: 110462

After a bit of haggling the

After a bit of haggling the local stack seems to be in line for this Windows version TEST09A. If you would be so kind as to test that assertion .... :-)

Cheers, Mike

 

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Holmis
Joined: 4 Jan 05
Posts: 1118
Credit: 1055935564
RAC: 0

That works much better,

That works much better, congrats on getting the stack in line!

The terrain bumps do look good and adds some nice details, keep up the good work!

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6534
Credit: 284710168
RAC: 110462

Thank you very much chaps

Thank you very much chaps for your help. Next up : some lighting from a virtual Sun, using the actual real-time position of the Sun in the constellations.

Cheers, Mike.

( edit ) This is going to be like a recipe for Rabbit Stew : first catch yourself a wascally wabbit ! For starters I need to roll my own day of the year function ie. how many days have passed ( since January the first ) until some system time now ( account for leap years ). Add 10 to that number ( late December is the winter solstice ) then multiply by 360 degrees in a circle, divide by 365 days in (most) years, then take the cosine of all that, and finally multiplying by 23.44 ( inclination in degrees of the Earth's equator to the ecliptic ) and voila! You have the declination of the Sun on the celestial sphere for most good purposes. Try that as an opener at your next cocktail party. As for the right ascension, well, that's on the backburner ... :-))

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

Mike Hewson
Mike Hewson
Moderator
Joined: 1 Dec 05
Posts: 6534
Credit: 284710168
RAC: 110462

By an ancient method called

By an ancient method called cheating I have sort of lit the Earth from the sun's position in the model. Here is the Linux version. Alas the windows build is showing contempt for the stack again. You'll note the day/night difference on the Earth with the added bonus of being correct in real time if your system clock is set right ( compare the rendering with here ). The quick & dirty method is to simply brighten up the texture rendering on the Sun's side and darken it otherwise. No normals, no fancy optics. Just take the dot product of the vector to some surface vertex with the vector to the Sun. If that is positive it's in sunshine. Alas one downside to be addressed is the terminator ( line b/w night and day ) is a bit jagged.

Now to grab a big stick and beat the stack with it .... it's not recursion depth or anything like that. I think that win32 seems rather less generous with stack size than linux. Investigations reveal it may be a 'compatibility' issue. Groan.

Cheers, Mike.

( edit ) Right. This Windows 32-bit version should be fine ( it was an array too large ). As a bonus I've also built a Windows 64-bit version ....

I have made this letter longer than usual because I lack the time to make it shorter ...

... and my other CPU is a Ryzen 5950X :-) Blaise Pascal

cecht
cecht
Joined: 7 Mar 18
Posts: 1421
Credit: 2445179647
RAC: 1500054

Linux TEST10 is looking good!

Linux TEST10 is looking good! To my eye, the dark side of the earth could be darker.
I like the constant smooth rotation of the sphere.

Ideas are not fixed, nor should they be; we live in model-dependent reality.

Holmis
Joined: 4 Jan 05
Posts: 1118
Credit: 1055935564
RAC: 0

I've now had the chance to

I've now had the chance to test the Windows versions and both of them are working fine on my computer! Good job at wrestling the stack and letting it know who's the boss! ;)

I concur with Cecht that the dark side could be a bit darker to give it some more contrast. The day and night sides does make it look more real and alive, nice work!

Is there any way to change the viewpoint upon the Earth?
As I live in Sweden and that's close to the north pole it would be quite nice to be able to rotate the whole thing so that I could get a better view of "my" part of this beautiful planet!
If not then consider it as a feature proposal ;)

Keep up the good work, it's starting to look really nice!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.