“WorldXf”在FX Composer2.5中的含义

时间:2013-09-26 14:51:48

标签: shader direct3d hlsl

我是初学者,学习HLSL(直接3D着色器)。 以下是构建简单LSLS Light应用程序的一些代码。 我的问题是函数mainVS()中“WorldXf”的含义。

代码位于【Fx Composer2.5】

代码正在流传:

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();
    }
}

1 个答案:

答案 0 :(得分:0)

这意味着“世界变换”,我不确定使用xform作为变换缩写的惯例来自哪里,但它有些常见。只使用Xf更加不透明。