Jump to content
  • Advertisement
Sign in to follow this  
pristondev

Problem With Hlsl Of Blur

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

Im trying run some shader of blur in my game, but nothing happen and the render be normal, without blur..

 

HLSL Code:

sampler ColorSampler1 : register(s0);

#define SAMPLE_SIZE 15

float2 texelSize = {1/1024,1/768};
float offsets[SAMPLE_SIZE] = {-0.006836,-0.005859,-0.004883,-0.003906,-0.002930,-0.001953,-0.000977,0.000000,0.000977,0.001953,0.002930,0.003906,0.004883,0.005859,0.006836};
float weights[SAMPLE_SIZE] = {0.008847,0.018216,0.033562,0.055335,0.081638,0.107778,0.127325,0.134598,0.127325,0.107778,0.081638,0.055335,0.033562,0.018216,0.008847};

float4 PS_BlurH(float2 texCoord : TEXCOORD0) : COLOR0
{
	float4 sum = float4(0.0, 0.0, 0.0, 1.0);
	
	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.0, 0.0, 0.0, 1.0);
	
	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();
	}
}

Screenshot:

b7189a0e52.png

 

As can see in pic, nothing happens with meshe, dno why.. If i change values of offsets and weights same thing... Blur dont work.

Someone know what can be? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Did you test if the expected pixel shader is executed at all, I.e output a static color?

First for the horizontal pass and then for the vertical.

Share this post


Link to post
Share on other sites

Maybe the render target is still bound as a input somewhere?

 

Don't quite understand this:

 

float4 sum = float4(0.0, 0.0, 0.0, 1.0);

sum += ....

clip(sum.a < 0.01f ? -1 : 1);

 

alpha channel will never be less than 1.0 because that's what it starts with and you're only adding to it?

Share this post


Link to post
Share on other sites
Thanks for all, I got it, i remade shader and now the blur works...

Now I need clip mesh from render and leave just the silhouette. Some idea?

Share this post


Link to post
Share on other sites

I can do this:

 

 

41b19e1a63.jpg

 

but, i need to draw just the silhouette outline,

 

anyone can help? Thanks ^^

Edited by sharedptr

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!