Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Problem With Hlsl Of Blur

$
0
0

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


Viewing all articles
Browse latest Browse all 17560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>