If I have 2D matrice (array) I can set the color scale for each value of this matrice and then plot it as in image attached where matrice of size 100x100 has values in range about [-6 : 8]. Every math program can do that. How can I do this in Unity?
The easiest way would probably be to use something like PixelSurface (see link in my signature).
Another way would be to make a dense mesh grid, and then dynamically set the vertex colors. This is a more advanced technique, though.
Unity is not a math program.
Thank you for the answer
Can provide some links for me to understand a little more how to perform the second way?
can also try setpixel,
and to get matching colors from that gradient,
create unity gradient Unity - Scripting API: Gradient
(no need to use script to set colors, do in the inspector)
then remap those -6 to 8 values into 0 to 1 range,
then use that remapped value to get color from gradient
then setpixel with that color.
Seems to me that this is something that I’m looking for.
Thank you, I’ll try to use it
Is there a way to implement Unity Inspector’s gradient to the application to let the user change colorbar of a data while using application?
yes, would need to build some gradient editor / color picker and then assign values to that gradient.
could also save/load those values to disk (some plain text format).
i did similar thing here, you could modity it.
just pass array of colors to the method,
it creates gradient from that. (and creates texture from it, but you don’t necessarily need that part)
also to add one more alternative option,
plot those colors as grayscale 0-1,
then using custom shader and gradient texture2D, it can pick gradient color from that texture, using the grayscale value.
(then its easy to have ready made gradient textures, and assign those to the shader material, and it instantly changes)
Thank you a lot!
I think I got the idea that you advised to me and I think I’m able to do that