Tip:
Highlight text to annotate it
X
Hello everybody! I am Magno Borgo
and this is another Nuke tutorial.
Continuing on the theme of multi -pass render , Today we explore the depth pass
also known as "Z-depth" : the depth along the Z axis
this pass is very useful, and one of its main uses
is creating defocus effects . We can use the depth field of a camera to create
defocus and/or focus on specific areas of image according to the depth .
Here we have the Channel Layer " depth "
In this Layer Channel we can observe the values
observe here the values of the red channel
they determine the depth in the Z axis , of each pixel of this image.
This lamp back there , has a value of 0.30
This lamp here in front, has values close to 1
this means that at render time, depth info was saved on each pixel
What is important when we generate a depth pass on a 3D software ?
First, for greater accuracy the render should be 32 or 16 bits
It is also important that this pass is not "anti-aliased" (AA)
The pass must be rendered without it . Usually when we render
special passes in 3D software , this is set automatically (without AA )
but in any case... verify!
This depth pass has many uses in Compositing
one of the most common is the defocus effect .
This defocus effect can be generated / rendered inside a 3D software
but it is usually a time consuming render and difficult to set .
When we bring this effect to Compositing we have more flexibility
and less render time . It's the kind of ideal effect to be done in Compositing
Before showing the effect , I will talk a little about optimization
inside nuke, since the effect is a bit "heavy" (slow)
if we know some resources, we can turn the effect the setup faster
The first is the " Proxy Mode" This button here
the proxy mode decreases the size of the image we are working
so effects become faster. When you activate the button
the image size decreases by half
which is the default behavior from Project Settings ( proxy )
if I disable the button , the image will return to the original size
Be aware the the Proxy mode affects the render: if the proxy mode is on
and you render the project , it will render it at half the resolution.
Another feature is the " downres " : it decreases the number of image pixels
causing processing to be faster
it does not reduce the image size : if I use "8"
he will use 1 of every 8 pixels of the image. The size of the image remains the same ....
depending on the situation we can use: " 2 " , " 4 "... we choose a resolution
and the effects will be much faster to render
A third option is the region of interest (ROI)
area of interest will limit the render to the area set
in this case, if I set the area just for this lamp, everything outside will be ignored
I will disable the ROI for the moment and apply the effect Zdefocus
This filter is here in the Toolbar , in the area of Filters > Zdefocus
down there . We have a filter called "Defocus" but this effect
does not use the depth channel.
I'll bring it here , and connect it to the image
How does it work?
It will affect a channel that you choose ( in this case the RGBA )
and using the channel "depth", it will apply a defocus. We can use this "focal point"
to choose where the focus of the image will be. If I put it here in this lamp on the middle of the image
this region will be in focus and defocus occurs forwards and backwards from that point (depth)
See that the " dowres " is set to 4, if it was at "1 " that would be taking a long render time
If you have a Nvidia video card (with CUDA support) and NukeX
You can render this effect using GPU processing
which makes rendering very quick . But it is not available for me here .
I'll push the effect to become visible to you
I set the "maximum " to 100 and the "size" to 50
let's wait for the processing ...
when we have this red icon thats means that the viewer is processing effects
something interesting ... I will return the " downres " to " 1 "
see that's taking quite a while to process
this line ( scanline ) goes down (or up ) depending on the situation .
If you want to see another area , double click on the Viewer
the scanline moves to the region and continues processing from there.
for slow effects is quite useful .
I will return the " downres " to 4 . The "size " determines the amount of defocus
and the "maximum " is the maximum defocus that will occur in the image
if you want a "size " higher than 100 (on this example)
we would have to increase the "Maximum". Its pointless to have the
size at "10" if the maximum is " 5"
it will limit the effect at "5"
With the " focal point" , you can click and drag
and set the focus based on the depth of the pixel
I have put the focus on this lamp.
Bringing it forward , we changed the focus again
and defocus the background.
What information is used by the " focal point" ?
It uses the channel " depth " of that pixel
I'll put the depth pass on the alpha channel this image
so when we hover on the image in the Viewer, we'lI see the value of "depth " in alpha
It'll be easier to associate the attributes here .
I will create a node " shuffle "
As I'm not using the " alpha " in this moment , put the " depth " on it
moving the mouse , note the depth value of the pixel
back there ... 0.31
1.02 here in front
this value of 1.02 here in the focal point is the same as here in the Viewer
we can manually set the depth , or by using the " focal point"
the "focal point" will have x and y coordinates , but if you enter a depth
manually , it moves the focus to that region
if I want to put it on this lamp ... the value will be approximately 0.56
go there and enter the value... wait the render...
the defocus is done , now independent from the "focal point" position
Let's take a look at the attributes of the node Zdefocus
First: the channel that will receive the effect and the depth pass
"math " determines the type of calculation used
this will depend on your depth pass , in the case of this image
that comes from Modo , this calculation "far = 0 " is the correct
this mode "far = 0 " is used by Nuke and also by PRMan
It will be defined by how the " depth " pass was generated iar render time
for example, if I look at the " depth " ...
an interesting shotcut to cycle Layers Channels in the Viewer
PageUp and PageDown .... press them to move to the channels
I'll go to the depth channeland see the pass rendered inside Modo
Where elements on the background have lower values , and the closest
to the camera have higher values ( note the values in the red channel)
I have a " depth " pass generated by Maya / Mental Ray
see that it is quite different .... comparing with one another ....
each render engine will save " depth " passes differently
what is important is observe the numbers , to configure the "math "
let's see ... that lamp back there is present , But the values are so high that I can not see it
value is 2.7. If you manipulate the Gain or Gamma Viewer
we can try to visualize the elements ... the information is there
the values are too high , making viewing them difficult
the lamp back there has values near 1.9
this lamp here in the front ... values around 0.37
it is the inverse when compared to the depth we saw in the other image (modo)
It is possible to use this depth pass , we just need to configure the "math " correctly
stopping the mouse over the attribute we'll see which mode will apply
In this case , the first two modes will work well for images coming from the mental ray :
"direct " and " depth "
But depending on your render , it may be set differently
the tip is to always to observe the values that you have on the depth pass
and choose the "math " more appropriate .
Returning to Zdefocus , I will change the Viewer to " rgba "
and wait for the calculation. I'll also turn off the Viewer Gain
on the the "output " we have some options : "result " is the end result
the other options are interesting to configure / set the defocus effect
the " focal plane setup" is one of the most interesting
if you stop the mouse over , it explains : red is forward
( in our direction ) of the focal point . Blue is behind the focal point
and what is in green is the focal point ( in focus )
If I move the focal point to the lamp back there
see here ... red is forward , blue is behind the point .
placing it at this lamp and increasing the " depth of field "
the green color will be the focused area
working with the " depth of field " , we can set specific values
to the focal plane
If I bring this point up here to the front
working with very small values
I can set a very specific focus in this green region
red is out of focus and the back also out of focus
these values will depend on your depth pass
let's see how this is looking
going back to "result "
and here is the result ....
to show the "layer setup" , I'll use an alternate depth channel
using a roto node, on the alpha channel
I generated a depth map ...
We can paint, draw depth maps .... it's not imperative to use a 3D rendered image
to use the Zdefocus effect
if we look at the values of this alpha channel , the edges of the image have values
around 1 and to the center of the image values are near 0
I'll use this as a depth pass ... how to do it:
I'll use a ShuffleCopy and feed the input 1 alpha into depth
I am replacing the original depth by this rotoscope
Let's take a look at the result
going back to the Viewer " rgba " and back on the node output for "result "
using the new depth , this is the result
I created this new channel to demonstrate the "layer setup ", It will be easier to explain/see ....
The Zdefocus effect is based on a number of layers , which will be
in front and behind the focal point , see that we have some "stepping" here
as I move the point , we can see the divisions of layers used
typically the layer spacing is automatic (default )
and this amount of layers will influence the quality of the defocus
usually the value is 50 , if I type for example 10... we see a larger spacing
on the preview . This will make the render faster, but with lower quality
we can define the number of the layers, and increase as required, depending on the scene
maximum is 256 and the minimum is 1
usually we want a large number ... 50 is a good compromise
the "layer curve" will define the spacing between the layers
The higher the value of "layer curve", nearer the layers become to the focal point
what is required for a good quality at the point of interest ( focus) in some cases .
going back to the original image . At anytime we can " reset " a node
that has been manipulated / created . Using the right mouse click : "set knobs to default"
when we use this, the attributes of the node are reset to default values
I just did it here ...
What will I do : I'll put the " focal point" at lamp in the middle
I'll switch to " focal plane setup"
increase the " depth of field "
increase the "size " to 50 and "maximum " to 50
let's see the result ...
Take a look at this brightest spot here ...
I will create a ROI (region of interest )
just drag the center/edges
I will focus in this area and work at final quality inside it
when we have elements over images on the Viewer , press "o" to
turn off the " overlays " . These " overlays " are elements of interface that allow us to
control interface / nodes / etc
I'll be easier to see the contents on this region
the next attribute that we will see is the "filter "
This "filter " define the look of brighter areas of the image (highlights )
How they will be generated ... here it is like a circle / disc
we have for example the " bladed " look
These effects are known as Bokeh (defocused highlights)
and this is determined by the type of lens used in camera
in the case of the " bladed " we now have a pentagonal shape
because the attribute " blades " is set to 5
could have a three sided shape, let's see ....
the defocus is now triangular
it all is determined by the lens , iris , anyway ... physical characteristics of the
camera that can be simulated here
by the type of "filter " : then we have "disc " , " bladed " which has several attributes
as aspect ratio , number of sides , roundness
rotation that can be animated ...
anyway ... you have to experiment a bit with those attributes
and we have a third option that uses images
to generate any shape with the filter
I'll use this Roto node
I will turn off the ROI and see the image at 100 %
this is a shape that I made using a Roto node
and I'll use this to generate the filter effect
going back to Zdefocus , turn on the ROI
and I will connect this node in the "filter" input
when I change the "filter " to "image"
We need to set up the channel that will be used ... here I'll use the alpha
and there is the defocus based on my customized design
is very interesting because we can create any shapes
more stylized effect.. less real
and the last two options :
the " gamma correction" will modify the calculations of the ZDefocus to intensify highlights
the brightest regions ...
and " bloom" will determine which elements will be further highlighted
all elements with values above this value will be highlighted
using the extra " gain" applied in these elements .
These are the Zdefocus attibutes..
Let's see the final image ...
after some"edit magic" ( because the render speed ... )
this is what I wanted to show
I hope you enjoyed it
do not forget to like the video and the video channel
remember that as more people watch the videos
I can produce more videos
A hug and until the next tutorial!
For more training : http://training.borgo.tv
Do not forget to subscribe to the channel !
Twitter : @ borgotvtraining facebook.com/borgotvtraining
Copyright © 2013 Magno Borgo
Subtitles by community Amara.org