Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Colorize an object based on X,Y and Z coordinates

Discussion in 'Editor & General Support' started by LukasAmmann, Aug 22, 2022.

  1. LukasAmmann

    LukasAmmann

    Joined:
    Aug 5, 2022
    Posts:
    6
    Hello everyone,
    I try to colorize parts of an object based on X,Y,Z coordinates from an Excel sheet. The data import shouldn´t be a problem for me. Is this even possible? And if so how can I pass the coordinates form the C# script to the object.

    Thanks in advance
     
  2. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    105
    you mean if you can use the excel sheet directly inside the C# script?
     
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,988
    would you have example image what it should look like? (like, is setting texture colors or is setting vertex colors enough?)
    i guess the object wont move in space? (just static and set colors once?)
    how many rows you might have there at max?

    some options:
    - build 3d texture from those values, then sample each cell in shader to get color (or mixture of closest colors)
    - iterate all vertices, take closest color from that x,y,z 3d array to pick color
     
  4. LukasAmmann

    LukasAmmann

    Joined:
    Aug 5, 2022
    Posts:
    6
    No, the data import from the Excel sheet into the script isn´t the problem. The problem is how I pass the coordinates from the c# script (that I got form Excel) to the object in Unity.
     
  5. LukasAmmann

    LukasAmmann

    Joined:
    Aug 5, 2022
    Posts:
    6
    First of all thanks for the answer. So here is an example of an object. In the excel sheet are only coordinates that exist and are not out of range of the object. In the first way one color should be enough but at the end there should be three.
    The object is static. I think there will be max 100 rows for big objects.
     

    Attached Files:

  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,988
    LukasAmmann likes this.
  7. Doomchecker

    Doomchecker

    Joined:
    Apr 5, 2021
    Posts:
    105
    So you just want to use some float values to modify the color of a material?
    Should be googlable quite easily ;-)
     
  8. LukasAmmann

    LukasAmmann

    Joined:
    Aug 5, 2022
    Posts:
    6
    Kind of this data. Endresult should be this: you point on a part of the object (via an AR app f.e.) -> exact coordinates of the pointer saved in the Excel sheet -> these coordinates will be colorized as red and ideal would be that based on the amount of touches of the exact same point there should be a color gradient form red to yellow to green. But this I will figure out later :D Thank you, you helped me :)
     
  9. LukasAmmann

    LukasAmmann

    Joined:
    Aug 5, 2022
    Posts:
    6
    The question is if I can pass the float value at the object and the object realize that the float value refer to the coordinates of the object.
     
  10. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,988
    ok so its like a 3d heatmap, that is viewed later using that recorded data.
     
  11. LukasAmmann

    LukasAmmann

    Joined:
    Aug 5, 2022
    Posts:
    6
    yes thats a good explanation