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

2D transformation of screen segments

Discussion in 'Scripting' started by kent13304, Jan 1, 2014.

  1. kent13304

    kent13304

    Joined:
    Aug 15, 2012
    Posts:
    9
    I'd like to be able to...

    1) Segment the screen into 6 subsegments (3x2 grid)

    2) Apply independent 2D transformations to each subsegment (rotate, translate, and scale)

    3) Render the resulting image to the screen

    I'm guessing the most efficient way to do this is to use a script attached to the camera and write an appropriate OnRenderImage() implementation; however, I'm not clear how to efficiently do the 2D transformations. Does this require calling Graphics.Blit() with a material that has a shader that does these 2D transformations?
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    I would say 6 quads with appropriate UV mapping, along with a rendertexture.

    --Eric
     
  3. kent13304

    kent13304

    Joined:
    Aug 15, 2012
    Posts:
    9
    To be clear, I think you are suggesting using 6 cameras each rendering to a different render texture placed each on a different quad and then a 7th camera that views the 6 quads. Correct?

    I guess I was hoping for something much more efficient. I was thinking a single camera with a custom post effect would work but I'm really not clear how to do the 2D transformations in the shader used by the material referenced by Graphics.Blit().
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    No, one camera. There's no reason to use 6 cameras when you would just have 6 quads with appropriate UV mapping and a single rendertexture.

    --Eric
     
  5. kent13304

    kent13304

    Joined:
    Aug 15, 2012
    Posts:
    9
    I see. So, one camera to render to a texture, 6 quads with different transformations and uv offsets, and 1 camera viewing the 6 quads.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Exactly.

    --Eric