Search Unity

MirrorReflection4 seems to ignore m_TextureSize, can't get high resolution mirror to work

Discussion in 'Scripting' started by ell1e, Apr 17, 2021.

  1. ell1e

    ell1e

    Joined:
    Apr 4, 2021
    Posts:
    15
    So, I tried out adding a mirror into my game using this:

    https://wiki.unity3d.com/index.php/MirrorReflection4

    ... with the only relevant change being the update from
    GL.SetRevertBackfacing(true); to GL.invertCulling = true; since the editor told me to, and using reflectionCamera.useOcclusionCulling = false; since otherwise it would glitch out badly.

    However, once I change m_TextureSize I get no effect. I can set it to as high as 1024 and as low as 16, and get no visual change. Not even after restarting the editor. It looks like it's rendering in something about the 128 range, which just makes the reflection look a tiny bit too potato. Does anyone happen to know why the RenderTexture size in this script could possibly be ignored like that? I tested it out in Unity 2021.1.3f1. Is there maybe something in the Player Settings with which I could have accidentally overridden this?
     
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,791
    It should work, screenshots?
     
    ell1e likes this.
  3. ell1e

    ell1e

    Joined:
    Apr 4, 2021
    Posts:
    15
    Ok, so I figured out the problem by reverting some other which I thought minor change that I had forgotten about, which caused the issue. I had changed this:
    Code (csharp):
    1. public int m_TextureSize = 128;
    To this:
    Code (csharp):
    1.  [HideInInspector]
    2.     public int m_TextureSize = 128;
    ... and then changed the value in the code, since I preferred having central control over all mirror instances like that. The result however was, that apparently even after a complete editor restart, any changes to that value in the file were ignored and it stuck with the one it had when I removed the "HideInInspector" part. Is there some special annotation I am supposed to use so it actually picks up the current recent value from inside the code instead of the outdated, stored one?
     
  4. - Make it private if you can (if you don't use it from other scripts)
    - or add
    [System.NonSerialized]
    https://docs.unity3d.com/ScriptReference/NonSerialized.html
     
    ell1e likes this.
  5. ell1e

    ell1e

    Joined:
    Apr 4, 2021
    Posts:
    15
    Omg thank you so much, that fixed it!