Colorize an object based on X,Y and Z coordinates

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

you mean if you can use the excel sheet directly inside the C# script?

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

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.

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.

8380137--1104969--Unbenannt1.PNG

is it something like cfd/fem data?

but i’d test the vertex coloring first, and see if looks good enough?

some examples accessing vertices here Unity - Scripting API: Mesh
then could just loop and take closest color point and set .colors array with that.
then find shader that supports vertex colors,
http://answers.unity.com/answers/928498/view.html *for builtin render pipeline

1 Like

So you just want to use some float values to modify the color of a material?
Should be googlable quite easily :wink:

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 :smile: Thank you, you helped me :slight_smile:

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.

ok so its like a 3d heatmap, that is viewed later using that recorded data.

yes thats a good explanation