Skip to main content
GameDev.net gamedev.net
🔒 Locked

HLSL Sample and Load return zeros

Started by andrey4 Jan 1 at 1:06 PM 1 replies 800+ views
Original Post
andrey4
andrey4

Hi, I moved my code from directx 11 to directx 12 and a shader doesn't work correctly.

    Material material = mesh_instances[pass_data.mesh_idx].material;
    Texture2D<float4> normal_texture = textures[material.normal_texture_index];
    Texture2D<float4> diffuse_texture = textures[material.diffuse_texture_index];
    Texture2D<float4> specular_texture = textures[material.specular_texture_index];

    float3 local_normal = normal_texture.Sample(linear_sampler(), vertex_out.uv).rgb;
    float3 normal = normal_mapping(local_normal, vertex_out.normal, vertex_out.tangent);
    float3 diffuse = diffuse_texture.Sample(linear_sampler(), vertex_out.uv).rgb;
    float3 specular = specular_texture.Sample(linear_sampler(), vertex_out.uv).rgb;

Samples methos always return zero and I don't understand what causes it. What I tried.

  1. Use SampleLevel with zero mipmap level.
  2. Use Load(int3(1024 *vertex_out.uv.x, 1024 *vertex_out.uv.y, 0)) I thought maybe SamplerState is broken.
  3. In RenderDoc Pipeline State→Pixel Shader displays all accessed textures.
  4. Textures were properly filled.
  5. Descriptors holds right information.

Thanks for your advices.

andrey4
andrey4

I just forgot to call SetGraphicsRootDescriptorTable with based descriptor of SRV UAV CBV descriptor heap

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.