Hi,
I’ve tried to do a kind of Bob deinterlacing:
https://vvvv.org/sites/default/files/imagecache/large/images/deinterlace.jpg
The code is this one:
{CODE(ln=>1)}
// this is a very basic template. use it to start writing your own effects.
// if you want effects with lighting start from one of the GouraudXXXX or PhongXXXX effects
// --------------------------------------------------------------------------------------------------
// PARAMETERS:
// --------------------------------------------------------------------------------------------------
//transforms
float4x4 tW: WORLD; //the models world matrix
float4x4 tV: VIEW; //view matrix as set via Renderer (EX9)
float4x4 tP: PROJECTION;
float4x4 tWVP: WORLDVIEWPROJECTION;
//texture transformation marked with semantic TEXTUREMATRIX to achieve symmetric transformations
float4x4 tTex: TEXTUREMATRIX ;
//resolution
float width = 720;
float height = 576;
bool oddFirst ;
//texture
texture Tex ;
//--------------------------------------------------------------------------------------
// Texture samplers
//--------------------------------------------------------------------------------------
sampler BaseTextureSampler = sampler_state
{
Texture = ;
MinFilter = Linear;
MagFilter = Linear;
MipFilter = Linear;
};
//--------------------------------------------------------------------------------------
// Vertex shader output structure
//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 vPos : POSITION; // vertex position
float2 TextureUV : TEXCOORD0; // vertex texture coords
//define new var pixel
float2 Pix : TEXCOORD1;
};
//--------------------------------------------------------------------------------------
// This shader computes standard transform
//--------------------------------------------------------------------------------------
VS_OUTPUT RenderVS( float4 vPos : POSITION,
float3 vTexCoord0 : TEXCOORD0 )
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.vPos = mul(vPos, tWVP);
Out.TextureUV = mul(vTexCoord0, tTex);
//une ligne c'est la hauteur de la texture 1/Height
Out.Pix.x = 1/float (width);
Out.Pix.y = 1/float (height);
return Out;
}
//--------------------------------------------------------------------------------------
// Pixel shader output structure
//--------------------------------------------------------------------------------------
struct PS_OUTPUT
{
float4 RGBColor : COLOR0; // Pixel color
};
// Bob Deinterlacing
//--------------------------------------------------------------------------------------
// This shader outputs the pixel’s color by using the texture’s color
//--------------------------------------------------------------------------------------
PS_OUTPUT RenderPS( VS_OUTPUT In )
{
PS_OUTPUT Output;
Output.RGBColor = tex2D(BaseTextureSampler, float2 (In.TextureUV.x,
In.TextureUV.y));
//alterne la passe paire et impaire
if (oddFirst==1)
{
//dedouble lignes paires
if (int (In.TextureUV.y*576)%2 == 1) //sur une ligne impair
{
Output.RGBColor = tex2D(BaseTextureSampler, float2 (In.TextureUV.x,
In.TextureUV.y-In.Pix.y));
}
}
else
{
//dedouble lignes impaires
if (int (In.TextureUV.y*576)%2 == 0) //sur une ligne paire
{
Output.RGBColor = tex2D(BaseTextureSampler, float2 (In.TextureUV.x,
In.TextureUV.y+In.Pix.y));
}
}
return Output;
}
//--------------------------------------------------------------------------------------
// Renders scene to render target
//--------------------------------------------------------------------------------------
technique BobDeinterlacing
{
pass P0
{
VertexShader = compile vs_1_1 RenderVS( );
PixelShader = compile ps_2_0 RenderPS( );
}
}
^
I would like to change the oddFirst boolean value after each pass. I’ve already tried to put a “oddFirst = !oddFirst;” line at the end of the pixelshader code but it seems that not possible to change global value between passes.
testBob Deinterlace.zip (2.8 kB)