Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Curved Canvas?

Discussion in 'UGUI & TextMesh Pro' started by LightStriker, Sep 1, 2014.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I'm trying to give the effect of a fighter pilot HUD, which is projected on the curved surface of his helmet.

    However, I can't find out how to do this kind of effect. The canvas doesn't appear to be able to deform its render view.

    The best I can come up with is this;



    Which is rather too linear for my taste.

    Does anyone know how to do it, or if it's even possible?
     
    rakkarage likes this.
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Just an idea, make a camera render a canvas. Then make the camera render to a texture. Then map this render texture onto a curved shape.
     
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Interesting, but I have the feeling that it would be terrible for performance.
     
  4. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    325
    Eh, it's a stable overhead. You'll probably be fine unless you're targeting mobile or low end machines.
     
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Well... I am targeting mobile. :p
     
  6. cowtrix

    cowtrix

    Joined:
    Oct 23, 2012
    Posts:
    325
    Have you considered programmatically setting the positions as a function of their X component at runtime? I.e. as the component gets closer to the middle, increase their Z and set their Y rotation to some sine function. Would look fine as long as you don't have large, solid and horizontal bits of GUI.
     
  7. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    I did... but as you can see from my screenshot, I do have long horizontal bits of GUI.
     
  8. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    The best way to do this would probably be with the fisheye image effect and a dedicated camera, but it's expensive. So what you're doing now is probably the only/best option for mobile, but you might be able to add prerendered images as well to help fake the distortion?
     
  9. JAKJ

    JAKJ

    Joined:
    Aug 17, 2014
    Posts:
    185
    Would fisheye really be less expensive than render-to-texture (since both would require Pro anyway)? I would've expected render-to-texture to be the cheaper of the two, since so little geometry is actually being rendered.
     
  10. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    By "best" I mean "best looking", but it is probably a lot more expensive than render-to-texture.
     
  11. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    file:///Applications/Unity/Unity.app/Contents/Documentation/html/en/ScriptReference/UIVertex.html
    I suggest playing with this one.
     
  12. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Interesting, but I can't find where it's used in Canvas...
     
  13. Ippokratis

    Ippokratis

    Joined:
    Oct 13, 2008
    Posts:
    1,521
    file:///Applications/Unity/Unity.app/Contents/Documentation/html/en/ScriptReference/UI.BaseVertexEffect.html

    It is the base for effects like shadows, outlines.
     
    amadlover and Senshi like this.
  14. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Quite interesting. However, it's only a vertex stream, there is no tris soup - index list, so I have no idea how to insert triangle into the existing structure.
     
  15. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,670
    Every four vertices is one quad.
     
  16. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Ok... Do I understand two quad cannot share the same vertex, or that the same vertex have to be added multiple time in the list?
     
  17. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,670
    Correct, you have to duplicate the vertex.
     
  18. thylaxene

    thylaxene

    Joined:
    Oct 10, 2005
    Posts:
    716
    how about pre-warping the UI elements in PS or AE? You would only need to do digits 0 - 9 and duplicate. It is pretty trivial to wire up some code to swap sprites to do you numbers instead of relying on fonts and setting text.

    Obviously it gets complex if you want onscreen alphabet text then I would go with RT.