Sign in to follow this  
winsrp

XNA wrong quad color interpolation.

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
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 [b]and that the triangulation is the same [/b](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 [b]Vector4 [/b]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 [b]slightly different [/b]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:

[img]http://s10.postimage.org/72yer58fb/interop.jpg[/img]

[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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this