Sign in to follow this  

What's wrong with this shader? Works only with DX10+8800

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi! Could anyone explain to me why does this shader require DX10 and/or an nVidia8800 to run?
texture2D vectorField;
sampler2D vectorSampler = sampler_state
{
	Texture = <vectorField>;
	MipFilter = POINT;
	MinFilter = POINT;
	MagFilter = POINT;
	AddressU = CLAMP;
	AddressV = CLAMP;		
};


struct vertexInput {
    float4 position		: POSITION;
};

struct vertexOutput {
    float4 position		: POSITION;
    float4 colour		: COLOR0;
};

//------------------------------------
float4x4 View : View;
float4x4 Projection : Projection;

float scale;
float4 pos;
float4 colour;

const float2 plusminus = float2(1,-1);

vertexOutput vsArrow(vertexInput IN) 
{
    vertexOutput OUT;
    float4 p = float4(0,0,0,1);
    float2 vect = tex2Dlod(vectorSampler, pos).xy;
  
    p.x = dot(IN.position.xy, vect*plusminus);
    p.y = dot(IN.position.xy, vect.yx);
    p *= scale;
    
    pos.xy = (pos.xy-float2(0.5,0.5))*plusminus;
    OUT.position = mul( p+pos, View);
    OUT.position = mul( OUT.position, Projection);
    OUT.colour = colour;

    return OUT;
}

It works as supposed with the config above. Produces empty screen on XP SP2 with nVidia6??? and 7????. The FX composer compiles it as a valid VS_3_0 vertex shader. Any ideas? shinjin

Share this post


Link to post
Share on other sites
Well, you are doing a vertex shader texture lookup, which isn't supported on all cards. Check if the geforce6/7 cards you are using support that or not.

If they support it, then maybe check your texture creation flags? I seem to recall there being some restrictions on how the texture is created/stored. The 8800 might be letting you get away with this due to its unified shaders.

Now, I've never actually used vertex shader texture lookup before in dx9. I looked into it once, but, my card didn't support it at all.

Share this post


Link to post
Share on other sites
I'm surprised the FX compiles it. The DX HLSL spec says tex2Dload is a pixel shader 3.0+ only function. However, doing a Google search returns evidence that many people use it in VS. Here is a person using it for displacement mapping: http://www.robertwrose.com/2005/05/vertex-texture-sampling-notes.html

I guess it is hardware support.

Share this post


Link to post
Share on other sites
tex2Dlod is definitely works with VS_3_0, that's a mistake in the SDK docs.

In the meantime I've managed to figure it out: the used texture format (D3DFMT_A16B16G16R16F) is not supported as vertex texture on those cards, switching to D3DFMT_A32B32G32R32F solved the problem

Share this post


Link to post
Share on other sites

This topic is 3592 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this