【发布时间】:2018-01-02 23:10:05
【问题描述】:
我制作了两个着色器,它们几乎共享所有代码,除了不应更改结果的行。 这是代码的共享部分:
struct VOut
{
float4 position : SV_POSITION;
float4 color : COLOR;
float4 ld1 : LD;
};
cbuffer LIGHT : register (cb0)
{
float4 light_direction;
float4 light_color;
};
cbuffer TRANSFORMATION_MATRIX : register (cb1)
{
float4x4 transformationMatrix;
};
cbuffer CAM_PROJ_MATRIX : register (cb2)
{
float4x4 cameraProjectionMatrix;
};
float4 PShader(float4 position : SV_POSITION, float4 color : COLOR) : SV_TARGET
{
return color;
}
改变的部分是顶点着色器:
VOut VShader(float3 position : POSITION, float4 color : COLOR)
{
VOut output;
float4 rpos = mul(transformationMatrix,float4(position, 1.0));
output.position = mul(cameraProjectionMatrix, rpos);
*output.ld1 = light_direction;*
output.color = color;
return output;
}
这个工作正常,但如果我将星号之间的线(显然星号不在实际代码中)更改为:
output.ld1 = float4(1.0,1.0,1.0,1.0);
然后我在屏幕上看不到任何东西。这怎么可能?
【问题讨论】:
-
LD不是标准语义,因此没有任何意义。尝试使用TEXCOORD0获取有效的级间插值器。
标签: directx-11 hlsl