Search Unity

Line rendering problem

Discussion in 'Editor & General Support' started by rasq, Apr 28, 2011.

  1. rasq

    rasq

    Joined:
    May 25, 2009
    Posts:
    51
    Hi,
    i have some problem with rendering lines in Unity3d, all geometry like a lines, or gaps are very low quality.

    On attachment You have a sample. This roads are geometry, from near view ther are ok, but when I zoomout they are shredded.

    I am using deffered rendering, NFAA and some other postproces, but without them this roads also bad quality.

    Maybe someone have any ideas how to improve rendering in unity?
    I know that AA in deffered rendering are broken, but in forward i have also problem with it.


    Thx for all reply.
     

    Attached Files:

  2. theinfomercial

    theinfomercial

    Joined:
    Sep 9, 2008
    Posts:
    1,000
    The geometry is being shredded because there aren't enough pixels to render such thin lines at the distance. AA would help, but no engine in the world is going to display parts of geometry that can't fit into the width of one pixel.
     
  3. rasq

    rasq

    Joined:
    May 25, 2009
    Posts:
    51
    I know this, but many engines have some algorithms to prevent shreddering.

    This is possibe to render thin lines or not render them at all when they too far from camera and we don`t have that much pixels.

    But how to achive?
     
  4. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Forward rednering and high AA would be a solution. Another way would be if the ground was just one mesh with a high res texture on it. then it would mip map and aniso in the distance and look very smooth.
     
  5. stimarco

    stimarco

    Joined:
    Oct 17, 2007
    Posts:
    721
    The problem you are showing us in your screenshot is called aliasing and is caused by the finite resolution of the computer's display being rather low. The only technically correct solution is to get a better display with a much higher pixel density, but nobody's making 300 dpi displays (yet; I think it's pretty clear Apple want to go in this direction sooner rather than later).

    You may be able to reduce the aliasing by writing a screen-space shader that blurs the pixels a bit, using the Z buffer to ensure it only bothers blurring the pixels that are some distance from the camera. You'll still get some jagged edges when close-up, but it's a tradeoff between jaggy sharpness and soft, blurry smearing. People are used to the background being a bit foggy and indistinct the further away it is from the eye, so limiting the effect to pixels with a higher Z depth should work tolerably well.
     
  6. rasq

    rasq

    Joined:
    May 25, 2009
    Posts:
    51
    Heh, on this screenshot i`am using: AAx16 but deffered rendering, on forward i was this same problem.

    Unfortunetly this lines are geometry, because on this map you can zoom in to FPP, and i have FSAA shader, this is very good solution byt only for near camera objects. :/
     
  7. skantron

    skantron

    Joined:
    May 5, 2011
    Posts:
    35
    you can try making your line meshes a transparent/diffuse material with the edges of the lines transparent. this will give you nicely AAed lines (a texture 1 pixel by 8 , with like the 4 pixels in the middle opaque and the 2 on either side transparent is where I would start for this). You may need to set filtering to Anisotropic... Mipping may be an issue, but it should fade gracefully rather then look so jagged. It may take some experimenting to get your final solution working.