graphics - Help to understand Pixelate effect -


i'm new hlsl , i'm trying understand pixelate sample. however, haven't been able find reference how couple of operations are. here shader example:

//-------------------------------------------------------------------------------------- //  // wpf shadereffect hlsl -- pixelateeffect // //--------------------------------------------------------------------------------------  //----------------------------------------------------------------------------------------- // shader constant register mappings (scalars - float, double, point, color, point3d, etc.) //-----------------------------------------------------------------------------------------  float horizontalpixelcounts : register(c0); float verticalpixelcounts : register(c1);  //-------------------------------------------------------------------------------------- // sampler inputs (brushes, including implicitinput) //--------------------------------------------------------------------------------------  sampler2d implicitinputsampler : register(s0);   //-------------------------------------------------------------------------------------- // pixel shader //--------------------------------------------------------------------------------------  float4 main(float2 uv : texcoord) : color {   float2 brickcounts = { horizontalpixelcounts, verticalpixelcounts };   float2 bricksize = 1.0 / brickcounts;    // offset every other row of bricks   float2 offsetuv = uv;   bool oddrow = floor(offsetuv.y / bricksize.y) % 2.0 >= 1.0;   if (oddrow)   {       offsetuv.x += bricksize.x / 2.0;   }    float2 bricknum = floor(offsetuv / bricksize);   float2 centerofbrick = bricknum * bricksize + bricksize / 2;   float4 color = tex2d(implicitinputsampler, centerofbrick);    return color; } 

i haven't been able understand computation happening in:

float2 bricknum = floor(offsetuv / bricksize); 

i'm not sure how compute division between 2 vectors, , don't know how compute floor of vector. (i'm assuming division of 2 float2 returns float2).

any idea?

hlsl operators , functions work structures float2 has x , y.

the division inside floor returns float2 x , y result of dividing x x , y y. , floor return float2 x , y of result floored value of x , y of input (the result of division).

the same true float3 , other similar structures.


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -