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
  4. Dismiss Notice

Render Texture not tiling - Wrap Mode Issue?

Discussion in 'General Graphics' started by FuzzyOnion, Feb 24, 2019.

  1. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    Not sure what's happening...

    Can't seem to get my render texture to tile no matter what the wrap settings, is this a bug or a feature?
     
  2. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,447
    It worked in the past for me. So either an issue with the unity version you use or specific to your project. Can you reproduce this issue in a new project? If so I would submit a bug report as it seems to be an unity bug. If it reproduce in your project only, it's probably related to something in your project.
     
  3. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    Yeah, I tried it in a new project, different version, and see the same behavior.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,242
    In what situation? Can you show how you're using it?

    I found in some situations Unity will not actually provide the original render texture, but instead a temporary copy which does not have filtering or wrapping settings copied. The only solution I found to this (apart from significant refactoring of the code to avoid this hidden copy) was to use an inline sampler state.
     
    PrimalCoder likes this.
  5. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    Ah, thank you for the lead. I'm relatively new to Unity and will have to research to know what an "inline sampler state" is or how to have it tile the texture.

    This seems to occur with any render texture.

    I just found out that setting the Anti-Aliasing to 2 or higher on the texture is a work around for this Wrap Mode issue.
    This sucks as I don't need to Anti-Alias my mp4 and I'm worried about the performance on the Oculus Go. :-/ I guess I'll report the issue for now.


    I've tried this in Unity 2018.3.4 and 2018.3.6
     
  6. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    Another note: Setting the Render Texture Depth Buffer to 'no depth buffer' also fixes the wrap mode.
    And on an unrelated note: in the Lightweight Pipeline the Render Textures only filtered in point filtering in the Android builds. Not suitable for my VR project unfortunately, I'll miss using the shader graph.
     
    skullthug likes this.
  7. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,852
    On which device does this happen and with which RT format?
    Some RT formats do not support bilinear filtering on some GPUs. When this is the case, it will fallback to point filter.
     
  8. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    This is on the Oculus Go. I'm doing an mp4 > video player > RT > material on a mesh. Color format - ARGB32.
    With the standard pipeline it works perfectly. On the lightweight it has only given me point filtering.
     
  9. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,852
    @FuzzyOnion Can you please make a bug report? For both issues, if possible :)
     
  10. FuzzyOnion

    FuzzyOnion

    Joined:
    Aug 22, 2014
    Posts:
    31
    Will do!
     
  11. patman

    patman

    Joined:
    Jul 4, 2012
    Posts:
    8
    Thank you so much for this thread. I have been trying to use 2018.3.6f1 on a project I last used with Unity 5. It has worked through Unity 3, 4 and 5, but now my rendertextures were ignoring TextureWrapMode.Repeat and were acting as though they were clamped. When I changed the depth buffer from 24 to 0 as you suggested it worked again. This is not how I wanted to spend the last two days and my brain was becoming clogged with this problem! I'll see if there was any reason the depth buffer needed to be 24, but just seeing these things tiling properly again is a relief.

    My current target is the Mac, but I too am intending to port to the Oculus Go.
     
    skullthug likes this.
  12. MrFigment

    MrFigment

    Joined:
    Jan 5, 2017
    Posts:
    27
    Same problem in 2019.1.3, It works if you create a custom render texture
     
  13. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,447
    Unity staff asked users to submit a bug-report in this thread already, but it seems nobody did so far. Please submit a bug-report as described in this document:
    https://unity3d.com/unity/qa/bug-reporting

    It's important that you report these issues together with a reproduction project if you want them to get fixed. If you don't do it, it might be a long time until someone else reports them or until Unity Technologies find them.

    After you submitted the bug-report, you receive a confirmation email with a bug-report Case number. Please post the Case number (number only, not the link) in this forum thread for Unity staff to pick up.
     
  14. HECer

    HECer

    Joined:
    Mar 17, 2013
    Posts:
    46
    I have the same issue, wrap mode set to repeat doesn't repeat the rendered texture for me as well. On older versions of unity it worked flawlessly (unity 5.6..) now I am using the unity 2019.1.10f1 version.
    I don't want to have Anti-Aliasing activated and also i need the depth buffer to work in repeat mode properly.

    Is there already a solution or a workaround?
     
  15. HECer

    HECer

    Joined:
    Mar 17, 2013
    Posts:
    46
    I reported this issue to unity in a sample project, I hope they will fix this issue very soon. I rely on this function of the render texture.

    RawImage settings (Should tile the rendertexture 3 times on x-axis):
    upload_2019-7-17_9-21-31.png

    Rendertexture WrapMode set to clamp:
    upload_2019-7-17_9-24-58.png

    The result:
    you can only see one rect:
    upload_2019-7-17_9-26-14.png

    Rendertexture WrapMode set to Repeat:
    upload_2019-7-17_9-19-16.png

    The result:
    you can still only see one rect:
    upload_2019-7-17_9-26-14.png
     

    Attached Files:

    PrimalCoder likes this.
  16. HECer

    HECer

    Joined:
    Mar 17, 2013
    Posts:
    46
    Rendertexture WrapMode set to Repeat And Anti-Aliasing to 2 Samples:
    upload_2019-7-17_9-29-24.png

    The result:
    you can see three rects, like it also should show without anti-aliasing turned on:
    upload_2019-7-17_9-30-20.png
     

    Attached Files:

  17. RobAtApex

    RobAtApex

    Joined:
    Jun 19, 2017
    Posts:
    19
    Same bug found here. Worked in 2018.2.2. Upgraded to 2019.2.5 and now it doesn't work. RenderTextures are stuck in clamp mode.

    The antiAliasing solution isn't good for me, because it stops mipmaps from working. But setting depth to 0 works.

    I had no idea that RenderTextures stored a depth buffer as well. Seems like that should be off by default!

    I couldn't find this issue in Unity's issue tracker though, at https://issuetracker.unity3d.com/

    Annoyingly I couldn't find a way to match all words when searching, which is far more useful than matching ANY word (means when entering more words, the search becomes more vague rather than more precise).
     
  18. ExcellencyHong

    ExcellencyHong

    Joined:
    Aug 9, 2016
    Posts:
    32
    you can be able that if set to "No Depth Buffer" of RenderTexture options.
     
    Gangsta-Geek likes this.
  19. bfoddy

    bfoddy

    Joined:
    Mar 27, 2012
    Posts:
    85
    This is still an issue in 2019.2.13. Couldn't find the bug on the bugtracker.
     
  20. Gangsta-Geek

    Gangsta-Geek

    Joined:
    Aug 11, 2012
    Posts:
    32
    Thank you this solved my problem I think. Well it works in Editor
     
  21. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,136
    Is this still a bug because my render textures are not wrapping after moving from 2018 to 2019 on some platforms?(opengl 2 mobile)
     
  22. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    201
    Still a damn bug in 2019.4.13f1. Confirmed setting the depth buffer to No depth fixes it. @HECer can you post a link to the bug report you made?
     
  23. PrimalCoder

    PrimalCoder

    Joined:
    Aug 12, 2014
    Posts:
    9
    Any chance you'd be willing to enumerate some of the situations in which you've seen this occur? This appears to be happening to me right now, and while the inline sampler state workaround works perfectly (thank you for that info btw), I'd like to know if this is happening because of something I'm doing, and whether it would be worthwhile at this relatively early point to engage in "significant refactoring of the code to avoid this hidden copy".
     
  24. NicoLeyman

    NicoLeyman

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    33
    Hi,
    This "bug" should be fixed in 2021.2 and beyond. It hasn't been backported to earlier LTS versions as it was ultimately by design. If a depth component was present on a Render Texture we would internally force the wrap mode to clamp.
    I'll bring this up internally to see if this fix can be backported after all since it can be interpreted as a deliberate regression in a way.
     
    PrimalCoder and andyz like this.
  25. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,136
    hmm the thing is you may need a depth buffer to render what you want into the render texture, but afterwards it is used as a texture and can wrap.
    You can use a temp rendertexture if in code, and copy contents to a texture2d after but this is still clunky (not sure why no CopyRendertextureToTexture() type function as ReadPixels just seems slow and awkward).
     
    CD-WR likes this.
  26. skullthug

    skullthug

    Joined:
    Oct 16, 2011
    Posts:
    201
    Thanks very much for the insight.
     
  27. PrimalCoder

    PrimalCoder

    Joined:
    Aug 12, 2014
    Posts:
    9
    Interesting! I had thought that I had the depth buffer disabled, but I guess I'll have to double check when I get back. I'm certainly not using any depth buffers for what I'm doing...

    [Edited to Add] Definitely no depth buffer enabled. Bummer, I had hoped that would be an easy fix ;-)
     
    Last edited: Apr 9, 2021
  28. ZLR_Games

    ZLR_Games

    Joined:
    Feb 18, 2020
    Posts:
    5
    My render texture has the exact same quirks. I remember setting the anti aliasing, cause i thought it would be nice for my render texture, when i made it. But i got an error in the console, that said anti aliasing wasn't supported. I then naturally turned it off, without know that would make my texture always clamp, no matter the wrap settings.
     
    PrimalCoder likes this.
  29. Spaniel

    Spaniel

    Joined:
    Dec 23, 2012
    Posts:
    52
    Unsure if this is the same issue, but I was making a copy of a RenderTexture in my Assets folder. Every time it created a new one as a copy, it would lose the `Repeat` setting. Had to explicitly set it in code. :(

    _rts[i].wrapMode = TextureWrapMode.Repeat;


    Hope this helps someone stuck in the same boat.
     
  30. ValentinHm

    ValentinHm

    Unity Technologies

    Joined:
    Dec 10, 2020
    Posts:
    13
    It seems the wrapping mode forced to clamp issue when a RT has depth has been fixed both in 2020.3 LTS and in 2021.2 and beyond. At least I haven't been able to reproduce it.
    Same for Spaniel's issue, which version are you using currently ?
    For earlier LTS versions I'd refer you to Nico's message :)
     
    PrimalCoder likes this.
  31. TieSKey

    TieSKey

    Joined:
    Apr 14, 2011
    Posts:
    219
    I'm having almost the same issue on 2022.2.0b15.
    Mirror mode works as clamp. Changing AA and depth values have no effect.
    Repeat mode works.