# Vertical Shear with DirectX

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

## Recommended Posts

Hi, How do I removed any vertical shearing with DirectX 9? I'm using the ID3DXSprite interface. I notice, especially with higher frame rates (like 60 FPS), that every few seconds, as my character is moving, he kind of distorts in a vertical shearing manner. I don't know how to describe it exactly. Any help would be appreciated. -Gauvir_Mucca

##### Share on other sites
It's probably that your presentparameters have a present interval of IMMEDIATE rather than ONE. IMMEDIATE allows you see your framerate accurately. ONE will sync with the monitor refresh rate. When your app is running near the refresh rate of the monitor, you can see tearing with IMMEDIATE.

##### Share on other sites
Gah, beaten by a whopping huge chunk o' minutes. Least I got chicken ASCII art.[/edit]

Well, you said yourself that you weren't sure how to describe it; hopefully I can help figure out what your problem is.

Taken literally, "vertical shearing" would probably mean that your sprite is tilted along the top/bottom edges, rather than being perfectly orthogonal and 90 degrees to everything.:
                         ___-+     +-----------+      ___---    ||           |    +-          ||           |    |           ||  Correct  |    |  Vertical ||           |    |  Shear    ||           |    |       ___-++-----------+    | ___---                 +-

A more common problem is "tearing", where moving objects look like the top half and bottom half are misaligned. This stands out more when objects are moving quickly. The problem is that at the time the monitor displays the current screen data, half of the screen data is updated to the new frame, but the other half of the screen data is still old data, that is in the process of being updated. It looks something like:
+-----------+      +-----------+|           |      |           ||           |      |  Tear     ||  Correct  |     _|_ _ _ _ _ _||           |    |           ||           |    |           |+-----------+    +-----------+

If your problem is indeed the second one, then the solution is to enable VSync. To do this in code, you do this when you create your DirectX Device object. One of the present parameters is PresentationInterval. The value you want for this is probably D3DPRESENT_INTERVAL_ONE. What you likely have is D3DPRESENT_INTERVAL_IMMEDIATE, which means that it doesn't wait for the vertical retrace to present the back buffer to the screen, but presents it immediately. But the first one actually waits for the first vertical retrace, and then presents the back buffer at that point, thus avoiding the tearing effect. (D3DPRESENT_INTERVAL_DEFAULT does roughly the same thing, but is slightly less accurate in favor of consuming less CPU power while waiting for the vertical retrace. This lower accuracy raises the chance that a vertical retrace would be missed, and DirectX would have to wait for the next retrace before the presentation could complete, resulting in a dropped frame. However, this is probably a highly minor problem in most cases.)

##### Share on other sites
Thank you for your responses. However, I am still having problems.

Initially, my PresentationInterval was D3DPRESENT_INTERVAL_DEFAULT.

I set my PresentationInterval to D3DPRESENT_INTERVAL_ONE, but the problem persists.

I notice that the vertical tearing (thanks for correcting my terminology) sort of happens like a wave....the distortion starts at the top and quickly flows down the image of the sprite, until the sprite is no longer torn.

Any other suggestions?

-Gauvir_Mucca

##### Share on other sites
Sounds maybe like "jaggies"? Is the 'tear' just a few pixels offset? If so, you can ussually fix it by running the application at a higher resolution.

Matt Hughson

##### Share on other sites
My resolution is 384x512. So I tried different resolutions:

480x640, 600x800, and 768x1024 (my laptop's max resolution). The distortion still occured, at each resolution.

##### Share on other sites
Quote:
 Original post by Gauvir_MuccaMy resolution is 384x512. So I tried different resolutions:480x640, 600x800, and 768x1024 (my laptop's max resolution). The distortion still occured, at each resolution.

What odd resolutions...? Is your motinor turned on its side?

Sorry that didn't help though. Sounds like it might be a more complex problem than I thought.

Matt Hughson

1. 1
2. 2
frob
16
3. 3
4. 4
5. 5
Rutin
10

• 18
• 13
• 14
• 76
• 22
• ### Forum Statistics

• Total Topics
632149
• Total Posts
3004365

×