Skip to main content
gamedev.net
🔒 Locked

D3D9 Texturing problem

Started by protemus Apr 29, 2004 at 9:58 PM 7 replies 900+ views
Original Post
protemus
protemus
I am having a strange problem with directx 9. I am trying to create a 2d user interface that pops up in front of my 3d app, while the backround 3d is still going on. I do all my 3d rendering, then switch the projection to orthographic and render the 2d elements last. I have been working in 640 by 480 mode for testing, and when I switched to a higher resolution, some of my 2d textures that are drawn on very large polygons are getting distorted. The polygon boundrys are ending on the correct pixel marks in all places, but the texture seems to be wobbling vertically. Note: There is NO distortion in 640 by 480 I am rendering textured quads with textures on the ^2 mark. 8x8 textures on a 8 x screenwidth quad. the problem quads Used to be stretching the texure the width of the screen (because it is a border and the texture is uniform accross the X axis), So, I thought the distortion may have been from stretching such a small texture over such a large space, but when I switched the app to tile the textures, I get the same problem. (I verified that the texture is correctly tiling by using a non uniform texture so I could see the tile.) does anyone have any ideas? I am trying to create custom widows by hand that can be sized, so the tile texture is neccessary. Unless I want to go crazy and waste resorces by tiling the actual polygons instead of the texture..... Bummed out.
-- * The source of all my problems is in the source * --
Supernat02
Supernat02
Is there any way you could get a screenshot of what''s happening, or a series of shots and make a movie? Also, I assume you are using 3D coordinates with an orthogonal projection. Does the quad wabble when you don''t move the camera?

Have you thought about using 2D RHW coordinates without changing the projection matrix or more simply D3DXSprites? I have made hi-res windows with RHW without any problems. That would be something quick and easy to try out.

What is your presentation interval? Also, do you turn filtering for min, mag, and mip off before drawing the windows (I assume they''re the last step in your render code)?

I''ve read somewhere that if you use orthogonal projections (and this may only apply to DX8, I don''t know), you should set the texture coordinates to 0.5 less than what you really want. So, if you want the quad to take up the entire screen, it would be:

(-0.5, -0.5) to (639.5, 479.5).

Again, I''ve read this and it may be a different topic, but I''m just throwing it in.

Chris ByersMicrosoft DirectX MVP - 2005
Supernat02
Supernat02
You create quads with D3DFVF_XYZRHW, x is for screen coordinate x in pixels, y is for screen coordinate y in pixels (where both = 0 in upper left corner), and just set z and rhw to 1.0f.

So, instead of having 3 floats for your 3D model, you can have 4 floats for a 2D model. Now how''s that for confusing! Anyway, creating D3DXSprites are the easier way to do that. As far as I know, that''s what they do. There was also an update with the Sprites in DX 9, and I remember that their speed was dramatically increased, so give them a try and see what you think.

The reason I asked about your presentation interval is that it''s possible you might be seeing tearing if you''re updating the display faster than your vertical retrace. For a quick test to see if that''s your problem, set the PresentationInterval parameter of your presentparameters object to D3DPRESENT_INTERVAL_ONE. This will make the video card wait for the vertical retrace before swapping buffers.

Good luck,
Chris

p.s. Transformations don''t apply when using transformed vertices (XYZ_RHW), so you don''t have to set them to anything.
Chris ByersMicrosoft DirectX MVP - 2005
protemus
protemus
ok, I''ll give the sprites a go.

incidentally, I have the presentation interval set to 1, and accross the frames, the image that gets displayed is static. when I said "wobble" I meant that it wobbled on the y from x=0 to x=800, so instead of giving a straight line horizontally accross the screen, in gave a wobbly line... (only off by 1 pixel though). If the presentation interval was causing tearing, I would imagine that the image would change slightly accross the frames. What I see is a fixed image that just isn''t correct.

I will start writing some sprite code, but I was hoping to get a clear understanding of what was going wrong. The displayed problem is most likely an indication that I am doing something fudamentally wrong, and I imagine it will start manifesting itself in other ways when I start using texturing on the 3d part of the UI.

Thanks for all your help so far... I imagine I will be needing a lot of help in the time to come and from browsing the rest of this forum, it is good to see such a benevolent community out there....

-- * The source of all my problems is in the source * --
Supernat02
Supernat02
A screenshot would be most useful. I can''t quite follow what the image is doing. Is one column of pixels right, the next column is 1 pixel too low, the next column is right, the next one is 1 pixel too low? Or do you mean the entire texture is 1 pixel too low every other texture? Can you post the code for when you create the quads for the window?

Thanks,
Chris
Chris ByersMicrosoft DirectX MVP - 2005
protemus
protemus
sure... I will have to get to my house first though, Then I will upload some code. I don''t have any public web storage, though, so can I email you with the screen shots?
-- * The source of all my problems is in the source * --
Supernat02
Supernat02
Sure thing!
Chris ByersMicrosoft DirectX MVP - 2005

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.