This tutorial is aimed at those who have a good grounding in objects and who have used a density shader before. This tutorial aims to take it a little further, some Node Editing is required.
Firstly, get your terrain made, make sure it's got some steep slopes. Now surface it, we will not be using the surfaces as blending shaders, because they can cause unpredictable results, so surface however you like.
Right, add a fake stones shader and set that up as well.
You should have something like this (below you'll find attached the tgd file for this stage):
*See img attachment 1*
NOTE: IF YOU USE MY TGD YOU WILL NEED TO REPLACE THE OBJECTS USED. I USED 2 POPULATIONS (XFROG FIR AND SWEET BIRCH) WITH TREE SCALE 3 AND DENSITY 20.
Busy, eh? The fake stones are almost completely covered by the trees.
Right, now add two object populations and make sure they're centered at the camera's location.
Good. Now for the fun bit.
I'm assuming you already know how to set up a powerfractal as a density shader - so as to provide variation and natural coverage to the population, but how do you ensure you have natural variation, as well as stopping the objects from appearing on sheer cliffs?
Say hello to the subtract colour function, get to know it, love it and take it home with you. It's the best thing invented since sliced bread. Honest.
Right now for a jump into the node editor, you'll notice that your object population appears as a grey node in the Objects Box. It only has one percievable input, but that is because the others are all inside the internal network. Right click and press "View Internal network" if you want to check, but we won't be working in there.
Add a powerfractal nearby, but don't connect it to anything. Set it up so that there'll be a percievable variation in the object population we'll be using it on. Now add a subtract colour function. Plug the powerfractal into one input, create a distribution node, set it up to not go on slopes, and plug it into the other input of the subtract node. What the subtract colour function will do is take the black areas from both input shaders, thereby leaving only the white bits that are in the same location for both shaders. For us, this means that the power-fractal will still provide natural variation, but the population will never appear on slopes. Hurrah! Let's do it again! Add another subtract colour function and a negate colour node. Plug the fake stones shader's blending shader (either an added blending shader like in my tgd, or a fractal breakup shader - I recommend the former method) into the negate colour node, and the negate colour into the subtract colour. Now add the first subtract colour node into the second subtract node.
*see img attachment 2*
Phew! Time for an explanation. What we've just done is subtracted the fake stone distribution data (the negate colour node) from our randomized grass surface layer (the first subtract node). What this means is that not only will we have our objects appear only on the grass surface layer, and they will be suitably randomized, but they will also never appear on a fake stone. Success! The reason we inverted the fake stones distribution is so that the white areas (where objects will be placed) will be the black areas (where the stones weren't placed) of the stones shader.
Right, now to actually plug it into the population. Double-click the population to get it's properties, now click the distribution shader field and select: Assign Shader > Subtract Colour 02 (or whatever you've named your subtract shader).
Now when you go back to the node layout it may look like the shader is plugged into the terrain field, but rest assured, it hasn't.
Now, to do the second object. We need to repeat our skills learnt from the last run, but also factor in our first object population as well. Incidentally (depending on how scaling is done in TG2) you may be able to restrict an object to appear around an object, but not in it, by scaling the first object's density shader by something like 3 or 4, and then subtracting the original density shader from the mutliplier and using that. I haven't tried this yet however, and would be interested to see how this turns out (most notable use would be for bushes under trees).
Add another subtract colour function and a negate colour function. Plug the original powerfractal into the negate colour function and plug that in turn into the subtract colour node. Next, plug the distribution shader we made earlier into the other input of the new subtract colour node.
Now add a second subtract colour function and plug the first subtract into the second. Now plug the negate colour function that we used on the fake stones density shader into the new subtract colour node.
This is the desnity for our second population. Plug it in properly.
Huh? how did we do that? It's quite simple really, by just inverting the original power-fractal the object placement for the second object will be exactly wherever the first population isn't, while still not being where the fake stones are, and only on the grass layer.The powerfractal is our original seed for object placement. Where that is white, trees will appear. Where it is black, trees do not appear. After that, all we did was subtract the additional areas we didn't want the trees to appear in. By inverting this seed, the original black and white are swapped, so where there were no objects originally, now there will be, however we still subtract the areas we don't want.
*See img Attachment 3*
Sorted.
This could be taken further by subtracting both density shaders again by another powerfractal, this would add random areas where neither object was placed, but that are still viable locations for objects. Couple this with image maps and you have a very flexible placement system indeed.
NOTE: This system will drastically increase population times. Sorry!
Hope this helped, here's my final render below.
*See img attachment 4*
*See img attachment 5*
This tutorial turned out to be a lot bigger than I expected.
What d'ya think?
I'm definitely interested in experimenting with scaling the density shaders for undergrowth population.