I had some questions about shading and shadows in NWN and while investigating them I came across two ugly issues. Just passing these general observations along.
Override Material Values screws up shading:In a nutshell,
here is a placeable which was meant to be set static and placed so as to look like it was covering parts of a specific tile. Note the shading on the left and bottom of the covering in the upper-left quadrant in the screenshot.
Now here it is, in-game:
Looks totally flat. Where did the shading go? It was blown away by the Override material setting on the Aurora TriMesh modifier. Here it is without the override set:.
Nice! Problem solved, right? Apparently not.
There's a Catch 22 here: If you
don't set the material override, your texture is going to look too dark- because almost every other model in the game has their material override set. If you
do set the material override (say, using the default which is white), you're actually losing quite a bit of range in the shading that happens on models in-game. The only way around it is to use a dark color for the ambient sun/moon color. This appears to be why almost all the lighting presets in the game have a dark color for ambient sun/moon: If they didn't, the shading would completely be blown away and everything would look flat.
Here are some other pair combos to show what I'm talking about. The key here is not the color, but the luminescence. These use the "Exterior Clear" preset with the only change being the sun ambient light color.
Bright yellow, with and without "Over-ride Mat Values" ticked on the Trimesh modifier:
Red, with and without "Over-ride Mat Values" ticked on the Trimesh modifier:
Flat. Hardly any/no shading at all for the ones with their material values overridden. In contrast, here are some using darker ambient sun (in this case) colors:
Dark blue, with and without "Over-ride Mat Values" ticked:
Dark-ish green, with and without "Over-ride Mat Values" ticked:
As you can see, it doesn't fix the problem, just sort of attempts to hide it. Apparently, the value of the sun object's ambient light in the area is being added to the material's ambient light value (specifically) and that when those values are higher than a certain threshhold, the beautiful Per-Pixel shading in NWN is reduced or evaporates entirely. I did similar tests on other objects, including flat planes. NWN will actually do smooth shading on a relatively simple flat surface from, say, a player's torch. But if the material override is set (as it often is), it hardly shades at all. The default override value in the Aurora Trimesh modifer is the worst possible value: White 255.
Shadows are not just worse than you thought, they're insidious:Let me quickly go over how the volumetric shadows in NWN actually work. For
every triangle in your shadowed mesh, at least
six more triangles are created in the form of quads which extend from the each edge of your triangle (away from the light source) down to the "shadow plane", where the shadow stops. That's with
one light source, like the sun in an outdoor area.
You can google around and find people who've written papers on volumetric lighting which specifically mention and analyze how NWN does its shadows, but if you can understand what's going on in the diagram below, this is really all you need to know:
If you can appreciate how the shadows act as a geometry multiplier for one light (as above, each shadow triangle causing the creation of at least six triangles), now realize that the client can set up to
three shadow casting lights in their settings. And that those lights can move. And that all these calculations are expected to take place in real-time. But even then, it's worse than "just" trebling a single shadow volume's geometry. Take a look at this, still using just one light:
The warping of the shadows should give you a good idea how much more processing is going on as these shadow volumes intersect with other volumes, like placesables or NPC's in this case. Now, to be fair, some of this stuff does take place on the GPU but the nature of this shadowing method is so intense it still chews through your video card's "fill rate", sucking horsepower/FPS from your GPU.
To get an idea what I mean by chewing through fill rate,
here's a shot of me standing with some NPC's. Unfortunately I didn't get the shot of them with shadows on, but you can imagine them. (LOL!)
Here is the mess of overlapping individual shadow volumes (as they hit the shadow plane) from the same exact shot,
before they're all turned into nice solid shadow areas. All those polygons, which you never really see, tax your video card enormously. You can see this FPS hit with the console command FPS or, a bit more accurately, using something like Riva Tuner. The extra geometry created can be viewed (comparing geometry count with shadows turned off and at various stages) using something like
gDebugger.
Amazingly, all thiis is a sort of high-level overview: Things get crazier with self-shadowing and with the fact that the lighting presets have
different shadow settings. For instance, tests with an indoor lighting preset will generally seem to work better than an outdoor one- because some of the client's shadow settings are actually overridden by environment.2da! You can see the differences by examining LIGHT_SHADOWS and DARK_SHADOWS, therein.
Just by ticking that leetle Shadow box on the Aurora Trimesh modifier. If your model isn't truly as low poly as an equivalent Bioware model, it would seem turning on shadows is opening a huge can of worms. Depending on the lighting preset, number of dynamic lights, creature shadow detail (at the highest level, turning on shadows for placeables!) and on and on.