Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to flip Horizontally my Sprite/Texture however the SpriteEffects.FlipHorizontally isn't cutting it for me as it just flips the texture in place.

I want to flip the texture over a specified Vector2/Vector3?


share|improve this question
up vote 2 down vote accepted

some quick resources i found:

C = A - (2 * B * (A dot B)) where A is original vector, B the mirror, C result.

edit: Sorry, I actually forgot what the actual question was. But yeah, you should be able to manipulate UV-values with that formula anyway.


This has the actual formula you wanted.

share|improve this answer
mmm does it work for Point2D? It doesn't seem to in the case where my point2D is (0,0) – Setheron Apr 25 '12 at 16:16
since A dot B would be 0 if A was (0,0) – Setheron Apr 25 '12 at 16:16
Ah, it's cause it reflects as if the vector was from the origin. But my vector isn't at the origin... – Setheron Apr 25 '12 at 16:22 – Toni Apr 25 '12 at 16:41
Sorry. Me brain too weak right now, so above you have actual reliable algorithm instead. – Toni Apr 25 '12 at 16:42

To do this you would most likely have to write a custom shader which provides a mechanism for flipping.

Create your shader and load it as an effect in xna. Then set it before doing any draw calls. You can load this shader through the content manager.

In your shader you will want to change the pixel shader. What you will want to do is mirror the texture coordinate supplied to the pixel shader in the vector. Also, remember to create a global variable, for the vector, which you can set in your xna code trough;

share|improve this answer
but my sprite already has a LocalTransformation? Why Can't I just modify his transformation to flip over the vector. I Just don't know the math – Setheron Apr 25 '12 at 16:07
Sorry, I thought you were wanting to flip the texture applied to the sprite, not the sprite itself. It was your mention of SpriteEffects.FlipHorizontally which confused me. This call is basically doing what I mentioned, but it's flipping the texture in a predefined vector rather than one you define. – OriginalDaemon Apr 25 '12 at 16:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.