Sign in to follow this  
Squitch

HLSL - Conditional texture sampling on NV cards

Recommended Posts

Hi. I have some problem on NVIDIA Cards (GF5 and GF6 series) when i try to do a texture sampling in a if(){} statement. The condition used in this statment is a boolean exposed value. And when i modified them in FX Composer no change appear to the screen. This shader works fine on ATI cards. Somebody know any limitaion on this subject on NV Cards ? Or it's a driver bug ? Thank. PS : Sorry for my poor english.

float4x4 		WorldViewProj	: WORLDVIEWPROJECTION; // World x View x Projection Matrix


bool Texture_Color = true;


texture2D TexMap;
sampler2D MyTex = sampler_state
{  
    Texture = <TexMap>; 
    MipFilter = LINEAR; 
    MinFilter = LINEAR; 
    MagFilter = LINEAR; 
};


struct VS_IN
{
    float4 Position : POSITION;
	float2 tc		: TEXCOORD0;
};

struct VS_OUT
{
    float4  Position 	: POSITION;
	float2	tc			: TEXCOORD0;
};

/**********************************************
The Vertex shader :
***********************************************/
VS_OUT VS_If(VS_IN i)
{
    VS_OUT   Out;
	
	// Basic vertex transform
    Out.Position = mul(i.Position , WorldViewProj); 
	Out.tc = i.tc;   

	return Out;
}


/**********************************************
The pixel shader :
***********************************************/
float4 PS_If(VS_OUT i) : COLOR
{

	float4 Out;
	float4 tmpColor;

	tmpColor = float4(0.f,0.f,1.f,0.f);

	if(Texture_Color)
		Out = tex2D(MyTex, i.tc);
	else
		Out = tmpColor;
	
    return Out;
}


technique tech
{
	pass p
	{
		vertexshader = compile vs_2_0 VS_If();
		pixelshader  = compile ps_2_0 PS_If();
	}
}


Share this post


Link to post
Share on other sites

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