Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Object is strangely flickering..

Discussion in 'General Graphics' started by sdf_eee, Mar 28, 2017.

  1. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    flickering.gif flickering_2.gif

    Information:

    tile's GameObject scale is Vector3.one(1, 1, 1).
    The distance between tiles is 1.
    This is originally a 32 bit texture game, but the GIF tool was made into low quailty. (it's not exactly 16bit. thx jvo3dc)
    plz consider this.

    Question:
    Outline(it just mesh & texture. not a shader things) of these tiles are very flickering. how can I fix it?
    (At first I thought this was a z-fighting problem. then I try to control near-far plane values but not working.)

    and, why are all the tiles' textures blinking?
     
    Last edited: Mar 29, 2017
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Changing the clip planes doesn't guarantee a solution to z-fighting. The best solution in my opinion is to actually have 0 distance between the two objects. Any small difference can lead to z-fighting, but rendering the exact same object twice won't. You do have to make sure the vertex shader is exactly the same for the part that calculates the clip space position of the vertices.

    Offtopic: GIF uses a 8 bit index (or palette) with 24 bit colors. 16 bit and GIF don't really make sense.
     
  3. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    I knew now about GIF details. Thank you very much for sharing your knowledge.
    So are you sure this is z-fighting? If so, I will look for more ways in that direction.
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    I'm not sure it's z-fighting, but I am sure that changing clip planes doesn't always solve it. It's a bit hard to see on the gif. Maybe turn it in to an actual video?
     
  5. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55


    This is recorded with everyplay. If you look close, you will see some lines are flickering in the edges.

    ex)
    upload_2017-3-30_12-57-58.png

    Marked white line appears, and disappear when camera moves.

    upload_2017-3-30_12-59-53.png

    These too.

    Also tiles are flickering too much. any idea?
     

    Attached Files:

    Last edited: Mar 30, 2017
  6. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Well, if the lines are separate objects, z-fighting. You should always try to avoid these type of overlay solutions. These lines can simply be applied to the boxes by a texture.
     
  7. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Actually, it is simple cube,

    upload_2017-3-30_19-4-44.png

    and textured / and uv-mapped like below. Lines are part of texture.

    upload_2017-3-30_19-2-10.png

    screenshot taken in blender.

    and finally, scale (size) and positions are all integer, so it does not have to do with overray at all (at least I think)

    so I dont think this is z-fighting problem. are you sure about that? thanks.
     

    Attached Files:

  8. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    In that case it should not be z-fighting. What are the import settings on the texture?
     
  9. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    upload_2017-3-31_14-44-34.png

    all tile's textures are imported with this setting - using unity 5.5.2p4.
     
  10. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,248
    On the white cubes, that's probably an artifact of MSAA causing it to sample the texture outside the UVs. You probably want to fill the white area with the outline color, and maybe increase the gutter between faces.

    The way MSAA works is it tests if a triangle is overlapping one or more of N subpixel points (i.e.: 4x MSAA tests 4 subpixel locations), but it still renders at the center of the pixel. That means it's possible the position being rendered is actually outside the surface of a triangle.
     
  11. sdf_eee

    sdf_eee

    Joined:
    May 30, 2015
    Posts:
    55
    Actually, I was testing with MSAA off and tried most of the ways - like fill white area with outline color, or fill with transparent, increase gutter, reduce gutter, add some paddings with outline color, transparent, white and etc. so Im out of idea :(