Skip to main content
GameDev.net gamedev.net
🔒 Locked

XNA wrong quad color interpolation.

Started by winsrp Jul 30, 2012 at 8:27 PM 3 replies 2.2k views
Original Post
winsrp
winsrp
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]
jrh2365
jrh2365
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.
winsrp
winsrp
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.
Koder4Fun
Koder4Fun
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.
Please vote usefull replies.
Marco Sacchi
Coding is a challenge ... but solving problems is the fun part
My Blog - XNA Italian portal
AmzBee
AmzBee
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
We are now on Tumblr, so please come and check out our site!    http://xpod-games.com

Topic Locked

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

Sign in to reply to this topic.