Тема: Странное.
Показать сообщение отдельно
Старый 20.12.2011, 22:24   #350
dsd
Мастер
 
Аватар для dsd
 
Регистрация: 13.06.2011
Сообщений: 1,103
Написано 481 полезных сообщений
(для 1,836 пользователей)
Ответ: Странное.


Вполне достойный блюр нормального качества с легко регулируемым радиусом.

// SCENECURRENT semantics is the texture which contains the scene right after the rendering.
// Its size matches the size of the backbuffer.
const texture sceneTexture : SCENECURRENT;

// Texture sampler to get access to texture pixels for shader
sampler sceneSample = sampler_state
{
	// Assing texture to sampler
	Texture   = <sceneTexture>;
	// We always needs clamping for textures
	AddressU  = Clamp;
	AddressV  = Clamp;
	// Linear texture filtering, also you may use "Point" or "None"
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Linear;
};

const float2 offsets[12] = {
   -0.326212, -0.405805,
   -0.840144, -0.073580,
   -0.695914,  0.457137,
   -0.203345,  0.620716,
    0.962340, -0.194983,
    0.473434, -0.480026,
    0.519456,  0.767022,
    0.185461, -0.893124,
    0.507431,  0.064425,
    0.896420,  0.412458,
   -0.321940, -0.932615,
   -0.791559, -0.597705,
};
// Pixel shader for uv-offset
float4 blur(float2 texCoords : TEXCOORD0) : COLOR
{
   float4 sum = tex2D(sceneSample, texCoords);
   float4 BlurScale=0.0078;

   for (int i = 0; i < 12; i++){
      sum += tex2D(sceneSample, texCoords + BlurScale * offsets[i]);
   }
	return sum/13.0;
}


// Shaders techniques. Shader must contain at least one technique.
technique MainTechnique
{
	// Sequence of technique passes. This passes will performs on stage.
	pass blur
	{
		PixelShader	= compile ps_2_0 blur();
	}

}
BlurScale - меняет радиус.
(Offline)
 
Ответить с цитированием