Composite CGI Element Behind Real Glass - Blender VFX Tutorial (Full)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
here's what we're after today we want to put a CG object behind some real glass object in our video will be working entirely in blender with a focus on how we can separate and composite the necessary elements to make this look as photorealistic as possible here's an overview of what we'll cover in this video first the obvious steps film your footage and then solve your 3d camera in blender there are plenty of tutorials on how to do this now it's time to recreate our real-world scene in 3d this means matching the geometry lighting and textures for the geometry of the shot I'll make a plane for where our objects sit then I'm going to model the glass and place it in our scene as closely as possible play through the shot to make sure that everything tracks well and that your objects don't slip out of alignment if there are some alignment issues make sure your CG object is resting on the plane and not floating above somewhere if it still looks bad your camera track might be off for lighting I created a 360-degree HDRI with my Ricoh Theta V otherwise add lights in your scene to match the light intensity color and shadow quality correctly for textures you'll want to recreate the table surface in my case I used a simple B SDF shader change the color and dialed in the roughness to match as closely as possible for the glass I use the principle of glass shader turn down the roughness some and use the noise texture in the normal input I tweak this in rendered view until my HDRI background was being distorted similarly to the original footage finally add in your CG object of choice in my scene it's this awesome keyboard model from blend swap comm okay let's talk about how to set all of this up for rendering using the cycles engine make sure your background is set to transparent hit render and you'll get this a fully CG shot which is not exactly what we're after so how do we extract just our CG object shadows refractions and reflections well we can control the visibility of these different elements within three areas in blender cycles that is object visibility collection visibility and view layer visibility known as Render passes now these three levels of control objects the collections and view layers they get pretty complicated when you add them all together and it's often at this point in a tutorial when you'll hear someone say it sounds confusing you don't have to worry about it as long as you just choose those two passes there and then we're ready to jump into our render settings here I understand why people often gloss over this part it's really complicated and it really takes a long time to explain to compromise I made an infographic which you can find linked in the description it should help you understand how objects collections and view layers work together to give you control over different visibility options in cycles let's start to use these three levels of control to break up our scene. we are going to take our current view layer and use it to render out just our CG object. so we will name the view layer main object. now within this view layer we want to control the visibility of our main CG keyboard object our table and our glass so we'll place them all in their own collections. select each object press M hit new collection. so I end up with four collections one for my scene camera and any lights one for my main object the keyboard one for my table and one for my glass. now if we right-click a collection and go to view layer we can set the visibility of the collection and all the objects that are inside it. you'll see in my infographic there is a section about these collection visibility settings. for our purposes we want to set the glass collection to hold out which will mask out wherever our glass is. then we'll set the table collection as indirect meaning it will show indirectly in our keyboard. now if we hit render we have just our main object without any part of it that goes behind the glass. main object view layer completed. let's create another view layer and name it shadow. you'll see we have the same collections in this layer as before all view layers share the same collections. now we want to extract just the shadows cast by the keyboard onto the table. we'll go to our table object and in the properties tab under visibility we'll make it a shadow catcher. this is part of the object visibility control I was talking about. again we want our glass to mask out the shadow so we'll set that collection to hold out. now even though our glass is set to hold out it will still cast a shadow so I'm going to go to my glass object visibility settings and disable shadow. I'll also disable diffuse and glossy while I'm here. now my glass object will not show up in any shadows diffuse surfaces or glossy reflection surfaces which is good because our real glass already shows up in those ways. finally we'll set our main objects collection to indirect only so we only see the shadows it makes. now shadows are done. we have just the shadows masked out by the glass. shadow view layer completed. let's create yet another view layer and name this one reflections. in this view layer will capture the reflections of our CG object on the table surface. to start we are going to duplicate the table collection we have. right click duplicate collection and turn the original one off. we're doing this because the original table object is now set to a shadow catcher and we don't want to change that. so now in this duplicate collection we'll also have created a duplicated table object. we'll go back into the object visibility tab and disable the shadow catcher so that it shows up normally. now we'll set our main object and glass collections to set holdout and in our render view we should see nothing but the table with shadows and reflections on it. to get just the reflections of the keyboard in the table will enable certain render passes for this view layer. remember this is our third level of controlling what we see in our scene. in the render passes tab then let's enable the glossy indirect pass. so why did we choose this? allow me to illustrate. the light rays which show the reflection of our keyboard in our table are the rays that leave our light source balance off our keyboard bounce off the table and into the camera. these particular light rays would be labeled glossy light rays since the last surface they interact with before hitting the camera is a partially glossy or reflective surface. and since our light rays bounce more than once we choose indirect. all together we get glossy indirect. see this section of the infographic linked in the description for more information. now if we enable render single layer and we render this view layer alone in the render view window we can then toggle down and view what this glossy indirect render pass looks like. note in blender 2.81 and above you can view different render passes in the viewport by going into rendered view and toggling this menu to view different passes. since we're done setting up this view layer we'll uncheck render single layer in the view layer tab. reflections view layer check. let's create another view layer and name it object through glass. now in this view layer we want our keyboard and glass collection to be fully visible like they are by default. we'll disable that duplicate table collection we made. to get just the keyboard showing through our glass will again enable certain render passes for this view layer. so let's go to the render passes tab and will enable the transmission indirect pass. in the viewport I can see what this looks like. so why did we choose this? well we want to extract just the light rays in our scene that leave our light source bounced off our keyboard go through our glass object and into the camera. these particular light rays would be labeled transmission light rays since the last surface they interact with before hitting the camera is this transparent transmitting glass surface. and we chose indirect since these light rays bounce more than once. all together we get transmission indirect. in addition will enable the glossy indirect pass which looks like this. I'll mention why we're doing that later. now looking at our transmission indirect pass there's one problem. we're seeing our HDRI environment reflecting throughout the glass. if you're not using an HDRI you still might be seeing the gray of your world shader throughout the glass. to solve this in the world shader editor we can add a light path node and add an invert to the is glossy ray and plug this into the strength of the background. now you'll see we no longer have the HDRI background showing in our transmission indirect pass. so when we render out this object through glass view layer will have these nodes connected to have this effect. but for the other view layers we've already made we'll connect this so that the HDRI behaves like normal. object through glass view layer check. finally I'm going to add just one more view layer name this one glass mask. just follow what I'm doing and I'll explain why later. in this layer we're going to duplicate our main object collection turn the original one off. for this duplicated object we'll set all the materials to a default emission shader. we'll duplicate the table collection turn off the other two ones we have. make sure the shadow catcher is disabled and assigned the table the same emission shader. in our render passes tab we will again enable the transmission indirect and glossy indirect passes and here's what the transmission indirect pass looks like. this render pass will serve as our black and white mask when we're compositing in the glass. note for this view layer we will also want to have that world shader limitation hooked up. glass mask view layer completed. now we have our five view layers setup. since all view layers share the same collections and we added more collections as we went we'll have to go back through our earlier view layers and completely disable the unneeded collections from those layers. just unclick the box to completely disable a collection. also to review as far as render passes go our main object view layer will output the combined and z paths which are enabled by default which we want this is good. the same for our shadow layer. our reflection layer will also output the glossy indirect pass we enabled. our object through glass layer will output the default passes in addition to the transmission indirect pass and glossy indirect pass we enabled. and our glass mask layer will output the same. now we have to render out our first three layers on their own since we need the world shader enabled as normal. we'll disable the last two layers by unchecking used for render then hit render. save out this image somewhere as an open EXR multi-layer file then only enable the two last few layers we made. hook up that light path node in our world shader render and save another openexr multi-layer file. now we'll head over to our compositor tab to start combining these different elements together. make sure use nodes and backdrop are on I'm going to delete everything here to show you how we'd start from scratch. create a viewer node and composite output node. we'll add an image input node and bring in the image sequence for our background footage. let's distort this to match the render size. hold ctrl shift and click to view a node. next we'll add another image input node. we'll open our first EXR file. we can see that we can switch between each of the first three view layers here. based on the view layer selected we have different output connections representing the render passes we enable. so how do we composite all these different render passes into our scene? well blender cycles has this master equation that is used which tells us how to reconstruct an image if you render out all the passes. you'll see in this equation that most of the time we are simply adding the light passes together that is using a color mix node set to add. only with color passes do we multiply the previous nodes. then all this is added together again to get the final combined pass. and remember this combined pass is what we output by default so when we enable certain render passes we're selecting specific ingredients of this combined pass. in summary this add in multiply node are the main ones we'll use when compositing. you'll also commonly use an alpha over node when compositing in a combined pass like our main object which has a clear alpha channel. we'll start by adding in some shadows. there are lots of ways to composite shadows. i'll add a color mix node set to multiply drop the alpha into the factor slot set the top color to white and bottom color to black this will give us a fully black and white image. let's add a color ramp to adjust the range of black and white we want. link in an RGB curves to add any needed color or brightness or darkness to the shadows. then we'll add a color mix node set to multiply and multiply our background image by the shadows output. boom. shadows done. next we'll add our main object on top of the shadows. duplicate our previous image input node and select the main object view layer. then we'll simply use an alpha over node to composite in on top of the background and shadow. next let's add the object showing through the glass. add an image input node and open up that second EXR file we've rendered out. select the object through glass view layer. remember we want to work with the transmission in direct render pass we created. now how do we put this on top of what we have already? well maybe we use a color mix node set it to add and try to add it in. no that doesn't look quite right. what about an alpha over node? that doesn't do much since our transmission indirect pass has that black background baked in with no alpha. we could try to key out the black background with a luma key node but those results look pretty bad. what would be ideal would be to have some sort of black and white mask that shows us exactly where our CG object shows through our glass and masks out everything else. well you'll remember that we made this so let's use it. we'll duplicate our image input node and switch to the glass mask layer we created. let's add a color ramp to make sure we crush the black and white values enough. we'll put this mask as the factor in put in our alpha over node our image we've composited so far will be the first input and the object through glass will go into the second input taking from the transmission indirect output. good job. take a deep breath and let's continue. now let's put in the reflection. duplicate our image input node. select the reflection View layer. now how do we composite this in? well in our equation here we usually add the glossy indirect pass. so we'll try that and it seems to look good. and yes this is the correct choice. and if you want more glossiness than this gives you duplicate the add node like this. now there's one final element that I added in to help sell the total effect. and that comes back to the glossy indirect pass that we created with our object through glass view layer. so let's duplicate that previous node and we'll add in the glossy indirect information again using our black and white mask in the factor input. and to tone this down I'll add another color mix node set to multiply and pick a gray value that looks good. now we have a composite that looks awesome! feel free to add in nodes to tweak sharpness and to work with color to improve the overall realism. and to render out the final sequence select use for render for our first three view layers only. make sure our HDRI is correct and in the compositor we'll have to make sure our composite node has a render layers node going into it. this is because whatever is hooked up into this composite node is what is saved out when we hit render animation. and we want to save out our render layers. set an output for the correct frame range and select open EXR multi-layer sequence. let that render out by hitting render animation. then we'll turn off these first three layers and only render out our object through glass and glass mask view layers. make sure to change that HDRI and render out another openexr multi layer sequence to a different location. now in the compositor everywhere we have those image input nodes will switch out our new openexr sequences instead of just those single frames. in the same way we can select the correct view layer and replace the connections for each node. now that this is all said and done we're ready to make a final render. make sure the final composite is hooked up to the composite node set an output type of PNG hit render animation. and this should go pretty fast outputting final PNG s of the entire composite we made. so there you have it. thank you for following along. congratulations if you made it this far. if you'd like you can download the blender project file over at my patreon linked in the description. these tutorials take a while to put together and I hope to do a lot more and so I'd be honored to have your financial support in doing that. more than that if you like this tutorial please give it a like share it with your friends subscribe for when more do come out. and until then bye bye. I am holding my phone with a sock over it so that you can have impeccable audio for this tutorial you are welcome
Info
Channel: InLightVFX
Views: 104,354
Rating: undefined out of 5
Keywords:
Id: qdqV4oortP0
Channel Id: undefined
Length: 18min 53sec (1133 seconds)
Published: Fri Mar 20 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.