I dont know why exactly stuff happens, its driving me fucking nuts..really fucking hell nuts
Example:
I have 3 buttons on a texture, Those 3 buttons are displayed on the bottom half of the screen, one bellow the other. Button 1 and 3 are perfect.
Button 2 tears, like its struggling to fit in its pixels. Heres what annoys, it just tears on this spot on the screen, after trying everything (setting pos to perfect ints, rounding UVs, doing that even on the shader) it still tears.
I put the button to move up and down on the screen so I can see what happens. That one little bastard just tears on that specific spot bellow half the screen, Id say in an area covering 50 vertical px, after that, bot above and bellow it doesnt tear anymore.
Now the fact is, if I change the UV coords of the button, say giving it button 1 or 3 UVs, it doesnt tear...so its happening both because pos and UVs..
My positions are in ints, Im setting stuff on pixel coordinates. My backbuffer is definetly at the same size of client coord (1280x720), wich matches exactly my viewport, and my projection Im setting using directX math ortho function, giving the 1280x720 coords also (I know I have pixel coords working fine, if I set to move 1 by mouse click, I can see the sprites moving by one px at a time ).
Heres my sprite shader:
vs_out vs_Sprite( float3 pos_p : POSITION, float2 uv_p : TEXCOORD ){
vs_out output = (vs_out)0;
//vertex scaling
pos_p.xy *= res;
output.pos = mul( float4( pos_p, 1.0f ), mWorld );
//camera(view) trafo:
output.pos = mul( output.pos, mViewProjection );
//on screen coords:
//output.pos = mul( output.pos, mProjection );
//uv offset:
output.uv = uvRect.xy + (uv_p * uvRect.zw);
// just pass color on:
output.color = color;
return output;
}
All my sprites use a vertex buffer specifying a 1.0 scale quad (-0.5f to 0.5f, with 0.0f to 1.0f uvs)
I generally create my texture files as equally spaced sprite sheet, so I easily set uvs like "1.0f/3.0f" instead of using px coords, but I dont see how that could have any influence, since in the shader uvs end up as 0.0 to 1.0 anyway (on the sample function), thats why I generally set myself on the 0.0 to 1.0 range, both easier and practical. (tryed already setting uv width / texture width, to see if would solve any imprecision, the result is the same)
Im using nearest sample, of course using linear smooths the issue, but its not even close to what I call a solution, as it blurs instead of fixing.
Heres a image showing the same sprite, same position on screen, same everything, except the uv coords:
You can see the A and Y have lots of aliasing. It of course, doesnt look like that on the texture file, nor in other positions of the screen.
What can/should I do to avoid that? Something I missed? Is it due the vertex buffer being a -0.5 to 0.5 scaled quad?
This is just an specific example where I tryed to focus to figure it out, other sprites end up tearing when moving on the screen (noting to do with vsync, its not screen tearing). Say I grab a sprite with mouse and use it to translate the sprite, mouse also moves on int coords, I can also notice tearing, like the sprite got shortenned by one px horizontally or vertically. Perhaps Im doing some really noob thing.