cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

xSergio74
Journeyman III

Problem with Effect Shader V2.0

Hi

I wrote an EffectShader to manage backface lighting not available in DirectX9.

It works fine on all nVidia card, but not in most recently ATI cards. I don't get any error, but I cannot see any rendered triangle

What is wrong?

thanks for help

Sergio


/* Parameters */

float4x3 mWorld; // Inverted-Transposed World Matrix
float4x4 mWorldP; // Projected World Matrix
float3   CameraPos; // Camera Position
float4   Diffuse; // Material Ambient/Diffuse Color are same
float4  Specular; // Material Specular COlor
float  Shiness; // Material Shiness

/* Constants */

const float3 LightDir  = {0.0f, 0.5f, -.866f}; //Light Direction
const float4 LightColor  = {0.7f, 0.7f, 0.7f, 1.0f}; //Light COlor (White)
const float4 LightDColor = {0.7f, 0.7f, 0.7f, 1.0f}; //Light Diffuse Color
const float4 LightSColor = {1.0f, 1.0f, 1.0f, 1.0f}; //Light Specular Color
const float4 AmbientColor = {0.3f, 0.3f, 0.3f, 1.0f}; //Global Ambient Color


/************* DATA STRUCTS **************/

struct DataIN {
    float4 Position : POSITION;
    float3 Normal : NORMAL;
};

struct DataOUT {
    float4 Position : POSITION;
    float4 AL  : TEXCOORD0;
    float4 DL  : TEXCOORD1;
    float4 SL  : TEXCOORD2;
};

struct OUTPUT{
    float4 color:COLOR;
};

/*********** vertex shader ******/

DataOUT MainVS(DataIN IN)
{
    DataOUT OUT;


    float3 N=normalize(mul(IN.Normal, mWorld));


    float3 P0 = IN.Position;
    float3 P  = mul(P0, mWorldP);
    float3 VH = normalize(normalize(CameraPos - P) + LightDir);


    if (dot(N,LightDir) < 0) {
  N = -N;
    }

    OUT.Position = mul(IN.Position, mWorldP);

    OUT.AL   = Diffuse  * (AmbientColor + LightColor);
    OUT.DL  = Diffuse  * LightDColor * dot(N, LightDir);
    OUT.SL  = Specular * LightSColor * pow(dot(N, VH), Shiness);

    return OUT;
}


/********* pixel shader ********/

float4 MainPS(DataOUT IN) : COLOR
{

 return float4 (IN.AL/1.7 + abs(IN.DL)/1.3 + abs(IN.SL)/2);

}


technique TAndLV {
    pass p0 {  
 ZEnable = True;
 SpecularEnable = True;
 CullMode = None;
 ShadeMode = Gouraud;

 VertexShader = compile vs_2_0 MainVS();
 PixelShader = compile ps_2_0 MainPS();

    }
}

0 Likes
0 Replies