Blender Cycles Landscape, Foreground
Posted by JTippetts, 15 August 2012 · 2,501 views
blender cycles render 3d goblinson crusoe
Now that I have a decent backdrop (see previous entry for more) it's time to work on the foreground. But first, I have to get set up. I start a new scene and add a plane to it. I also delete the camera and add a new one. I rotate both the plane and the new camera by 90 degrees on the X axis, then I move the camera down along the Y axis for some distance, and move the plane back up the Y axis by some distance. At this point, the camera is looking through the origin at the plane. I set up my image dimensions for rendering, then switch to camera view and start scaling the plane in X and Z until it just fills the viewport, with some slight bit of overlap at the edges to ensure no weird edge pixels show through at the borders of the render. This plane will form the backdrop. I need to ensure that any time I rotate the camera, the plane gets rotated as well so that it is always filling the viewport.
At this point, I need to map the backdrop rendering onto the plane. I Tab into Edit mode on the plane and hit 'u'->Project From View (Bounds) from camera view, to map UVs across the whole plane. Then I create a new material.
The backdrop needs to be in the scene, but not affect it. It shouldn't cast shadows, it shouldn't be affected by the angle of the sunlight, etc... In Blender Internal, to do a backdrop like this I would simply create a new material and tick the Shadeless button, then apply a texture map. But in Cycles, of course, the Shadeless button is gone. However, it is easy enough to do with nodes. To be brief, here is the node tree I use:
This node setup shows something I wanted to talk about: the Light Path node. This node is handy in subtle ways. When Blender Cycles is casting rays around, bouncing them off stuff and scattering them around, each ray is tagged with the type of ray that it is. A ray cast into the scene from the camera is a Camera Ray. A ray that bounces off a diffuse material is a Diffuse ray. And so forth. With this node, it is possible to setup a material that acts in different ways depending on the type of ray it is interacting with.
In the case of this material, I want a material that will show the color of the mapped texture if the ray is a Camera ray, and to act as if it were completely transparent to all other kinds of rays. So I set up a Texture Coordinate node to get the UV input, and feed that to an Image texture node. In that node, I load up the rendered backdrop image. Then I feed that image to an Emission node.
I use an Emission node for one reason: a diffuse shader would be affected by the angle and color of the sun lamp, so with the sun at an angle oblique to the plane, the brightness of the backdrop plane would be altered. An Emission node emits light, with a varying Strength parameter. According to the Cycles docs, an emission node with a strength of one emits light exactly equal to the brightness of the incoming light; that is, an Emission node with strength=1 acts much like a Material node in Blender Internal with the Shadeless button ticked. It emits exactly the amount of light denoted by the incoming background texture pixel.
I combine the output of the Emission Node with the output of a Transparent node using a Mix shader. I use the output of the Camera Ray tab on the Light Path node to do the mixing. The Camera Ray tab will output a 1 value (if it is a camera ray) or a 0 (if it is any other kind of ray). A mix node will pull values from its second input tab for input values of 1, and from the first input tab for factor of 0. This means that any time the ray being calculated is a Camera ray, color is pulled from the Emission node with the texture map. For other rays, color is pulled from the Transparent shader (meaning that the material is ignored, and color comes from the environment instead). This way, the backdrop is shown in the background of the scene, but it has no effect on the scene. Diffuse shading shadows come from the environment color, which I can set in the World nodes to something appropriate for the foreground scene.
Now, moving on, I need to create another ground plane in the foreground and add the tri-planar mapped dirt/grass material to it in preparation of sculpting the foreground scene.
For a foreground like this, I usually forego displacement mapping in favor of sculpting, as it gives me more control over the exact placement of terrain. So I add a Multiresolution modifier, crank out a few (maybe 7 or 8) subdivisions, and switch to Sculpt mode from Top View. Then I grab a brush and just go to town, sculpting the ground as I see fit.
This is where the sheer neatness of having access to a tri-planar mapped texture material comes into play. At this stage, I don't worry about the effects of stretching on the terrain. I'm not hindered by the requirement to think about relative face sizes, extreme levels of distortion on the terrain causing stretch, etc... There is no stretching with tri-planar mapping. I am free to sculpt whatever weird and crazy terrain I want, and the texture will obediently follow along.
In the above shot from Blender's viewport, I've set the plane to Flat shading so you can see the extreme amount of stretch going on with some of the faces. But here is how it looks when rendered smooth and with the tri-planar material:
There are some lighting artifacts from the godawfully stupid amount of stretching, but there is no stretching in the texture mapping. The terrain even includes cliffs and overhangs, and still the texturing is neat and tidy.
Now, that example of course is not what I really wanted with this scene. I was going for a simple tower-on-a-hill scene. So the actual sculpting was a bit more muted and tame:
I can imagine a tower rising up from the trees on a hill like that. This shot, though, shows something interesting, though. I wanted the ability to mix my blended grass/dirt terrain with just dirt, for places like steep slopes and so forth. So I made a slight change to the tri-planar material:
If you refer to the shot I posted of the tri-planar node tree, you will see that here we have the Noise texture that is used to mix between dirt and grass. Only now, we also have an image texture that is multiplied against the Noise texture. Anywhere that is 1 in the image texture will result in the dirt/grass mix, but anywhere that is 0 will result in dirt alone. I can then go into Texture paint mode in Blender and, with a brush, paint directly on the terrain in shades of black, wherever I want there to be only dirt. Hence the large patches of dirt in the render, where the slope is steep. If I were to generate my terrain procedurally, this is where I could import the steepness map and use that to blend instead.
Now, with all that out of the way, it is a simple matter to bring in trees. Again, I use a Python script to generate areas of steepness where trees can not grow, and I tweak the size parameter to get a scale I like.
I do have some more detailed bark and leaf textures, but the setting feels pretty cartoony to me, which was kind of the intention, and I didn't really like the whole feel of the more realistic bark on the trees. So I yanked it, and just used some solid colors and slight bump-mapping. I added just a slight bit of distance mist, just to help the trees in the lower left to fade more into the forest behind them, to give a sense of continuity to the scene.
Then, I added a tower.
For the tower, I just very quickly beveled the corners of a subdivided plane and extruded a shape upward. Cut some holes in the sides for the arched windows, made a thingy at the top, etc... I mapped it with a tri-planar material, just to get something up there quick-like. Then I added some lights. It was literally the work of, like, 20 minutes tops. I kind of like the starkness of it, though.
Now, as far as lighting effects go, Cycles is pretty awesome. It is so easy to add area lights of any shape. Just create a mesh, add an Emission shader node to it, and crank it on. For the lights here, I just duplicated three spheres with Emission nodes. I used a similar trick as I used for the ground plane to make the spheres themselves transparent. By using a Camera Ray node, I Mix between Transparent (if it's a Camera Ray) and Emission (any other kind of ray). That way, the balls contribute their light to the scene but aren't drawn themselves. I cranked the Emission strength up to 6 or so, to give a nice warmish and welcoming glow, but without being too bright. Finally, I did a bit of post-processing in the Gimp to add a sort of darkish fade-out at the edges, to accentuate the tower and push the rest of the scene more into the background.
There are a lot more things I wanted to do with it. Some additional ground clutter, maybe some additional texuring on the ground to make it more interesting, a few more varieties of trees plus some low brush. It'll have to wait until I get back, though; the wife and kid and I are flying to California for a couple weeks on Friday, and I doubt I'll have time to do a whole lot while we're there.
For several years now, ever since I really started to learn Blender, I've had the thought in my head of doing a little serial webcomic using rendered 3D scenes. Doing stuff like this always brings that desire back. I've got a finished novel based on Goblinson Crusoe, maybe it would translate well to a webcomic. Seems like a fun sort of project to take on. Just, you know, not right now. I've got too many unfinished projects as it is, why add another one?
Anyway, I'll probably be out for a couple weeks. So, later.