Introduction to LuxBlend
From LuxRender Wiki
Introduction to LuxBlend
LuxBlend is the add-on for Blender that enables you to set up and render scenes with LuxRender. LuxRender has recently gone through a major rewrite allowing much faster rendering, GPU rendering and internal rendering in Blender.
The rewrite introduced the new render API called LuxCore and it is what this tutorial will be using. The introduction tutorial for the classic way of rendering is still available here
LuxCore is still under development so some things are not supported yet and there are some rough corners here and there.
First make sure that LuxRender is selected as render engine and LuxCore API is selected on the Render tab.
Let's render a simple sphere. Shift+A > Mesh > Ico Sphere and add a level 2 subdivision surface modifier to it (Shift+2) and set shading to smooth. We also need a light source so add the sun lamp if there isn't one already in the scene (Shift+A, Lamp > Sun). Move it to the right of the sphere and rotate it to face the sphere. Add a plane (Shift+A > Mesh > Plane) under the sphere. Press F12 to render.
We did not set up any materials so the sphere and plane are using the default material. Let's take care of that in just a minute. But first let's do a one-time setup of LuxBlend.
This step is not absolutely necessary but recommended because it will make LuxBlend and LuxRender easier to work with. And we only need to do this once. When we are done we simply save the startup file in Blender and the settings are there the next time you start Blender.
Move over to the scene tab in Blender. In the Units section pick the measurement unit you are used to. This is important for several reasons:
1. LuxRender is a physically based render engine, and that means you need to model the scene with correct size and scale in order to get a correct render. If you model a glass of water, model it to scale (about 10cm tall, not 1-2m tall). Blender's default cube is 2m x 2m x 2m and you can confirm this by using orthographic mode(numpad 5) and front view(numpad 1). Check the upper left corner of the 3D view and check the background grid.
2. A lot of settings in LuxBlend uses real units, like bump maps and hair strand size. Take an orange for example. Let's say it's not modeled to scale, instead it's about 1m wide. You know that the bump amount on an orange is about 0.5-1mm simply by looking at one. So you put that bump amount in LuxBlend and you hit F12, and later wonder why it's showing a weak bump or no bump in the render. Because a 0.5mm bump is very little on a 1m wide orange :)
3. You will sooner or later reuse an old model and append that into another blender file. If you did not model to scale the sizes will be off. Sure, it can be scaled afterwards to fit the new scene but all the settings that rely on real sizes will then be wrong and the render will not look the same.
That's it for the one-time setup of LuxBlend. Save the start-up file now to have Blender use these settings from now on.
It's good practice to get in the habit of modeling to scale. Once you do, it takes just a few seconds to find out or estimate an object's size before starting modeling. One more thing that's important about scale is Blender's scale property found on the properties panel in the 3D view (N). Select a mesh object and check the panel. These three should all be '1'. LuxRender uses this scale so be sure to apply the scale (CTRL+A) if you scale in object mode.
Here is how to apply materials (shaders) to objects. Most materials are set up in the same way as the glossy material, so we will cover glossy and the ones that differ from it.
We can use the objects from the previous section. Select the sphere and move to the material tab and add a new material for the sphere. If there is already a material there, delete it and add a new one.
Click Use Material Nodes to create a node tree for this material. Split the 3D view and change one of the views to the node editor. At the bottom of the node editor you can switch between the different node views. Pick the material node button if it isn't already selected.
Delete the default matte material node and add a glossy node (Shift+A > Material > Glossy) and connect it to the Surface socket on the Material Output node. Glossy is a basic shiny material, and can be used to create a lot of different materials which are glossy (plastic, anything painted, lacquered wood, wet concrete). Pick a color for the diffuse color channel to give the sphere a solid color. You should never pick a color value higher than 0.8 on either R, G or B channels because no material in the real world is that bright/saturated (LuxRender is physically based renderer). Adjust how shiny it is by changing the Roughness. Press F12 to render the sphere.
Specular color is the color of the specular highlights, and it should always be a dark color (default 0.04). Please note: Specular color is not the same as specularity in other render engines. Roughness is the same as specularity. Change the specular color to a red color and render just to see what it does.
Let's try putting a texture on the sphere. First right-click the Specular Color and 'Reset to default value' to change it back to the default dark grey (RGB: 0.04). Add a new procedural clouds texture for the material (Shift+A > Texture > Clouds) and a Bump Map/Height texture (Shift+A > Texture > Bump Map). Connect the Clouds node to the bump map node and the bump map node to the Bump socket on the Glossy material node. Pick Noise Size: 0.05 on the clouds texture and bump height: 5mm on the bump map. Render this now and we will get a bumpy sphere.
LuxRender supports three texture data types, and two of them you will use the most. Those two are float(grey scale) and color textures. What we just used as bump map was a float texture. Float textures are grey scale and represent "how much" of something and color textures represent, well, color.
Let's try a color texture by using an image map and put that on the sphere. Before we can use an image map, we need to UV unwrap the sphere. Back in the 3D View, enter edit mode, select all faces on the sphere and press 'U' and Sphere projection. Split any of the views and open UV/Image editor in the new view. Open the image you want to use in the image editor or drag and drop it there from your OS.
Back in the Node editor, add a new image map texture (Shift+A > Texture > Image Map). In the drop-down, pick the image you opened in the image editor and connect the node's color socket to the glossy material's diffuse socket. Render!
Most procedural textures are float(grey scale) textures so they have no color. What if we need one with color? We can use the mix node for that. More of that later.
Delete all material nodes for the sphere except the Material Output. Add a Glass material node (Shift+A > Material > Glass) and connect it to the Material Output surface socket. Render this now and you should get a solid clear glass sphere.
Three important things about glass:
1. Glass must always have a thickness. Always. Every time. A sphere or cube already have thickness but a simple plane or circle does not. It's very easy to get thickness to them by using the solidify modifier. For a sheet of window glass you could use a simple plane and the solidify modifier with a 3-4mm thickness.
2. Metropolis sampler. Glass is difficult to render for any render engine. While the Sobol sampler is fast when rendering simple scenes, it has trouble with hard to find light paths. No big deal, just switch to Metropolis (on the Render tab) and render away. Consider using Metropolis when rendering difficult scenes such as indoors, glass or water.
3. Check the normals. This is very important in order to get a correct render. This applies not only to Glass but all materials. Blender does a great job on getting the normals right when using CTRL+N in edit mode but some times it's off.
The sphere has correct normals but let's check it anyway before moving on. Go into edit mode in the 3D view and open up the properties panel (N). Toggle on show normals and change the size to 10cm. The normals are pointing out from the sphere and that is correct. Normals should always point to the outside of the object.
With the mix material you can mix two different materials. That material can in turn be mixed with yet another material enabling countless combinations.
Delete the glass material node and add two metal material nodes(Shift+A > Metal) and a mix material node (Shift+A > Material > Mix). Connect the sockets from the metal nodes to the mix node and the mix node to the Material Output Surface socket. Increase the Roughness on one of the metal nodes to 0.2 and change its color to some dark red. If we render this now we will get a combination of the two materials based on the Mix amount value.
We can control the mixing further by specifying which part of the sphere should get more of one of the metal nodes and less of the other. We do this by using a float (grey scale) texture and connect that to the mix amount socket. Add an Image map node (Shift+A > Texture > Image map) and connect it to the mix amount. Open an image in the image editor or drag and drop one in there from the OS and select that image in the image map node you just added. Render! (F12).
The mixing can be inverted by swapping the material 1 and 2 sockets. A procedural texture connected to the mix amount socket would work fine as well instead of the image map.
That was mixing materials. If we need to mix textures or colors there is another mix node for that.
Delete the image map node, mix material node and one of the metal nodes. Connect the remaining metal node to the Material Output Surface socket. Add a color mix node (Shift+A > Color & Math > ColorMix) and connect it to the Metal node Color socket. Add a Stucci texture (Shift+A > Textures > Stucci) and connect it to the Mix node Amount socket. Pick Noise type: Hard on the Stucci node and pick two different colors on the Mix node. Render.
To mix two image maps you simply add two image map nodes and connect them to the Color 1 and 2 sockets on the Mix node.
Rendering a part of an object invisible based on an image map is done by connecting the image map node to the opacity socket on the material node. This can be done in two different ways depending on what image you have that contains the alpha information.
Delete the sphere and add a plane. Add a material for it on the material tab and click 'Use Nodes'. In the Node editor, delete the matte material node and add a Glossy Translucent material node. Connect it to the Material Output surface socket.
Open the diffuse image you want to use in the image editor or drag and drop it there from the OS. Add an image map node in the node editor and select the image from the drop-down list.
The channel on the image map node should be set to RGB by default, which means the actual color in the image. Good. Connect that to the Diffuse Color and Transmission Color sockets on the Glossy Translucent node. Now, if you are using a png image that has got an alpha channel we can easily use that alpha. Duplicate the image map node (Select it and Shift+D) and connect the duplicate's socket to the Opacity socket on the Glossy Translucent node. Select Alpha from the channel drop-down list. Render!
If you are not using a png with alpha channel, the setup is pretty similar except that you need another image that shows the area to mask as visible (White is opaque and black is transparent). The Image map node that connects to the Opacity socket should now be set to either Mean (which is greyscale) or RGB. Open the mask image in the image editor and select the same image in this image map node. Render!
Lighting a scene is usually done by using area lights and/or a hdri. Let's try those. First change the material of the sphere to glossy in the node editor (Shift+A > Material > Glossy) and put some color on it.
Back in the 3D View, delete the sun lamp and add an area light (Shift+A > Lamp > Area). Place and rotate it to face the sphere. On the object data tab for the area light, change its size to something like 5m and hit F12 to render.
ESC out of the render and add another area light somewhere in the scene facing the sphere.
Now when we added the second light let's have a look at light groups, a very powerful feature of LuxRender. With these you can control the power and color of the lights at render time. Yep.
First create two new light groups on the Render Layers tab.
Then select one of the area lights and, on the object data tab, pick the appropriate light group from the drop-down list. Do the same thing for the other area light. Render.
While it's rendering, open up the properties panel(N) in the Image editor. Change the light intensities and colors of the two groups to something appropriate.
To use HDRI lighting we add a hemi lamp in the 3D view (Shift+A > Lamp > Hemi). On the object data tab for the hemi lamp we can select a HDRI map or pick a solid color.
HDRI lighting (hemi lamps) and sun lamps will have a different intensity than the area lights. These will require some tweaking to their Gain value on the object data tab when they are added to the scene. The sun lamp for instance is very bright compared to other lamps so decrease its Gain value on the object data tab to get more even lighting when using it with another lamp. It can seem like the other lights are not even on but they are actually overpowered by the sun lamp.
First delete the sun lamp and the sphere. Next we need an object that will act as container for the volume. Let's add a simple cube and make its size something like 4x4x10m. Then we need a room. Shift+D the cube and scale it down just a little bit. We want the room to be a little smaller than the volume container. Add a material for the 'room' cube on the material tab and click 'Use Nodes'.
Select the volume container and add a material for it on the material tab. Click 'Use nodes' and in the node editor delete the matte material node and add a Transparent material (Shift+A > Material > Transparent(Null)). Connect it to the Surface socket on the Material Output node. On the Material Output node we can see the Interior and Exterior volume selection. Right now we can't pick a volume for either of them because we haven't created a volume yet. So let's do that.
On the World tab we add a new volume and click 'Use Volume Nodes'.
Back in the node editor the volume nodes view should already be selected. Delete the Clear Volume node and add a Homogeneous volume node (Shift+A > Volume > Homogeneous). This volume type supports scattering, such as the light ray/dusty air effect.
Set IOR to 1.0. You should have a Color at Depth node there already so connect its output socket to the Absorption color socket. Add one if it's not there (Shift+A > Color & Math > Color at Depth). Set Scattering color to RGB: 1,1,1 (white) and change the Scattering scale to something like 0.1. The higher this value is the more pronounced the scattering effect will be. It seems like a low value and that is because scattering in air is low compared to some high scattering liquids such as milk or orange juice which can be a scale of 100 or more.
Select the material node view again at the bottom of the node editor. On the Material Output node select the volume we just created as 'interior'.
Before moving on, let's have a quick look at what the interior and exterior really is. In the 3D view, enter edit mode, bring up the properties panel(N) and toggle on Show Normals. The normals should always point to the outside of the object. Where the normals point to, that is the 'exterior', regardless of the shape of the object. Opposite side of the normal is the 'interior'. We want the scattering effect to be on the inside of the cube, the opposite side of the normals. That is why we selected the volume we created as the 'interior' for the volume container.
One more thing to keep in mind when using volumes is what volume the camera and lights are in. Select the camera and go to the object data tab and select the volume we created as the exterior for the camera.
Note: When you use a sun lamp or a hemi lamp (HDRI) you should never have a scattering volume set as their exterior. Those lamps are considered to be at an infinite distance from the camera, they do not have a real position. You can place them anywhere in the scene and it won't matter, only their 'rotation' matters.
Area lights however have got a fixed location and should have their exterior set to the volume they are located in.
Bidirectional path tracing handles this scene a little better than path tracing so switch render engine to bidir on the render tab. These two work in different ways and they both have their own strengths and weaknesses. Which to use is difficult to say, you just need to try them and see how it renders.
Next add a Suzanne monkey and add 'two' materials for it on the material tab and click 'Use Nodes'. The first material is by default assigned to all faces. Select the second material and enter edit mode and select the faces representing the eyes and click 'Assign' on the material tab to make those faces use the second material. In the node editor add a Light Emission node (Shift+A > Light > Light Emission) and connect it to the emission socket. Pick a suitable Light Color on the Emission node and select the volume we created as 'exterior' on the Material Output node. If you check the normals on the monkey you will notice they point outwards. The normals always points to the exterior so we select the volume we created as 'exterior' on the Material Output node. Now select the first material on the material tab and in the node editor select the same volume as 'exterior'. That's it. Render this now (F12).
This page was just an introduction to using LuxBlend and to get started using LuxRender. It showed new users where to find the most important settings and how to use them. For details on the settings please refer to the LuxBlend manual and the LuxRender manual.