Texture2D.Load работает во фрагментном шейдере HLSL, но не в вершинном шейдере - PullRequest
0 голосов
/ 19 октября 2018

В документации утверждается, что она поддерживается от vs_4_0 и выше [ link ] (я использую vs_5_0), но все значения возвращаются (0, 0, 0, 0).Я что-то пропускаю?

Texture2D view0 : register(t0);

SamplerState MeshTextureSampler: register(s0) {
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Wrap;
    AddressV = Wrap;
};

cbuffer InputData : register(b0) {
    uint width;
    uint height;
}

struct VertexInputType {
    float4 position : POSITION;
    float4 color : COLOR;
    float2 tex : TEXCOORD0;
};

struct VertexOutputType {
    float4 position : SV_POSITION;
    float4 color : COLOR;
    float2 tex : TEXCOORD0;
};

VertexOutputType VShader(VertexInputType input) {
    VertexOutputType output;
    output.position = input.position;
    output.tex = input.tex;
    output.color = view0.Load(int3(output.tex.x * width, output.tex.y * height, 0));

    return output;
}

float4 PShader(VertexOutputType input) : SV_TARGET
{
    //DOES NOT WORK
    return input.color; 

    //WORKS
    return float4(view0.Load(int3(input.tex.x * width, input.tex.y * height, 0)).rgb, 1); 
}
...