Jump to content
  • Advertisement
Sign in to follow this  
pulo

Iso-/Dimetric tile texture has jagged edges

This topic is 852 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So i am trying to render a small isometric tile-map and just started with a single tile to feel the thing out. But i am running into a problem where if the tile gets jagged edges, even though it looks ok on the texture itself. The strange thing is that it also appears to be right if i use the Graphics Debugger in Visual Studio (And that is because it tile gets displayed a little smaller than the real one - slighty zooming in has the same effect). Here is a picture to better visualize what i mean:

 

4CNt0Yr.png

 

The left picture is a part of the rendered frame inside a normal window. The right part is the captured frame for the graphics debugging tool. As you can see the display for the captured frame looks completely ok. The normal rendering inside a window also starts to look good if i scale this tile up by some factor.

 

Here is my Sampler Desc. I am creating the texture by using the CreateDDSTextureFromFilemethod provided by the DirectXTK (https://github.com/Microsoft/DirectXTK).

CreateDDSTextureFromFile(gfx->GetGraphicsDevice()->GetDevice(), L"resources/tile.DDS", nullptr, shaderResource.GetAddressOf())

ZeroMemory(&g_defaultSamplerDesc, sizeof(D3D11_SAMPLER_DESC));
g_defaultSamplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; //D3D11_FILTER_MIN_LINEAR_MAG_POINT_MIP_LINEAR
g_defaultSamplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
g_defaultSamplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
g_defaultSamplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
g_defaultSamplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
g_defaultSamplerDesc.MinLOD = 0;
g_defaultSamplerDesc.MaxAnisotropy = 1;
g_defaultSamplerDesc.MaxLOD = D3D11_FLOAT32_MAX;

I checked the .dds file and there is only 1 Mip-Level. Here is also the Texture description which the DirectXTK method is using. Seems fine to me:

Width 64 unsigned int
Height 64 unsigned int
MipLevels 1 unsigned int
ArraySize 1 unsigned int
Format DXGI_FORMAT_B8G8R8A8_UNORM (87) DXGI_FORMAT
+ SampleDesc {Count=1 Quality=0 } DXGI_SAMPLE_DESC
Usage D3D11_USAGE_DEFAULT (0) D3D11_USAGE
BindFlags 8 unsigned int
CPUAccessFlags 0 unsigned int
MiscFlags 0 unsigned int

And for what it's worth here is also my Vertex-Setup:

Vertex v[] =
{
Vertex(-32.f, -32.f, 1.0f, 0.0f, 1.0f),
Vertex(-32.f, 32.f, 1.0f, 0.0f, 0.0f),
Vertex(32.0f, -32.f, 1.0f, 1.0f, 1.0f),
Vertex(32.0f, 32.f, 1.0f, 1.0f, 0.0f)
};

Any idea what might be causing this? This also happens with other dimetric textures.

 

Full disclosure: I also asked this question on stackoverflow, but since i have got no real reply (beside some nice help from one fella) for 5 days i am getting a bit desperate, especially because i already tried a lot of stuff. Here is the original question: http://stackoverflow.com/questions/36068768/isometric-tile-has-jagged-lines

Edited by pulo

Share this post


Link to post
Share on other sites
Advertisement

My best guess is that you're running into an issue with fill conventions: https://msdn.microsoft.com/en-us/library/windows/desktop/cc627092%28v=vs.85%29.aspx
Basically, in the "clipped" portion of the triangle, the "edge" of your triangle is not to the top-left of the center of the pixel.
You can try turning on multisampling to resolve the issue.

EDIT: It also appears you're using alpha along the edge of the texture. If you're doing this to anti-alias the edge, you're going to want multisampling on anyway, and you might even want to enable alpha-to-coverage: https://msdn.microsoft.com/en-us/library/windows/desktop/bb205072%28v=vs.85%29.aspx#Alpha_To_Coverage

Edited by nfries88

Share this post


Link to post
Share on other sites

I had a similiar issue once, and it turned out I was doing windowed mode wrong in terms of calculating the window size to fit the backbuffer
size etc., resulting in a vaguely stretched display that was hard to notice for a long while.. Maybe you could check your window+DirectX
initialisation code?


I was going to say the same thing. You want to make sure that the client area of your window is the same size as your D3D backbuffer,
otherwise you'll get really crappy scaling when the backbuffer is blit onto the window. You can use something like this:
 
RECT windowRect;
SetRect(&windowRect, 0, 0, backBufferWidth, backBufferHeight);

BOOL isMenu = (GetMenu(hwnd) != nullptr);
if(AdjustWindowRectEx(&windowRect, style, isMenu, exStyle) == 0)
    DoErrorHandling();

if(SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOMOVE) == 0)
    DoErrorHandling();
See the docs for AdjustWindowRectEx for more details. Edited by MJP

Share this post


Link to post
Share on other sites

I had a similiar issue once, and it turned out I was doing windowed mode wrong in terms of calculating the window size to fit the backbuffer size etc., resulting in a vaguely stretched display that was hard to notice for a long while.. Maybe you could check your window+DirectX initialisation code?

 

 


I was going to say the same thing. You want to make sure that the client area of your window is the same size as your D3D backbuffer,
otherwise you'll get really crappy scaling when the backbuffer is blit onto the window. You can use something like this:
 
RECT windowRect;
SetRect(&windowRect, 0, 0, backBufferWidth, backBufferHeight);

BOOL isMenu = (GetMenu(hwnd) != nullptr);
if(AdjustWindowRectEx(&windowRect, style, isMenu, exStyle) == 0)
    DoErrorHandling();

if(SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, windowRect.right - windowRect.left, windowRect.bottom - windowRect.top, SWP_NOMOVE) == 0)
    DoErrorHandling();
See the docs for AdjustWindowRectEx for more details.

 

 

Thank you! Both of you! That was indeed my problem. I was so focused on checking the pipeline that i totally forgot about the window/directx initialization.

EDIT: If any of you two also want to answer the question on stackoverflow, feel free to do so. I will wait till tomorrow and just accept the first answer that comes. Otherwise i will just answer the question myself and link to this thread.

Edited by pulo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!