Off-axis rotation of spheres and planets

Started by rca06d, March 03, 2022, 07:26:46 PM

Previous topic - Next topic

rca06d

I would like to animate the sun and stars moving realistically together across the sky. This apparently isn't easy to do if you want the axis of rotation to be different than one of the coordinate axes in terragen. Any tips on how to pull this off? If my sun is at heading 330 for example, how do I get a star field image-mapped on the background to rotate with it correctly?

WAS

I think this relies on a conversion of coordinate systems. I'm really tired and about to pass out and I can't think of what the coordinate system is that elevation/heading is based upon, or how you would convert it, but I am pretty sure that's what you'll need to do. Otherwise you could play with a light source that's super bright and act as your sun and move it in XYZ with your background map.

Dune

Simply said I would make a starry background in the background shader (either by image map or power fractal), attach to luminosity of a surface shader (use that instead of the default background shader inside), and put a transform shader between them. Use rotate X and Y to make some sort of trajecory over time.

WAS

I think the issue is he wants to lock in the rotation of the background sphere with the sun. The sun works on Elevation and Heading which requires some mathing to match up the sun to the stars. The sun and stars are fixed in our sky pretty much. Maybe slight variance. The planet is rotating and orbiting the sun. 

Dune

If you animate the sun position, with a bit of experimentation you can probably rotate starfield with them, or any way needed.

rca06d

Yeah WAS has it. If there isn't a nice easy checkbox or trick I can do with transform shaders, this appears to be a rather complicated trig problem that I have yet to figure out. Starting to wonder if its actually easier to turn the planet and compute the camera motion and tilt so its locked with the planet. Both seem hard.

Dune

No there isn't, it has to be some sort of mix between Y rotation for heading and x/z rotation for elevation. If you're only looking north, it might not be that hard though (just X and Y), but as you turn Z comes into play. Good luck anyway.

rca06d

Specifically rotating with x and y seems to be the key, together they actually behave like azimuth/elevation. I was trying to use y and z before and apparently the y transformation is applied before z, which is wrong for an off axis rotation. Here's what I'm working on. Still tweaking...

Dune