Shader on OpenGL Desktop

Some could help me do found why my shader parameter “xLightDir” is present in DirectX profile and not on OpenGL ?

   effect.Parameters["xLightDir"] is NULL  on OpenGL !

rk. All others parameters work.

Thanks.

/////////////////////////////////////////////////////////////////////////////////////////////
// Cube Shader for Cubes Debris
/////////////////////////////////////////////////////////////////////////////////////////////

float4x4 xWorld;
float4x4 xView;
float4x4 xProjection;

float xFogNear;
float xFogFar;
float3 xFogColor;
float3 xLightDir;
float4 xDebrisColor;

float3 AmbientLightColor = float3( 0.08f, 0.08f, 0.1f );

Texture2D xDiffuseTexture;//Cube Material Texture
sampler DiffuseTextureSampler = sampler_state
{
texture = ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = Wrap; AddressV = Wrap;
};

struct VS_IN
{
float4 vertexPosition : POSITION;
float3 vertexNormal : NORMAL0;
float4 vertexColor : COLOR0;
};

struct PS_IN
{
float4 position : SV_POSITION;
float4 Color : COLOR;
float fogFactor : TEXCOORD0;
};

PS_IN VertexShaderFunction(VS_IN input)
{
PS_IN output;

//Position View
float4 worldPosition = mul(input.vertexPosition, xWorld);
float4 viewPosition = mul(worldPosition, xView);
output.position = mul(viewPosition, xProjection);

//Normal
float3 normal = normalize( mul( input.vertexNormal, xWorld ));

// Direction to the Light
float3 lightDirection = normalize( -xLightDir );
float3 diffuse = saturate(abs(0.5 + (dot(lightDirection,normal)*0.5)));

//Debris Color
output.Color = xDebrisColor;

// fogFactor for fog
output.fogFactor = output.position.z;

return output;

}

float4 PixelShaderFunction(PS_IN input) : SV_Target
{
float fog = saturate((input.fogFactor - xFogNear) / (xFogFar-xFogNear));

float4 diffuseColor = input.Color;

return lerp(diffuseColor, float4(xFogColor,1), fog);

}

technique Technique1
{
pass Pass1
{
CullMode = CCW;
FillMode = Solid;

#if SM4
VertexShader = compile vs_4_0_level_9_1 VertexShaderFunction();
PixelShader = compile ps_4_0_level_9_1 PixelShaderFunction();
#else
VertexShader = compile vs_2_0 VertexShaderFunction();
PixelShader = compile ps_2_0 PixelShaderFunction();
#endif

}

}

the float3 diffuse is not used in your vertexshader, which is removed / should be also removed from the dx version.
If a variable is not in the “path” 'till the final output, it will be removed by 2mgfx (? Cant find the page where i saw this)
As xLightDir is only used in

float3 lightDirection = normalize( -xLightDir );
float3 diffuse = saturate(abs(0.5 + (dot(lightDirection,normal)*0.5)));

I suppose it is what happens.

float3 lightDirection = normalize( -xLightDir );
float3 diffuse = saturate(abs(0.5 + (dot(lightDirection,normal)*0.5)));

//Debris Color
output.Color = xDebrisColor;

You don’t use the diffuse parameter, I suppose you want to use something like this
output.Color = xDebrisColor * diffuse;

Yes that it !
I lost “* diffuse” !
Sorry, thanks a lot.