UV mapping a texture generated from a script

210 Views Asked by At

I would like to create a simple material in Unity 3D using a C# script.

My idea: I would create an array of points with coordinates then use these points to define shapes with a class (lets say squares) which would also contain their colors and feed these shapes with their information into a shader which would then display them (using the points' coordinates as UV coordinates).

Example (image below): Lets say I have a mesh of two triangles making a square. And 9 points in the script lets say (0,0) (0,0.5) (0,1) (0.5,0) (0.5,0.5) (0.5,1) (1,0) (1,0.5) (1,1) and that would make 4 squares with different colors on the mesh.

Example

How do I approach this correctly to define the squares in the script and project them onto the mesh?

Also this is a simplified version of what I want to do. Eventually I'd like to do this on a sphere and use the information from the class to for example display different actual textures in each shape.

I tried to google this problem but I didn't find many results. Maybe I just don't know the right terms because it doesn't seem to me as a very difficult thing to achieve. I just don't know where to begin.

0

There are 0 best solutions below