1
DotNet / Textured Quad blending problem (Solved)
« on: February 19, 2015, 08:52:21 pm »
I am having a strange problem, and forgive me if this has been solved as I've looked through quite a bit of the forums and found one other issue similar to this but it wasn't really resolved other than "Write a pixel shader" (which I don't really know how to do).
I am currently rending a 2d grid of 64x64 tiles using a vertexarray and quads.
I am using the following function to add quads with per vertex alpha blending to my vertex array:
Using this method I am getting some strange blending results which I can only assume are coming from OpenGL translating my quad into 2 triangles.
Here is an example of 2 different "fringes" being generated on the fly, #1 (V0, V1, V3) with an alpha of zero this works.
But #2 (V0,V1,V2) with an alpha of zero does the blend improperly.
Here is a close of how I think the triangles are being rendered properly.
Here is an improper alpha blend:
Is there anything I can do to make the alpha blend occour across the whole quad and not just the individual triangles?
A
I am currently rending a 2d grid of 64x64 tiles using a vertexarray and quads.
I am using the following function to add quads with per vertex alpha blending to my vertex array:
// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public void AddGroundTileWithAlphaAndColorAndTransparency(float X, float Y, int TileNumber, int Scale, Color V0, Color V1, Color V2, Color V3)
{
FloatRect MyGraphic = Tool_GetRectForTile(TileNumber, 64, Texture);
Vertex MyVert1 = new Vertex(new Vector2f(X, Y), V0, new Vector2f(MyGraphic.Left, MyGraphic.Top));
Vertex MyVert2 = new Vertex(new Vector2f(X + Scale, Y), V1, new Vector2f(MyGraphic.Left + MyGraphic.Width, MyGraphic.Top));
Vertex MyVert3 = new Vertex(new Vector2f(X + Scale, Y + Scale),V2, new Vector2f(MyGraphic.Left + MyGraphic.Width, MyGraphic.Top + MyGraphic.Height));
Vertex MyVert4 = new Vertex(new Vector2f(X, Y + Scale), V3, new Vector2f(MyGraphic.Left, MyGraphic.Top + MyGraphic.Height));
VT_VertexData.Append(MyVert1);
VT_VertexData.Append(MyVert2);
VT_VertexData.Append(MyVert3);
VT_VertexData.Append(MyVert4);
}
public void AddGroundTileWithAlphaAndColorAndTransparency(float X, float Y, int TileNumber, int Scale, Color V0, Color V1, Color V2, Color V3)
{
FloatRect MyGraphic = Tool_GetRectForTile(TileNumber, 64, Texture);
Vertex MyVert1 = new Vertex(new Vector2f(X, Y), V0, new Vector2f(MyGraphic.Left, MyGraphic.Top));
Vertex MyVert2 = new Vertex(new Vector2f(X + Scale, Y), V1, new Vector2f(MyGraphic.Left + MyGraphic.Width, MyGraphic.Top));
Vertex MyVert3 = new Vertex(new Vector2f(X + Scale, Y + Scale),V2, new Vector2f(MyGraphic.Left + MyGraphic.Width, MyGraphic.Top + MyGraphic.Height));
Vertex MyVert4 = new Vertex(new Vector2f(X, Y + Scale), V3, new Vector2f(MyGraphic.Left, MyGraphic.Top + MyGraphic.Height));
VT_VertexData.Append(MyVert1);
VT_VertexData.Append(MyVert2);
VT_VertexData.Append(MyVert3);
VT_VertexData.Append(MyVert4);
}
Using this method I am getting some strange blending results which I can only assume are coming from OpenGL translating my quad into 2 triangles.
Here is an example of 2 different "fringes" being generated on the fly, #1 (V0, V1, V3) with an alpha of zero this works.
But #2 (V0,V1,V2) with an alpha of zero does the blend improperly.
Here is a close of how I think the triangles are being rendered properly.
Here is an improper alpha blend:
Is there anything I can do to make the alpha blend occour across the whole quad and not just the individual triangles?
A