Vertex Painting in Lightwave

From The DarkMod Wiki
Jump to: navigation, search

Here we'll discuss from start to finish, a Vertex Color Material for a model converted from Dark Radiant brushwork. Software you'll be using are Dark Radiant and Lightwave Modeler. How you procure a copy of Lightwave is entirely up to you; I happen to be using Lightwave Modeler 11.5 for this tutorial. It's worth noting that Lightwave saves it's model data into the proprietary binary file type LWO. LWO is one of two primary formats supported to run in the Doom3 engine (the other being ASE). This painting method can be done in either format but LWO is by far a superior type as it usually only amounts to mere kbs of data for multiple files.

You may ask, what does Vertex Painting do? In short, it allows you to paint two materials onto the same mesh using Black and White colors stored in the vertex data (denoting one or the other material). This is extremely useful for many different scenarios but can only be done with models.

This tutorial already assumes you know how to create levels and manage brushwork in Dark Radiant. After covering this tutorial you should cleanly be able to add in material blending to your levels, with no prior modeling experience. See the bottom of this page for basic hotkeys to use for Modeler.


Step 1: Prep and Export Brushwork

Here I already have a prepped small space done up in DR. It's important that you texture and scale the surface properties to your liking. When we export this data in the OBJ script, this will be used as your UV data in Lightwave. When ready to export in DR go Scripts>ExportOBJ and be sure to center objects.

Vertex Paint Tut 001.jpg

Step 2: Importing and Painting in Lightwave

Now it's time to head to Lightwave and open your OBJ file you've exported. First thing you'll want to do is press F5 to bring up the Surface Editor panel. Two things you'll want to do is check smoothing on and find a good value (I use 60 degrees) and then press rename in the top right corner to specify the material name you want to embed in the saved LWO. Here I use vertex_blend_test for my example material name and it must be devoid of typos to match the name we'll declare in the MTR later.

Vertex Paint Tut 002.png

Next we're going to paint black and white vertex colors to define material blending. To find the painting window you'll have to go to the Map tab and find Vertex Paint under Color.

Vertex Paint Tut 005.png >> Once the paint window loads, hit Edit and Create Vertex Color Map from this drop down >> Vertex Paint Tut 006.png

Here's an example of how your mesh should look when painted. Be sure you use solid white and black to paint with. The exception being grays where you want longer blend transitions. Once complete save and exit the paint window.

Vertex Paint Tut 007.png

Step 3: Final Model and Material

Finally we just need to triangulate the polygons (since TDM can't render straight quads) and then save your new mesh to your desired output folder. To Triangulate the mesh simply go to the Multiply Tab and press Triple. You can now save the file to it's output directory. Note: LWO is Lightwave's native format and will save a working model for TDM by default.

Vertex Paint Tut 004.png

A short rundown here on the material composition. This is a material I put together from stock assets so you can plug this right in (or modify it) to your heart's content! The first two blocks containing (This is white coverage) literally will only be visible in white painted sections of your mesh. As the like, same goes for the next two blocks for black coverage. You can also use the VertexColor/InverseVertexColor commands across additional blocks to create more complex material functions depending on what your project requires.

vertex_blend_test
{
	surftype15
    	description "grass"

        {
	blend bumpmap 
	map   textures/darkmod/nature/foliage/leaves_small_local
	VertexColor
	//This is white coverage
   	}
	{
        blend diffusemap                                                    
	map   textures/darkmod/nature/foliage/leaves_small
        VertexColor                
	//This is white coverage
        }
	{
	blend bumpmap 
	map	textures/darkmod/nature/dirt/dry_earth_stones_local
	inverseVertexColor
	//This is black paint in coverage
   	}
	{
        blend diffusemap                                                    
	map	textures/darkmod/nature/dirt/dry_earth_stones
	inverseVertexColor    
	//This is black paint in coverage	
        }
}

Save that into an MTR and make sure that name matches with the one you chose in the Surface Editor. If all goes well you should be able to pull of some more natural looking blends like this.

Vertex Paint Tut 008.jpg


Ending Tips

Merge unwanted hard edges. If you're stringing together multiple patches and don't want a hard seam to be present go to the Construct tab in Lightwave and find Weld Edges. If your edges in question all occupy the same 3D space, it will merge them and combine the polygons as one contiguous surface.


Use the Caulk texture wisely if you're exporting regular brush primitives from Dark Radiant (eg. not patches) as you can cull out unneeded faces to further clean up your model beforehand. Your mesh in this workflow is only as good as your prep for it in DR. Only assigning textures to the surface you wish to have showing is your best bet.


Use textures that blend well together. Some textures just don't look too good side by side, so finding the right combination is key. Also creating a secondary distress/grunge texture from the original image has fantastic benefits of the two materials sharing similar details. This aids the blending and doesn't present as hard of a visual gradient where the blend occurs.


Use noshadows in your MTR definition when appropriate. Any time you know the model in question will never need to cast shadows, add this option. Since most scenarios require us to pad and, "insulate" or models with brushes, those solids will block lights for us. Anything you can do to chip away at the tris considered for shadow casters will help performance.


Lastly I'd suggest to anybody doing floors or terrain, to save and reuse their original brushwork/patches textured with tdm_nodrawsolid_grass (or a collision type appropriate). This ensures that AI will traverse it correctly and footstep collision sounds wont be faulty.


Hotkeys for Lightwave Modeler.

-S (save current model to file)

-Alt+LeftClick (rotate Camera)

-Alt+Ctrl+LeftClick (zoom Camera)

-Alt+Shift+LeftClick (pan Camera)



-Epifire 8/15/2017