Menu

Labels

Tuesday 7 August 2012

Blender 2.63 - Cycles - Infinite plane -(update/ver#1)

(Video tutorial will be available soon)



It's workaround, reason is that i wanted to achieve this effect with material nodes, not compositing, there for i called it wrokaround, anyhow it's working. I hope that this post isn't too long, and hopefully it contain some useful stuff. When the whole node thing is setup, it can be pretty flexible considering results that could be achieved.  Ver#2 of this tutorials will be done only by materials, which makes it a lot easier and shorter, but while i figure that out, this tutorial is the thing to go with.
Issue with previous tutorial i had about infinte plane is that ground is partially transparent, i didn't like that. So this tutorial is one way to go, it's kinda long, but once you know how it is done, it could be done in no time.

(If at any point this tutorial become confusing or unclear, please let me know, so i can keep tutorial readable... and non-confusing)
Click on image to enlarge
































Part one - Scene setup


To test the effect, we need a couple of objects in the scene, in my case those are sun, camera, ground, and two models that are used to test the distance fading or vanishing point.

















One model is placed near the camera, and the other a bit further.

















Form camera view, it looks something like this.



















Now, to start form the ground plane.
It should be a large plane. So, while i'm in metric units, i'll add a circle first, than in edit mode, while all vertices are selected, choose fill. Now we have a ground plane. Because ti has to be a large one, for x and y 600m will be just fine.





-set metric units

  













-add circle























-circle in :)

















-enter edit mode, and from Mesh menu choose Fill within Faces submenu.

























-cirlce as ground plane

















-exit edit mode, and for x, y dimensions ender 600m, it should looks like in the image below





















-one more thing, in render settings, under Film tab, check transparent box, i think that this is the option that allows to generate alpha channel.









-now material for the ground, i did a little tweaking, very simple
Connect diffuse and glossy shader nodes with mix shader as it is on the image below.
Now to get something like fresnel effect, i ain't gonna use fresnel input node as i did before, there is another one called Layer Weight input node.
Within there is Fersnel, i think that this is the old one, just moved to another node, newer have IOR as value.
Connect Layer weight to the Fac input within Mix Shader node.
Now add ColorRamp node, and put it between Layer weight and Mix Shader.
What this option is allowing is to change colors of the ground normal to the camera point of view.

















These are couple of examples on how ColorRamp works:



a)















b)
















c)

















Next thing are objects.
Any objects could work, cubes, spheres... i used very old allotop model, well it's kinda cool. Any material can do the job as well.
















Now, how to set up this scene for rendering.
Select Ground plane, in the name field you can change the name that way, and under Relations settings move Ground plane to the second layer, as it is in an image below.



























The other two object will remain on the first layer.




Light.
Default light is Lamp, change it form Lamp to Sun. Cast Shadows should be ON, and i increased strenght to 5. 






















That is all i think, as far as it goes for scene setup. Now we moving on to the compositing.





Part two - Compositing

Tricky thing... i must say, but it doesn have to be.
This is our node setup.




















Before we jump into compositing, few more things are needed to setup final render. Those are layers outputs.
So one more time i'm going to take a look at render settings. But now under Layers tab. We need two Render Layers.
First Render layer i'll keep as it is, i called it "objects", under Layer only the first layer should be selected, which means that only objects on layer one will be rendered on fisrt Render Layer.
Also, AO and Shadow passes need to be selected.

























By clicking on the plus sign at right upper corner, new Render layer will be created. I called it "plane". On this render layer it should be only second layer selected. I moved the ground plane to the second layer before.
























Now compositing window.
It can be separated into three major groups, first one is for the ground plane, second is for the objects and third one is for combinig first two groups.



















After rendering the scene, we have two images that need to be combined together.


First one is ground plane


















and second one are objects























So, to begin...
First thing i need is Render layers node. Because i had selected before AO and Shadow passes, now it is available as outputs on the Render layers node.


























Now i need to combine this passes. The only reason i added this passes is to enhance the shadows under objects.



















First thing to do is to combine orignal image and z depth, by simply combinig them like in an image below. The result is only white picture.






















Now, i need one group, that is gonna generate distance fading, it looks like in an image below.
Add Map Value node, and for the offset enter -15, for the size 0.010, but this is my case, values depends from models in the scene and size of the scene. Than add ColorRamp node.
ColorRamp node will takeover MapValue setups, and by adjusting grey sliders, we are affecting distance visiblity. Select these two nodes and press CTRL+G to create group.



















After z value from the Render layer node and first input on the Add node is connected, reconnect those with the group "fading" like it is in an image below. We should get something like in an image below.

























Wtih SHIFT+D we can duplicate Add node and instead of Add choose Multiply. Now Add node and Shadow pass connect to the Muliply node inputs. Result should be somethig with sharp edged shadow.
To remove that problem, i am going to add Alpha pass to the Shadow pass, thus shadow calculate alpha information.
























And, that can be done by connecting Alpha pass from Render layers node with Fac input on the Multiply node, but it has to go trought the Invert node.
I think that both RGB and Alpha should be selected on the Invert node. As a result we have much better looking shadow.





















Duplicate Multiply node, and connect AO pass and previous Multiply node to the new one. AO pass should be visable in render. 


















Now, to make alpha pass visible as white, i need one more Add node. So now, connect last Multiply node and group "fading" to the image inputs within new Add node. And, i wanted control over the Fac as well so i connected group "fading" to the Fac input, as it is shown in the below. 


















Now second group of nodes.
I need one more Render Layer node. In the layer list, layer 'objects" should be selected. Will get something like in an image below.



















I'll do the same thing as i did with the first Render layer node. And here is something i should mention. The 'distance fading' (or group "fading") is the effect that Render layers should share.
By duplicating this group, groups will share the same information, thus changing one will affect the other one. What it means that, changing "fading" for one Render layer, it will affect any other layer that share same fading settings. Now Image pass and Z pass should be connected to the Add node as it is shown in the image below, for fading to work.




















Because of Render layers combinig issue, Alpha pass need to be connected to the Fac input of Multiply node trought the Invert node, like in an image below. There won't be any changes in the image.



















And now the magic comes in. From the first group, connect the last Add node to the Multiply node at second input. We get two Render layers combined. But we have a problem.





















If you take a closer look, white line at the edges of the second layer is bit of a problem. This is alpha issue. To solve this, AlphaOver node need to be used.























Start by adding AlphaOver node, and connect both Render Layers to the image inputs, objects with first image input and ground plane with second image input. Here we don't see the objects yet.








































Add two more MapValue nodes, and two Z combine nodes. Now how to connect those in our case.









































For more information about this issue (removing alpha outlines), go here https://wiki.blender.org/index.php/Doc:2.6/Manual/Composite_Nodes/Types/Color and take a look at the 'Z-Combine Node'.




Connect Z passes from the Render Layers nodes to the MapValue inputs as it is on the image.





















Now this is little tricky. 




















First, connect both MapValues nodes to the first Z Combine node with Z inputs.










































Second, connect Z passes from both Render layers to the Z inputs within second Z-combine node.


























Now, 'objects' Multiply node connect with both first image inputs within both Z-Combine nodes,
and 'ground plane' Add node connect with both second image inputs within both Z-Combine nodes..



























The last thing is to connect both Z-Combine nodes with AlphaOver node as it is shown in the image below.









































And we have our infinte plane.




















If you need to change environment, there is a quick way to do it. Add Mix node and choose type Darken. Connect AlphaOver node with first image input within Mix node. Second color could be used to change the background or distance.



Add Color Balance node, and here you can play with environment.