Introduction to Compositing in Blender

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
- [Martin] Oh yes, compositing, if you have never tried it, it may seem like a giant waste of time, I mean why render out something in layers only to put everything back together later? Especially since I can just render it all in one go, right? Well, kinda, but in this video, I'm here to tell you why you might be better off using compositing, especially with heavy scenes, you might encounter your render failing a lot, running out of CPU or GPU memory and rendering in layers helps with that, but of course, that's not all, in my experience from any larger production, compositing is a must because only in that stage, one can really fine tune colors, blend everything together nicely, add extra effects and much, much more, in other words, the real final image only comes about in the compositing stage. Before we start, let me make a little note, I personally like to have my Blender UI a little adjusted when it comes to these menus here, I like to right click like this and flip them to the bottom, so yeah, it may be a little bit different from what you're used to, also be sure to have Node Wrangler activated before going into this tutorial, you do it in preferences, add-ons and node wrangler here, and then save your preferences, otherwise some of the shortcuts I'll be mentioning won't work for you. So, as an example, I have here this desert environment, I'm sure you'll recognize it at this point from my Master 3D Environments in Blender course where you can learn how to make it step-by-step and the cool thing is, this scene, yes it is made entirely out of planes, with this main desert plane as a basis for our terrain, of course when I switch to rendered view, it gets displaced because it's using this adaptive subd modifier with a combination of textures in Shader Editor. Then to extend the scene without adding too much of a performance strain, we have these 2D planes, placed so far behind that we do not even realize they're 2D. In the mid-ground is the desert plane, rendered and put on a flat card and in the background, it's some hazy mountains and the sky, yep, it's 2D too. In the course, you'll learn how to make all this and also add a particle setup with dust elements, some HDRI lighting and atmospheric layers, plants and more. Alas, that's not what this video is about, as I said, it is about compositing this scene together to achieve even better results than we see here and rendering is a first step to being able to composite your layers. By the way, this workflow applies to all of the other scenes of the environment course, only in the rest of them, we go more in-depth, using more advanced compositing networks, still, the techniques remain the same all throughout. Before I explain what render layers are, first let's take care of organizing our collections here, throughout the lessons, we have diced up our elements into these groups to make the scene a bit more tidy and by the way, you can just download this blend file to follow along, from the resources section of CG Boost, just have a look at the info of this video and click on a link there. So, we have this desert layer, the 2D desert planes, atmosphere, dust, mountains, sky and more, but we didn't create these collections just to make our Outliner more organized, these will actually help us with our goal, rendering and compositing in layers, now thinking about how to dice up your scenes is a big part of this compositing process, but let's make our composition fairly simple for the sake of this tutorial and let's base it on the actual distance from the camera, so we have this whole foreground element, comprising of the desert dunes, both the 3D ones and the 2D ones, also the dust and some grass particles, so that will be our first foreground layer, then we have this far background mountains, so that will be our second layer, then the sky and finally, I have a very foreground element here, this FG dust, which is just two dust particles placed in front of a camera to give the scene a bit more depth, we will composite that one in front of the desert, which gives us four layers and we will now try to render them separately, for that let me check the collections here, to make this all very simple, it is always best to have the stuff you want to have on one render layer, to have it in a single collection, so we have these mountains here, good, then the sky collection and the FG dust collection, exactly as we need it and then we have all the rest of this mess, so let's say we make a new collection by right clicking here, choosing new collection and then double clicking on it, and rename it base, and take all these, and put it there, then we can even push the collection up here to have it after the FG dust, which is the foreground layer, but above the mountains, which is the background layer, so this way, we've ordered everything as it overlays each other, you can see there is some extra stuff here, cameras and one sun lamp, but that doesn't really need to be in any collection because I want these to be active on all my render layers. Cool, let's try this out, hide these three and leave just the FG dust, just the foreground dust is visible and if I unhide the desert, and hide everything else, just the base layer is visible and so on, so far, so good, but we don't want to always manually activate and deactivate the various collections to render various layers of the scene, what we want is to save four different setups, where Blender would store the visibility of these collections for all the four layers we want to render, the FG dust, the desert, the mountains and the sky. Well and that is what render layers are for. You will find them up here where there is this render layer sign, so now we have the base layer active, let's rename it to have the same name as the collection we want to render, just base, now Ctrl select these three collections that we don't want to render on this render layer, right mouse button and find this view layer menu, and in it, find disable from view layer. Yep, you may be a little confused at this point because the sign here stated render layer, but now we read view layer menu, well yeah, but that's not my fault, these layers we are creating are called view layers, basically storing sets of activated collections in your viewport, but they also function as render layers, storing which collections should be rendered on a specific view layer, yeah, thanks Blender. Just bear with me everyone, it should be clear soon. Okay, menu here, so we can see shortcut here which is E to disable the selected collections from this view layer, let's try it, go back to Outliner, hit E and see? These little checkers got deactivated and the collections disappeared from the render, exactly what we wanted. Next, let's just duplicate this view layer with Copy Settings, this basically just takes all the info of which collections are activated and which are deactivated, and copies it to a new render layer, a new would activate all your collections and blank would deactivate them all. Name it FG dust, because that's the collection we want active for this render layer and now we don't want the base layer this time, so select it and hit E to deactivate it, and then select the FG dust collection, and hit Alt E to bring it back, done. Now, this view layer renders only the foreground dust, next, repeat the process for the mountains, so copy settings, rename the view layer, hit E on FG dust and Alt E on mountains, and finally the sky collection, copy settings, name it sky and you know what? You do not have to hit E and Alt E, you can of course always use these checkers, so we just uncheck this and check the sky collection, I just wanted you to know the keyboard shortcut. Now, when you switch between these, the layers we set get activated and that is really a great way to separate your blend scenes to render only separate collections and store those settings for later. A little note here, there are also these render overrides hidden here and among them, super useful option like this, Holdout mode, basically punching a hole into your composition wherever the objects on this specific collection are, or then there is this Indirect mode which will hide the objects, but make them visible in reflections, refractions, glossy passes and well, all the other indirect light effects, we will use this a lot in the course, especially for reflections on water. We can give it a quick render now with F12 to only render one frame, you see? I'm making this render faster by only rendering 25% of the overall resolution and also worth mentioning is I have the various layers transparent because I've checked this transparency checker here under the film tab in the render properties and it goes through all four of the view layers or at this stage render layers and you can then see them stored here separately, and if you were after just a single rendered image, you can just hit save as on all of these four layers, write them to your disk, switch to another Pass, save this one as well and do it for all the four layers, and then just skip to compositing. However, we are making a shot sequence, for my shots, unless I want to go really professional with EXR or DPX formats, with great data depth, I just usually pick this PNG format, sometimes with 16 bits for colors and I render out sequences of images, "But hey, Martin, why image sequences and not a video?" You ask, well, I'll tell you, two reasons actually. One, most video formats include a form of compression to them, so they lose quality in order to be able to play the video smoothly, which we do not want, we want to retain the quality of each frame. Second, most video formats do not have the option to include Alpha channel, which we actually need for compositing, fortunately, the PNG format will allow us to store all this data with only a limited loss of quality. All right, now let's specify where to put the sequences, create a base folder and give it a name base_, I use underscore here because image sequences are rendered as separate images with a number at the end, indicating the frame number and I find it better to have this number separated by underscore. Cool, so logically we now want to render out all our render layers at the same time onto our disk, just by hitting this render animation command or Ctrl F12, so let's see what happens if I render a few frames. Okay, so I'm done rendering a few frames and when I opened the folder, I specified in the output menu, I can only see the base layer rendered here, not the mountains, not the sky and not the foreground fog, so how to solve that? Well, we'll use a compositor window for it, if by any chance nothing appears in the window, just make sure you've checked the use nodes option, only then the node workflow will be activated, you can now even maximize the window by hitting Ctrl spacebar to see it better, what you see here is a rendered layer node, connected to the composite node and if you don't see it, just Shift A search for it, add it from this menu here, just like you would in Shader Editor, basically what is happening, the frame is rendered, stored here, these connection lines take the first rendered layer here ordered alphabetically and drive it into the composite image socket, which is then saved as our final frame, but you can see here, there is the rest of our layers and those do not get saved, what we can do though is to duplicate a render layer node three times and in each one, set another pass here, FG dust, mountains, sky and now let's just set where should these layers be stored on our disk, so hit Shift A, add three file output nodes and connect them like this, so now what this does, each of these image sockets will be driven into file output command, which will then save this image into a folder we specify here, after that I like to go in here and create those specific folders, so one for FG dust and you can delete anything from here, and hit accept. Then, one for mountains, delete this and one for sky, and delete this again, accept and here we go, now hit render animation and if we have a look in the folders afterwards, yes, these are now rendered as well, very good. The only issue I still have now is that all these, the FG dust, the mountains, the sky, it is called image001, image002 and if all our extra rendered layers are going to be called image, it might get real confusing, real fast. So, let's have a look at the file output nodes here, hit N to bring out the sidebar, expand the properties of the node and let's name this little fella right here, then mountains_ for this one and finally, sky_ for this and with that if we hit render animation, all our layers are rendered and saved at once, in separate folders, pretty useful I'd say. Having finished the render layers and setting up the renders so that it automatically stores the rendered images onto our disk, we only have to setup a few values into render and output tabs. First, the output menu where we can set the size of our rendered images, up here you can see that I've set this cinematic format I like to use, which is 21 to 9, most commonly using this 2560 to 1080 resolution, this gives you the super wide cinematic image, the percentage here I cranked up to 100, you may even go to 150 to achieve 4k resolution, of course with all this you can go lower to save some computing power and sure you can even change the resolution format, I specified frame rate to be 30 here, that's the rate I've chosen for all of the scenes in the course, other than that it's just end frame here, I need just 90 frames to have a three second shot and the output with the location, where to save the base layer and then the PNG format set here, good. So, now let's move onto the rendering tab because that is where we can really influence the speed of the rendering. First things first, I am using the experimental cycles render engine for this, I use it for the adaptive subd displacement with which we've created a desert in the course and I'm also using GPU computing here, if you can't switch to GPU or if it's grayed out for you, you'll need to check it in preferences and switch to CUDA, or if your graphic card allows it to Optics, if you happen to run out of memory when rendering, it doesn't automatically mean you have to switch to CPU, first make sure you have switched to shaded view here before hitting render, because render preview takes some memory too, also close any other GPU based applications you may have running, like other 3D software, image editors or Cyberpunk, especially Cyberpunk... finally, I sometimes restart my computer before the final render, you know to give it a fresh start and make it rest for a bit after weeks of rendering, no idea if it really works, but I do it anyway, only if all this fails and you still run out of memory, switch to CPU rendering here, it is generally more reliable, but slower for this sort of job. Next, in here I use just 256 samples for the render, I didn't really need more because I have great experience with Blender denoising, so I've chosen to rather denoise the render frames than go overboard with all the overall sampling which would slow down the render a lot. I did not use any of the OptiX denoising, which is great but I rather wanted to do some denoising in the compositor later. In the light paths, I found that the default values are way over the top, I didn't really need too extreme values here, just eight for total light bounces, two for diffuse, four for glossy, I probably could have gone even lower here, as well as with this transmission and yeah, zero for volume, we don't have volumes anyway, the only thing I cranked up were the transparency levels, I added 40 because we have a lot of transparent planes in the scene creating the dust and if we didn't have higher numbers, there would be a lot of dark fragments where the transparent particles overlap, the rest I left mostly as it was, apart from this subdivision menu, I changed some values here to make the computation of the subdivisions a bit faster, this off-screen scale ensures that anything that is outside the range of the cameras specified here will not be subdivided as detailed as anything that's in camera view, so that usually helps a lot and I also activated motion blur to have it baked into my rendered elements, I raised the shutter to have more of it, but default values of 0.5 would probably be okay as well. In film tab, do not forget to check this transparency here, to get your separate passes with transparent background and then if you're using Blender version 2.9, and below, a very important option here, definitely check the settings of your performance tiles, if you've set the render to GPU, it's better to set bigger tiles here like 256 or 512, if CPU values of 64 to 64 pixels will be good and if you're using the new Blender 3.0, you can safely disregard this option because it is now calculated automatically. After that, I just hit render animation and finally went to sleep, well not really, let's render one frame here, let's speed up the video and see how it looks, nice, but noisy. So, it's time to go back to the compositing window and see what we can do about it, first though we need to activate an option that will allow us to denoise the final image, it is called denoising data and you find it here in the passes menu, with that checked, let's re-render the image, when you do, you will notice that in the compositor, there is a few new output sockets in your render layer node, the denoise image, normal and albedo, without really going into this, how this thing works, not that I really know how it works, but all we need to do now is to use denoise node, Shift A, search for it and add it here, now connect your resulting image here, then the denoise normal and albedo here, with that done with F11, activate your render output window and have a look at how the composited image looks, and to compare it, let's switch to the original base image with the noise, with the noise, without the noise, with the noise, without. The result is a tiny bit mushy, but quite okay for my final shot, because remember, even shots from your digital camera are always a little bit blurry and imperfect, so having a perfectly crisp and sharp picture, isn't really the best solution and while you're at it, you can also go through the various view layers and activate the denoising data for the rest of them, and then plug it the same way we did before, so denoise node in between the file output and the render layers, and then image, albedo and normal into the denoise node, and with that I finally hit render animation, and waited until all my layers were rendered, and next up, we'll finally get to compositing. Wonderful, when all this is rendered, we can take the image sequences and put them together in a compositor, for example, Blender's compositor, as you can see I have started a new Blend project and created a slightly different setup here for this compositing stage, by dragging the corners of the windows, I repositioned the windows and I have this big window with my compositor here, and below that a timeline window, since we are going to be working with image sequence clips, so that I can scrub through them and now let's put our shot together, if you're new to this compositor window, know one thing, it operates basically the same as Shader Editor, you can add stuff with Shift A and here you can search for your first node called image, put it here and open it up, search for your desert base footage and load it in. Now, if you have this option to detect sequences checked and hit A to select all of your images in the folder, it should automatically set it up for you, so image sequences here, number of frames and with an offset here because we start the numbering at zero, also auto-refresh is checked and RGB values here are fine, this is good, but we don't see it, well for that, let's put the composite result directly into this compositing window. First, plug it in here and get rid of the render layers window, then create one more node called viewer, this one will allow us to preview the composited image in the background of our window here, to do it, hit N to open up the shelf and since we have our output view here, we can now activate the preview in this view menu, check backdrop and voilĂ , we have our layer in the window, you can now still move your node with middle mouse button and zoom around, but the backdrop stays there, at this point it is too big though, so what I like to do is to go in, zoom out here and push it up like this all right, now let's get compositing. First things first, we will blend all our layers together, so if you want to overlay various rendered layers in the simplest way, just like you mix textures in Shader Editor for example, we can mix image sequences, the node that does it is called Alpha Over, so let's add it, move our desert base. Oh and by the way, you can always rename your image sequences here and name it desert base, now duplicate it, put it here and let's choose for example the mountains instead, it's all setup here automatically, so we can proceed to connecting the nodes and then to the output image sockets, it's a real pain to always connect these two, so one thing to streamline this is actually to Shift right mouse and drag to create a reroute node here, and drag the connection out of it, now we can always connect just one connection here, it saves some clicks, well now it's of course the wrong way around, we need to switch the inputs here and actually move the nodes so that they do not crisscross with their connection lines and this doesn't look good, well, Blender's viewport always had problems with previewing transparency right off the bat, especially when you are compositing on a transparent background, which we currently are, what helps though is to use this convert premultiply checker here, again without going into details because that would be a topic for a whole separate video, what it does is it takes our Alpha channel of the image and then multiplies the black color over the RGB channel, making the transparency work as expected and yeah, this is much better, now of course we want to see the backdrop better, so what you can do is to zoom in and by the way, super handy shortcut is Alt middle mouse button to be able to move it around with the mouse, without Alt, you are moving the nodes, with Alt you're moving the backdrop. Cool, so Shift D, load in the cloud image sequence and rename it, then duplicate the Alpha over, plug it here and actually, again switch the connections and finally, let's bring in our dust layer, so duplicate, replace the image sequence and Alpha over it. Good, however this dust, you may not want to mix in hard like this, just covering the background elements, for this layer you actually may want to use mixed node, add it in, mix these two and replace the Alpha over connection here, now something terrible is happening again, but that's just a problem with the transparency, so we need to use this checker this time to actually use the transparency of the input, now in this node as it is now in Mix mode, it functions basically the same as the Alpha Over, however in here, you have all the other blending modes to choose from, so what I like for this dust, even though it's not actually correct and any skilled compositor would kill me for that is I sometimes like to set dust elements to screen, or even add mode, now, why is it wrong? Dust doesn't really brighten up your shots, instead it covers it because it basically is a layer of solid particles over your shot, however, I sometimes like to go with what's nice, rather than what's correct, I mean when it comes to compositing, not in real life of course. (Martin clearing his throat) So, when I compared the add value to the mixed value, I like the add more, however, you can definitely bring it down to about 0.5, if you now hit M, you can deactivate the node and then hit M again to reactivate it, and since it's better than Alpha Over in this case, let's delete the node. Cool, so this way, we connected our nodes, basically we just reconnected the stuff we would get if we rendered all as a single layer. So, again that question, why render it in separate layers at all? You ask, well now it's time to show you because in compositing stage, you can do all sorts of extra 2D work, you wouldn't be able to do in 3D stage, or at least it would take time and it would be too difficult, the simplest thing you can do is for example add a RGB Curves node and very quickly, play around with the lightness of the nodes, like this mountain node here, see? I can make it brighter, darker, even change the color tones, by just adding one more point on the green curve and messing around with this position, and also on the blue curve, I was able to bring the colors of the mountains closer to the colors of the sky and the desert, and now it all blends more believable. Another great thing, even after the rendering stage, I can for example play with the positioning, so I add a transform node and here I can push my mountains up or down in the image, or scale it, even rotate it, that's especially good for some 2D elements you want to add to your compositions, see why this stage might be useful? And seeing this I think we can raise this curve to make the mountains brighter after all, just like you would in Shader Editor, you can now select your nodes and hit Ctrl J to frame them, you can then move the whole frame and also if you don't like the looks of it, you can go to shelf and node here, and give this thing a label, so let's name it BASE for example and you can also make the label bigger, and give the frame a color. At this point you can of course scrub through your timeline down here, unfortunately, Blender is not really fast at this and definitely do not expect seamless play, it will be the slower the more elements you add to your composition. Speaking of 2D elements, let's add some over our image base, I have prepared some very simple elements to add to our image here, so first, I have this gradient image, from your folder, you can in fact directly drag it here to the compositor window and it pops right in, what I want to do is to overlap it on top of our image, to create a bit of sun glow on the right side of the frame, so first, duplicate this add node, Shift D and push it to the right, Alt P will remove it from the frame and now it got very bright because it is adding white color from the second socket to the composite result, so I will instead add the gradient, see? Now it's adding this orange sun glow to the shot, however, I want it to be on the right side of the shot, so let's add another node meant for moving images called Translate and push it on X axis about 1000 pixels will do, easy, right? We can even push it up a little on the Y, about 200 will do. Next, I want to scale it a bit, so before the translate node, add Scale node, I want it to be taller, so Y axis and 1.2 is okay, finally, what I feel it needs is a bit more intense saturation, or maybe even a hue shift, well for that, there is of course the hue saturation node which we can plugin here to control the colors, put these nodes to the side, so that we have a slightly better view, crank up the saturation to feel more like warm desert sun, about 1.7 will be good and let's adjust the hue a tiny bit to about 0.51, you need to be very careful with this value, but it helps to shift your colors overall. Cool, one more thing we can do, here in the Mix node, if you go to the shelf, item properties, you will see this factor value here, so we can adjust the intensity of the mixing, let's go with 0.4 or you know you can always change the values here, I just wanted you to know that in the shelf, in these properties there are the same options as are in the nodes, frame it, name it gradient and we are done with this element. In the similar way, we can mix in another important effect, a vignette, I myself use two ways to do this and the first is I have this transparent image here of a black color on the sides of our frame which we can mix in, or we could of course make own in the compositor, I find it faster to have some prepared elements that I just use for all my shots, but the other way is more versatile for various resolutions, though it is usually slower. All right, let's try the image method, bring it in, duplicate the add node and connect these two, of course set to add, black color doesn't really do anything, however, set to overlay, a different story, right? You can go lower with the mixing factor, 0.2 or 0.3, something like that, I'll go with 0.2, a slight but important effect I'd say, frame it as a vignette and here we go, a nice cinematic darkening for our image. The second way to make the vignette is manually with several nodes, one little note here for this to work, you will need to copy the exact same resolution settings as your footage has, including this percentage here, so set 2560 and 100% here, next let's bring in this ellipse mask node and plug it in here, it makes for us this hard edged ellipse which we can now adjust to our needs, so resize it here until it almost touches the corner, but not really, this doesn't have to be precise, now bring in a blur node like this and change it to Fast Gaussian to make it faster, and with it, blur it significantly on X and Y, by the way you can also switch to this Relative mode and there you will be working with percentage instead of blurring pixels if it suits you more and in the end I just duplicated this overlay node and deactivated this one, and voilĂ , that's how you make your own vignette effect. Now, we can focus a tiny bit on the coloring, let's add a curves modifier and let's play with this curve, you can lower the green highlights and raise the midpoint of the reds, just to give it a little bit of red tint, you can also increase the contrast of the image by making a contrast curve like this, raising the high points and lowering the low points, you can also raise the low point of the blue curve, because blue shadows make everything a little bit more cinematic, as does more contrast by the way. Next, a node I really like, but one you also have to be careful with, the glare node, set it to fog glow with low settings here and then threshold of about 0.5, and size of nine, see? You can give the dunes a bit of that glowy punch it needs, if you want to have more sense of motion blur at the edges of the screen, right around here, you can also add a direction blur node, if we really crank up the values like eight iterations and zoom of 0.1, see what it's doing? But for my purposes, the zoom value needs to be raised only slightly like 0.05 and one iteration, almost like a cheap motion blur and finally, to top it all off, A thing that you may have seen in the trailer for the course and also, an effect that in my opinion is way overused these days, the Chromatic Aberration effect, you add it through this lens distortion node, add very low value in here and then to remove these weird edges, check fit, just promise you will not use it too much guys, it can get real artificial looking, real fast. So, if I now Ctrl Shift click on this first mixed node where we put all our layers together and preview it, well it's a change, right? With this composition we have of course just scratched the surface of what's possible in this compositing stage, but I think already, the result is a bit more interesting and now when you want to render the final sequence, you just bring in properties here, specify your output and the format, which is the same as the input, you do not want to deviate from the images you put into the comp and then hit render. So, my friends, I hope this video was useful to you, introducing you to a topic which at least in my opinion does not get mentioned nearly as much as it should in Blender tutorials, I for one, know that compositing saves a lot of my 3D scenes which would otherwise look uninteresting and boring, with a few well placed 2D elements, some nice blending and color adjustments, you can do wonders for your CG images and shots, and if you want to know more about all these topics, as well as how I've made these 3D environments in Blender, I talk about it at length in my Master 3D Environments in Blender course, which is finally in it's complete form, polished and ready for you to level up your Blender knowledge, so I hope to see you there or next time in one of these YouTube videos, until then, stay creative my friends, Martin out. (calm outro music)
Info
Channel: CG Boost
Views: 71,430
Rating: undefined out of 5
Keywords: compositing, vfx, visual effects, blender, cycles, tutorial, blender 3d environment tutorial, blender environment modeling, blender landscape tutorial, blender 2.9 landscapes, blender 2.9 envirnment, blender large environment, blender large scale landscape, blender large scale terrain, blender terrain tutorial, blender best way to create landscapes, blender 3.0, blender compositing, blender compositing tutorial, blender render layers, blender view layers, blender compositing nodes
Id: bIZrTXtyQkY
Channel Id: undefined
Length: 38min 45sec (2325 seconds)
Published: Thu Oct 07 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.