Saturday 7 September 2013

Render Layers

Update: I've just had a quick look at this post the morning after I wrote it and I realise I forgot to enable anti-aliasing while I was rendering these out: the rendered car is very grainy.  It shouldn't be and I will correct that when I post the render layers in full.

I have written previously about render layers in my post on the finished typewriter.  That was a very simplistic overview of render layers.  Today I will write more about the concept and practice of render layers, and why they are used in VFX.  This is a long one. Make tea/coffee/beverage.

Render layers are, as Wikipedia succinctly says, "multiple images designed to be put together through digital compositing to form a completed frame".  The final image is separated out into these separate images to make it easier to change things further down the pipeline.  If everything is rendered into one image then re-rendering that shot may take days.  This means that making small changes such as the colour of objects, or the intensity of shadows is not possible near the deadline.  By rendering in layers and separating those elements into parts we can make those changes without incurring massive time delays.

There are actually two different forms: render layers and render passes.  Ultimately these two things lead to the same end.  Render layers are slightly more 'old school' and now we would usually use render passes.  For the purposes of this blog the two are exactly the same - the differences are more procedural.   I will use the term render layers because I think it makes more sense to the lay reader.

Render layers are similar to layering pieces of cut paper over each other to form an image:

This beautiful image is made by Carlos Meira - http://www.carlosmeira.com.br/
His site is a treasure trove.

In the lovely picture above, the sky is made up of layers of light blue paper; the clouds are off-white paper; the ship, brown; the sea, green and so-on.  Each of these elements individually do not amount to much but when they are layered up properly, in the right order, they make the final image.

The same principle is true with render layers.  The layers are created and added on top of each other, finally creating the final scene.  In this update I will go through the process of adding each stage to a simple render.  I will write a short, separate update detailing the individual layers; I intended to add them to the end of this one but am having some problems.  Hopefully separating them out will allow the process to be made clear without convolution, but an idea of the scale of VFX can be had at the end.

All of the image and assets in this update were created by Escape Studios; until now I haven't used any of the stuff they've actually provided us with but today's exercise is particularly useful for explaining this idea.  The piece of work I will be writing about today was to composite a Porsche 911 (one of the old, nice ones) into this scene:

Image courtesy of Escape Studios - http://www.escapestudios.com/
who agreed I could use it etc. etc.
The laborious work of matching the camera angle, modelling the car and placing it in the scene had already been done for us, which was a bonus.

Rough plate.
This first render is basically what you see upon loading the file.  At the stage of this render I have actually already matched the lighting in this scene to the backplate; however, I've turned off shadows so it's basically, it's a brand new scene.  The first thing we do, though, is match the lighting so let's pretend I haven't already done it.  

This scene has one direct light - the sun, and one indirect light - the sky.  I have written a little more about this distinction in a previous post on lighting.  For this scene matching the lighting is done as follows: match the colour of the object in shadow (indirect light) to the backplate; match the angle of shadows from the sun (direct light) then match the colour and brightness of the sunlight falling on the object.  The angle of shadows is matched by eye.  To do this we usually use white and grey spheres placed in the scene.  Failing that we use the backplate and helpfully this backplate has a white object - the flatbed van - relatively near where our object will sit. 

Final Gather, indirect light matched.
Above is the object with shadows - indirect light - roughly matched to the backplate.  This was done in a very simple, crude way, by making the object white and removing all reflections.  The colour of the front bonnet which I happen to know will be in shade was matched to the tailgate of the truck behind it - the truck being white, also.  Once the colour and intensity of the indirect light was matched, a direct light was added to simulate the sun.

Final Gather and direct light.
The angle of the shadows - and so the position of the light - now roughly matches that of the backplate; certainly close enough for this example.  The colour of the shadows doesn't matter because we will correct it in post.  Shadow colour and density (how light or dark shadows are: how much can you see) is normally corrected in comp just because it's easier and often quicker.  It also leaves open the option of tweaking at the last minute.   Again the colour of the light was matched by roughly matching the colour of the side of the car to the side of the truck behind.  

It's quite striking how effectively the object sits in the scene, now.  There is nothing more complicated than a backplate, Final Gather, and a direct light.  Disregarding the shadow colour/density, at a cursory glance you may already not consider that the Porsche was CGI.  

Final Gather, direct light and reflections.
Above we have added the reflections.  Again, another small layer added to the realism, and reflections really sell it.  The whole purpose is not to deceive the keen-eyed viewer but to achieve an effect such that it never occurs to look for the CGI.  That is the goal - make it so good no-one even considers it.  The reflections are cleverly done: instead of reflecting a mirrored sphere as per my typewriter we have just wrapped the backplate, exactly as it is, around the object.  The eye sees reflections and is satisfied: no-one really checks what's being reflected. (Except film or VFX nerds... like me.)

Reflection of the background!
In this quick render I've made the car 100% reflective - a mirror.  It's a little difficult to make out but on the car's front-right wheel arch the reflection is obviously that of the top-right corner of the casino.  These sort of tricks are used all of the time, usually to make up for lack of useful data.

re·frac·tion
1. The fact or phenomenon of light, radio waves etc., being deflected in passing obliquely through the interface between one medium and another.

Next, the glass.

Final gather, direct light, reflections and refractions.
Another layer that sells it to the eye.  In this layer the glass is transparent and refracting with the correct refractive index - it bends light by the right amount.  To further convince the eye the car is really there, the backplate is visible through the glass.  This is an extremely simple thing to do - it doesn't happen automatically - but it pushes things another notch.  The interior of the car is extremely simple and has barely been modelled.  It would be ideal to have more detail in there but it's barely visible so we get away with it.

That's really the final layer.  There is a lot of behind-the-scenes stuff which isn't visible here.  The next quick update will just have all of the proper render layers on their own with a caption explaining each one.  I haven't gone over the Ambient Occlusion again as we saw it previously but it is in there, doing its bit.  

In the context of the course, we covered this whole process - and a lot of other layers that I haven't written about - in the morning and early afternoon.  In many ways today was one of the most intense because it was an astonishing volume.  We were warned in the morning that, "this is the lesson that people usually really struggle with".  I'm pleased to say that the class as a whole kept up, and we all understood what we were doing.  Until we moved into the software Nuke, which I'm still not going to talk about because I don't understand it. 

No comments:

Post a Comment