- Home /
"Baking" to 2d UV Map?
This question is actually simpler than described...
How do you show this Mesh.colors procedural color designation on a UV map?
Trying something like this yields a noise texture that seems different each time:
for(i=0;i< mesh.uv.Length;i++){ texture.SetPixel (mesh.uv[i].x, mesh.uv[i].y, colors[i]); }
Answer by Dreamora · Dec 19, 2011 at 02:23 PM
You aren't working on a UV map, you are working on the texture which expects pixel coordinates, not UVs (which are always [0,1]). Additionally you aren't interpolating the UVs to really draw the pixels you are only filling single distinct points as a mesh does not have as many vertices as the texture pixels - you could map a 4096x4096 texture on a quad with 4 vertices each in a corner and it would look perfect. yet if you would draw the UVs the way you do, you would get a color only in exactly the 4 corner points (if you calculated the pixel coordinate correctly. if you would keep it as it is you would get 4 pixels in top left due to the 0 and 1 only values on the 4 vertices)
Question is what you really try to achieve. Do you simply want to apply height*width pixels? if so simply use SetPixels or even better SetPixels32 as its faster. if you want to store something different best clarif what you want to calculate / bake in detail.
What you don't need to store down is the UV coordinate of the texture into the pixel cause thats a thing you can simply read out in the pixel shader again (its data you have for every single pixel at runtime on the gpu out of the box already)
Your answer
![](https://koobas.hobune.stream/wayback/20220613062129im_/https://answers.unity.com/themes/thub/images/avi.jpg)