Turning 3D model's colors into texture(s)?

Community Forums/General Help/Turning 3D model's colors into texture(s)?

Guy Fawkes(Posted 2013) [#1]
Hi all. Is there any way to like turn vertex colors into a texture and then save it as a texture file?

Thanks!


MCP(Posted 2013) [#2]
If the model has a UV set you could generate mesh geometry from this converting UVs to vertex information on the x,y plane scaling to the required texture size and copy also the vertex colour information. Surface triangle information is the same so just copy them over into your new mesh.

Render final mesh facing camera in ortho mode to a viewport equal to your desired texture size ie: 512x512 and save scene as a bitmap.

Almost forgot... Make sure your original mesh is hidden and your new mesh is rendered with doublesided, vertexcolors and fullbright turned on.


Kryzon(Posted 2013) [#3]
If the model has a UV set you could generate mesh geometry from this converting UVs to vertex information on the x,y plane

How interesting, thanks for sharing.

With what you said it should be very easy to do what he asked.
Position all vertices of the mesh using their UV values, each with a XYZ of...
Const TEXTURE_SIZE# = 512
vertOffset# = (4.0 * TEXTURE_SIZE) / GraphicsWidth()

;Position all vertices with this.
VertexCoords(surf, vert, (U-0.5)*vertOffset, (V-0.5)*vertOffset, 2.0)

CameraViewport(camera, 0, 0, TEXTURE_SIZE, TEXTURE_SIZE)
CameraProjMode(camera, 2)

[...]
...then render, grab to image same size as viewport, save image as bitmap.

In Blitz3D, at a distance of +2 from the camera's Z axis, the screen width in 3D units is 4 units across and the screen height is (GraphicsHeight/GraphicsWidth)*4 units high (resulting in 3 in a ratio of 4:3, or 2.25 in a ratio of 16:9).


MCP(Posted 2013) [#4]
That's correct Kryzon. Of course the method described does assume the original UVs are within the range of 0...1 but as you've said it's easy enough to implement the technique in it's current form.


Guy Fawkes(Posted 2013) [#5]
Kryzon, by ortho mode, you mean???


Kryzon(Posted 2013) [#6]
With the command CameraProjMode.


Guy Fawkes(Posted 2013) [#7]
Thanks, Kryzon! :)