Hello, I’m building a representation of Saturn’s rings in THREE.js using a RingGeometry. I have a texture that is 2048x1, with each pixel representing the color of Saturn’s rings at a given radius.
As expected, it is not enough to simply apply this texture to the RingGeometry:
I don’t know too much about graphics but I understand I need to adjust the UVs. I found a similar example and attempted to do this in the Codepen but did not have success.
Am I on the right track? Is there a better way to adjust the texture?
THREE.RingGeometry already comes with the UVs pre-set in a “billboard” fashion. I guess you could change the way they’re mapped to all be [0, y] on the inside vertices, and [1, y] on the outside vertices. However, it would be much faster and simpler to just change your texture to be a ring with Photoshop’s Polar Coordinates filter: https://helpx.adobe.com/photoshop/how-to/use-polar-coordinates-filter.html
Using the ShaderMaterial approach, I was successful in writing a custom shader that applies shadows (Codepen here).
Because meshes are treated as solid from the point of view of the light, I realized I would need a customDepthMaterial on the ring mesh in order for it to cast striped shadows on the sphere.
Wondering what’s easier - fixing shadows + custom depth material using THREE.js-supplied materials or doing it on my own in custom shaders.
Try using Lambert, Phong, or MeshStandardMaterial instead. Also, using THREE.DoubleSide might give you bad shadow artifacts because one face is affected by the light, but the opposite face is in its shadow. You might need to create two ring planes that are separated by a tiny bit of space.