David Roberson |
I recently looked at and updated the Rotatable Sphere Snippet by ThreeDee. Unfortunately, I could think of no way to correct the distortions that are part of it, and started wondering how I'd make an undistorted version I could use in a filter designed to showcase a planet. The obvious thing to do is to try and create a Map Script that will produce a gradient sphere like the example (below) that could be used to map a surface using the Lookup component. Sadly, I have no idea how to do it.
If you think you can help I'd be very grateful, just a link to a good example would be appreciated. I am looking at the Raytracing Snippet by Egret as a starting point, so even help with mapping a gradient onto one of his spheres would be great. Thanks for your attention. ![]() |
|||||
Posted: May 31, 2021 5:27 pm | ||||||
David Roberson |
I was able to get pretty far working with a Refraction based mapping to a rotatable sphere. Unfortunately, it's only fooling the eye; there's still unwanted distortion and not-quite full range of motion. A proper sphere mapping will take a bit of pseudo 3d scripting. Lua can do it, but most of the methods I've come across require external libraries. For what amounts to a sphere primitive, I don't think I would need to go that far.
Anyway, here's the ffxml for my rotatable sphere snippet: Rotatable Sphere Snippet V3.ffxml |
|||||
Posted: May 31, 2021 8:20 pm | ||||||
David Roberson |
I've been tinkering with the Raytracing Snippet by Egret, trying to map a gradient onto one of his spheres. I got as far as isolating a sphere in a bigger space with an associated uv surface, but it only seems to respond to the alpha channel. The RGB channels do not respond to the raytrace, so I get either a clear, refractive surface or a black one (reflections still work, too). I'll post what I've got here, in case someone can point out where I'm going wrong. l think this is on hold until then...
Raytracing Lab.ffxml |
|||||
Posted: June 1, 2021 5:01 pm | ||||||
David Roberson |
I succeeded in accomplishing half of the gradients needed to create a Rotatable Sphere Script -- a gradient from the north to south pole (is that the y-axis?). To complete my script I need some help with the math to produce the x-axis, basically an angle gradient from the far east to the far west. There's an example of this above. I have tried finding an example of cartesian to polar mapping for lua, but have had no luck. I'm hoping that is the solution I'm looking for.
Here are a couple examples from other scripting languages...
|
|||||
Posted: June 20, 2022 12:38 am | ||||||
David Roberson |
Since I've just been banging my head against a wall on this, here's an upd ate on my progress. This may clarify what kind of help I'm looking for, in case what I've already posted is unclear.
0 I am working on a Spherical Map Script that generates a linear gradient along the y-axis and an angular gradient around the y-axis in the green and red channels, respectively. I have been unable to find any documentation suited to this online, but have experimented using examples in Javascript and C#. The linear gradient has worked out fine, but the angular gradient (one describing a 360 degree arc around the y-axis) continues to elude me. My working script is as follows.
|
|||||
Posted: June 20, 2022 11:18 pm | ||||||
David Roberson |
After several days of poking around I have only found one working example in which the x and y gradients can only be generated along their respective axes. I just can't puzzle out a method of generating a gradient around an axis using polar-to-cartesian and cartesian-to-polar coordinate conversions. Does that seem right? I may just be failing to do the cartesian-to-polar correctly, most likely due to the boolean operation inside the examples I found for other coding languages. I still have to say that the apparent logic of those equations makes it seem like longitude variable contains a circumferential gradient. You just can't pull it out using polar-to-cartesian equations. If I could, then a sampling of source images would be possible in a map script. Maybe that requires some form of computational uv mapping?
Any kind of feedback would be welcome here... |
|||||
Posted: June 22, 2022 5:29 am | ||||||
David Roberson |
Well, I finally got a grip on how this map script works and the solution was so much simpler that what I'd been trying to do. Here's my solution:
Edit: I may have spoken to soon.... On first glance the circumferential gradient looked right, but as soon as I tried to test it in a Lookup I discovered a problem. I'm inverting the values wrong, dealing with the -1 to 1 range. It's probably a simple fix but my brain is too tired to sort it out right now. |
|||||
Posted: June 22, 2022 6:46 am | ||||||
David Roberson |
Well, the long and the short of it is that the process I've been working with is in the wrong coordinate system. The gradient sphere I have is based on the polar-to-cartesian coordinate system. That gives me x, y, z gradients in the three axes. What I want is gradients for theta and phi, or longitude and latitude. I'm actually getting values for theta and phi from my control sliders, which rotate the generated sphere. I'll try to see if I can sample those values, and if they (somehow) produce the correct gradients, but a little help would be appreciated, since I don't have any examples to work with like that.
|
|||||
Posted: June 22, 2022 9:01 am | ||||||
David Roberson |
I found a potential solution that would employ rotational offsets on three versions of the x-axis gradient fed as r, g, b components of an rgb2hsl function to produce a spherical angle gradient. Unfortunately, an odd problem popped up with the rotational offsets. They are not constant during rotation, which creates a messed up gradient. Am I doing them wrong here?
|
|||||
Posted: June 25, 2022 6:18 am | ||||||
David Roberson |
I managed to solve the problem of scripting a rotatable sphere with the proper remapping gradients sometime last month, but am still tweaking and experimenting with the next logical steps. I never bothered to update this thread with my progress, and now there are too many different script versions; I can't decide which one to share. However, there's a good chance a few of them will find their way into filters. I have a number of planetary filters in the works, so you can expect to see some there. I'll probably submit one as a 3d rotatable sphere snippet (or even effect filter, since I can now map the input to a sphere, assuming it's prepared for spherical mapping). If I do, I'll come back and post the code that goes with it, for anyone who might just want to look at the script but doesn't need a working copy.
TTFN |
|||||
Posted: August 8, 2022 12:15 am |
Filter Forge has a thriving, vibrant, knowledgeable user community. Feel free to join us and have fun!
33,711 Registered Users
+18 new in 30 days!
153,533 Posts
+38 new in 30 days!
15,348 Topics
+73 new in year!
18 unregistered users.