Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

XNA wrong quad color interpolation.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 winsrp   Members   -  Reputation: 218

Like
0Likes
Like

Posted 30 July 2012 - 02:27 PM

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.

blend test.jpg

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

blend test 2.jpg

Sponsor:

#2 jrh2365   Members   -  Reputation: 353

Like
0Likes
Like

Posted 30 July 2012 - 09:11 PM

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.

#3 winsrp   Members   -  Reputation: 218

Like
0Likes
Like

Posted 31 July 2012 - 10:01 AM

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.

#4 Koder4Fun   Members   -  Reputation: 146

Like
0Likes
Like

Posted 21 August 2012 - 07:59 AM

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

#5 AmzBee   Members   -  Reputation: 414

Like
0Likes
Like

Posted 21 August 2012 - 06:38 PM

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:

Posted Image

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

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, 21 August 2012 - 06:41 PM.

Aimee Bailey
Lead Programmer / Co-Founder

http://xpod-games.com
@XpodGames




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS