Author Topic: Shadow Game  (Read 492 times)

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Shadow Game
« on: December 31, 2013, 10:51:59 pm »


               Guys, I've been playing around with custom content for a while, but one thing I can't figure out is shadows. There's plenty of great models for PC parts, creatures and placeables out there, which have shadow bugs, like articfacts and such.

Seeing as content creators re-pack them, re-skin them, or alter them in lots of creative ways, yet the shadows keep being broken, I was wondering if it is too difficult to fix them.

I use 3DS Max in a very small capacity. I rotate, reskin, resize and mix models here and there, but don't know anything beyond such simple tasks.

I was wondering if anyone can point me to some tutorial or tool for dealing with these shadow problems, so I can try and fix them. I have used some "shadow fixing, converting tools" to no avail, so I suspect a more direct approach is needed.

Also, has anyone noted custom trolls "hover" above the ground? Every modern troll model I have seen floats above the ground. I tried to fix it, but ended up ruining the creature... <><>

               
            

Legacy_Valthrendir

  • Jr. Member
  • **
  • Posts: 80
  • Karma: +0/-0
Shadow Game
« Reply #1 on: January 01, 2014, 01:44:50 am »


               It is the auroratrimesh modifier (a ticked box in properties) that makes geometry cast their shadow in the game.

An easy, at least for placeables, way to prevent shadow artifacts is to create a seperate, really simple geometry to use for shadow-casting. Artifacts result from geometry that is either really complex or contains some bugs resulting from modeling.

For creatures, fixing the shadows could be slightly more problematic. You could apply the same technique with seperate, non rendering shadow meshes. You then would have to make the shadow-caster follow the same animation through linking or attaching it correctly (requires some in depth understanding).

As for ''hovering'' of the trolls, that is most likely due to the Z-axis of the model in relation to its base. To my knowledge, most creatures contain body parts that are linked to a ''main'' body part (usually the torso in human context). If you were to unlink this ''main'' part from the base and adjust its Z-axis, that would be sufficient to solve the hovering shenanigans.
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Shadow Game
« Reply #2 on: January 01, 2014, 06:32:43 am »


               Thanks for the help! It seems I need to learn a lot more before I can fix the shadow thingie, though!
               
               

               
            

Legacy_Zwerkules

  • Hero Member
  • *****
  • Posts: 1997
  • Karma: +0/-0
Shadow Game
« Reply #3 on: January 01, 2014, 09:24:06 am »


               There's only one fix for shadow problems: turn shadows off! '<img'>
Even simple meshes that SHOULD cast proper shadows sometimes cause problems and running the model through Clean Models didn't fix the problem because CM didn't find anything wrong with it. That's probably because there is nothing wrong with it. Even if you follow the guidelines you can get shadow problems.
Look at all the Bioware tiles like the graveyard in the forest tileset that still have shadow problems.
Nobody ever fixed them. The best thing to do is probably to turn off the shadows of those trees.
If you want to fix all those shadow bugs, especially on creatures, you'll need a lot of time and patience.
Run the model through Clean Models first though. It won't fix every problem, but many of them.
Just don't let it fix the walkmeshes, because if you do that, you'll have to let it do that for every tile in the tileset if it changes the tile edges of the walkmesh.
               
               

               
            

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
Shadow Game
« Reply #4 on: January 01, 2014, 12:01:06 pm »


               

Valthrendir wrote...

As for ''hovering'' of the trolls, that is most likely due to the Z-axis of the model in relation to its base. To my knowledge, most creatures contain body parts that are linked to a ''main'' body part (usually the torso in human context). If you were to unlink this ''main'' part from the base and adjust its Z-axis, that would be sufficient to solve the hovering shenanigans.


The hovering may also be caused by an incorrect scale setting - the SetAnimationScale parameter - in the model's acsii file. If the model uses a supermodel - listed under the SetSupermodel parameter (the second entry), this scale factor determines how the animations are scaled for the model. 

Creatures are always linked to a rootdummy. For Type F creatures (e.g. PC races, orcs, etc.), Torso_g controls the upper part of the body and Pelvis_g controls the lower party of the body. Other monsters have different node names but will still have a "rootdummy" of some sort. Both branch from the rootdummy. Therefore, if you need to adjust the Z-height of the model, move the rootdummy. This is what the hierarchy of a Type F model looks like:

Rootdummy (main dummy)
     handconjure (dummy for casting vfx)
     headconjure (dummy for casting vfx)
     Torso_g
          Neck_g
               Head_g
                    head (dummy for vfx)
          LBicep_g
               LForearm_g
                    LHand_g
                         lhand (dummy for weapons)
                    lforearm (dummy for shield)
          RBicep_g
               RForearm_g
                    RHand_g
                         rhand (dummy for weapons)
           impact (dummy for attack impacts)
           wings (dummy node for attaching wings)
     Pelvis_g
          LThigh_g
               LShin_g
                    LFoot_g
          RThigh_g
               RShin_g
                    RFoot_g
          tail (dummy node for attaching tails)

Note: This is the main hierarchy tree. I did NOT include the cloak nodes, but I'm sure you can figure those out.
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Shadow Game
« Reply #5 on: January 02, 2014, 06:20:25 am »


               Zwerk: Well, yes... I 'm sure turning shadows off would put and end to this, but that's hardly a solution! I think the game is greatly diminished in its ambiance and impact by de-activating shadows. Even setting simple shadows for creatures makes it less... appealing. I do concur there are many shadow issues, and it would take a long time to fix them all, though.

Pste Marie: Thanks for the explanation! I will check up the models and see if it is this scaling thingie!
               
               

               
            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
Shadow Game
« Reply #6 on: January 02, 2014, 01:35:36 pm »


               <getting a bit...>

Keeping in mind what Z said about the mysterious ways that some things interact with the engine, the primary problem with shadow-casting occurs when the origin of that particular piece of mesh is on the wrong side of one of the faces of that mesh.

In a cube, if the origin is in the center, the "normals" of each face is on the outside of the cube. Casting a ray of light from a torch to the origin of the box hits one face on the correct +normal side and so the outline of that face is added to the shadow cast (I'm simplifying :-P ).

If you make a really cool old gnarled tree-trunk and the raycast to the origin of the trunk passes through the *wrong* side of a face, the engine can get mighty confused and end up assigning some of the corners of the face to infinity or 0,0,0, - which leads to wierd shadows racing off in all directions.

Most of what CM3.5 does is try to center the origin of mesh *inside* all faces, so raycasting will always hit a +normal before a -normal. Sometimes it will break a mesh up into pieces to do this, which may cause other problems. But that is the main issue of shadows in NwN; concave mesh or flipped normals (a face that faces the wrong way). Especially if you have a two-sided mesh like a flag. Each side is actually a different face and if the face facing away from the light is calculated before the correct +normal face, the engine either ignores it (correct) or gets a wild hare and goes bounding off. Although it adds extra faces to simple models, it is actually better (for shadow casting) to extrude the mesh and give a little separation to the two sides. Give it thickness, and the engine gets much less confused.

Well, less confused than I am right now... what did I just babble?

<...techni-illogical>
               
               

               
            

Legacy_Master Jax

  • Hero Member
  • *****
  • Posts: 618
  • Karma: +0/-0
Shadow Game
« Reply #7 on: January 03, 2014, 07:45:02 am »


               Well, I actually ran some of the bugged models through clean models, but unfortunately it didn't fix them. The uploader was kind enough to explain why that could happen, though! Still, it was worth a try! Thanks, Rolo!