Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

How do i get albedo informatian from some material, using script?

Discussion in 'General Discussion' started by sammtan, May 8, 2021.


Which do u prefer?

  1. Unity Default Terrain

  2. Mesh as Terrain

  1. sammtan


    Jul 2, 2019
    Hi guys, im a noob at scripting.
    How do i get albedo information from some material?
    Basic material have albedo, normal, metallic, specular, anything else base on the shader. Then i want access that albedo, so my script can read that albedo data, for to use with my own purposes.

    For example, i have a mesh, and a terrain. I want to lerp my terrain albedo, with my mesh albedo. Then i create a script, at my mesh, to get the albedo from my terrain. How to do that?

    Also, i need another help.
    Which do you (guys) prefer, unity default terrain or terrain using mesh? Vote at the poll below. Plz

    Every solution and advice are acceptable. Built-in RP.
    Sorry for bad English
  2. neginfinity


    Jan 27, 2013
    It would be better if you said what you're trying to achieve.

    You can't do that easily, because albedo changes for each pixel, if the material is textured.

    If you use Raycast, then you can determine individual triangle you hit from the hit result, and coordinates within the triangle.
    Based on that data you could try determining which material you hit, and then you could manually sample texture, which will only work if the data is readable by the script in the first place.

    You could also try rendering the part of the terrain/mesh you want with a tiny render target and a replacement shader, and read the data from there.

    And in case of built-in terrain, you'd be using this:

    Which will give you access to blend values used by terrain, and then derive the values from there.

    That's why I said it would be a good idea to know what you're trying to do...


    Jun 1, 2017
    I can't tell you how but I know this is done with microsplat/megasplat. I think you can get a free version from the asset store - you could reverse engineer that.