Lightmapper QML Type
Specifies lightmap baking settings for a scene. More...
Import Statement: | import QtQuick3D |
Since: | Qt 6.4 |
Inherits: |
Properties
- adaptiveBiasEnabled : bool
- bias : real
- bounces : int
- denoiseSigma : real
(since 6.10)
- indirectLightEnabled : bool
- indirectLightFactor : real
- indirectLightWorkgroupSize : int
- opacityThreshold : real
- samples : int
- source : string
(since 6.10)
- texelsPerUnit : real
(since 6.10)
Detailed Description
Used when baking direct and indirect lighting. Most of these settings are not relevant at other times, such as when using already generated lightmaps to render a scene. The exception is source, though this has a sensible default for development.
On a successfull bake a single file will be generated at the value specified by source. This binary file contains the results of the bake, including the per-model lightmaps and the mesh files with lightmap-compatible UVs. The individual model data is accessed via BakedLightmap::key.
The data contained in the resulting lightmap file is all tightly coupled to each other and to the current scene state. This means that any modifications to the original mesh files, Lightmapper settings or other scene changes will require a new bake to be executed to see the updated result.
Note: As of Qt 6.4, lightmap baking is in an early technical preview state. Changes to features, quality, and API are likely to happen in future releases.
The Lightmapper object works in combination with:
- Model::bakedLightmap and the associated BakedLightmap,
- Model::usedInBakedLighting and Model::texelsPerUnit,
- Light::bakeMode,
- the engine's built-in lightmap baker.
See also Lightmaps and Global Illumination and Qt Quick 3D - Baked Lightmap Example.
Property Documentation
adaptiveBiasEnabled : bool |
Enables applying an additional, dynamic bias based on the surface normal.
The default value is true.
bias : real |
Raycasting bias used during baking. Adapt the value in case artifacts occur, for example in order to reduce undesired shadowing patterns. In many cases the default value is sufficient.
The default value is 0.005.
bounces : int |
The maximum number of indirect light bounces per sample. The value should at least be 1, no point in indirect light calculation otherwise.
The default value is 3.
The value heavily affects both the performance and quality of the resulting lightmaps during lightmap baking.
denoiseSigma : real |
This property defines the sigma value of the Non-local means based denoiser. This means that the higher this value is the stronger the blurring will be. Try to keep this value as low as possible to avoid losing visual features while still removing the noise.
This property was introduced in Qt 6.10.
indirectLightEnabled : bool |
Normally there is no need to change this value. The default value is true. Setting this property to false disables indirect light computation during lightmap baking. Thus the resulting texture maps will only contain direct light information. At run time, the engine will continue to use the maps normally, assuming they contain both direct and indirect lighting.
indirectLightFactor : real |
Multiplier for the indirect light amount. While it is the value of 1 (i.e., not affecting the indirect light amount calculation) that provides the strictly correct rendering results, a slightly higher value can often give better looking results when using the lightmap, even with a lower number of bounces.
The default value is 1.
indirectLightWorkgroupSize : int |
The size of the sample workgroups. These workgroups are attempted to be executed in parallel. (the exact behavior depends on the number of CPU cores and the QThreadPool configuration)
The default value is 32. With the default sample count of 256 this means attempting to run 8 groups in parallel per model.
opacityThreshold : real |
The opacity (alpha) threshold below which an object is ignored in ray - mesh intersections when calculating lighting via raytracing. When the opacity falls below the threshold, the model (submesh) will not occlude lights and thus will not generate shadows either.
The default value is 0.5.
Note: The lightmapper takes the material's opacity and the baseColor alpha combined with the base color map's alpha into account. Other sources of semi-transparency, such as the opacity map or alpha cut-off settings are ignored during the lightmap baking process.
samples : int |
The number of samples per lightmap texel.
The default value is 256.
The value heavily affects both the performance and quality of the resulting lightmaps during lightmap baking.
source : string |
The path to where to save the generated lightmap file on a successful bake and where to load the file at runtime.
When baking, the path needs to be set up to be a regular file location which is writable. By default the value is lightmaps.bin
, meaning the current working directory, in a file called exactly that. This location is also readable, which makes the final result instantly appear on a successful bake.
When loading a bake it will try to look at an actual file location on disk, falling back to looking at files embedded in the executable via the Qt resource system if not found. To control the value more explicitly it can be prefixed, with for example qrc:/
and the Lightmapper will always look for a file in resources.
The following example always tries to load the lightmap file embedded via resources. First set the value to a writable location and bake. Then copy the generated file into the source directoy. Then by listing the file in the application's CMake project as a resource under the /lightmaps
PREFIX, lets the build process pick up the file and include it in the executable.
Lightmapper { source: "qrc:/lightmaps/lightmaps.bin" // will attempt to load from :/lightmaps/lightmaps.bin at runtime. // this will result in a "Location not writable" when initiating a bake. }
Note that just omitting the prefix will still make the Lightmapper try to load the lightmap file from resources at runtime if the file is not found on disk. This is a convenience during development. If a bake is then initiated and is successful, the same path is converted to absolute and the generated file will be saved to that location. Now the results will insantly appear. Then it's just a matter of copying this file to the source directory and adding back the prefix to start explicitly loading from resources again.
Note: It is not possible to write to the resource system, so an error is given when a bake is initiated and the path is explicitly set up to point there.
This property was introduced in Qt 6.10.
texelsPerUnit : real |
This property defines the unit to texel scale, meaning a 1x1
quad with texelsPerUnit of 32
will take up approximately 32x32
texels in the lightmap.
This property was introduced in Qt 6.10.
See also Model::texelsPerUnit.