Tutorial: Build surfaces in LightWave
Andrew Comb shares his techniques for creating paint chips and blended surfaces in LightWave 11
This tutorial will cover a number of techniques focused on building complex surfaces and simulating mixed materials, as well as showing you some more exotic tricks to get pretty lighting effects. I’ll explain how to build energy-conserving surfaces, which will work properly under most situations and respond to light and reflections correctly. You shouldn’t need to build specific versions of them for some scenes. Once you move over to this technique, lighting will just start to work without too much cheating.
This project relies on two superb plug-ins that should be part of every LightWave artist’s installation: Denis Pontonnier’s DP Kit and the Tools collection from db&w. Both plug-ins have been updated for LightWave 11, are free to download, and are available for Windows and Mac OS X.
Download the supporting files for this LightWave tutorial here.
01 Colour spaces
The first thing to do is make sure you’re working in the sRGB colour space. The default sRGB preset supplied with LightWave since version 10.0 should be fine for good lighting and shading under most circumstances. I prefer to leave all the colour inputs set to Linear and simply have Display Colour Space set to sRGB. This is the most important setting to get right, because then you know everything is being displayed as it should be.
Typically, while I’m working in Modeler I have Colour Correct OpenGL unticked , and have it ticked in Layout. This is because it also affects the colour of the wireframes, which makes modelling awkward – but this is a personal preference. The important thing is that Display Color Space is set to sRGB, so that the surface editor previews and rendering are correct.
Altering the Color Space settings within Modeler is done in the General Preferences (press [O] and go to the Color Space tab) and in Layout it’s done in Display Preferences: press [D] and choose the Color Space tab. The main reason for this is to ensure LightWave is correctly rendering in linear colour space, with all of the colours and textures converted so that they add to the light calculation properly. Most modern monitors and image formats are configured so that they display correctly in sRGB (approximately Gamma 2.2). If these textures and colours are added to the linear lighting model, they throw out the maths. Remove the gamma in textures and colours and the lighting model will work correctly.
You can correct the colours by either changing the colour space settings to sRGB or eyeballing the colours in the surface editor and leaving them set to Linear. For textures, any images that contribute to ‘colour’ need to be set to sRGB, so the gamma is removed (open the Image Editor ([F6]), select your image and set the Colour Space RGB setting for the image to sRGB).
However, any images that are to be used for texturing inputs, such as reflection, specularity, diffuse and normal maps, should be left set to Linear, or they won’t work correctly. This is why I leave the preset for images set to Linear (off) and manually set each image.
02 Set up the scene
For the scene I’ve used a new feature in LightWave 11, Instances. Instead of just cloning the item (via Item > Add > Clone > Clone Current Item), I used the simple instance command (Item > Add > Clone > Clone Instance). This creates a null, which has an instance generator inside it. You can then treat this null like a regular object, and rotate and position it. I created 12 instances of the cargo object and four of the central strut object, as I modelled them separately, and simply rotated each instance into place – just like you would with a clone.
Create 12 instances of the cargo object and four of the central strut object, then rotate them
Note that by default the instances are set to invisible/bounding box mode. To change that so you can see them, go into the properties for the null ([P]), then go to the Instances tab and open the instance preferences. In there you can see the instance Visibility settings, just as with the scene editor (a small eye icon) – change the Visibility setting and your instance will appear. If you’re in textured wireframe mode, you won’t see wireframes because instances don’t support this mode, so it’s a quick way to know which items in your scene are instances. In all other respects they will render identically to other geometry, and save a lot of memory.
Instead of using a Distant light as my scene’s key light, I used a Dome light with Angle set to 1. That’s all I use in the scene for lights, except enabling radiosity, so the objects bounce light around, and some luminous surfaces on the objects.
03 Create the basic energy-conserving shader
If you open the finished model, the final shaders look horrendously complex. However, I’ll go into the basics. Open the model and check out the test_cube surface. This has the main components of a basic shader to handle opaque dielectric materials, such as wood, ceramic, paint, plastic and so on.
The Schlick’s Approximation node is a new node by db&w that can be used to create a fast Fresnel-like effect, with a number of texturable channels. (It’s found in the node editor in db&w > Math > Schlick’s Approximation.) Typically, Grazing Reflectivity is left at 100 per cent and Facing Reflectivity is adjusted to create metals (if you use high numbers) or dielectrics (low numbers). The strength channel is excellent for plugging in textures for your surface, in order to vary them subtly.
Another excellent feature of the tool is the No Preprocess Reflectivity checkbox, which causes the reflectivity output of the tool to render as black during the radiosity preprocess, which can dramatically speed up that phase of rendering.
To get the right settings for the tool, add a Fresnel node (Math > Scalar > Fresnel), type in the value for your material (1.3-1.5 for a plastic- or paint-type material) and then alter the Facing Reflectivity value so it looks roughly the same. Plug the Reflectivity output into the Reflection input of the surface, and the Inverse output into the Diffuse. This way you have a simple energy-conserving material.
I use another Schlick’s node with a larger Facing Reflectivity value for the Specular shader: this is because the specular hit isn’t really energy-conserving, so I eyeball this to look good. If you’re just using HDR-based lighting, you can ignore this part of the shader; but for a space-type scenario, there isn’t usually an HDR environment, so just use Specular.
If you look at what I’ve done with the reflection and specular shaders, you’ll see that I added a Scalar constant (Constant > Scalar) and an Invert node (Math > Scalar > Invert), and plugged the Scaler constant into the Reflection Blur amount, and Invert into the Glossiness value for the Cook Torrance shader. This is because in LightWave, Reflection Blur and Glossiness are inversely proportionate (approximately).
Plug the Scalar constant into the Reflection node’s Blur input, and Invert into Cook Torrance’s Specular
This way you make one value that controls both shaders, so if you increase the Blurriness value, the specular hotspot spreads out more. I use the Reflections shader and the Cook Torrance Specular shader because I find these yield better results than the native, but you can plug the same inputs into your Glossiness and Reflection Blur inputs in the main surface node if you prefer.
For a metal shader, simply increase the Facing Reflectivity value and lower the colour. If you’re creating a coloured metal such as copper, then plug the colour texture into your surface colour, specular colour and reflection colour.
04 Make the material with a switch
Making one material blend with another is tricky. You could use Material Mixer (Materials > Material Mixer) and blend together two surfaces with your paint-chip texture, but in LightWave this is wasteful because each surface is calculated and then mixed, so that means calculating two sets of Reflection Blur. Instead, simply modify the surfaces using Remap nodes to achieve the same effect.
I use a few of the nodes from db&w’s tools nodes. The Cache node (db&w > Tools > Cache) stores a value that can then be reused without being recalculated. The Remap node (db&w > Maths > Remap) is useful here. It will remap one set of values to another. For example, I mapped 0-1 (0 to 100 per cent) to be 0.03-0.4 (3 to 40 per cent). If I plug into a black-and-white texture, when a value is black it will be converted to 3 per cent and when a value is white it will be converted to 40 per cent.
Modify the surfaces using Remap nodes to make one material blend with another
Feeding this Remap node into the Schlick’s Approximation node controls how reflective the surface will be based on the texture you feed into it. In this way, I control the reflection blur (and glossiness) with an input value, and the specular and reflection values too. The surfacing colour is also being driven by the same input. Using it as the opacity for a Mixer node (Tools > Mixer), you can have the two surfacing colours in the background and foreground colours.
The texture input that will drive the reflective amount also drives the reflective blur value, but this amount is multiplied with the Switch texture, and then remapped, to give the minimum and maximum blur values. This should yield variances in the reflection blur, based on the texture. To see what this effect is doing, you can type a value into the top-left Constant Scalar node. If you type in 0, you’ll see the red paint material; if you type in 1, you’ll see the grey metal finish.
05 Create paint chips using textures
Once you have your basic material set-up, it can be copied and pasted over your surface, and you can plug in the textures. If you open the st_paint_white_panels surface, you can see where I’ve plugged in the textures. To load in textures, add an image node (2D Textures > Image) and select the textures from the image drop-down. They’re set to be cubic repeating textures. (Set the Mapping type of the texture to Cubic, and set Scale to 3m.) The black-and-white mask image (hull-chipped-mask.png) is plugged into the Switch cache. The image is back to front, so I inverted it using an Invert node (Math > Scalar > Invert) so the background is black and the chips are white. There’s a texture for the metal surface (hullmetal-chipped.png): this is used for the Foreground input of the Mixer node, as the background colour is that of the paint. I also generated a normal map, based on the image, and plugged it into the Normal input to add a relief effect.
For the slight modulation of the reflection amount and reflection blur, I used a tiling scratches image (metal-grungy.png), remapped it so it’s not as strong, and then plugged it into the second cache node. This way it slightly varies the surface reflectivity and the reflection blur amount.
06 Generate paint chips procedurally
To create the procedural chips on the edges of the material, I used the Edge shader, which is part of DP Kit (DP Kit > Shaders > Edge). If you plug the shader into a Make Material node’s diffuse input (Materials > Make Material), it generates a black-and-white image based on edge detection.
You can plug a texture (procedural or image based) into the Edge Width input. I added a couple of the Standard LightWave procedurals, and then multiplied them by 0.4.
This essentially scales the maximum effect the edge width has to 0.4 metres. (One node editor unit equals one metre.) If you plug this output into the top left cache node, it will function just as the image map did, and control the mix between the metal-like material and the paint-like material.
To create the procedural chips on the edges of the material, you can use the edge shader that’s found in the LightWave plug-in DP Kit
The red paint material is exactly the same as the white material, with a red constant colour added to the background colour mixer (Constant > Colour). A note about the Edge shader: it’s limited in that it can’t be used on a surface if that surface is on more than one layer (although clones and instances don’t count). That is why there are several identically duplicated surfaces on the model. I just copied and pasted the surface back and forth if I made any changes. It also doesn’t give you any sort of preview feedback in either the node editor interface or in OpenGL (along with all node shaders), but it previews excellently in VPR.
07 Make the glass shader
The glass material for the coloured lights uses several of the same principles as the paint material, just without the paint chip texture. The lights are modelled with a chrome reflector interior and a lighting strip. The lighting strip is simple geometry with a 1,200 per cent bright luminous value applied. The glass is what does most of the work. The glass object is modelled with a smooth front face and ribs on the back, so that it refracts the light in interesting ways, like a car headlight.
I’ve used Schlick’s Approximation again for speed (and disabled reflection during the radiosity preprocess). The only difference between this and the opaque surface is that I’ve also plugged the Invert output into transparency. To make the refractions happen properly, I’ve used a Refractions shader node (Shaders > Transparency > Refractions), set its Refraction Index to 1.5 – which is analogous to crown glass – and plugged the colour used for the diffuse colour into the refraction colour to tint the material.
Another trick I used with this material was to help it cast coloured light in the scene. Unless you have Directional Rays enabled in the Radiosity preferences (Render Globals > Global Illum), the luminous surface behind the glass doesn’t contribute anything to the lighting of the scene as it can’t be ‘seen’ by radiosity rays.
However, the Directional Rays attribute in the Render Globals slows down the radiosity calculation. To fix this, I made the glass material emit light by making it a luminous orange (or blue for the blue glass), but that is only visible to the radiosity rays. I plugged all the shaders used for the surface into a Make Material node (Materials > Make Material), which are all labelled as such. I then added a second Make Material node, and into this I plugged a Scale node (Math > Vector Scale) to the Diffuse input and plugged the colour into the Vector input.
Use a refractions shader node, set Refraction Index to 1.5, then plug in the colour used for the diffuse colour into the refraction colour
I then typed in a value (200 per cent) that doubled the strength of the colour to make a luminous orange material. Using the Multi Switch node (Materials > Multi Switch), I plugged the glass material into input 1, and the luminous surface into input 2. To switch between materials, I used a Spot node (Spot > Spot Info) and plugged the Radiosity Ray output of this into the Switch input. This means that if the material is being sampled by a radiosity ray, it only sees the bright orange luminous material.
08 Render settings
The unified sampling system in LightWave 11 is designed to simplify and improve material shading and AA. The samples taken equal (per pixel): Shading Samples x Shadow Samples x Minimum Samples. Then if you enable Adaptive Sampling (in the Camera properties) it takes a defined number of additional samples up to the Maximum Samples value. These are taken a single sample at a time (if your Minimum Samples was 4, and your Maximum Samples was 8, it would take four additional sub-passes) using a Threshold value, so the samples are only taken where needed: in the noisy areas of the render.
Before LightWave 11, each shader, material and light could have individual settings, so it could become complex to manage and optimise large scenes. The AA settings were also slightly complicated because it was based on the threshold, which could be confusing at best. Now each pixel is re-rendered with a single sample per pass, which can make the render appear a lot slower than it will be. This project, with high polygon counts and lots of blurry reflections, appears to render a lot slower than it does.
Unified sampling in LightWave 11 is designed to improve material shading and AA
Typically, good settings for situations where you have blurry reflections or refractions are low Shading samples (around 2) and Shadow Samples, and high Minimum Samples. I’ve set my Minimum and Maximum to 8 and 32 respectively, which cleans up most of the noise. In most scenarios you need to keep Minimum samples to a reasonable level, otherwise you’ll get shader or shadow noise that the adaptive sampling can’t cope with. The VPR with this scene can seem quite blotchy, because of the small size of the parts in the scene. However, VPR is only a preview renderer, so don’t be put off – this isn’t what the final render will look like. I’ve set the Radiosity sampling settings quite high to eliminate blotches, so it will be slow to render – but the results speak for themselves.
Andrew Comb, aka ‘tobian’ on forums, is a freelance digital artist and designer, specialising in hardsurface modelling, surfacing, lighting and rendering. Most days he can be found tinkering around with his Pluto Station
on Thursday, August 23rd, 2012 at 3:58 pm under Guides, Technique, Tutorials.
You can subscribe to comments.
You can leave a comment, or trackback from your own site.
Tags: LightWave, surfaces, Technique, tips, tutorial