This blog contains the scripts for my Blender 3D YouTube videos. They're published as follows:
Buy The Blender 3D Cookbook as a book!
Buy the Blender 3D Cookbook for your iPad!
Buy the Blender 3D Cookbook for your Kindle!
Wednesday, November 11, 2009
2.49b World Colors
Blender provides a number of useful settings to set up a background color, image, and texture, as well as the special effects of mist and stars. These settings are important because they interact with many other parts of your scene, such as lamps, materials, and textures on your objects. You need to be aware of how the world settings work even if you don't change them often. The purpose of this tutorial is to explore the one setting you can't miss - the world colors.
First, let's set the scene. Delete the default cube (Right click, press the delete key, and press Enter to confirm). Add a UV Sphere (Space - Add - Mesh - UV Sphere), accepting the default of 32 segments and 32 rings. Press the Set Smooth button in the Edit panel to smooth out the UV Sphere. Add a subsurf modifier by pressing the Modifiers button and selecting Subsurf. Set the levels to 2. Switch to Front view (Num1). You know you're in Front view if the blue Z arrow points upward. Make the UV Sphere red by pressing the shading buttons (F5), pressing Add New, and setting R=1, G=0, and B=0.
Press the Home key to see the lamp, the sphere, and the camera. Move the lamp near the camera. Select the lamp first, then the camera, then Control-P to make the camera the parent of the lamp. We want to be able to position the camera so that it can track the UV Sphere and we can see the horizon. Go to the Object buttons (F7), then go to the Constraints button, at the far right. Select the Track To constraint. Enter the word Sphere in the Ob: area. Click the -Z button, the last - sign in the To: area, and the Y button in the Up: area. No matter where the camera is positioned, its focus is on the sphere.
Press F12 to render. Note that the sphere is red and the background color is blue. The background color comes from the World color settings, which you get to by pressing F5 (Shading), and then pressing the World icon in the Subcontext area. The preview square shows the default background color, which is derived from the Horizon color - Red=.05, Green=.22, and Blue=.4. Move the camera closer to the ground (the horizontal red line across the window) and press F12 to render. The background color is blue no matter where you position the camera.
There are many ways to change the background color. The first is just to change the horizon color directly. Make the background magenta by setting R=1, G=0, and B=1 for the horizon colors.
That's simple enough. You can also make the background a gradient of two colors, from the top to the bottom. Let's make the background color a gradient, from blue at the top to orange at the bottom. To do that, set the Zenith color to blue (ZeR=0, ZeG=0, and ZeB=1) and the Horizon color to orange (HoR=1, HoG=.5, HoB=0). Click the Blend button to activate color blending. Press F12 to render. Move the camera around the cube and render. No matter where the camera is positioned, the background is the same blue to orange blend.
Click the Real button. Now there are two gradients. The first, from the zenith (the top) to the horizon, goes from blue to orange. The second goes from the horizon to the nadir (the bottom), from orange to blue. If the camera has the horizon line (the red line in the 3D view) in range, it's rendered as an orange line, as a real horizon. However, if the camera is directly overhead or beneath the horizon, the orange horizon line is not rendered.
Click the Paper button. With all three buttons active, the zenith to horizon to nadir gradient is always rendered, no matter where the camera is positioned.
Of course, if you have a real sky image, you can use it instead of the colors. To do that, you add an image texture. Go to the Texture and Imput panel and select the first texture rectangle. Name the texture Sky. Then press F6 to go to the Texture panel. Click the Load Image button. Select the Sky image. Then go back to the World buttons, select the Map To panel, and click on Hori, for Horizon. Press F12 to render. If you click the ZeUp and ZeDown buttons as well, the Sky image is rendered no matter where the camera is positioned.
That's it. I hope this gives you a good grasp of how to use world color settings. Happy Blendering!