Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualShenjoku

Posted 15 April 2013 - 07:36 PM

I'm having some strange issues rendering single-pixel thick lines with DirectX 9 and MSAA, but only on AMD cards. I'm already adjusting the coordinates to convert them from texels to pixels by subtracting 0.5, which works perfectly fine and fixes rendering bugs on NVIDIA cards, but when doing the same on a system using an AMD card the line ends up rendering partially transparent because it's being anti-aliased when it shouldn't be.

 

Here's some sample code to show yout how the coordinates are calculated and how the line is being rendered:

 

// v is the locked vertex data which contains two points and is using an FVF of D3DFVF_XYZ | D3DFVF_DIFFUSE.
//
// x,y,w,h is the position and size of the line. For one thickness lines, either w or h is zero depending on whether it's horizontal or vertical.
//
// kVertexModifier is used to convert from texel to pixel coordinates based on the documentation found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx
const float kVertexModifier = -0.5f;

if (h == 0.0f)
{
	x += kVertexModifier;
	w -= kVertexModifier;
}

if (w == 0.0f)
{
	y += kVertexModifier;
	h -= kVertexModifier;
}

v[0].mSet(fColor, x, y);
v[1].mSet(fColor, x + w, y + h);

// Rendering is done like the following:
device->SetFVF(fFVF);
device->SetStreamSource(0, fVertexBuffer, 0, fVertexSize);
device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

 

I took some screenshots from a test project to show what the problem looks like. Pay attention to the border around the blue rectangle (you'll most likely have to view the full-size image and zoom in to be able to see it):

 

 This is how it looks on a machine with an NVIDIA card.

[attachment=14874:one_thickness_correct.png]

 

This is how it looks on a machine with an AMD card. Notice the border is very transparent compared to the other one.

[attachment=14873:one_thickness_broken.png]

 

I'm banging my head against a brick wall trying to figure out this problem, mainly because any fix that I figure out to make it work for AMD cards doesn't work for NVIDIA cards, and vice-versa. If anyone has any information or leads on how to fix this it would be greatly appreciated.


#3Shenjoku

Posted 15 April 2013 - 07:36 PM

I'm having some strange issues rendering single-pixel thick lines with DirectX 9 and MSAA, but only on AMD cards. I'm already adjusting the coordinates to convert them from texels to pixels by subtracting 0.5, which works perfectly fine and fixes rendering bugs on NVIDIA cards, but when doing the same on a system using an AMD card the line ends up rendering partially transparent because it's being anti-aliased when it shouldn't be.

 

Here's some sample code to show yout how the coordinates are calculated and how the line is being rendered:

 

// v is the locked vertex data which contains two points and is using an FVF of D3DFVF_XYZ | D3DFVF_DIFFUSE.
//
// x,y,w,h is the position and size of the line. For one thickness lines, either w or h is zero depending on whether it's horizontal or vertical.
//
// kVertexModifier is used to convert from texel to pixel coordinates based on the documentation found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx
const float kVertexModifier = -0.5f;

if (h == 0.0f)
{
	x += kVertexModifier;
	w -= kVertexModifier;
}

if (w == 0.0f)
{
	y += kVertexModifier;
	h -= kVertexModifier;
}

v[0].mSet(fColor, x, y);
v[1].mSet(fColor, x + w, y + h);

// Rendering is done like the following:
device->SetFVF(fFVF);
device->SetStreamSource(0, fVertexBuffer, 0, fVertexSize);
device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

 

I took some screenshots from a test project to show what the problem looks like. Pay attention to the border around the blue rectangle (you'll most likely have to view the full-size image and zoom in to be able to see it):

 

 This is how it looks on a machine with an NVIDIA card.

[attachment=14874:one_thickness_correct.png]

 

This is how it looks on a machine with an AMD card. Notice the border is very transparent compared to the other one.

[attachment=14873:one_thickness_broken.png]

 

I'm banging my head against a brick wall trying to figure out this problem, mainly because any fix that I figure out to make it work for AMD cards doesn't work for NVIDIA cards, and vice-versa. If anyone has any information or leads on how to fix this it would be greatly appreciated.


#2Shenjoku

Posted 15 April 2013 - 05:14 PM

I'm having some strange issues rendering single-pixel thick lines with DirectX 9 and MSAA, but only on AMD cards. I'm already adjusting the coordinates to convert them from texels to pixels by subtracting 0.5, which works perfectly fine and fixes rendering bugs on NVIDIA cards, but when doing the same on a system using an AMD card the line ends up rendering partially transparent because it's being anti-aliased when it shouldn't be.

 

Here's some sample code to show yout how the coordinates are calculated and how the line is being rendered:

 

// v is the locked vertex data which contains two points and is using an FVF of D3DFVF_XYZ | D3DFVF_DIFFUSE.
//
// x,y,w,h is the position and size of the line. For one thickness lines, either w or h is zero depending on whether it's horizontal or vertical.
//
// kVertexModifier is used to convert from texel to pixel coordinates based on the documentation found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx
const float kVertexModifier = -0.5f;

if (h == 0.0f)
{
	x += kVertexModifier;
	w -= kVertexModifier;
}

if (w == 0.0f)
{
	y += kVertexModifier;
	h -= kVertexModifier;
}

v[0].mSet(fColor, x, y);
v[1].mSet(fColor, x + w, y + h);

// Rendering is done like the following:
device->SetFVF(fFVF);
device->SetStreamSource(0, fVertexBuffer, 0, fVertexSize);
device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

 

I took some screenshots from a test project to show what the problem looks like. Pay attention to the border around the blue rectangle (you'll most likely have to view the full-size image and zoom in to be able to see it):

 

 This is how it looks on a machine with an NVIDIA card.

[attachment=14874:one_thickness_correct.png]

 

This is how it looks on a machine with an AMD card. Notice the border is very transparent compared to the other one.

[attachment=14873:one_thickness_broken.png]

 

I'm banging my head against a brick wall trying to figure out this problem, mainly because any fix that I figure out to make it work for AMD cards doesn't work for NVIDIA cards, and vice-versa. If anyone has any information or leads on how to fix this it would be greatly appreciated.


#1Shenjoku

Posted 15 April 2013 - 04:36 PM

I'm having some strange issues rendering single-pixel thick lines with DirectX 9 and MSAA, but only on AMD cards. I'm already adjusting the coordinates to convert them from texels to pixels by subtracting 0.5, which works perfectly fine and fixes rendering bugs on nVIDIA cards, but when doing the same on a system using an AMD card the line ends up rendering partially transparent because it's being anti-aliased when it shouldn't be.

 

Here's some sample code to show yout how the coordinates are calculated and how the line is being rendered:

 

// v is the locked vertex data which contains two points and is using an FVF of D3DFVF_XYZ | D3DFVF_DIFFUSE.
//
// x,y,w,h is the position and size of the line. For one thickness lines, either w or h is zero depending on whether it's horizontal or vertical.
//
// kVertexModifier is used to convert from texel to pixel coordinates based on the documentation found here: http://msdn.microsoft.com/en-us/library/windows/desktop/bb219690%28v=vs.85%29.aspx
const float kVertexModifier = -0.5f;

if (h == 0.0f)
{
	x += kVertexModifier;
	w -= kVertexModifier;
}

if (w == 0.0f)
{
	y += kVertexModifier;
	h -= kVertexModifier;
}

v[0].mSet(fColor, x, y);
v[1].mSet(fColor, x + w, y + h);

// Rendering is done like the following:
device->SetFVF(fFVF);
device->SetStreamSource(0, fVertexBuffer, 0, fVertexSize);
device->DrawPrimitive(D3DPT_LINELIST, 0, 1);

 

I took some screenshots from a test project to show what the problem looks like. Pay attention to the border around the blue rectangle (you'll most likely have to view the full-size image and zoom in to be able to see it):

 

 This is how it looks on a machine with an nVIDIA card.

[attachment=14874:one_thickness_correct.png]

 

This is how it looks on a machine with an AMD card. Notice the border is very transparent compared to the other one.

[attachment=14873:one_thickness_broken.png]

 

I'm banging my head against a brick wall trying to figure out this problem, mainly because any fix that I figure out to make it work for AMD cards doesn't work for nVIDIA cards, and vice-versa. If anyone has any information or leads on how to fix this it would be greatly appreciated.


PARTNERS