Topics

Friday, October 18, 2013

Noising up a texture procedurally

When applying texture to a CG surface, there are two basic options:

1) Texture mapping - using an image map to define the patterns
2) Procedural textures - using a mathematical algorithm to define the patterns

Naturally there are pros and cons to both methods. The first affords maximum artist control but incurs a memory and resolution limit. When you zoom in on an image texture too closely, it loses detail and becomes blurry. Procedural textures do not have this problem, but they are much more difficult to art-direct and may require programming skills beyond the more artistically inclined user.

With Project Eden there is really not much choice except to go with option 1. Even though fractal terrain generation and rendering has come a long way, the Earth has a highly recognizable face thanks to NASA photo imagery, so a purely procedural approach can be easily spotted.

I'm going to describe a method which can be used to push the image texture resolution limit a little further by making use of procedural noise. Typically, a CG texture artist would add noise to the color, diffuse, specular or bump channels, but we'll be doing something different today.

Here's a flat plane mapped with a grid image:


Here's the same grid with noise added. Notice that the grid pattern has been distorted procedurally, without needing to increase the resolution the original texture:


More noise can break up the pattern even further:


By now, some of you would have probably guessed how it's been done. Instead of adding noise to the pattern, we add noise to the UV lookup coordinates, so each texel lookup will return information that is offset from where it should be. Here's the Houdini shader network used:


You can see that a bit of turbulent noise has been added to each UV coordinate before being passed into the texture lookup node. The noise is based on surface position so it is independent of the resolution of the texture image.

Hence, we can use this simple trick to add more "resolution" to our image textures. A relatively inexpensive technique without the need for fancy Photoshop filters or edge detection algorithms. The results are especially applicable for naturalistic patterns, not so much for mechanical patterns. Now go out there are make some noise! ^^;;
 
Pixel art of world map found on the internet
Same pixelated texture reference by noisy UV lookup

Tuesday, April 23, 2013

Minor update

Just a quick status update. Project Eden is kinda on hold as I'm currently researching into character animation and games development. However, I did edit a remixed video based on the reaction that I received when I showed my previous test shots to people. Seems that not all the shots were effective so I cut out the weak ones and added a bit of music to the remixed video.



As always, I'm happy to hear any comments on how to improve things. Until the next update!

Wednesday, December 5, 2012

Black Marble - Earth at Night

New data from the Suomi NPP satellite allows NASA scientists to create new global views of Earth's city lights at night. More here.


Wednesday, September 12, 2012

Centennial

The new Universal Centennial Logo which you might have already seen in the cinema this year. Great CG by Weta Digital:

Sunday, September 9, 2012

Making of a Planet - Part 4 - Simple atmosphere shader


Here's a good place to start if you need some instant texture maps for creating a CG Earth: JHT's Planetary Pixel Emporium. The color, bump and specular maps are self-explanatory, although in my case I'm using true displacements instead of bump. You can also get the Blue Marble textures from NASA's Visible Earth here.

The tricky part is to create the Earth's atmosphere. From reference photos, we can see that due to the curvature of the planet, the atmosphere appears more visible along the circumference compared to the center.


To achieve this effect, we can make use of the facing ratio of the surface toward the camera. Referring to the diagram below, when the view vector and the surface normal is in line, the facing ratio is 1, when they are perpendicular, the facing ratio is 0. Surfaces that face away from the camera are not rendered, so need not be considered. As such, the facing ratio at any point always fall between 0 and 1:


There are different ways to obtain the facing ratio. Maya has a very useful Sampler Info utility node which will provide that information. In Houdini, it is simple to build using the Eye vector (I) and the surface Normal vector (N). Just do a dot product, which will give you the cosine of the angle between them as long as the vectors are normalized. When the angle is 0° (I aligned with N), the cosine is 1. When the angle is 90° (I perpendicular to N), the cosine is 0°. Remember to normalize both N and I, and also, since I is the direction from Eye (camera) to the surface, it has to be negated. Finally, an Absolute node is used to ensure that the output values are positive. The SHOP network is shown below:


The network above will shade any object as if there is a headlight attached to the camera (surfaces facing the camera are brighter and surfaces facing away are darker). From there, we will adjust the output into a suitable type and range using a bit of math. The diagram below illustrates what we are trying to achieve:


The following SHOP network does exactly the above:


The Complement node inverts the black and white facing ratio, and the Power node (exponent of 6 used in this example) adjusts the intensity. A Constant of type "color" set to a suitable shade of blue is multiplied with the output of the Power node to get the blue tinted version, which is then output as the Surface Color. The output from the Power node is fed into the Surface Opacity output to allow for transparency.

Let's apply this shader to a new sphere object slightly larger (1% larger in this example, using a uniform scale factor of 1.01) than the original Earth sphere :


Of course, this is just a starting point. There is immediately the problem of the atmosphere being lit even along the shadowed side of the Earth. This is easily remedied by multiplying the output color by a shadow term, or by a self-shadowing diffuse shader such as Lambert:

The example below uses a Lambert diffuse intensity of 2

While this is more physically correct, the previous unshadowed version looks aesthetically more pleasing, which is why many planetary artists invoke artistic license to bend the laws of physics. Alas, our goal is photorealism, so we will stick with the correct look for this kind of exposure levels. Just remember it is a viable option because the stars (and sometimes the Moon) always provide faint illumination to the night side of the Earth.


Long way to go...

There's still so much that needs to be done to improve the quality of my CG Earth, and I've been exploring options and learning that I really don't have enough know-how to get there yet.

Clouds are the biggest challenge and I've never been happy with my solution, so I'm going back to the drawing board with them. It's a tough nut to crack so it might be a while before I can achieve a proper cloud-filled Earth.

Next, surface detail. Considering I'm using at best 500m/pixel data from BMNG, I began experimenting with adding fractal noise to the displacement and other channels in the hopes of being able to do more close-up shots.

Since I'm starting with a displacement map, just adding displacement noise without regard for the existing topography will result in very artificial output - the same way that simply combining multiple orders of fBm noise will not make a fractal landscape look natural. I'm convinced I need some kind erosion algorithm (fractal, hydraulic, thermal...) but I haven't been able to find any good reference on the subject.

Sometimes when I look up one subject, I find that I need to understand several other topics before I can proceed. Other times, one subject leads to several other related issues that I had not been aware of. There's so much to study, understand and implement that I have to become less of an artist and more a weekend programmer, mathematician and scientist. Gradually, I hope to summarize what I've learnt that is relevant to the CG Earth project within the pages of this blog.

Meanwhile, here's another WIP shot. It has subtly better atmosphere and surface detail than a similar shot I created last year.

2012 version with better terrain detail, specular (rivers) and atmospherics (no more volumetric hack).
2011 version, took some hacking to get it looking like this.

Wednesday, August 22, 2012

Another making-of

Ever wondered about the Earth image on the screen background of every new iPhone? Turns out it's another Blue Marble image and here is an article on how it's made written by the artist Robert Simmon himself: Crafting the Blue Marble.