Search Unity

Material HDRP changing texture scale at runtime doesn't work

Discussion in 'Shaders' started by CrymX, Jul 23, 2019.

  1. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    Hello guys, i have some simple code there :

    Code (CSharp):
    1.  
    2.         MeshRenderer.sharedMaterial.mainTextureScale = new Vector2(1, textureRepeat);

    My texture is set as : Wrap Mode : Repeat.

    My code works well with the shader unlit/Texture but with HDRP/Lit changing the scale does nothing.

    I'm missing something with HDRP ?

    Thanks !
     
  2. jRocket

    jRocket

    Joined:
    Jul 12, 2012
    Posts:
    700
    The "_MainTex" is no longer used in the HDRP lit shader so that shortcut won't work. I'm not sure what the replacement would be, but you can try
    SetTextureScale("_BaseColorMap")
    , or
    SetFloat("_InvTilingScale")
     
    CrymX likes this.
  3. CrymX

    CrymX

    Joined:
    Feb 16, 2015
    Posts:
    179
    HeyjRocket,
    Code (CSharp):
    1. SetTextureScale("_BaseColorMap")
    works like a charm. Many thanks !
     
    ricardomaroquio likes this.
  4. ricardomaroquio

    ricardomaroquio

    Joined:
    Jul 31, 2015
    Posts:
    1
    Yes... "_BaseColorMap" is the guy... Afff... Saved my day!
     
  5. Noeinz

    Noeinz

    Joined:
    Jun 1, 2013
    Posts:
    14
    renderer.material.SetTextureScale("_BaseColorMap", tileScale);

    Thanks!!!!!
     
  6. SeveQStorm

    SeveQStorm

    Joined:
    May 7, 2013
    Posts:
    7
    This does not seem to work if you have a UV map with separate islands. As soon as you set a different scale than 1.0 in each direction, the UV map does not fit the mesh anymore. At least for me. Do you have a solution for this problem?