Skill Level Intermediate
- In this week's Blender's Tips, Tricks & Techniques I'm going to show you the simplest, most mundane tip of them all, how to save on memory usage. Now if you have a scene with multiple textures memory usage is going to be really important. That initial overhead will take awhile to process or, if you're rendering on a graphics card, you have a hard limit to your memory usage already, so you want to make sure things are really efficient, and I'm going to show you how to make them as efficient as possible in Blender. First, let's go to Cycles and let's take this cube and let's rotate it.
We want to just make it a little different than the default cube. Let's pull this out over here, and let's go to Texture. Let's make a new one really quick. Click on New again. Type in texture, and then I'm going to type in something crazy. I'm going to type in 8,000 twice, so tab 8,000, tab 8,000, and then I'm going to pick Color Grid and then click on OK, and that's going to generate this big ol' color grid. Now I'm going to come over here to this material.
Click on Use Nodes. Under color I'm going to click this little dot and go to Image Texture. Right here I'm going to click on Texture and where it says flat projection I'm going to go to Box. Let's go to Material, and there's one more thing we need to do. Let's pull this out right here. Let's go to Node Editor. Hit n to get a little bit of real estate, and let's just shift + a add a texture coordinate node and drag generated over to vector.
There we go. Let's close this, and now we have ourselves a cube with an 8K texture map on it. Okay, so now let's hit ctrl + c and copy that to the buffer. It should say Copied selected objects to buffer up here. Now, just a side note, if you did get an error go to File, User Preferences. Click on File and change this temp directory to a directory that you can write to. Sometimes you might get an error and that's because you don't have permission to write to the temp directory.
So just put a directory that you can write to and everything should work out. So ctrl + c, Copied selected objects to buffer, good. Now let's make a new file, ctrl + n. Let's get rid of this cube, and let's switch this to cycles. Hit ctrl + v. Let's switch to material. There we are, and let's just move it over to the side somewhere. There we go. I'm just going to, just move it so it looks a little different, and then I'm going to go to Render and hey look at that.
I've now rendered a cube. It took me about 3.6 seconds and a peak memory usage of 245MB. Not bad. Now let's go over here and switch to Slot 2. Come back to 3D view and let's hit ctrl + v one more time. Now without doing anything else go to Render, and hey look at that we've rendered the cube again, two of them, but this time our peak memory usage was 489MB.
Now I really believe a couple of vertices won't really add that much to it, let alone a full cube, so something's definitely happening. We're definitely using way more memory than when we did on Slot 1 so what could it be? Well, let me show you. Let's pull this open, bring this down a little bit, and let's switch all scenes to Blender File, and that Blender file's going to show everything that's in this current .blend file: images, objects, textures, materials, animation, things that are linked in, et cetera.
And if you open up images you'll see there's a Texture and then another Texture.001. Now this is the root of our problem. Blender doesn't know that these textures are exactly the same. This is even a bigger problem when, for example, you have a scene with multiple image textures that are on disk and Blender says, "Oh, well this is Texture.001 and Texture.002," even if they're pointing to the exact same file on your disk. This can eventually eat up and add to more and more memory usage, which is really not ideal.
So let's right-click on Texture.001 and go to Remap Users. You don't have to change the ID type, but under New ID click on that and just go to Texture, and then click OK. Now, for good measure, let's click on 3D View, Image Editor, and let's switch to Slot 3, and let's render. And hey look at that, we've rendered the entire cube, yet again, and we've only used 245MB of memory use, compared to, say, 489 when we added it the first time or when we rendered initially 245.
So we've definitely cut our memory usage in half just by remapping this texture user. Remapping will take you a long time, honestly, but it'll save you so much in headaches, in trying to fit it on your graphics card, in memory usage, on you scenes, and frankly it'll make your scenes really, really efficient. So I definitely recommend you add this to your workflow. Until next time, this is David for Blender's Tips, Tricks & Techniques.
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.