Jump to content
  • Advertisement
Sign in to follow this  
simotix

HLSL Textured blurred

This topic is 3803 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

I am using a very basic shader to just apply a texture to a mesh. The problem is I have rendered it with out the shader and textured without it being blurry. I then render it with the shader and it blurry (even when I am right in front of it). Does anyone know why?
float4x4 worldViewProj : WorldViewProjection;

texture testTexture;

sampler Sampler = sampler_state
{
    Texture   = (testTexture);
    MipFilter = LINEAR;
    MinFilter = LINEAR;
    MagFilter = LINEAR;
};


struct VS_INPUT
{
    float3 position	: POSITION;
	float2 texture0 : TEXCOORD0;
};

struct VS_OUTPUT
{
    float4 hposition : POSITION;
    float2 texture0  : TEXCOORD0;
    float4 color	 : COLOR0;
};

struct PS_OUTPUT
{
	float4 color : COLOR;
};


VS_OUTPUT myvs( VS_INPUT IN )
{
    VS_OUTPUT OUT;

	OUT.hposition = mul(worldViewProj, float4(IN.position, 1));

	OUT.color = float4( 1.0, 1.0, 1.0, 1.0 );

	OUT.texture0 = IN.texture0;

	return OUT;
}


PS_OUTPUT myps( VS_OUTPUT IN )
{
    PS_OUTPUT OUT;

    OUT.color = tex2D( Sampler, IN.texture0 ) * IN.color;

    return OUT;
}

technique ShaderRender
{
    pass Pass0
    {
	Lighting = false;
	Sampler[0] = (Sampler);

	VertexShader = compile vs_2_0 myvs();
	PixelShader  = compile ps_2_0 myps();
    }
}

Share this post


Link to post
Share on other sites
Advertisement
That effect file looks good to me.

Only thing is I don't specify Sampler[] in my Techniques, as in the line:

	Sampler[0] = (Sampler);



Does removing it help?

Share this post


Link to post
Share on other sites
When I remove that line it is still the same result. Could it be with the ps being multiplied with the sampler also?

Share this post


Link to post
Share on other sites
Your filtering is linear, which if you do not have a power of 2 texture, it will blur it slightly. Try changing that to NONE or POINT (Point sampling).

Jeff.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!