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

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:
    319
    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:
    319
    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,618
    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,618
    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.