User:Patchouli Woollahra/Lightwave Sculptie Rendering
From Second Life Wiki
Any version of Lightwave with:
- gradient maps as a map type
- native UV mapping support
- Surface Baking implemented
is immediately usable to pull this off.
If possible, I would recommend using Lightwave 9.0 or newer - a plugin is available from D-Storm called the Sculpt Shader For SL that can significantly boost your speed while baking sculpties in Second Life, especially in combination with the "Surface Baking Camera" implemented in Lightwave 9.2+, which is multithreaded and hence much faster than the original Surface Baker on Multi-threaded/multi-cored PCs/Macs.
For more information on how to use the Surface Baking Camera, please read the Lightwave 9.0 manual and 9.2 Addenum provided with your boxed or download copy of Lightwave 9.0
This tutorial will briefly mention how to setup a bake Sculpt Shader For SL with Lightwave 9.2 to further emphasise the advantage of an upgrade if you are a serious or regular Lightwave user.
First, create a UVmap and give it a name. It's not really important exactly what name you give it, but I call mine SculptUVs for expediency. Keep this UVmap selected while prepping the sculptie prim.
Rez out a cylinder on the Z-axis, keeping its radius at 50cm on all sides, top at 5cm, bottom at 50cm, check "Make UVs" while doing this. Surface with a name such as SculptieMap or Sculpties to keep track of this) Surface Baker unfortunately barfs on polygons with less than 3 or more than four polys. The endpolys of this cylinder will choke SB, so they need to be dealt within in one of three ways:
- Simply select the polygons and triple. This is relatively similar to how SL deals with the ends of the Sculptie cylinder, but is awfully ugly, and will cause problems if you intend to keep the object metanurbed.
- select the end polys and kill them. Out of sight out of mind - but if you're texture or occlusion baking you might have problems with the missing geometry as well.
- kill the end polys, then seize the top and bottom-most series of points and drag them inwards around the Y-axis.
This will produce a sculptie primitive that you can bake sculpty maps out of. But we're not done yet.
In another layer, Create a default cube (or via these specifications)
This cube will be 1m x 1m x 1m, and it will be used as a bounding box to check prior to rendering a sculptie map that we do not have any geometry outside the 1m range on any axis. (such geometry will 'white-out' on at least one channel in the resulting sculptmap. This may be what you want but for most purposes it is not.)
Save the resulting object as a LWO file to be safe, and then create a copy to work on whenever you need a sculptie. I would suggest creating an endomorph or morph map ( depending on your version of Lightwave) and working with this instead using non-destructive modelling tools such as move, rotation and translation tools in Modeler.
(This is the example I'm knocking out, saved in the LWO as a endomorph. Now in general, using a single prim to build an object means you will have very simple, or very lame objects. But I'm demoing only, so this wellie thingy will do.
When you're ready to generate sculptmaps, save the LWO again, and bring it into Modeler.
Layout Steps (for versions of Lightwave 6.0 - 8.0)
Rez out a null in the exact centre of a fresh scene file. I usually call mine "SculptieRef" but you can call it anything you like as long as you can remember it. Load up the cylinder/plane/whatever you built up in the end. position it in such a way that none of the points on the sculptie object cross any of the XY, YZ or XZ planes in world.
- This step is important as Lightwave unfortunately does not have a way of surfacing a object based on distance AND direction from any object right out of the box.
Go into the Surface Editor and create the following three layers in the surface for the object:
- Set the surface of the sculptie to 100% luminosity, 0% diffuse, 0% specularity. Use pure black (0,0,0 RGB) for the surface as a base.
- Gradient, X Distance To Object, specify the 'sculptieref' null as the reference point, and set the gradient up with pure black at 0m and R:255 red at the other end of the gradient (your preference for what size you want to work on the sculptie at will determine this comfy region. Set this layer to blend in 'Add' mode.
- Gradient, Z-Distance To Object, same null as reference point, gradient with pure black at 0m and pure green (0,255,0) at the other end of the gradient, across the same distance as the first gradient. Set this layer to blend in 'Add' mode. (It is extremely important that you note Lightwave and Second Life disagree on which axis is Y and which axis is Z, so assigning the color ramps improperly could mean a tonne of flipping inworld :( )
- Gradient, Y-Distance To Object, same null again as reference point, gradient as with the last two except using Pure blue (0,0,255) on the far end of the gradient, additive blend as well.
- Add a 'Surface Baker' shader to the sculptie surface as well. Configure it to bake out only the color of the texture, and only to a 64pixel-wide square, in order to save time when rendering the sculpture map.
What the four layer surface I specified above attempts to create an approximate RGB blend in the manner that sculptmaps use to describe their nature. The baker is added in as a final step to capture the resulting fake sculpture map that will be generated by the multilayer surface.
Save the scene for safety's sake, then go hogwild with your Modeler tools.
Exporting the map from LW
Ensure that you're rendering on only one thread (Surface Baker hates multithreaded renders unfortunately) and rendering as small a frame as possible (The render is irrelevant when generating sculptie maps). As part of the render process, the system will save out the baked map to the location and filename as specified in Surface Baker. Take the resulting output from Surface Baker and upload it into Second Life as per a normal image file, apply as a sculpture map to a sculptie.
- Serve with scripts/bling/physics as required by your build.
Layout Steps (in LW 9.0+, with Sculpt Shader For SL)
With LW 9.0+ and Sculpt Shader For SL, you can ignore the drudgery imposed by the steps required in previous versions of Lightwave to some extent. In fact, you can leave each sculptie in its original position in your modeled object instead of breaking up the object and baking each sculptie one by one.
However, to facilitate baking if you are using Surface Baking Camera (in LW 9.2 onwards), you will need to cut and paste each sculptie into its own layer in your object file, taking care to use a sensible naming scheme to help you find each prim later.
If you still insist on using Surface Baker, each sculptie will have to be surfaced with a different surface instead. C&P to separate layers is not required in this case.
(Both approaches listed here also serves as a sanity check. If you think you're experiencing a very poor legwork-to-payoff ratio with either of these approaches, chances are you may be using too many sculpties! Consider examining your sculpt for similar shapes to reduce the amount of sculpt baking that needs to be done.)
Sculpt Shader For SL uses a wierd setup method. This has to be explicitly followed or the shader will fail to generate proper sculptmapping.
Under the "Utilities" tab in Layout...
Look for the the "Additional" dropdown under the "plugins" section of the menu.
Scroll down till you see two options: "Turn Sculpt Shader ON" and "Turn Sculpt Shader OFF". These do exactly what they say.
selecting "Turn Sculpt Shader ON" will produce a single-option dialog asking you what object or object layer you wish to bake to. in this case, select the object/layer containing the sculptie you wish to bake out, and hit "OK" to add the "Sculpt Shader" to the object properly. Rinse and repeat for ach sculptie you wish to bake out.
Optional Step: When you no longer need them, run "Turn Sculpt Shader OFF" on each sculptie you no longer require, if you plan to bake normal textures out on the same model at a later stage (to avoid the Sculpt Shader overwriting the texture bake by accident).
Exporting the map from LW
Use either Surface Baker or the Surface Baking Camera to bake each sculptie out to a 64x64pixel texture in a format such as TGA_24 or PNG_24 (you do not need an alpha channel in the render, so avoid using a RGBA format in order to save file sizes). Avoid using JPEG as this will impose additional compression artifacts to the sculptmap (on top of what normally exists in Second Life)
Upload as normal, taking care to use the "Sculpted Prim Preview" option prior to confirming the upload.
Serve with parametric prims/bling/scripts/physics.
An archive containing the LW9 scene, object and surface data for sculptie baking in LW is included here. It may or may not work with earlier versions of Second Life - Please don't ask me to figure out how to revert to an earlier version.
LW9 Sculptie Bake Hack Using DStorm Sculpt Map Baker (If you're using a 6.0-8.0 version of Lightwave, the sculptbase geometry contains UVmapping for you to surface bake the normal map gradients to, but you will need to roll your own using the instructions I provided above in another scene file. This need only be done once and can be reused with minimal changes as long as you remember the limitations noted above.
Worst case scenario (i.e. your version of LIghtwave cannot read the files at all), build it up from scratch, and render regularly as you build up the gradients. - it helps you to understand better why the gradients are set up in the way I'm noting.