Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dex7

Impossible to do pixel PRECISE 2d blits through D3D !

This topic is 6197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

example: i have 256x256 texture which contains a lot of sub bitmaps: cursors,buttons, ...(also to mention i use point filtration - i need to be exact copy of rect from texture) i want to blt rect from (x,y) with dimensions(w,h) so triangle list -> 4 vertices, 6 indexes, i set TU & TV to following: left top vertex : [tu,tv]=[x/texWidth,y/texHeight] right top vertex : [tu,tv]=[(x+w)/texWidth,y/texHeight] right bottom vertex : [tu,tv]=[(x+w)/texWidth,(y+h)/texHeight] left bottom vertex : [tu,tv]=[x/texWidth,(y+h)/texHeight] what happen is that: for example, that it is moved a little to left in texture or so ... WHAT IS STRANGE is that it seems to work precisely when blitting whole texture [0,0]-[1,1] something i should also mention: this problem disapears when PERSPECTIVE CORRECTION is off - but only for SW Renderers - also rhw/z values of vertex have effect on this (i currently set them to rhw=1, z=0 (but also tried all possible other values) ANY HELP? i tried everything, i''m getting mad... - dex

Share this post


Link to post
Share on other sites
Advertisement
Just a little comment.

According to the DirectX SDK doc (I can''t remember where), to be pixel-precice --on the screen-- you have to offset your transformed coord by -0.5, -0.5. (Because I guess you are using transformed vertices)

To blit over 0,0 - 32,32, you have to specify -0.5, -0.5 - 31.5, 31.5.

Maybe it will make a difference.

Share this post


Link to post
Share on other sites
I already had a post about that somewhere else,too, but did not get any reply :-((. I have the same problem when drawing my thin window borders, and I do calculate the vertex coordinates offset by 0.5 in each direction, as told in MSDN. Still the same problem, do you think it would matter if I splitted the file in more pieces, and used each as a separate texture? But then I would also have to create more VB''s, and that''s bad for the performance :-(((.

Share this post


Link to post
Share on other sites
What do you mean by ''in each direction'' ?
You do subtract 0.5 from all coords right? All the coords must be 0.5 unit smaller.

Also, can you show me a screen shot?
Otherwise I am sorry, I am clueless.

Share this post


Link to post
Share on other sites
Hi Dex.
I''m in the same situation as you, but I also have another problem that I wonder if you may have an answer to. Go here if you''re interested to help.

Interesting to meet another GUI developer, have you implemented a lot of controls yet?

Good luck with your project.

Share this post


Link to post
Share on other sites
I think it should overlap it evenly on all sides? Here is a quote from MSDN, maybe I interpret it in a wrong way?
quote:

To map the texture (with a 4 texel width) to the pixel coordinates 0 through 3, you would draw a four-sided polygon (from two triangles) that have screen-space coordinates of –0.5 to 3.5, and texture coordinates of 0.0 to 1.0, respectively.
And also in the picture under that, the screen coordinates overlap the pixels drawn to on all sides...

About the tiling: I ended up putting only those textures in one bitmap which are tiled in the same direction or not tiled at all, i.e. all the corners are in one picture, all the horizontal borders, and all the vertical borders. The horizontal borders are under each other, so that by setting texture coordinates of (0|0)-(20|0.5) I can tile the upper border 20 times, and by using (0|0.5)-(20|1) I can tile the lower one. I have not found any way to tile only a part of a texture :-((



Edited by - asd_de on December 29, 2001 3:39:10 AM

Share this post


Link to post
Share on other sites
so thanks for all replies, i tested a little, read the sdk and came up with this:
(it is good idea to read following topics from sdk first (ihave ver.7):
1. ''Directly Mapping Texels to Pixels''
2. ''Nearest point sampling''
3. ''Triangle rasterization rules''
)

FromSdk: ScreenX = (TextureX (aka tu) * TextureWidth)-0.5f;
same for y

so the trick with setting coords of vertex to [sx-0.5,sy-0.5] works good in SW Rastersizer, however my old Riva128 ignores it

so i tried letting sx,sy as it is and modifing [tu,tv] to [tu+0.5,tv+0.5] which have the same effect on above equation but WORKS! on my Riva128 - the question here is if it does work on other cards , i''ll be happy if u guys test it with your geforce 7231321 cards and let me know here (or mailme at johnpx2@yahoo.com)


Tahrarez: to your tiling problem: if i understood, u want to repeat a portion of texture, like [0.3,0.3]-[0.7,0.7], and u want [0.8,0.8] to be at [0.4,0.4] right?
i think theese render states will do the trick : D3DRENDERSTATE_WRAP[0-7]

bye all



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!