Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: VertexArray Rendering Issues  (Read 4666 times)

0 Members and 2 Guests are viewing this topic.

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
VertexArray Rendering Issues
« on: November 23, 2012, 04:12:16 am »
I recently made a tile map renderer using VertexArrays and noticed that it does not work as expected with an odd window height. Here are some screenshots showing what is happening:

800x600 window: http://i.imgur.com/tcBhK.png
800x601 window: http://i.imgur.com/tYSQS.png

I am using one texture for all tiles so the white you see is from the row below it. I am using SFML.NET.

Code can be found here: https://github.com/Rohansi/Californium/blob/master/Californium/TileMap.cs

Anyone know how I can fix this?


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: VertexArray Rendering Issues
« Reply #1 on: November 23, 2012, 08:06:51 am »
Decimal coordinates can produce this kind of artifact.
Laurent Gomila - SFML developer

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: VertexArray Rendering Issues
« Reply #2 on: November 23, 2012, 09:45:14 am »
Decimal coordinates can produce this kind of artifact.
No decimal coordinates are used (or are floats that inaccurate near zero). It is something in SFML causing inaccuracies in the rendering. Here is another screenshot of a window that I maximized but did not alter the view for. To show that it is displaying part of another tile I added a black pixel to the tile directly below the grey one, shown here.

Using decimal coordinates for a view will create the same artifacts but I am rounding its position. The only code difference for the comparison in the first post is the initial RenderWindow size. I can specify any even height and it will look fine, but odd heights are an issue. It is also worth noting that all widths appear to work with no issues.
« Last Edit: November 23, 2012, 09:48:33 am by TheMagicNumber »

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: VertexArray Rendering Issues
« Reply #3 on: November 24, 2012, 04:21:42 am »
I have found a workaround for this as I was trying to replicate the issue. Offsetting View.Center.Y by 0.5 if View.Size.Y is an odd number will fix it. Although I found this I am still unable to replicate the problem. Resizing the window is the closest I can get it. It still demonstrates strange behavior because resizing the window affects my texture coordinates.

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: VertexArray Rendering Issues
« Reply #4 on: November 26, 2012, 01:59:28 am »
Just got around to trying zooming and I see it again. I'm not really sure of how to get this working correctly, I don't think my VertexArray generation is wrong.

Edit: Just tried offsetting texture coordinates by (0.01, -0.01) and it appears to work in all cases I know of. Strange.
« Last Edit: November 26, 2012, 07:13:05 am by TheMagicNumber »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: VertexArray Rendering Issues
« Reply #5 on: November 26, 2012, 07:57:18 am »
Quote
Just tried offsetting texture coordinates by (0.01, -0.01) and it appears to work in all cases I know of. Strange.
That's what you get when your name is TheMagicNumber ;D
Laurent Gomila - SFML developer

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: VertexArray Rendering Issues
« Reply #6 on: April 18, 2013, 10:20:43 pm »
I was working on this again and realized it affects Sprites too.

800x600: http://i.imgur.com/g4eUQ9d.png
800x601: http://i.imgur.com/UciHz6v.png

I can't use the same workaround for sprites because Sprite.TextureRect is an IntRect.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: VertexArray Rendering Issues
« Reply #7 on: April 18, 2013, 11:13:22 pm »
So is your view still set to integers and your sprites also set to integer?

Anyways it's a known problem, but I haven't seen a really clean fix. What I suggest though, is to change the texture and place a one or two pixel wide transparent line between all the images, so if for some strange reason it shows one pixel further than it should, it will get the transparent line and render nothing there. For not connected entities, this might work well.
But make sure you're not moving the view with decimals, but always round to integers!
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: VertexArray Rendering Issues
« Reply #8 on: April 19, 2013, 12:05:49 am »
The problem has been known since a long time.
http://en.sfml-dev.org/forums/index.php?topic=5952.0

There are many other threads related to this issue, you can find them with the search function.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

TheMagicNumber

  • Jr. Member
  • **
  • Posts: 64
    • View Profile
Re: VertexArray Rendering Issues
« Reply #9 on: April 30, 2013, 04:32:27 am »
So is there any chance of a fix or am I going to need to find something else?

 

anything