Hey guy, I have a project about procedural generation. I am having problem with saving the color of the mesh in builded app. Here some general info. I have a Plane that have MeshFilter component (i have caculated normal,uv, vertices and triangles and able to save it as .obj so no problem here), and a MeshRenderer Component that use have a Material assign to it. The Material that i assign using a cumstom shader. And the shader logic mainly about set the o.Albedo value in the void surf(). So when the app running, the shader receive some stuff and set the o.Albedo of the Material and since the Material assign to the MeshRenderer, the Plane have color on it. What i want is a way to save the texture of the mesh. PLS Help i find help everywhere but doesn't get what i want or no reply.
If you want anymore info i will provide to you.
#Saving the texture of the MeshRenderer
1 messages · Page 1 of 1 (latest)
if you are doing anything to the final pixel color on the shader to "save" that would require baking it, which is complex but doable, if you really, really need it, there is a way to do it without third party assets
in essence you have to first unwrap the mesh onto a uv plane, so you take all the vertices of each triangle and flatten them out by using their corresponding uv coordinates, then you take a picture of that with a camera
there is zero guarantee that the result will be anything close to what it looks in 3d because you will lose all the lighting information, but if its unlit and only color it will work
there are probably assets that bake
yeah theres a lot of them
search for texture bake / material bake / shader bake
can check github as well
Thanks you for reply, i don't know much about baking but the method of capture it with a camera have been metion by some people. Since i have no choice so this is not a bad idea but how can i achive it? i using perlin noise to generate a height map and set it value to y value of the mesh.vertices so to flatten the mesh all i need to set it to 1 or 0 (i will give the pictue of the mesh). So how can i get the color of it with the method you mention above?
and i can't afford paid third party asset 
- create a RenderTexture of desired resolution
- create a camera, set its output to this render texture
- position the camera perfectly above the plane
- use Camera.Render() api to capture it into the render texture
- save the rendertexture https://answers.unity.com/questions/37134/is-it-possible-to-save-rendertextures-into-png-fil.html
Unity is the ultimate game development platform. Use Unity to build high-quality 3D and 2D games, deploy them across mobile, desktop, VR/AR, consoles or the Web, and connect with loyal and enthusiastic players and customers.
lol i feel like chatgpt
- this step trouble me the most. My mesh have different size so how can i position the camera to fit the mesh perfectly ?
math