Search Unity

Custom texture wrap modes?

Discussion in 'Shaders' started by Splatypus, Mar 19, 2019.

  1. Splatypus

    Splatypus

    Joined:
    Jul 20, 2013
    Posts:
    4
    In the shader I'm working on, the texture doesn't cover the entire mesh. So I want anything sampled outside of a texture to return a set color (in this case just black). In the inspector, none of the default options (Clamp, mirror, etc) let me do this. Is there any way to make a custom wrap mode, or do I just need to check the bounds manually in the shader?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Unfortunately Unity does not expose the border wrap mode (which does exist). The options are doing it in the shader, or putting a single pixel wide black border on your texture, selecting Border Mip Maps in the texture import settings, and Clamp wrap mode.