HLSL着色器不起作用

问题描述 投票:0回答:1

我制作了两个着色器,它们几乎共享所有代码,除了一行不应该改变结果。这是代码的共享部分:

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

然后我在屏幕上看不到任何东西。这件事怎么可能?

directx-11 hlsl
1个回答
0
投票
  struct VOut
    {
        float4 position : SV_POSITION;
        float4 color : COLOR;
        float4 ld1 : TEXCOORD0;
    };
© www.soinside.com 2019 - 2024. All rights reserved.