virtuaout material shader

Concept

This custom shader allows you to apply VirtuaLight shading information to your trueSpace objects in a way that feels like you are applying regular tS materials - because you are! The settings you apply will be saved with the model, and you can make material libraries of VL shaders. The major difference is that your scene will not look correct in tS (either in realtime or rendered), only when rendered with VirtuaLight.

The use of this shader is entirely optional - you can continue to use your regular materials and vo will convert them when it exports, but this shader is intended to give you a lot more control. This documentation will not show the format for the VL shading language, you must read the VL reference manual first.

settings


preferences panel

Quite an imposing preferences panel, but we have a lot to fit in!

Before we look at the settings themselves, we should look at the two special controls at the bottom of the panel:
render sample automatically - When checked, every time you make a change to the shader settings, VL will be called to render a material sample, which will in turn display in the regular tS material preview panel. For this to work correctly, you must follow a few rules:
-Make sure VL is installed properly
-Setup the path to VL correctly in the main virtuaout plugin panel
-Set the tS material panel to show a plane for the sample shape, not sphere or patch.

resolution - controls the size of the VL material sample that is rendered - a smaller size will render faster but will appear blocky in the tS material preview panel.

When the material preview is rendered it will appear like this in the trueSpace material panel:

parameter format

Although there appears to be a lot of settings, the main shader panel can be broken down into only a few areas: surface type, reflectance values, bump/displacement mapping, and radiosity settings.

surface type

VL allows for 3 different types of surface. A plain surface will render the fastest, but it can only have basic settings - simple color, ambience, diffuse, etc. Functional surfaces take longer to evaluate but can contain many different calculations such as Fresnel falloff effects for reflections, procedural textures, and so on. Pattern surfaces fall in between, but are not yet really supported in this shader. If you experience problems rendering a sample, try setting the surface type to functional - if it is left on plain and you try to use more complex parameters, they will not be used.

reflectance values

These are the values for ambience, diffusion, specular highlights, reflections, and refractions. Most of these work in the same way as you are used to in trueSpace, but a little explanation of the format of the settings is in order:

parameter format

As you can see, you can use the number spinner (or colorbutton) to set a regular value, or you can enter some custom text to perform a calculation. The checkbox determines whether or not vo will use the number spinner or the custom text for the shader. Remember this - it's either the spinner/colorbutton value, or it's the text box, one or the other.

ambience

As you would expect, this controls how emissive the material is. This is the Ka value.
You can choose to specify a color for this emissiveness by checking the specify color box or leaving it unchecked to use the base color, and then decide whether to use the colorbutton or have a custom color text.

diffuse color

This is where you set the base color of the material, either a plain color with the color button, or something else by using the custom color text. For example, if you wished to use a texture map, you would enter something like:

PlanarImageMapping(ImageFile("c:\images\grass.jpg", BILINEAR), (u, 0, v), 1)


You set the diffuse amount with the Kd parameter. Related to this value is the Kb (brilliance) setting, which you can experiment with for metals and glasses.

specular highlights

The name of this section should be pretty self-explanatory; these value controls the highlights on your material for simulating rough/smooth/shiny/dull surfaces. Ks is the strength of the specularity, the BRDF value is akin to the roughness slider in trueSpace - lower values give you tighter highlights and thus a smoother, harder surface. The difference is that VL allows you to choose from different BRDF models, which you can access from the type dropdown. Phong will give you that classic look, Cook can give you some nice glossy highlights for glass-type surfaces. Experiment to see what you like the best.

You also have a chance here to specify the color for your highlights, if needed.

reflections

The Kr value is akin to mirror in trueSpace - it's how reflective the surface is.
Changing the metal value affects how much the base color affects the reflections, for simulating metallic surfaces.
You can specify a color for the reflections, this can help give you certain results - try it off and on to see.
VL supports blurred reflections with the blur parameter. Set it closer to 1 to get blurred reflections - the number of samples used is controlled by the blur samples and blur level settings in the main vo interface, on the gi panel.

refraction

The Kt value controls the amount of transmission in the surface, and the ior value is the index of refraction, as usual.
You can choose whether or not specify a color for refraction, this can be very useful if you are trying to do colored glass and things don't look quite right.
New for 1.3, the dispersion value will calculate chromatic dispersion for refraction - the little rainbow effect you get on refractions in glass, for example. A dispersion value of 1.0 will switch off this effect - small increases are common, water is 1.007 and diamond is 1.035. The samples setting controls how smooth the dispersion will be - higher is better, but at a rendering time cost.
For simulation of translucent materials, you can use the absorption value - a value greater than 0 switches this feature on.

bump mapping and displacement

You can apply bump mapping to any object in VL, and you can use an image file or do it procedurally. For an image map, you would do something like:

PlanarBumpMapping(ImageFile("c:\images\grassbump.jpg", BILINEAR), (u, 0, v), 2.0)


That last 2.0 refers to the bumpmap amplitude, you can jack it up nicely, or make it negative to invert the bumpmapping effect.

The displacement mapping option doesn't just give the effect of a bumpy surface, it actually modifies the geometry. Again, you can use an image file or a procedural effect. For example, entering fnoise(P) will give you a simple displacement. If you want to use a file, you could do:

PixelHeight(ImageFile("c:\images\grassbump.jpg", BILINEAR), (u, 0, v), 0) * 0.005


Note that you can only use displacement mapping with NURBS objects. The vo output panel parameters u subdivs and v subdivs should be increased in order for the displacement to be effective, to at least 32.

irridescence

This is quite a nice effect; it can simulate the look of irridescence - the sheen of color found on the surface of a bubble, for example. The VL documentation has full information on the use of irridescence.

caustics

You now have the power of controlling caustics on a per material basis. For a vomat material to use caustics, you must check the box and enter a value greater than 0 for the density. Density works as a percentage and refers to the surface area of the object that should be used for calculation. The internal flag can be used for more accurate (and slower) representation of glass surfaces.

irradiance

This setting allows you to specify the number of irradiance samples this surface will use when doing gi renderings.

declarations

A lot of the power of VL shaders comes from the ability to define (e.g.) color gradients and functions for procedural textures. The problem is, if we allowed for all possible instances where you would write such things, this shader interface box would be more massive than it already is! To get around this, we make use of the fact that VL shaders can include parts of a shader from other files. You would define your color gradients and such in a file, and save it as a .vs file, say mygreatshaderstuff.vs. Then just click the declarations button and browse to this file. You can now reference anything from this file in your other shader parameters. For example:

In the declarations section, use the alien.vs file that is included with VL. It should be in the Examples directory of wherever you installed VirtuaLight.
This alien.vs file contains a procedural texture function called swirl, which can be used with a color gradient, also contained in the file.
In your color section, enter:

swirl_map[swirl]

in the custom color text box, and check the box to use the custom color. A procedural texture will now be used for the color.

Conclusion

This may seem like a complicated tool, and it is. However, it is the only way to easily apply real VL materials to your meshes.
Again I have to stress that you must read the VirtuaLight Reference PDF that comes with VL, in particular the sections near the end on the shading language used, before you can understand how this shader will benefit you.
If it still seems too complicated, don't be disheartened - the old method of converting trueSpace shaders will still be supported in the future, so you have no reason to stop doing what you're doing, but you do lose the control you get with this special shader.