I’m trying to bake from a shader material down to a flat texture, but getting results that seem rather sparse…
Wanted result:
[58076-316d33bcfab36f18dbc18500054932b4.png*_|58076]
What my below attempts are getting:
[58075-d48a169e60140110152bfb1843a47641.png*_|58075]
Actually - I am not sure if I am looping through the constructs right to be able to get the color of each UV point to bake to texture?
texBaked = new Texture2D (512,512); MeshFilter mf = goBakeMe.GetComponent (); Mesh mesh = mf.mesh; /*for(int i=0;i<mesh.vertices.Length;i++){ Vector2 uv = mesh.uv*;* _ Color color = mesh.colors*;*_ _ int minx = Mathf.FloorToInt (uv.x * 512); int maxx = Mathf.CeilToInt (uv.x*512);_ _ int miny = Mathf.FloorToInt (uv.y * 512); int maxy = Mathf.CeilToInt (uv.y*512);_ _* for(int a=minx;a<=maxx;a++){*_ _* for(int b=miny;b<=maxy;b++){*_ _* texBaked.SetPixel (a,b,color);*_ _* }*_ _* }*_ _ }*/_ _* for(int i=0;i<mesh.triangles.Length;i++){*_ _ Vector2 uv = mesh.uv[mesh.triangles*];*_ _ Color color = mesh.colors[mesh.triangles*];*_ _ int minx = Mathf.FloorToInt (uv.x * 512); int maxx = Mathf.CeilToInt (uv.x*512);_ _ int miny = Mathf.FloorToInt (uv.y * 512); int maxy = Mathf.CeilToInt (uv.y*512);_ _* for(int a=minx;a<=maxx;a++){*_ _* for(int b=miny;b<=maxy;b++){*_ _* texBaked.SetPixel (a,b,color);*_ _* }*_ _* }*_ _* }*_ _* texBaked.Apply();*_ _**_
*
*