B Info 3D Basics of Materials for artists

Currently viewing this thread:

xenoargh

Grandmaster Knight
OK, here's some basic documentation about the flags in the shaders, that should be useful for newbies, or artists who don't know anything about the rendering process (mtarini and a few others will find this basic, but the vast majority of artists don't know jack about how it works). Mtarini, feel free to edit it to correct terminology mistakes or errors; I am a self-taught programmer, so I mis-use terms fairly frequently.

Basic Terms
Some basic terminology, hopefully made comprehensible to non-programmers:

Texel:  The equivalent of a pixel, at render-time.

Z-order:  rendering systems have to decide in which order to render things, so that things that are far away are rendered before things that are up close.  This is done with a variety of methods.  If it goes wrong, things that should be "far away" are rendered too late, resulting in a visual problem for us poor humans, who are used to the way depth works in the real world.

Z-value:  how close a given a texel is to the camera.  This concept comes up a lot with normal maps, where the z-value may be displaced mathematically by the normalmap.  Note that with the bump map technique used in the Warband engine, the texel isn't being "physically" moved; it is just being treated as if it has been displaced a small amount.

Rendering queue:  during each rendering pass, objects are queued, or put into a list that is rendered in a given order, that is independent of Z-ordering within the queue.

Alpha blending, alpha additive, alpha multiplication:  These are different ways of interpreting an alpha channel in a RGBA texture.  Blending averages the two values, generally.  Additive adds the alpha level to the current RGB value (this is usually done to make things "glow").  Multiplication multiplies one value by another.

Fog:  fog is a special depth-sensitive operation that multiplies the scene's fog color RGB by the distance, using a scalar.  We have no idea exactly how far the scalar in Warband reaches, but my guess is that it's 1 game kilometer.

Material Settings: The Basics
So here are the values that we see in Materials, and the basics about what they do:

1.  Spec RGB:  this is a multiplier to the RGB values for a given texel of the highlight (the little shiny spots) applied after the texel's z-value is determined.  With typical shaders in Warband, this may mean either an alpha channel in the diffuse texture (iron_shader, for example) or a separate RGB image (specular_shader_noskin_bump_high, for example). 

I am not 100% sure, because I haven't bothered to test it yet, but I think that the RGB values aren't discarded- i.e., with shaders that use an RGB image, you can have a colored specular (which can be used to produce some very interesting effects).  This requires some testing on my part to determine.

These are extremely important values; setting them high results in a very shiny object, and setting the RGB values to different colors will displace the resulting specular color over the entire model (and, if RGB from the specular is preserved, is not recommended).

2.  Coeff:  This is the specular coefficient.  Setting this number to a low value results in big highlights;  Setting it to a small amount makes the the highlights shrink.  Depending on the feel you want for your model, this value can have different effects.  It can also vary a bit between shaders; iron_shader uses values as high as 50, whilst the Warband shaders tend to use 16.

3.  Rend Ord:  this sets the Rendering Queue position.  Less than zero is earlier, greater than zero is later.  Generally speaking, unless you know exactly why you should be changing this... don't :smile:

Common Materials Explanations / Guesses

After thinking about it awhile, I've decided that it's best to list the most commonly-used shaders, rough guesses how they work and their flag values; this will probably be more help to our artists here than anything else, and then a couple of stabs at explaining a few of the "mystery" uniforms.

Before I get to that, here's a basic explanation of the flags that have to be present for the shader to operate properly:

The flags for each shader refer to the uniforms that are passed to the shader, or specific pre-processing that occurs on the textures or geometry.

Uniforms are numbers that have a specific meaning to the shader, and in fact may mean different things to different shaders; as we're no longer able to write new shaders in Warband, nor do we have access to the source, we have to be careful about generalizing too much about what they do, exactly.

Material "Families"
I have broken this section up into "families" of common shaders, which all have slightly different operations.

Normalmap Shaders for Armors and Weapons

With the exception of the "nobump"/"nospecular" variety, these shaders require a normalmap/specularmap to function properly, and will generally cause Warband to crash otherwise.  The "high" tag means that this shader is the fanciest version of its family; if the shader fails due to lack of the DirectX version required or the HLSL shader failed to compile due to a driver error, it "falls back" to another, more-primitive shader.  So, generally speaking, there isn't any reason not to use "high", unless for performance reasons.

The most common example of this is specular_shader_noskin_bump_high, which is used for a large number of objects.

However, there's also specular_shader_skin_bump_high, which probably uses a cubemap reflection, in addition to the normalmap and specularmap; this is probably an expensive shader, vs. other ones, as that cubemap is an additional texture load.  Not used a lot.

Lastly, if you don't need specular shininess, i.e., the surface is dull all over, such as cloth armor without leather or metal, seriously consider using standart_shader_skin_bump_nospec_high, as that will improve performance, since it just needs a diffuse and bumpmap.


Normalmap Shaders for Buildings
Basically, there are two, and they're both special:

bumpmap_static is for exterior objects of a large size.  No specular component, render order is always -8 (i.e., renders before practically anything else).  Uses a special bumpmap; the height grayscale, instead of being normalized, is simply shifted to the green channel.

bumpmap_interior is pretty much the same, but is specially made for the interiors (special treatment of shadowmaps, amongst other things).

Other than these two, you can use bumpmap_interior_new, which accepts shadows, but can only be used on props, and standart_shader_bump_nospec_high_noterraincolor, which is the exterior version.  These are newer shaders, and probably look better or handle shadows in a different way.  However (having played with all of this at one point) I should warn you that all of them have various issues with light and shadows, and that perfection is not going to happen.

None of these shaders use Coeff values or specular at all; they just require diffuse and normalmaps.

Special-Purpose Shaders
These are miscellaneous shaders that can be used to do various cool things:

flora_shader and tex_mul_color_alpha:  These are both shaders where the alpha component of the RGBA image is used to multiply the resulting alpha value of the texel. 

Using grayscale values between zero and one results in translucency; thus these shaders can be used to make "glass", albeit fairly crude.  There isn't, so far as I was able to find, a "real" glass shader, let alone one with a bumpmap; my guess is that the team hasn't written one because glass was relatively uncommon IRL in 1257 AD, but I wish they would include one, as it has all sorts of uses.

Flora shader is special; the "unused?" value refers to a special reflection operation involving the skybox.  This appears to be true of the water_shader_high, water_shader_for_objects and a few other things as well.  With the flora shader, this is to give the lighting a more lifelike hue without resorting to specular, and it's very faint.

These shaders can be used for glassy effects of various kinds; keep in mind that, generally speaking, they need to be either early in the rendering order or late, due to the way that they need to handle depth-testing.

Lastly, we have the particle shaders, such as soft_particle_add and soft_particle_modulate.  These are special, in that they're designed for objects that use a special projection technique, so that they're always perpendicular to our POV.  The "modulate" version of this shader uses an alpha channel to determine transparency; add uses the diffuse RGB.  "Nofog" means that they aren't affected by the fog value when rendering.

These probably can be used for "glow" effects on multimesh items, if the "no Z-write" flag is removed, but I haven't tested it.
 

xenoargh

Grandmaster Knight
Oh, and please let me know about mistakes or additions you'd like to see.  Nicely, please- I pretty much wrote this all in one go, so goofs may have happened  :lol:
 

xenoargh

Grandmaster Knight
Also, don't forget nospecular_shader_skin_bump_high_aniso, aka "the horse shader", which uses a cubemap reflection of the skybox instead of a specular.  I don't see any way to control the effect's strength, though.
 

Hinkel84

Master Knight
I have a problem:

When I make a Bumpmap for buildings, the building is black when I use the bumpmap in the Brf Editor.
I made the bumpmap with photoshop, with the normalmap filter.. any help?
 
Top Bottom