Hello,
I have an annoying problem. I made a really simple sprite and static mesh render system. When I run my framework on my GeForce 6600 everything is ok. So i passed it to a few people. I found out that it works well on all GeForce cards but doesn't work on almost all ATI Radeons. They get good FPS, but the scene looks like the vertex shader wouldn't work. When I turn off shaders initialization in my framework I get the same scene look as they get. So the problem probably lies somewhere in shaders code or their initializaion.
This is how it starts:
void initShaders()
{
CgContext = cgCreateContext();
if (CgContext == NULL)
MessageBox(0, "cgCreateContext", "ERROR", 0);
CgProgram_Surface = cgCreateProgramFromFile(CgContext, CG_SOURCE, "surface.cg", CG_PROFILE_ARBVP1, "main", NULL);
CgProgram_Mesh = cgCreateProgramFromFile(CgContext, CG_SOURCE, "mesh.cg", CG_PROFILE_ARBVP1, "main", NULL);
if (CgProgram_Surface == NULL || CgProgram_Mesh == NULL)
MessageBox(0, "cgCreateProgramFromFile", "ERROR", 0);
cgGLLoadProgram(CgProgram_Surface);
cgGLLoadProgram(CgProgram_Mesh);
cgGLEnableProfile(CG_PROFILE_ARBVP1);
CgParameter_Surface_ModelViewProj = cgGetNamedParameter(CgProgram_Surface, "matrixModelViewProj");
CgParameter_Surface_CameraPosition = cgGetNamedParameter(CgProgram_Surface, "cameraHeight");
CgParameter_Mesh_ModelViewProj = cgGetNamedParameter(CgProgram_Mesh, "matrixModelViewProj");
CgParameter_Mesh_CameraPosition = cgGetNamedParameter(CgProgram_Mesh, "cameraHeight");
}
Shader code of surface.cg (mesh.cg looks very similiar):
void main(in float4 position: POSITION,
in float3 translationVector: NORMAL,
in float4 color: COLOR,
in float4 texCoord: TEXCOORD0,
out float4 oPosition: POSITION,
out float4 oColor: COLOR,
out float2 oTexCoord: TEXCOORD0,
out float oFog: FOG,
uniform float4x4 matrixModelViewProj,
uniform float cameraHeight)
{
float4x4 matrixTransformation = { texCoord.w, -texCoord.z, 0.0f, translationVector.x,
texCoord.z, texCoord.w, 0.0f, translationVector.y,
0.0f, 0.0f, 1.0f, translationVector.z,
0.0f, 0.0f, 0.0f, 1.0f };
float4 transformedPosition = mul(matrixTransformation, position);
oPosition = mul(matrixModelViewProj, transformedPosition);
oColor = color;
oTexCoord = texCoord.xy;
oFog = distance(transformedPosition.z, cameraHeight);
}
// texCoord.w contains some sine value, texCoord.z contains some cosine value
Maybe the problem is
NVIDIA's Cg but afaik for example Far Cry uses Cg shaders and it doesn't have problems with Radeons.
Have anyone ever met such a problem and/or have any idea on how to solve it? I'd be really grateful