Forum

Simple Tile Shader?

I found this link for implementing a tiling Shader in Silverlight. I can’t seem to implement the same thing in vvvv (my starting point is actually the Svvvvitcher Post FX template). I’m originally a programmer but have never played with HLSL before.

You could achieve the same or at least a similar effect by transforming the texture coordinates. Read.

Thanks for the link… However I’d still like to be able to do this with a Shader

the code is very similar:

.
.
.

float2 TileCount;

float4 PS(vs2ps In): COLOR
{
float4 col = tex2D(Samp, In.TexCd * TileCount);
return col;
}

.
.
.

ah, forgot something. you have to set ‘AddressU’ and ‘AddressV’ of the sampler, to define in which way the repetition of the texture works, the default is ‘Mirror’:

//texture
texture Tex ;
sampler Samp = sampler_state //sampler for doing the texture-lookup
{
Texture = (Tex); //apply a texture to the sampler
MipFilter = LINEAR; //sampler states
MinFilter = LINEAR;
MagFilter = LINEAR;
AddressU = Wrap;
AddressV = Wrap;
};

Thanks this has been illuminating. Both methods actually work in Svvvvitcher’s Post FX I learned…

{CODE(ln=>1)}float2 tilecount;

float4 PS(vs2ps In): COLOR
{
float2 newUv = float2(In.TexCd.x * tilecount.x % 1, In.TexCd.y * tilecount.y % 1);
return tex2D( Samp, newUv );
}{CODE}

Thanks this has been illuminating. Both methods actually work in Svvvvitcher’s Post FX I learned…

{CODE(ln=>1)}float2 tilecount;

float4 PS(vs2ps In): COLOR
{
float2 newUv = float2(In.TexCd.x * tilecount.x % 1, In.TexCd.y * tilecount.y % 1);
return tex2D( Samp, newUv );
}^