• 15
• 15
• 11
• 9
• 10

Nvidia vs. ATI issues

This topic is 3518 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I asked a question like this a while back and did not receive any valuable answers. Here is the original post: regarding the difference Now, I have a Vertex Shader that has a prototype of:
outNormalMap NormalMapVS(float3 posL      : POSITION0,
float3 normalL   : NORMAL0,
float3 tex0      : TEXCOORD0,
float3 tangentL  : TANGENT0,
float3 binormalL : BINORMAL0)

//outNormalMap is defined as
struct outNormalMap
{
float4 posH      : POSITION0;
float3 toEyeT    : TEXCOORD0;
float3 lightDirT : TEXCOORD1;
float3 tex0      : TEXCOORD2;
float fogLerpParam : TEXCOORD3;
float2 tex1		 : TEXCOORD4;
};


In my code, my vertex declaration is:
elems(0) = New VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0)
elems(1) = New VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0)
elems(2) = New VertexElement(0, 24, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0)
elems(3) = New VertexElement(0, 36, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 1)
elems(4) = New VertexElement(0, 48, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 2)
elems(5) = VertexElement.VertexDeclarationEnd


I also set my vertex format as: VertexFormats.Position Or VertexFormats.Normal Or VertexFormats.Texture3 Or VertexTextureCoordinate.Size3(0) Or VertexTextureCoordinate.Size3(1) Or VertexTextureCoordinate.Size3(2) I set both VertexDeclaration and VertexFormats (not sure if I should or what adverse affects I would see). So with all of that being said, everything works perfectly on NVidia cards. However, it does not work with ATI cards (it creates the visual artifacts in the original post). Any ideas as to why? What should I be looking at? I compile the shader to 2.0. Is it possible that the shader compiles differently from ATI to NVidia? If so, would the difference be so much that it would cause very odd visual artifacts? Could be a texture stage state, sampler state, or any other external setting? If the shader is likely not an issue and it is likely an external setting, which ones would affect the shader in such a way? Any help would be appreciated.

Share on other sites
Setting FVF and Decl is not needed. The last one set is in effect. Decls are prefered as they can represent multiple streams, variable formats for inputs, additional input types, or inputs in a different order.

You still have the issue your first post had. In both decl and fvf you define your input as:

pos, norm, uvw0, uvw1, uvw2.

Your shader however isn't expecting 3 texcoords. It's expecting 1 texcoord, a tangent, and a binormal.

Either change your vertex shader input semantics to texcoord1, texcoord2, OR stop setting an FVF, just set the decl, and change your vertex declaration types to tangent and binormal.

Share on other sites
Thanks for the response. Got me excited to think it may have been that easy. But, it was not.

After trying it in several combinations I end up with this result every time:

I have removed the use of VertexFormat.

I have tried the following combinations:
//decl to Pos0, norm0, tex0, tex1, tex2 outNormalMap NormalMapVS(float3 posL      : POSITION0,                      float3 normalL   : NORMAL0,                      float3 tex0      : TEXCOORD0,                     float3 tangentL  : TEXCOORD1,                     float3 binormalL : TEXCOORD2)//decl to Pos0, norm0, tex0, tan0, bin0outNormalMap NormalMapVS(float3 posL      : POSITION0,                      float3 normalL   : NORMAL0,                      float3 tex0      : TEXCOORD0,                     float3 tangentL  : TANGENT0,                     float3 binormalL : BINORMAL0)//decl to Pos0, norm0, tex0, tan1, bin2outNormalMap NormalMapVS(float3 posL      : POSITION0,                      float3 normalL   : NORMAL0,                      float3 tex0      : TEXCOORD0,                     float3 tangentL  : TANGENT1,                     float3 binormalL : BINORMAL2)//decl to Pos0, norm0, tex0, tan1, bin2outNormalMap NormalMapVS(float3 posL      : POSITION0,                      float3 normalL   : NORMAL0,                      float3 tex0      : TEXCOORD0,                     float3 tangentL  : TANGENT0,                     float3 binormalL : TEXCOORD0)

All of these did not work. Is there another I should try? I'm very anxious to try anything.

Share on other sites
Hangon, I tried something. I just noticed that the artifact happens where buildings are. On the buildings, we do a terrain adjustment to indicate a sort of civilization there.

That adjustment seems to be the culprit because if I remove it, ATI works fine. So something is happening in my tangent calcs. Even though it calls the same function... so, I may have more details in a bit.

Share on other sites
Just a follow up - it was the recalculation of the tangent and binormal. The index list was cleared so the Tan and Bin got set to 0,0,0. Cleaning it up now and it seems to work on every card.

Thanks for the help as you also have fixed some of our other lingering bugs.

Share on other sites
Hey I am getting the same glitch on my game as you seem to be, alot of my triangles are "flickering" with parallax mapping or normal mapping on...the thing is that it works great on nvidia cards...so I dont know what is going on. you say its a tangent/binormal issuse right? How would I fix this in my code?

my code is:

int f2 = sizeof(FLOAT)*2;
int f3 = sizeof(FLOAT)*3;
int f4 = sizeof(FLOAT)*4;

D3DVERTEXELEMENT9 TerrainDec[] =
{

{ 0, 0 ,D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, // pos
{ 0, f4 ,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 }, // tex0
{ 0, f4 + f2 ,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 }, // normal
{ 0, f4 + f2 + f3 ,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, // tangent
{ 0, f4 + f2 + f3 + f3 , D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, // binormal

D3DDECL_END()
};

Anyways am I doing this correctly? or not?
I am calculating the tangets and binormals like this

TerrainMesh->CloneMesh(D3DXMESH_MANAGED, TerrainDec, D3DDevice, &TerrainMesh);
D3DXComputeTangentFrame( TerrainMesh, NULL );

is this correct? or am I doing something wrong here also. I really need to get this issue resolved. Thanks for any help.

Share on other sites
Ok ive had some progress....very stange though maybe someone here knows how to solve this problem?

If I set
dwBehaviorFlags = D3DCREATE_SOFTWARE_VERTEXPROCESSING;
dwBehaviorFlags = D3DCREATE_HARDWARE_VERTEXPROCESSING;
everything looks perfect. So I'm wondering if this is the cause of the problem? If so then why? Maybe its an ATI related problem maybe not? I dont know, Im really getting frustrated here cause this is so lame. Thanks all.

Share on other sites
Is your position really a float4? What matters here is the actual data you put in the structure, not what you declare in the shader.

Next you say you have a float3 tangent, but then only add f2 as an offset, not f3, so all the remaining vertex data is off by 1 float.

An alternate way to set the offsets is to use offsetof.

ie:

0, offsetof(MyVertex, Position), ...
0, offsetof(MyVertex, Normal), ...

though that may be C/C++ specific. I don't know if C# offers anything similar.

Share on other sites
Quote:
 Original post by david wint f2 = sizeof(FLOAT)*2;int f3 = sizeof(FLOAT)*3;int f4 = sizeof(FLOAT)*4;D3DVERTEXELEMENT9 TerrainDec[] ={ { 0, 0 ,D3DDECLTYPE_FLOAT4, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 }, // pos { 0, f4 ,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 }, // tex0 { 0, f4 + f2 ,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 }, // normal { 0, f4 + f2 + f3 ,D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 }, // tangent { 0, f4 + f2 + f3 + f3 , D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 }, // binormal D3DDECL_END()};

This doesn't look right ... Make sure that you always triple check your vertex declarations!

Share on other sites
It would appear your offset is... erm... off.

you have f2 as a float2, f3 as a float3, f4 as a float4.

However, in your DECL, you have a float4 for pos, float3 for tangent, float3 for binormal, float3 for normal, and a float2 for texcoord.

In your final offset, you have f4+f2+f3+f3. I believe it would be f4+f3+f3+f3. Every item in the decl list is similar. I'd start there. If that doesn't completely fix your issue, it may be an issue with D3DXComputeTangentFrame as I recall it being rather quirky and wanting the DECL in a certain order (Pos, Norm, Tex, Tan, Bin)... but that may have been a compounded issue.