-1
\$\begingroup\$

I'm trying to sample a image in the compute shader.

My code is

    [numthreads(1, N, 1)]
void VertBlurCS(int3 groupThreadID : SV_GroupThreadID,
                int3 dispatchThreadID : SV_DispatchThreadID)
{

    float4 test = gDiffuseMap.SampleLevel(samAnisotropic,0,0);
    gOutput[dispatchThreadID.xy] = test;
}

I'm getting one solid color.

What is wrong with my code?

\$\endgroup\$
8
  • \$\begingroup\$ I think compute shaders are fundamentally broken / don't behave how we would expect ... gamedev.stackexchange.com/questions/116323/… \$\endgroup\$
    – War
    Feb 9, 2016 at 23:01
  • \$\begingroup\$ The input params are uint3 I believe what are the other variable types? \$\endgroup\$
    – War
    Feb 9, 2016 at 23:05
  • 1
    \$\begingroup\$ @Wardy No, select isn't broken. Don't bring your overly verbose and floundering discussion into other questions. \$\endgroup\$ Feb 10, 2016 at 12:21
  • \$\begingroup\$ What type is gDiffuseMap and is it properly bound according to a graphics debugger? Does the debug runtime for Direct3D give you any diagnostics? \$\endgroup\$ Feb 10, 2016 at 12:23
  • 1
    \$\begingroup\$ @Wardy I was referring to the hopefully well known section in The Pragmatic Programmer that bears that title. See this article on CodingHorror for a summary. Blaming upstream functionality more often than not just results in the blamer looking silly. \$\endgroup\$ Feb 10, 2016 at 12:51

1 Answer 1

3
\$\begingroup\$

You are sampling from the same location on the texture for every output, therefore the output is a single colour.

See the documentation for SampleLevel

A fix would look something like this:

float2 uv = float2(dispatchThreadID.xy) / float2(textureWidthHeight); float4 test = gDiffuseMap.SampleLevel( samAnisotropic, uv, 0 );

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .