Shader Problem

Jun 22, 2010 at 3:50 PM
I got another Problem with an own Terrain Shader.. Im just trying to get the basic things working, to get an overview of the shader stuff
float4x4 World:WORLDVIEWPROJECTION;
float4x4 WorldViewProj:WORLD;
float4x4 View:VIEWPROJECTION;
float4x4 Projection:PROJECTION;
float4 vLightDir;
float4 vecEye;
float4 vDiffuseColor;
float4 vSpecularColor;
float4 vAmbient; 


struct VertexShaderOutput
{
    float4 Position : POSITION;
    float3 L :TEXCOORD0;
    float3 N :TEXCOORD1;
    float3 V:TEXCOORD2;
    float4 Color:COLOR0;
};

VertexShaderOutput VertexShader( float4 Position:POSITION, float3 Normal:NORMAL, float4 Color:COLOR0 ) 
{
    VertexShaderOutput output;
    output.Position = mul( Position, WorldViewProj);
   output.L=normalize(vLightDir);
   output.N=normalize(mul(Normal,World));
   output.Color=Color;
               
   
    float4 PosWorld = mul(Position, WorldViewProj);   
   
    output.L = vLightDir;
    output.V = vecEye - PosWorld;
    return output;
}

float4 PixelShader(VertexShaderOutput input) : COLOR
{  
    float3 Normal = normalize(input.N);
    float3 LightDir = normalize(input.L);
    float3 ViewDir = normalize(input.V);   
   
   
    float Diff = saturate(dot(Normal, LightDir));
   vAmbient=input.Color;
    // R = 2 * (N.L) * input.N – input.L
    float3 Reflect = normalize(2 * Diff * Normal - LightDir); 
    float Specular = pow(saturate(dot(Reflect, ViewDir)), 15); // R.V^n
    // I = A + Dcolor * Dintensity * N.L + Scolor * Sintensity * (R.V)n
    return vAmbient + vDiffuseColor * Diff + vSpecularColor * Specular;
}

technique Diffuse
{
    pass Pass0
    {
        VertexShader = compile vs_2_0 VertexShader();
        PixelShader = compile ps_2_0 PixelShader();
    }
}
This is my shader and it display nothing... When i change World to WorldViewPro too its shows the terrain but lightning is calculated in a wrong way.. Any ideas whats wrong with it?

Jun 22, 2010 at 3:51 PM
Nevermind i found the Error just when posting it ^^ Sorry for this but i just switched WORLD and WORLDVIEWPROJECTION now it works fine
Coordinator
Jun 23, 2010 at 5:16 PM

Yes, that was the first thing I saw too:

float4x4 World:WORLDVIEWPROJECTION;
float4x4 WorldViewProj:WORLD;

:-)