News Overview SceneEngine Downloads VideoTutorials Main Page SourceForge Get Involved Bookmark and Share
Up : Tools
Next : Texture Painting

Texture Baking

Contents


Texture baking, also known as render to textures, is the process of rendering the scene directly into an object's texture. SceneEngine's Texture Baking is implemented in the raytracer library, and supports projective rendering. The UV channel of an object (the target) is used to cast rays and intersect them with other objects in the scene (the source), transfering materials, texture, lighting and surface properties to the target's object texture.

SceneEngine's Texture Baking session is implemented as a Tool Block that holds all the information necessary to render a set of textures.

Concepts

Image:Texbake_target_source.jpg

Target objects : These are the objects that will receive the rendered textures. The uvw meshes of these objects are used as the texture baking canvas. The target objects must have a valid uvw mesh. To avoid artifacts and noise, the uvw mesh cannot have overlapping faces, and all their faces must be contained in the [0.0,0.0] [1.0,1.0] texture space.

Source objects : These are the objects that are rendered by the Texture Baker. The target object can be a source object too. By default the Texture Baker uses as source objects all objects in the scene except those that are target objects.

How Texture Baking works

When a scene is being rendered in Texture Baking mode, the renderer uses the surface of the target objects to cast the rays into the scene. The uvw meshes of the objects are used to create a canvas that represents the rendered bitmaps (the textures). Then each pixel of this canvas is rendered. For this, the texture baker first intersects the uv point in the bitmap with the uvw meshes in the canvas:

Image:Texbake_uvw_mesh_hit.jpg

The red asterisk is the pixel that is being rendered. The canvas returns a face in the uvw mesh of the target objects, which is converted to a point in the 3D world.

Image:Texbake_world_point.jpg

A new point is created by moving the surface point a distance d in the direction of the render normal. Then a ray is created between these two points and cast into the scene.

Image:Texbake_world_ray.jpg

All points intersected by this ray are rendered:

Image:Texbake_render_complete.jpg

This image shows the complete rendered image, and the diffuse and normals render elements.

Quality Control

To get the best possible results the target objects should follow a few simple guidelines:

UVW mesh

The target objects must have a valid uvw mesh. The uvw mesh shouldn't have overlapped faces, if there are overlapped faces the renderer will select only one of the faces, and the other faces will be ignored. All the faces should be contained in the [0.0,0.0] - [1.0,1.0] texture space.

Image:Texbake_uvw_issues.jpg

This images illustrates both issues.

The green square shows the [0.0,0.0] - [1.0,1.0] texture space. The dice faces 4 and 1 are overlapping, and the renderer is only rendering face 1. The faces 3 and 6 are half outside the valid texture space, so the rendered image for face 6 is tiling and going into face 1 texture space.

If the target objects don't have a valid uvw mesh, or if it is not ready for texture baking, an UVAtlasModifier can be applied to them, and it will generate a valid uv mesh automatically.

Render normals

The render normals are used to generate the ray that is casted into the scene. In SceneEngine the render normals can be built in rendering from the smoothing groups or the hard edges they can be specified in the mesh (imported or edited). If two contiguos faces have different render normals, some entire areas of the scene can be ignored by the raytracer, creating discontinuities, or can be rendered twice, creating repeated details.

Image:Texbake_render_normals.jpg

Render Elements

SceneEngine's raytracer supports the following render elements in Texture Baking mode:

  • Diffuse
  • Specular
  • Lighting including Ambient Occlusion
  • Normals
  • Wireframe

CrackArt

Texture Baking is a Tool Block that can be created and linked to the scene from the Control Panel Tools page.

Texture Baking Video Tutorial

Lua script

Texture Baking is a mode in SceneEngine's raytracer. To activate it set do_texture_baking to true in the render parameters table. This is a list of the texture baking options in the render parameters table:

  • do_texture_baking : If true, the raytracer renders in Texture Baking mode.
  • ray_offset : A positive number that defines the distance from the target surface point from where the ray is casted.
  • prefilter_size : To avoid dark areas in the textures when these are applied to the target objects the colors are expanded a certain number of pixels.

The following samples illustrate how to use Texture Baking using Lua:

ScEngSDK

The texture baker is part of SceneEngine's raytracing engine. The raytracer has a virtual class called RenderEye with a method GetRay, which returns a GMT::Ray3D that can be intersected with the scene. In Texture Baking mode, the raytracer creates a TextureBakerEye, a class that builds the UV canvas from the target objects and intersects the uv point with the uvw meshes, and returns the ray into the scene.

Development Info

Known issues

Things to do

Start a RayTrace Texture Baking session in Lua from the Texture Baking Tool Block.

Management

A ToolBlock that can hold multiple Texture Baking sessions within the scene.

Hit resolution

When the ray intersects a source object in more than one point the renderer just registers into the Texture Baker the first hit.

Cage objects

Cages are objects that have the same topology as the target objects, and they define from where the ray is casted, instead of using the render normal. The advantage of cages is that the user have greater control over the ray casting system.

Rendering to do

Texture Baking would benefit from any improvements done in the raytracer, like multithreading, network control, faster kd-trees, etc!

Views