Search Unity

Is it possible to flatten a 3D scene into a 2D image?

Discussion in 'Editor & General Support' started by chrissunity, Aug 19, 2019.

  1. chrissunity

    chrissunity

    Joined:
    Aug 19, 2019
    Posts:
    6
    Hi,

    I created a 3D scene in unity3D where camera viewing direction coincides with my eye viewing screen direction, and two objects along the viewing direction at different distances. I would like to flatten the viewing scene and export it as a 2D image. Is it possible?

    Thanks
    P.S. I am using 2019.2.1f1 release on ubuntu18.04.
     
  2. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    You mean "render"?
    Or setting camera to be orthographic?
     
    Kiwasi likes this.
  3. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
    Here is our in game map camera, its a isometric camera pointing down on the world

    Code (CSharp):
    1.  
    2. var rect = RealtimeMapImage.GetComponent<RectTransform>();
    3. mapCamera.aspect = rect.rect.width / rect.rect.height;
    4.  
    5. mapCamera.targetTexture = new RenderTexture(mapCamera.pixelWidth, mapCamera.pixelHeight, 24);
    6.  
    7. mapCamera.Render();
    8. RealtimeMapImage.texture = mapCamera.targetTexture;
    9.  
    Looks like this in game

     
    Martin_H and Antypodish like this.
  4. chrissunity

    chrissunity

    Joined:
    Aug 19, 2019
    Posts:
    6
    The 3D scene is orthographic. I would like to convert it to a 2D perspective image.
    Thank you
     
  5. chrissunity

    chrissunity

    Joined:
    Aug 19, 2019
    Posts:
    6
    Thank you for sharing the code segment. I will look into it.
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,160
    ...what?

    Give us an example of what you're trying to do, because you're really not making a lot of sense here.
     
    SparrowGS likes this.
  7. FMark92

    FMark92

    Joined:
    May 18, 2017
    Posts:
    1,243
    Print screen?
     
    Joe-Censored likes this.
  8. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,780
    To me it sounds like you want to create impostor equivalent. Or relevant. Or simple 2d image of 3d scene, which can be output on ingame tv/screen. Either way, look at Andrew example and try it. Use different angles of the camera.
     
  9. AndersMalmgren

    AndersMalmgren

    Joined:
    Aug 31, 2014
    Posts:
    5,358
  10. Edna4978

    Edna4978

    Joined:
    Aug 20, 2019
    Posts:
    1
    The set of all possible 3D scenes for a movie is really smaller than the set of all 3D scenes dqfansurvey.
     
  11. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    If it's a background image then you could render it to a skybox. I think reflection probes do this automatically not sure how to convert their texture into a skybox.