Pixel Shader 3 weirdness

Started by
2 comments, last by Matias Goldberg 7 years, 11 months ago

Hi all,

I have this simple post process blur shader:

sampler ColorSampler1 : register(s0);

#define SAMPLE_SIZE 15

float2 texelSize;
float offsets[SAMPLE_SIZE];
float weights[SAMPLE_SIZE];

float4 PS_BlurH(float2 texCoord : TEXCOORD0) : COLOR0
{
    float4 sum = float4(0.f, 0.f, 0.f, 1.f);
    
    [loop]
    for (int i = 0; i < SAMPLE_SIZE; i++)
        sum += tex2D(ColorSampler1, float2(texCoord.x + (offsets[i] * texelSize.x), texCoord.y)) * weights[i];
    
    clip(sum.a < 0.01f ? -1 : 1);
    
    return sum;
}

float4 PS_BlurV(float2 texCoord : TEXCOORD0) : COLOR0
{
    float4 sum = float4(0.f, 0.f, 0.f, 1.f);
    
    [loop]
    for (int i = 0; i < SAMPLE_SIZE; i++)
        sum += tex2D(ColorSampler1, float2(texCoord.x, texCoord.y + (offsets[i] * texelSize.y))) * weights[i];
    
    clip(sum.a < 0.01f ? -1 : 1);
    
    return sum;
}

technique Glow
{
    pass BlurHorizontal
    {
        PixelShader = compile ps_2_0 PS_BlurH();
    }
    
    pass BlurVertical
    {
        PixelShader = compile ps_2_0 PS_BlurV();
    }
}

But if I change ps_2_0 to ps_3_0 the shader doesn't work anymore? No errors on compiling...

Anyone with a clue?

Advertisement

Could it be because ps_3_0 requires a vs_3_0 vertex shader?

From experience, not as a Microsoft employee, I always seem to recall that VS Shader Model had to match PS Shader Model and that any mismatch between the versions was not guaranteed to work. I believe it worked on either AMD or NVIDIA hardware, not the other's, but I can't remember which way round that was. So I think Mona200 may be on to something.

Adam Miles - Principal Software Development Engineer - Microsoft Xbox Advanced Technology Group

The others are right. It is a requirement to match VS 3.0 shaders with PS 3.0

The only exception is VS_SW 3.0 which can be matched with PS 2.0 (very old Intel cards).

If you turn on the Debug Layer you would have spotted this issue. The Debug Runtimes are your friend.

This topic is closed to new replies.

Advertisement