Jump to content
  • Advertisement
Sign in to follow this  
winsrp

XNA wrong quad color interpolation.

This topic is 2161 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

So,

I made a simple quad, assigned 4 colors, and displayed the quad. The interpolation of colors on the center edge (diagonal) of the quad is wrong. Anyone knows how to fix this?

This is the wrong one, can you see the blue color in the diagonal... going into the green.

[attachment=10357:blend test.jpg]

This is one done in dx10 and looks good (got it from the web)

[attachment=10358:blend test 2.jpg]

Share this post


Link to post
Share on other sites
Advertisement
For a start, try changing your vertex color from Color.Green (0, 128, 0) to Color.Lime (0, 255, 0) and see how that looks.

Share this post


Link to post
Share on other sites
its almost the same thing... the worst case is when I do it with 3 vertex with black and 1 with white.. depending on where the white vertex is, it looks way different, will post a screen later on, as I'm at work right now.

Share this post


Link to post
Share on other sites
GPUs operate only on triangles so, to have the same shading, you need that colors on vertices are the same and that the triangulation is the same (a quad is composed by 2 triangles).

However your quad (I think XNA shot it's the first) seem to be rotated of 90° around the axis you are looking.
I don't know if you use or not a camera.
If you directly render quad vertices without transformations you may be need to swap X/Y components and set Z (the depth onto the screen) to 0.0.

Also if you put the quad vertices directly to the shader use the Vector4 and specify a W = 1.0. (so {X, Y, 0.0, 1.0} ).
W=1.0 indicate a position and not a direction vector. This fourth component is important when you use matrix transforms onto the shaders.

Another thing: XNA is based on directX 9.0c that is a slightly different from DX 10 and later.

Share this post


Link to post
Share on other sites
I hope you do realise that the DX10 sample you've provided is actually a quad with a texture mapped onto it don't you? Because your quad is made up of two triangles, there will not be any interpolation between red and yellow, hopefully my modification of your image will illustrate why:

interop.jpg

[s]See there is no centre point, on the DX10 one you have is like a sky blue. Hope this helps.[/s]

Scrap that, just realised that the DX10 one looks the same if you rotate it anti-clockwise by 90 degrees lol.

Aimee Edited by AmzBee

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!