Search Unity

Question Specific parameter per object

Discussion in 'Shader Graph' started by Rachan, Mar 23, 2023.

  1. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    774
    Hi there!

    I really want to know how to have a specific parameter for each sprite renderer
    such as 1 tree have a colors or texture per each, if I change, it will not effect other
    trees with same materials

    this is possible?

    Thanks!!!
     
  2. chemicalcrux

    chemicalcrux

    Joined:
    Mar 16, 2017
    Posts:
    720
    Yes, there are a few ways to go about doing this.

    You can use MaterialPropertyBlocks to override specific properties on a per-renderer basis.

    Alternatively, you can just create a material for every object. This is what happens automatically if you access the "material" field on a renderer.

    I don't know enough to say which one of those is "better". I usually use property blocks, though.
     
    Rachan likes this.
  3. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,306
    SRP batcher does not support MaterialPropertyBlocks, so the way to do this in rendering pipelines (at least in 3D) is to use separate material instances (assuming you want to put srp batcher into use).

    However sprite renderer has tint/color property and you can use it to chage color of the sprite.
     
    Rachan and chemicalcrux like this.
  4. Rachan

    Rachan

    Joined:
    Dec 3, 2012
    Posts:
    774
    Ok, so it impossible right? what a pity..
     
  5. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,306
    Execuse me, excluding base texture and color properties of sprite renderer @chemicalcrux provided you already two possible methods to set parameter per instance and you say it's not possible...
    I am confused.
     
    Rachan likes this.