Author Topic: Some observations on shading (with Override Material Values) and shadows:  (Read 431 times)

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               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:
'Image
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:.
'Image
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:
'Image'Image

Red, with and without "Over-ride Mat Values" ticked on the Trimesh modifier:
'Image'Image

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:
'Image'Image

Dark-ish green, with and without "Over-ride Mat Values" ticked:
'Image'Image

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:

'Image

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:

'Image

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.
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #1 on: January 03, 2013, 08:01:28 pm »


               <walking the line...>

So I'll be setting material overrides to 128 - grey for the next bit and we'll see how they look. At least on creatures (Homonculi), placeables (Its bottle) & vfx (Mounted Familiars).

<...between black and white>
               
               

               
            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #2 on: January 03, 2013, 08:12:36 pm »


               ARGH...that topic!!! You know everytime i did something in 3dsmax that looked realy good lighting wise i pulled out my hair when seing it in our lovely aurora editor. This thought how i can get my meshes doesnt look as flat or more 3d like costed me many many hours. I have buildings done especialy for my module, a whole building arrangement like the witcher 1 has (long before my not released city tileset) and abandoned it as i saw it ingame. I tried everything, I used only ambient lights, no lights with only placeable light sources to get the darker parts (small alleys) realy dark to no succes. Even dark lights...FT!!!

I for myself have givin up on that, i see red when i only think about to try it again to make my stuff more 3d like.... grmbl....

p.s. i also did use shadowmaps for whole tiles. Imagine a 2nd walkmesh typelike mesh over the whole geometry with a shadowmap.. you know how long that takes to move every vertice just a tiny before the real geometry....':sick:'
and it also moves when you rotate the tile... stupid just stupid!
               
               

               


                     Modifié par NWN_baba yaga, 03 janvier 2013 - 08:22 .
                     
                  


            

Legacy_T0r0

  • Sr. Member
  • ****
  • Posts: 380
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #3 on: January 03, 2013, 09:23:38 pm »


               I'll not pretend to understand all this but I do play with the override mat setting in my projects (even tho it's simple geometry) to give variety to the same texture. So what does the shiniess do?
               
               

               
            

Legacy_Zwerkules

  • Hero Member
  • *****
  • Posts: 1997
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #4 on: January 03, 2013, 09:51:57 pm »


               

T0r0 wrote...

I'll not pretend to understand all this but I do play with the override mat setting in my projects (even tho it's simple geometry) to give variety to the same texture. So what does the shiniess do?


I'd like to know that, too. I tried changing the shininess, but couldn't see any difference. At least the textures didn't look more shiny than before.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #5 on: January 03, 2013, 11:30:52 pm »


               BTW, I wanted to include one other grim little tidbit I forgot to include in the original post::  When area builders click on the ambient color of the sun, for instance, in the toolset, here's the color selection that comes up:

'Image

Now that's not quite the default colors that come up but it's not very far off.  Point is, from what I recall in my tests, about 1/3 are "okay" (shading-wise), 1/3 lessen the shading somewhat and 1/3 just soak the models in kool-aid of whatever color. 

How likely is it that a large percentage of builders (like me) ignorantly selected ambient lighting colors over the years which actually made their areas look worse?

Here's an animated .gif showing what happens when an "Exterior Clear" lighting's sun ambient preset is changed from RGB 255 to 0, pure white to pure black, in 15 point decriments:

'Image

If you're not seeing it or you want a bigger version, you can download the animated gif here:
'Image

It does a good job showing how the bright ambient blows away shading.  Note the pillar and the circular stone apron around the pillar are affected at different times.  I haven't looked at this particular model but this is almost certainly due to the material value settings differing.

@Rolo -
You may find for creatures/placeables that you get a better deal going with material overrides and letting the textures give the illusion of shading.  It's the big stuff (like big placeables, structures, etc.) where this "flatness" has the most deleterious effect.

@Baba - I can't tell, are you saying that this specific issue bit you that hard, or lighting in general?  BTW, I love that you tried dark (I presume you mean 'negative') lights.

@T0r0 - Shininess?  That should affect how much envmap shows through a texture.  Higher shiny = more envamp.  What makes armor "shiny" is the amount of envmap which shows through.  Maybe take a quick look here. (see my next response in the thread)
               
               

               


                     Modifié par OldTimeRadio, 04 janvier 2013 - 07:46 .
                     
                  


            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #6 on: January 04, 2013, 12:15:54 am »


               (I think I fixed the animation in the message above.  See download button if you're still having troubles)
               
               

               


                     Modifié par OldTimeRadio, 04 janvier 2013 - 12:41 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #7 on: January 04, 2013, 02:54:20 am »


               very useful. it appears i need to adjust bright ambients down a little.

What about diffuse colors? From a quick look over bright diffuse colors don't seem to result in a wash out of shading. What is your take?
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #8 on: January 04, 2013, 07:46:10 am »


               @T0r0 - I'm retracting that answer about shininess.  I was heading out the door and shouldn't have shot from the hip.  I'll let someone else comment or maybe come back and give a better answer, later.

@henesua - I'm glad it helped.  Diffuse doesn't appear to (specifically) affect shading.  If you do an Omnibus search for "ambient color" AND "diffuse color" the first two glossary definitions (from the GMax help) are helpful to get an idea why the settings work the way they do in NWN.  I don't have a link but once Derek French (IIRC) gave the definition of ambient light which was almost word for word the GMax definition. FWIW.
               
               

               


                     Modifié par OldTimeRadio, 04 janvier 2013 - 07:50 .
                     
                  


            

Legacy_NWN_baba yaga

  • Hero Member
  • *****
  • Posts: 1944
  • Karma: +0/-0
Some observations on shading (with Override Material Values) and shadows:
« Reply #9 on: January 04, 2013, 05:20:46 pm »


               @OTR:
Lighting in general for many meshes that requires some real kind of depth. Especially for outdoor areas and things like cliffs...terrible flat looking at times and the better or detailed your textures it gets even worse. But here are shadows the problem. Well... i dont like the outdoor lighting at all but I made my peace with it:)

And negative ligths are what i used or tried to use to get it a bit more realistic looking. An alley that is only lit by almost no sunlight and covered in shadows cant look like the street itself. Thats what bothered me the most.