Sunday, August 21, 2016

Planets via Image Mapping

In my previous post on Classic Fractal Landscapes I posted some simple full-planet fractals I had created, but as plate carrée projections.  I thought a brief mention of how to make them look like proper planets might be in order.  Most rendering packages include a capability for texture mapping, in which an image is placed onto a model.  Here's an example of what happens when I mapped the fractal images from that post onto spheres using POV-Ray:




Full code can be found in my GitHub repository.  The image above is generated by MappedPlanets.pov, from which the following is excerpted:

#declare Fractal1=
object {
    sphere {
        <0,0.0,0>,
        0.55      
    }  
    texture {
        pigment {  
            image_map {
              png "Fractal1.png" // image to map
              map_type 1        // 1=spherical
              interpolate 2     // 2=bilinear
            } // image_map                                                                            
        }                      
        finish {
            ambient rgb <.35,.35,.35>
        }
    }                      
    no_shadow  
}


 I used my fractal images above, but the image could just as easily have been a map created with a digital art program (even Microsoft Paint), a scan, or a map.  A couple examples are below, generated by the PaintMap.pov file.




Most 3D modeling programs contain a feature to perform similar mappings.  For programmers seeking to display a planet (or globe) in an application, this can be done via some simple UV mapping between a sphere and the map by applying some spherical trigonometry.  I'll cover that at some point in the future - perhaps I'll create a simple application to let you select an image file and manipulate the resulting globe.  In any case, that's it for now.

The next post is likely to be on another topic, however.


No comments:

Post a Comment