UV and Lightmaps
This article covers textures and lightmaps.
Last updated
This article covers textures and lightmaps.
Last updated
UV Mapping is done in 3D modelling software usually directly to the model being used. A piece of geometry will have one or multiple UVs correctly mapped to multiple channels that Unreal Engine will make use of.
Let's start with a more detailed look at the concepts:
UV Mapping is the process of a resolving a 3D model's surface into a 2D surface. This can be commonly thought of as unwrapping a surface.
UVs denotes the two axes of the 2D space that the unwrapped surface sits on. The UV map can be considered as the way that the unwrapped surface sits on a texture.
Any piece of geometry can have multiple UV 'channels' that will hold one map each. Usually there will be two channels consisting of one of each:
Texture UV Mapping: Mapping how a texture/material sits on a model
UV Lightmapping: Providing a clean unwrapped texture for light to bake onto.
In Unreal Engine, Materials help represent the object's materiality and lets it interact with lighting more accurately. Materials are layers of information that come together as a surface that interacts with the Level Lighting. For accurate representation of the object it is necessary to Texture Map.
Texture mapping refers for the the process of using UV mapping to resolve how the 3D model maps a 2D texture to itself. The above image of the cube and timber texture is an example of this. Texture mapping therefore depends on how the object needs to look when a material has been applied. Here are the concepts that apply to Texture Mapping:
How the UVs get unwrapped and mapped determines how a material will later apply to the geometries' surface, and is generated using different methods. The different mapping methods used will give different results and may be more suited for specific types of geometry, but this will covered further down the page. Compare the two images below:
This Surface Mapping method (above) unfurls the curve of the geometry, allowing the wood grain to map along the curve.
This Box Mapping method (above) unwraps the UVs by projecting from the six sides of a cube so there are top-down-left-right-forward-back fragments of the model as seen from those views as UVs. The texture sits like as if blankets of texture have been dropped onto the model from the six sides of the cube, most noticeably the top of the surface.
When UVs are made, the initial parameters define what 1 UV tile is, this determines the size of the texture that sits on it. UVs will tile indefinitely in every direction to account. For texture mapping, UVs that sit beyond the UV space will still have their texture registered as it tiles. This can be visualised in the following way:
In the example pictured above, the intended outcome is for the timber to tile nicely along the curve of the geometry. The initial UV space is too small lengthwise to fit the unwrapped geometry without distorting it in other directions via scaling it non-uniformly.
Aside from the general orientation, each unwrapped UV face can be manipulated across the texture space to various effects.
Scale, Rotation, Distortion
UVs can be manipulated to change how the texture gets mapped. For example in the above image, [1] is a rotation, note that the texture on the cube face is also rotated. [2] is a distortion, and [3] is a change of scale, note that it is 'capturing' more of the texture, and hence the cube face reflects this.
Seamlessness
The UVs can be split or adjacent to simulate material continuity.
Different parts of the texture to be used can be dedicated to various parts of the texture.
As the UVs merely dictate what part of the texture should be mapped to which part of the 3D model, overlapping UVs merely means that the same part of the texture will be mapped again. This is actually useful to save on texture size as a form of optimisation.
Lightmaps dictate how the lighting is 'baked' when building lighting. Baking is the process that combines lighting and materials into new textures for geometry with lighting and shadow effects built in. This can be thought of as an empty square image for Unreal Engine to draw on, which is then used in the final experience in place of the materials. Unreal Engine uses this to minimise overhead when running the experience by pre-calculating the lighting for the level.
This is primarily for stationary and static lights/objects. For a more in-depth explanation for Actor Mobility and when lighting is baked, refer to:
Actors: Components, Content and EditorsUV Lightmapping is done the same way as Texture Mapping, except it has these key concepts:
How the UVs get unwrapped and mapped determines the resolution of the final resolved light map. While this resolution can be determined within Unreal Engine, distortion in the UV face shapes may result in pixelated lighting as it needs to be stretched and pulled to the size of its corresponding geometry face, but without the level of pixel detail to do so adequately. Distortion should be kept to a minimum. Shown above is an example of a clean lightmap UV.
Lightmaps cannot exceed the initial UV space as they do not tile like Textures. Technically, this means that UVs outside the border do not have anything to bake to, and will result in incorrect lighting. In the example above, the lightmap does not conform tot he bounds of the initial space, leading to defects in the lighting.
UVs cannot overlap in lightmaps. Technically this means that multiple geometries' final surface will be baked onto the same patch of the lightmap, resulting in incorrect or error results. In the example above, the lightmap overlaps with each other at multiple points, leading to defects in the lighting.
The same tools and workflow is used for Lightmapping as well, albeit for different principles. However, due to Rhino3D incompatibilities, Lightmaps will be done in a different application. For such purposes, this section is titled as Texturing. If Rhino3D updates in the future this guide will be updated as well.
The basic steps are:
Finalise the geometry to be UV mapped.
Apply an appropriate UV mapping method.
Review the UV map.
Export the model with its UV maps.
For simple objects, a Basic map should do the job, but when an object with very particular material orientation requirements and has doubly curved surfaces, seams in the model, or complicated faces consisting of various parts of different sizes, then consider using the Advanced methods.
In Rhino3D, the UV maps are tied to the geometry itself. The toolset that will be used is the Texture Mapping tool. With the piece of geometry you want UV mapped selected, the Texture Mapping toolset can be found in the Object Properties tab:
Reference | Aspect | Description |
1 | Texture Mapping | Found through an object's Properties panel and Texture Mapping tab |
2 | UV Mapping Tools | Different Mapping methods, map editors and visualisation tools |
3 | Type of UV Map | Change the mapping method of an existing map, and the projection method |
4 | Mapping Transform | Origin of the mapping and rotation. This is a global shift that will alter the UV map. |
5 | Mapping Scale | Scale of each UV tile. This is a global shift that will alter the UV map. |
6 | UV Options | Further options to adjust how the texture sits. Offset refers to the position, repeat refers to the tiling ratio, and rotation refers to the tiling angle. |
7 | Multiple Mapping Channels | Unused because Rhino3D cannot export multiple mapping channels, but if it can in the future, this can be used to do multiple maps (Texture & Lightmaps) using Rhino only. |
The majority of the work will be done using the [2] UV Mapping tools, so let's examine this toolbar next.
In the Rhino to Unreal Engine workflow, materials created in Rhino do not translate 100% accurately over to Unreal Engine, in most cases it is easier to create native Unreal Engine materials. Therefore, using a reference texture or the built-in UV grid will help in visualising the mapping process.
Here are the tools that allow for checking the existing UV maps:
Ref. | Tool | Description |
1 | Show Mapping | Show the existing Mapping channel, if multiple channels is toggled on, the currently selected channel will be displayed. |
2 | Hide Mapping | Hide the currently shown Mapping. |
3 | UV Editor | Used to both show and edit Mapping Channel #1 only. |
Ref. | Tool | Description |
1 | Delete Mapping | Deletes the existing UV map of the geometry, if multiple channels is enabled, it will delete the selected map from the channel list. |
2 | Match Mapping | Applies another object's mapping to the currently selected object. Follow the command prompts to select another object with applied mapping. |
3 | Edit Channel | Only used if multiple channels are being used. Change the channel number of the selected mapping channel. |
If multiple channels are being used, they can be viewed here. Channels are indexed starting from 1. Most other software begins indexing from 0 (Rhino#1 = 0, Rhino#2 = 1 and so on.)
Channels are referred to by their index always, and not their relative position. Channel #1 (index 0) refers to the channel that is denoted as #1 only.
Across many modelling software, these common unwrapping procedures are available:
These are based on primitive geometry, and are projection techniques that will try to break up a surface based on the projection geometry.
Will try and unwrap the geometry using a two-sided plane. This method will result in many overlapping UVs for complex objects. Useful for relatively flat objects and objects visible only from one camera angle.
Select the object to be UV mapped.
Click on the[Apply Planar Mapping]
icon.
Create the Plane to create UVs from the prompts. Follow the command line for different types of Planes. The size of the Plane equates to 1 UV tile.
When prompted for UV/UVW: use UV.
When prompted for the Mapping Channel, enter the desired Mapping Channel. If only one channel is being used, stick to 1.
Will try and unwrap the geometry using the six faces of a cube. This method is commonly used for many types of objects that have distinct views from a few sides.
Select the object to be UV mapped.
Click on the[Apply Box Mapping]
icon.
Create the Box to create UVs from the prompts. Follow the command line for a different Box creation method. The size of each face equates to 1 UV tile in that projection direction.
When prompted for the Coordinate system, use World
When prompted for Capped: Yes for a six-sided map, No for a cube-map without the top and bottom
When prompted for UV/UVW: use UV.
When prompted for the Mapping Channel, enter the desired Mapping Channel. If only one channel is being used, stick to 1.
Will try to unwrap the geometry like a sphere. This method is ideal for spherical-like objects without any projecting or hollow parts.
Select the object to be UV mapped.
Click on the[Apply Spherical Mapping]
icon.
Create the Sphere to create UVs from the prompts. Follow the command line for different types of Spheres.
When prompted for the Mapping Channel, enter the desired Mapping Channel. If only one channel is being used, stick to 1.
Will try to unwrap the geometry along a cylinder, with one continuous tube two end caps. This method is ideal for cylindrical objects without any projecting or hollow parts.
Select the object to be UV mapped.
Click on the[Apply Cylindrical Mapping]
icon.
Create the Cylinder to create UVs from the prompts. Consult the command line for a different Cylinder creation method. The size of each face equates to 1 UV space.
When prompted for Capped: Yes for a six-sided map, No for only the tube.
When prompted for the Mapping Channel, enter the desired Mapping Channel. If only one channel is being used, stick to 1.
For more complicated geometry, these following methods are used; usually combining a more manual unwrapping method with UV editing:
Seams are a key concept to advanced UV Mapping. They are the lines on the object where unwrapping happens. Imagine that you are peeling an orange, the seams are the series of cuts are made to assist with the cutting. When trying to lay the orange peel flat, the more seams there are, the less distortion, but the more pieces there are. For complex geometry, breaking up the model into more manageable parts using seams or before identifying the seams is necessary.
Unwrap gives the option to manually choose the seams of the object. This gives very fine control over the final UV, especially for ensuring seamless-ness. This maps the object onto 1 UV tile.
This method is also used for very large or complicated objects. Understanding how the seams work is integral.
Select the object to be UV mapped.
Click on the[Unwrap]
icon.
Select the seams of the object. [Click]
to select an edge. [Ctrl + Click]
to deselect.
Use[Chain]
to filter the next selection for only connected edges. [Enter]
on your keyboard to exit out of [Chain]
selection. Both basic and chain selection modes can be toggled between at any point.
[Apply]
to finish the selection process and Unwrap.
The Unwrap method will always override the first mapping channel if multiple channels are being used.
2 - Custom Mapping
Uses a user-defined custom surface or mesh as the projection technique for unwrapping
Select the object to be UV mapped.
Click on the[Custom Wrapping]
icon.
Select a custom surface or mesh to use.
When prompted for the Mapping Channel, enter the desired Mapping Channel. If only one channel is being used, stick to 1.
3 - Surface Mapping
Attempts to leave all surfaces intact and join surfaces where possible. This is similar to using the Unwrap method and selecting all seams, but generally deals with distortion better. This process will usually leave clean surfaces that is more suited for Lightmapping. This maps the object onto 1 UV tile.
Select the object to be UV mapped.
Click on the[Apply Surface Mapping]
icon.
When prompted for the Mapping Channel, enter the desired Mapping Channel. If only one channel is being used, stick to 1.
4 - UV Editor
The UV Editor will only show Channel #1, otherwise it will default to a Surface Mapping. This only applies if multiple channels are being used, if another channel needs to be edited, use [Edit Channel] to adjust the channel to #1.
Allows for the UV map to be shown and edited. To use:
Select the object to be UV mapped.
Click on the[UV Editor]
icon.
Upon startup, a UV Editor panel will pop out.
Follow the command prompt to draw a rectangle, this will be the UV space to display.
Ref. | Aspect | Description |
1 | UV Space Display | Functions like a texture with the editable UVs on top. |
2 | UV Editor | Main editor window |
3 | Texture Transparency | Transparency of the underlying texture in the [1] |
4 | Display Options | When selecting the mesh in [1], whether to highlight the corresponding component in the geometry or not can be toggled. |
5 | Display Texture | Whether to use the object's applied material (if applicable) or to use a custom texture for [1] |
6 | Texture | If [5] is using a texture, the texture to be shown can be chosen/adjusted here. |
7 | Apply/Cancel | Apply or Cancel any changes made to the UVs. |
Manual refinement of the UVs is possible in [1]. This mesh can be adjusted as if it were a Rhino3D mesh object. If the texture to be used is known already, it can be used to very accurately map the UVs, otherwise the inbuilt UV grid texture (shown above) can be used to get a general idea of the mapping, especially in terms of the displacement/distortion.
As the mesh can be edited, you can do the following and more to refine the UV:
Points On/Off to make control points editable.
Gumball
Transformation Move, Rotate, Scale
SetPt to align points to an axis.
When geometry is changed, existing UV maps will be distorted. Note that in the example below, the adjusted geometry using the previously existing mapping will distort by repeating the edge of pixels to fill out the space. This will be lead to materials and textures distorting too.
In the case of a change in geometry:
Make the necessary changes to the geometry and finalise it.
Remap the geometry using an appropriate UV map technique, OR Edit the UVs using the UV editor.
Unreal Engine has a feature to automatically generate Lightmap UVs upon importing. This feature assumes that the fist channel (or default channel) is a Texture UV map, and will create (or replace) the second channel by cloning and nesting the Texture UV map so that there are no overlaps.
Therefore, as long as the Texture UV map is done correctly and is properly assigned as the first channel, then Autogenerate Lightmap UVs should usually be fine to use.
This can be checked via opening the Static Mesh Editor for that piece of content by double clicking it, and using the UV tool to preview the UV map. If this auto-generated Lightmap does not look neat and with no overlaps, or the geometry in Unreal Engine does not look right with the lighting built, then a custom Lightmap may be necessary.
At the time of publishing this article, Jan-2019, Rhino3D does not allow the exporting of compatible .fbx files with multiple UV mapping channels, meaning custom Lightmaps must be created in alternative software and is shown below, this will be updated as software progresses.
This section will go over the specific steps in Blender to create a second texture channel.
For a quick overview of the Blender UI:
In Rhino3D, use [ExportWithOrigin]
to export a Motionbuilder .fbx file. Export as Meshes Only and enable Map Rhino Z to FBX Y.
Choose the desired Mesh quality.
Importing in Blender
Navigate to [File > Import > FBX (.fbx)]
Navigate to the file directory and choose the file.
[Import]
to import the selected file.
Adding a Second Texture Channel
[Select the Geometry]
, it will usually be embedded in its Transform layer.
Select [Object Data]
.
Add a UV Map using the [+]
button in the UV Maps collapsable panel.
UV Mapping Window
Click and Drag this window to create a new view.
Change the display to the UV/Image Editor
UV Mapping Display
With the object still selected in the top left, press the [TAB]
key to change into Edit Mode for the object. The object should be indicated via an orange selection colour.
In the UV viewer, the existing UV map should be shown.
This method will indiscriminately nest the object faces onto the UV space.
Select the second UVMap channel (UVMap.001 by default)
Use the [U]
key to bring up the UV Mapping context menu.
Use [Lightmap Pack]
to efficiently pack each face to the UV bounds. Use the default settings.
This method allows for more control, similar to the Rhino3D Unwrap method.
Use [Ctrl + TAB]
to bring up the Selection Modes context menu.
Select [Edge]
to enable Edge Select mode. Selecting edges can be done by:
Action | Command |
Select Single Edge | [RMB] |
Select Multiple Edges | [Shift + RMB] on each additional edge |
Deselect Edge | [Ctrl + RMB] on each unneeded edge |
Selection Window | [Ctrl + LMB] |
Deselection Window | [Ctrl + Shift + LMB] |
Select Edge Loop | [Alt + RMB] to select an edge and all other edges in its loop |
Select Edge Ring | [Ctrl + Alt + RMB] to select an edge and all other edges in its ring |
Select edges to be used as seams.
Use [Ctrl + E]
to bring up the Edge Menu, [Mark Seam]
to mark these edges as seams. [Clear Seam]
is used to unmark these edges. Marked seams will be red.
Use the [U]
key to bring up the UV Mapping context menu.
[Unwrap] to complete the unwrap along the marked seams.
Editing UVs
If it is necessary to edit the UVs further, use the UV viewer.
Tool | Command |
Select a Point | [RMB] |
Select Multiple Points | [Shift + RMB] |
Selection Window | [Ctrl + LMB] |
Deselection Window | [Ctrl + Shift + LMB] |
Tool | Command |
Move | With something selected, [Drag RMB] to initiate Move. [RMB] to cancel, [LMB] to confirm. |
Rotate | With something selected, [R] key to enter Rotate mode. This will set the rotation point to the average of the selected objects. [RMB] to cancel, [LMB] to confirm. |
Scale | With something selected, [S] key to enter Scale mode. This will set the origin point to the average of the selected objects. [RMB] to cancel, [LMB] to confirm. |
Transform Menu | [T] will bring up the transform menu for further tools. |
With the object selected, go to [File > Export > FBX (.fbx)]
.
Navigate to a save location, name the file and [Export FBX]
.
This section is Work in Progress
Unreal Engine will always use the texture channel index 0 (Rhino3D channel #1) for its Texture map. Other mapped channels can be used for the Lightmap.
If a custom lightmap channel is available, it can be changed through the objects Static Mesh Editor. Double click on the piece of content in the Content Browser to open.
Available UV channels can be viewed here. If Auto Generate Lightmap UVs was used upon Import, this will have added a second channel ( channel index 1).
Change the Light Map Coordinate index to your custom lightmap channel index.
As lightmaps are baked, the lightmap resolution determines the overall quality of these lightmaps. A Low resolution can make shadows and other effects appear inaccurate.
Resolution can be changed using the Light Map Resolution. If shadows in the project appear strange, try increasing the base resolution of 64 using multiples of 2 (128, 256 etc.)
Usually a resolution of 128 is enough. Larger resolutions means longer build times, as well as extra computing power for less-powerful machines so this is a balancing act.
Unreal Engine's Message Log will notify of any Lighting upon building, as well as the possible reason. This is common for incorrect Lightmap UVs.