Search Unity

How is it possible to set mainTextureScale on the lwrp lit shader ( Tiling )

Discussion in 'Universal Render Pipeline' started by Strieglitz, Aug 12, 2019.

  1. Strieglitz

    Strieglitz

    Joined:
    May 11, 2017
    Posts:
    13
    I was able to do smth like this to strech an material with standartShader in the standart render pipeline.

    Code (CSharp):
    1. Renderer renderer = getComponent<Renderer>();
    2. renderer.material.mainTextureScale = new Vector2(5,1);
    but doing so with the lit shader in lwrp nothing happens.

    tried it with the following, but i guess "Tiling" is not the Right Propety name. Inside the lit shader i couldnt find the Right Property by lookig at it.

    Code (CSharp):
    1. MaterialPropertyBlock block = new MaterialPropertyBlock();
    2. block.SetVector("Tiling",new Vector4(5,1,0,0));
    3.  
     
  2. Nidhii

    Nidhii

    Joined:
    Jan 28, 2015
    Posts:
    26
    Did you find any solution?
     
  3. ismaeel_unity

    ismaeel_unity

    Joined:
    Oct 21, 2019
    Posts:
    12
    use mat.SetTexture("_BaseMap", texture);
     
  4. Robber33

    Robber33

    Joined:
    Feb 22, 2015
    Posts:
    52
    block.SetVector( "_BaseMap_ST",new Vector4(1.0f, 1.0f, 0.0f, 0.0);

    these are set per material
    if you do instance rendering you have to adjust the shader to set tiling for different instances
     
  5. justaguygames

    justaguygames

    Joined:
    Mar 4, 2015
    Posts:
    21
    I have this problem too, did you get it to work?

    EDIT:

    This works, for anyone completely new this is the full code I used:

    Code (CSharp):
    1.   Material m = gridPlane.GetComponent<MeshRenderer>().material;
    2.         MaterialPropertyBlock mblock = new MaterialPropertyBlock();
    3.      
    4.         mblock.SetVector("_BaseMap_ST", new Vector4(5.0f, 5.0f, 0, 0));
    5.         m.mainTexture.wrapMode = TextureWrapMode.Repeat;  // it wasn't repeating for me so I added this
    6.         gridPlane.GetComponent<MeshRenderer>().material = m;
    7.         gridPlane.GetComponent<MeshRenderer>().SetPropertyBlock(mblock);
     
    Last edited: Dec 2, 2019