我是学习 HLSL(Direct 3D Shader)的初学者。下面是一些代码来构建一个简单的 LSLS Light 应用程序。我的问题是函数 mainVS() 中的“WorldXf”是什么意思。
代码在【Fx Composer2.5】</p>
代码正在流动:
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();
}
}