Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

assigning rendertexture to non square box

Discussion in 'Immediate Mode GUI (IMGUI)' started by raoul, Jan 15, 2008.

  1. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    I can´t figure out how to correctly assign a rendertexture to a non square gui.box

    First I tried a 512 x 512 rendertexture but it doesn´t clamp to the edges of the box.
    Then I tried to change the cameras aspect ratio, hoping it would keep the remaining part of the rendertexture transparent. But the transparant area is distorted.
    Then I created the rendertexture manually with the same size as the GUI.Box size. This does work but the aspect ratio is wrong and I get the message below:

    Code (csharp):
    1.  
    2. Error assigning 2D rectangle texture to 2D texture property '_MainTex': Dimensions must match
    3.  
    Changing the viewport rect of the cam to fit the rendertexure size doesn´t seem to fix the aspect ratio problem. I get again a distorted rectangle on the rendertexture.

    Anyone knows how to do this?

    Many thanks,
    Raoul
     
  2. Marc

    Marc

    Joined:
    Oct 4, 2007
    Posts:
    499
    I Got that error to when assigning render textures to non power of two dimension boxes. Never got any answer to the problem.

    The way i fixed it was to model geometry in the size i wanted and create an uv map that fit the geometry and use power of two size render textures, then the error went away. But guess that is not an option for gui elements.

    Would love to hear the solution to this problem.

    Edit: The thread i refered to - http://forum.unity3d.com/viewtopic.php?p=59186&highlight=#59186

    Cheers
    Marc.
     
  3. raoul

    raoul

    Joined:
    Jul 14, 2007
    Posts:
    6,722
    Yes, I found your threads. I just wonder how serious the error message is and how to get the right proportions ( or maybe the 2 are related!?). I would think this has to do with the camera viewport and the texture size as was mentioned in your threads. But even when I have the same with/height ratio for both I get a distorted area on the texture.