Jump to content
  • Advertisement
Sign in to follow this  
Squitch

HLSL - Conditional texture sampling on NV cards

This topic is 4640 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. 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!