2013-09-26 46 views
0

我是學習HLSL(Direct 3D Shader)的初學者。 這裏有一些代碼來構建一個簡單的LSLS Light應用程序。 我的問題是「WorldXf」在函數mainVS()中的含義。FX Composer2.5中的「WorldXf」意味着什麼

的代碼是在【Fx的Composer2.5】

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

回答

0

這意味着「世界轉變」,我不知道在哪裏使用的XForm作爲變換的縮寫的約定來源於卻是頗爲普遍。只是使用Xf更加不透明。