Home   Help Search Login Register  

Author Topic: Perplexing Shading Problem  (Read 3844 times)

0 Members and 1 Guest are viewing this topic.

Offline Max_Power

  • Members
  • *
  • I'm a llama!
Perplexing Shading Problem
« on: 07 Feb 2009, 01:57:39 »
The problem seems related to the orientation of my uvw unwrap.  Pieces of the model that aren't orientated the same way (say, the front of the car is orientated with the top to the right, and the sides are unwrapped with the front to the top) show massively different lighting conditions.  Conversely, there are hard lighting transitions along the uvw seams that should be soft shaded.



I have a specmap applied, and hard and soft edges have been applied properly before I imported it via obj file.  The specmap was created with Linker Split's filter code in Texview2, so it should work well enough for this purpose.  I got it from here.

Code: [Select]
sp = 10;
p = src pixel [u,v];
x = 1 - green p;
y = green p * ((sp * blue p + 1) / (sp + 1));
c = color[x,y,blue p,1];

edit: I should say that it has only 1 LOD and no config.

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: Perplexing Shading Problem
« Reply #1 on: 08 Feb 2009, 00:36:58 »
hmm ,sounds like you answered your own question ?
 You think the way it was unwrapped has led to the faces being shaded in a different orientation to where they should be or something ?.
 I aint big on this subject , but i do know you can change properties a few ways regarding shading, one as you mentioned is in the wway the rvmat is created. 2 is to select the face the select the Faces tab > properties and there are some options there ,also for points.
 thirdly although i use linkers method too, there is apparrently a few ways to create the smdi\_as textures one is linkers the other is to simply save the _co/_ca  as an  _smdi or _AS in textview2 depending on your needs, they never looked right to me.
 like i said this aint my bag , thought i would throw a few ideas in because you havent had much response.

Oh and just so you can eliminate in future because i don't think its the case here, always work on the p drive  and a forked model.cfg can throw up things like this too in my experience.

 also ,wiki explanation with some refference to shadows and shading properties .

 http://community.bistudio.com/wiki/ArmA:_RVMAT
 
 good luck.
 DB
« Last Edit: 08 Feb 2009, 10:53:31 by DeanosBeano »
I love ofp

Offline T_D

  • CWR
  • **
  • Troubleshooting Device
Re: Perplexing Shading Problem
« Reply #2 on: 08 Feb 2009, 03:11:21 »
I cant imagine that the uv mapping is the cause for this because uv just defines where the texture is on the grid and not how it is lightened. First try to redo sharp and smooth edges after importing the model. If this doesnt help, it just can be the material in my opinion.

Offline Max_Power

  • Members
  • *
  • I'm a llama!
Re: Perplexing Shading Problem
« Reply #3 on: 09 Feb 2009, 08:57:50 »
Thank you for your kind replies.

I'm still at a loss as to what is going on.  I've tried to tackle the problem from so many different angles.

I've tried rebuilding the shader, tried a different shader configuration, re-exporting the mesh, re-exporting the mesh after performing 'unlock normals' operations, unlocking the normals in o2, setting all faces to soft shaded, setting all faces to hard shaded, etc. ad nauseum.  I think there must be something wrong with the normals properties of the vertexes, as this problem is only surfacing when it needs to calculate the differences between vertex normals and the normal map.  I think when you generate a normal map, the 3d app creates a vertex normal property.  Since I didn't do this, and just did a height map => normal map conversion, maybe I've missed out on generating proper vertex normals.  I'll try duplicating my mesh in Maya, applying the bump map, and transferring the normals with the bump map from one mesh to another to see if it will change anything.

edit:  I've been able to replicate the behaviour in Maya, but no matter how I generate the normal map it doesn't make a difference.  I'm not sure what's wrong with the model.  :(

edit2:  I'm fairly sure it has something to do with the bitangent vertex property of the mesh.  I was reading that this is normally generated by the rendering engine- in this case, buldozer.  I've got that artifact displaying in some version of my mesh in Maya, but it renders fine in xNormal.  I wonder if there is a way to regenerate the bitangents in O2.
« Last Edit: 09 Feb 2009, 13:31:16 by Max_Power »

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: Perplexing Shading Problem
« Reply #4 on: 09 Feb 2009, 13:49:02 »
Out of interest ,could you post your rvmat in text format ,eithere here or at pastebin.?

 1. also have you tried it ingame ?
simplest way would be to class it as an object/house.
 2. have you tried it with a shadow LOD ?
 3. try it fully loaded with correct config.cpp and model config.
 4. in o2 \bulldozer options do you have ticked the option ,include model.cfg if so try with it unticked.
 5. say its due to moss because its been stored in a bar since wayback ;).

I love ofp

Offline Max_Power

  • Members
  • *
  • I'm a llama!
Re: Perplexing Shading Problem
« Reply #5 on: 10 Feb 2009, 23:17:41 »
I spent all day yesterday importing / exporting and rebuilding the model.  When I put it back into o2 now, I have different results.  Now, No parts of the model are lit.  It is a jet black silhouette.

Here is the RVMAT I'm using right now.

Code: [Select]
ambient[]={1.000000,1.000000,1.000000,1.000000};
diffuse[]={1.000000,1.000000,1.000000,1.000000};
forcedDiffuse[]={0.000000,0.000000,0.000000,0.000000};
emmisive[]={0.000000,0.000000,0.000000,1.000000};
specular[]={0.000000,0.000000,0.000000,1.000000};
specularPower=1.000000;
PixelShaderID="NormalMapSpecularMap";
VertexShaderID="NormalMapDiffuse";
class Stage1
{
texture="Trabi\data\trabinormal_NOHQ.tga";
uvSource="tex";
class uvTransform
{
aside[]={1.000000,0.000000,0.000000};
up[]={0.000000,1.000000,0.000000};
dir[]={0.000000,0.000000,0.000000};
pos[]={0.000000,0.000000,0.000000};
};
Filter="Anizotropic";
};
class Stage2
{
texture="Trabi\data\trabitex_SMDI.tga";
uvSource="tex";
class uvTransform
{
aside[]={1.000000,0.000000,0.000000};
up[]={0.000000,1.000000,0.000000};
dir[]={0.000000,0.000000,0.000000};
pos[]={0.000000,0.000000,0.000000};
};
};

edit:

I GOT IT WORKING PROPERLY! 8)

All it took was for me to spend like 20 hours running it through different exporters and rebuilding the model.  :banghead:

Thank you all for your kind support.  It turns out it wasn't material or O2 related, but a result of a corrupt model from when I was forced to use my old computer with a failing motherboard and ram bus (frequent CTDs, etc).  Be that as it may, your contributions to this thread were supportive and motivating.  If I had nowhere to turn I would have given up long ago.  Thanks a lot!
« Last Edit: 10 Feb 2009, 23:52:42 by Max_Power »

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: Perplexing Shading Problem
« Reply #6 on: 11 Feb 2009, 00:05:00 »
 well, congratulations on that its already apparent that this car deserves to be working fully from your picture.
 glad you sorted it out , hope we can assist in configs if you need us.
 out of interest i was going to compare your rvmat too hmmv body.
 As you can see there are some subtle differences, some which you may know more about than me ,for instance :
 specualarpower of 70 in bis and 1 in yours is obviosly less shine  but :

 yours = specular[]={0.000000,0.000000,0.000000,1.000000};
 Bis =   specular[] = {1.0, 1.0, 1.0, 1.0};

 yours = NormalMapSpecularMap
 Bis = NormalMapSpecularDIMap

 yours = NormalMapDiffuse
 Bis = NormalMap

 maybe these differences mean nothing , but i think for this thread and future refference , it would be nice if someone could explain ,if these would give different results and why / which is best if any ?

Code: [Select]
ambient[] = {1.0, 1.0, 1.0, 1.0};
diffuse[] = {1.0, 1.0, 1.0, 1.0};
forcedDiffuse[] = {0.0, 0.0, 0.0, 0.0};
emmisive[] = {0.0, 0.0, 0.0, 1.0};
specular[] = {1.0, 1.0, 1.0, 1.0};
specularPower = 70.0;
PixelShaderID = "NormalMapSpecularDIMap";
VertexShaderID = "NormalMap";

class Stage1 {
texture = "ca\wheeled\data\hmmwv_body_nohq.paa";
uvSource = "tex";

class uvTransform {
aside[] = {1.0, 0.0, 0.0};
up[] = {0.0, 1.0, 0.0};
dir[] = {0.0, 0.0, 0.0};
pos[] = {0.0, 0.0, 0.0};
};
};

class Stage2 {
texture = "ca\wheeled\data\hmmwv_body_smdi.paa";
uvSource = "tex";

class uvTransform {
aside[] = {1.0, 0.0, 0.0};
up[] = {0.0, 1.0, 0.0};
dir[] = {0.0, 0.0, 0.0};
pos[] = {0.0, 0.0, 0.0};
};
};
« Last Edit: 11 Feb 2009, 00:07:06 by DeanosBeano »
I love ofp

Offline Max_Power

  • Members
  • *
  • I'm a llama!
Re: Perplexing Shading Problem
« Reply #7 on: 11 Feb 2009, 01:11:41 »
Thanks for your continued analysis of my model, DeanosBeanos.  I will test those changes and report back at the differences, if I can find any.

I have an update.  Embarrassingly enough, I think the problem was ultimately CrossfireX.  I was just reviewing the old models that didn't work before, with the old rvmats that also didn't work, with crossfire off.  They seem to work properly.  Then, I turned CrossfireX back on, and... it worked properly.  All of my old objs, rvmats, and p3ds are now working properly.  I have no idea what the hell is going on.  Maybe it was a synergy of corrupt models and crossfire behaviour.  But, the first thing I would suggest to anyone who is having bizarre shading problems is to ensure they are only rendering on one gpu to start.

Offline Max_Power

  • Members
  • *
  • I'm a llama!
Re: Perplexing Shading Problem
« Reply #8 on: 17 Feb 2009, 05:45:58 »
There is a great deal of difference between those shaders, not the least of which the vertex shader.  NormalMap permits specular, but NormalMapDiffuse does not.  And for the Pixel shader, I was using the wrong Specular map type, which shouldn't have really affected the results since Buldozer was generating the paa from a straight up Specmap at any rate.