0

I'm a beginner to learn HLSL (Direct 3D Shader). Here are some codes to build a simple LSLS Light app. My question is what "WorldXf" means in the Function mainVS().

The codes is in the 【Fx Composer2.5】

Codes are fllowing :

float4x4 WorldViewProj : WorldViewProjection;

uniform float4x4 WorldXf : World <
    string UIWidget = " None";
>;


uniform float4 Color
<
    string UIName = "color";
    string UIWidget = "Color";
> = float4 (1.0f,0.0f,0.0f,1.0f);

float3 Light0Pos :Position<
    string Object = "PointLight0";
    string UIName = "PointLight0 Position";
    string UIWidget = "Position";
    string Space = "World";
> = float3 (0.0f,0.0f,0.0f);

float3 Light0Color : Diffuse <
    string Object = "PointLight0";
    string UIName = "PointLight0";
    string UIWidget = "Color";
> = {1.0f,1.0f,1.0f};

struct VS_INPUT
{
    float4 Position : POSITION;
    float3 Normal   : Normal;
};

struct VS_OUTPUT
{
    float4 Position : POSITION;
    float4 Color    : COLOR;
};
VS_OUTPUT mainVS(VS_INPUT In){

    VS_OUTPUT Out;
    Out.Position = mul(float4(In.Position.xyz,1.0f),WorldViewProj);
    float3 vWorldNormal = mul(In.Normal,(float3x3)WorldXf);
    float3 vWorldPosition = mul(In.Position,WorldXf).xyz;
    float3 vDir = normalize(Light0Pos - vWorldPosition);

    Out.Color.rgb = Light0Color * saturate ( dot(vDir,vWorldNormal));
    Out.Color.a = 1.0f;
    return Out;
}

float4 mainPS(VS_OUTPUT In) : COLOR {
    return In.Color;
}

technique technique0 {
    pass p0 {
        CullMode = None;
        VertexShader = compile vs_3_0 mainVS();
        PixelShader = compile ps_3_0 mainPS();
    }
}
genpfault
  • 51,148
  • 11
  • 85
  • 139
MiLu
  • 25
  • 2

1 Answers1

0

It means "World Transform", I'm not sure where the convention of using xform as an abbreviation for transform comes from but it is somewhat common. Just using Xf is even more opaque.

mattnewport
  • 13,728
  • 2
  • 35
  • 39