AutoLOD Impostors: Difference between revisions
No edit summary |
|||
(12 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Setup == | == Setup == | ||
The whole package is contained in the AutoLOD folder resulting from the import. You can move it wherever you want, but it is recommended to keep the same folder structure | The whole package is contained in the AutoLOD - Impostors folder resulting from the import. You can move it wherever you want, but it is recommended to keep the same folder structure. | ||
== What is an impostor == | == What is an impostor == | ||
An impostor or imposter is a billboard whose material displays a picture of a 3D object. Depending of the view angle, a different picture of the object will be displayed, to fake a 3D effect. Several pictures from several angles are baked into an atlas texture to access them quickly. | An impostor or imposter is a billboard whose material displays a picture of a 3D object. Depending of the view angle, a different picture of the object will be displayed, to fake a 3D effect. Several pictures from several angles are baked into an atlas texture to access them quickly. | ||
[[File:ALI EditorWindow.png|frame|The AutoLOD Impostors editor window.]] | |||
== How to use == | == How to use == | ||
Line 14: | Line 15: | ||
Click on the <code>Generate Impostor</code> button and wait a few seconds. Unity will temporarily open another scene and enter/quit play mode, just let it do it, don't try to stop the process. | Click on the <code>Generate Impostor</code> button and wait a few seconds. Unity will temporarily open another scene and enter/quit play mode, just let it do it, don't try to stop the process. | ||
When you get back in the scene, your object should now have a LODGroup attached, and the impostor should be instantiated as its children. Try to zoom out to see the LOD transition between the original object and its impostor. | When you get back in the scene, your object should now have a LODGroup attached / updated, and the impostor should be instantiated as its children. Try to zoom out to see the LOD transition between the original object and its impostor. | ||
=== Advanced === | === Advanced === | ||
The provided scene <code>BakingScene-Default</code> is automatically loaded in the Baking Scene object field. Note that you can use your own scene, the only constraints are the presence of an object named "Target" and a main Camera with the script <code>ImpostorTexturesGenerator</code> attached. <blockquote>If you are using URP, you must also fill in the <code>UniversalRenderPipelineAsset</code> and the <code>UniversalRendererData</code> fields at the bottom of the camera impostor. </blockquote>The provided scene is the recommanded one for high-fidelity results, but you can modify the lighting settings or add objects in the scene to achieve some interesting result. It's up to your imagination! | |||
* You can change the generated atlas size with the <code>Texture Size</code> popup. The estimated size below gives an idea of the full impostor (Albedo atlas + Normals atlas + Billboard) size on the disk after DXT1/DXT5 compression. | * You can change the generated atlas size with the <code>Texture Size</code> popup. The estimated size below gives an idea of the full impostor (Albedo atlas + Normals atlas + Billboard) size on the disk after DXT1/DXT5 compression. | ||
* The atlas is baked following a sphere vertices coordinates. Currently, two types of sphere are available. | * The atlas is baked following a sphere vertices coordinates. Currently, two types of sphere are available. | ||
*# UV sphere: The default choice. The UV sphere is based on a constant number of longitude and latitude samples. | *# '''UV sphere''': The default choice. The UV sphere is based on a constant number of longitude and latitude samples. The coverage is denser at the poles.<big><math display="block">N_{pics} = S_{Long}*S_{Lat}</math></big> | ||
<math>N_{ | *#'''Pseudo-Fibonacci sphere''': at an experimental stage. Provides a homogeneous coverage. Not compatible with latitude smoothing in the impostor shader. <big><math display="block">N_{pics} = \sum_{l=-S_{Lat}/2}^{S_{Lat}/2}cos(\frac{2\pi.l}{S_{Lat}}).S_{Long} | ||
</math></big> | |||
* The ''Optimization info'' panel is some read-only information to help understanding the coverage and the atlas layout. | |||
* The ''LOD Group Settings'' panel contains the settings of the upcoming LODGroup. If you don't want to setup any LODGroup and just bake an impostor, you can uncheck the panel toggle. | |||
* Impostors baked as prefab only. You have to enter a valid output path (''i.e.'' child from the ''Assets/'' folder). A preview text will display the full path of the upcoming impostor. | |||
====Post baking improvements==== | |||
If you select the impostor object in the hierarchy, you will see that the shader has a few parameters to improve the fidelity. | |||
* The Brightness slider can increase/decrease the albedo power. | |||
* The Smoothness/Metallic/Occlusion sliders work the same way than the default diffuse material. | |||
* The Curvature Occlusion slider applies an additionnal occlusion in rifts, sharp inward angles. | |||
* The Cutout slider can increase/decrease the sharpness of the alpha clipping geometry. | |||
* The Smooth toggle turns On/Off impostor bilinear interpolation smoothing. | |||
* The Dithering Fade toggle turns On/Off Dithering fading on the edges of the impostor. | |||
[[File:Impostor2.gif|none|thumb|429x429px|From left to right: The original model, smooth enabled, smooth disabled.]] | |||
* The Yaw/Elevation offset sliders is the way to virtually rotate the object. | |||
=== Lit / Unlit === | |||
By default, impostor shaders are rendered lit. You can change this for a provided unlit shader. | |||
=== LODGroup Management === | |||
If you tick the toggle 'LODGroup Setup' in the editor window, '''the impostor will be part of a LODGroup''' when the baking process ends. | |||
From there, there are 3 possible scenarios: | |||
# The target object is not part of a LODGroup : It will be created with the provided settings. | |||
# The target is already part of a LODGroup in which there is no impostor : the impostor will be added in last position with the provided transition height value. | |||
# The target is already part of a LODGroup in which there is already an impostor : The impostor will be replaced. | |||
<blockquote>Tip: if you want to add an additionnal impostor in a LODGroup instead of replacing it, just delete the ImpostorReference component on the LODGroup holder before baking.</blockquote> | |||
=== Presets === | |||
You can save and load presets by pressing the buttons "Load Preset" and "Save Preset" respectively. It will save/override the following settings: | |||
* Resolution | |||
* Latitude Samples | |||
* Latitude Offset | |||
* Latitude Angular Step | |||
* Longitude Samples | |||
* Sphere Type | |||
=== How to bake several objects at once === | |||
Since version 3.4, there is a new component called "AutoLODImpostorsQueue". Here is how to use it: | |||
* Create an empty GameObject in the scene. | |||
* Add the component "AutoLODImpostorsQueue" from the bottom of the inspector. | |||
* In the script editor, you can fill the array with the objects you want to bake. | |||
* Click on the "Show settings" button. The AutoLOD Impostor window will dock next to the inspector. | |||
* Tweak the settings as you want. | |||
* Come back in the queue inspector and click on "Generate Impostors" | |||
* Take a coffee while your objects are baked automatically | |||
==== Warnings: ==== | |||
* Baking a lot of objects at once may take a long time (depending on your settings and hardware) | |||
* Don't try to interrupt the process. It could lead to a corrupted scene. | |||
* Keep the focus on the unity editor. | |||
== Contact == | |||
[mailto:support@leochaumartin.com support@leochaumartin.com] | |||
== References == | |||
https://www.gamedeveloper.com/programming/dynamic-2d-imposters-a-simple-efficient-directx-9-implementation | |||
https://calcifer.org/kenneth-christiansen/ComputerScience/imposters.pdf | |||
Latest revision as of 14:38, 11 February 2024
Setup
The whole package is contained in the AutoLOD - Impostors folder resulting from the import. You can move it wherever you want, but it is recommended to keep the same folder structure.
What is an impostor
An impostor or imposter is a billboard whose material displays a picture of a 3D object. Depending of the view angle, a different picture of the object will be displayed, to fake a 3D effect. Several pictures from several angles are baked into an atlas texture to access them quickly.
How to use
Basics
AutoLOD Impostors
consists in an editor window. You can open it via Window->AutoLOD->Impostors
.
Drag & drop the object to be processed into the ”Target” field. Please note that a MeshFilter is required otherwise the object cannot be added.
Click on the Generate Impostor
button and wait a few seconds. Unity will temporarily open another scene and enter/quit play mode, just let it do it, don't try to stop the process.
When you get back in the scene, your object should now have a LODGroup attached / updated, and the impostor should be instantiated as its children. Try to zoom out to see the LOD transition between the original object and its impostor.
Advanced
The provided scene BakingScene-Default
is automatically loaded in the Baking Scene object field. Note that you can use your own scene, the only constraints are the presence of an object named "Target" and a main Camera with the script ImpostorTexturesGenerator
attached.
If you are using URP, you must also fill in the
UniversalRenderPipelineAsset
and theUniversalRendererData
fields at the bottom of the camera impostor.
The provided scene is the recommanded one for high-fidelity results, but you can modify the lighting settings or add objects in the scene to achieve some interesting result. It's up to your imagination!
- You can change the generated atlas size with the
Texture Size
popup. The estimated size below gives an idea of the full impostor (Albedo atlas + Normals atlas + Billboard) size on the disk after DXT1/DXT5 compression. - The atlas is baked following a sphere vertices coordinates. Currently, two types of sphere are available.
- UV sphere: The default choice. The UV sphere is based on a constant number of longitude and latitude samples. The coverage is denser at the poles.
- Pseudo-Fibonacci sphere: at an experimental stage. Provides a homogeneous coverage. Not compatible with latitude smoothing in the impostor shader.
- UV sphere: The default choice. The UV sphere is based on a constant number of longitude and latitude samples. The coverage is denser at the poles.
- The Optimization info panel is some read-only information to help understanding the coverage and the atlas layout.
- The LOD Group Settings panel contains the settings of the upcoming LODGroup. If you don't want to setup any LODGroup and just bake an impostor, you can uncheck the panel toggle.
- Impostors baked as prefab only. You have to enter a valid output path (i.e. child from the Assets/ folder). A preview text will display the full path of the upcoming impostor.
Post baking improvements
If you select the impostor object in the hierarchy, you will see that the shader has a few parameters to improve the fidelity.
- The Brightness slider can increase/decrease the albedo power.
- The Smoothness/Metallic/Occlusion sliders work the same way than the default diffuse material.
- The Curvature Occlusion slider applies an additionnal occlusion in rifts, sharp inward angles.
- The Cutout slider can increase/decrease the sharpness of the alpha clipping geometry.
- The Smooth toggle turns On/Off impostor bilinear interpolation smoothing.
- The Dithering Fade toggle turns On/Off Dithering fading on the edges of the impostor.
- The Yaw/Elevation offset sliders is the way to virtually rotate the object.
Lit / Unlit
By default, impostor shaders are rendered lit. You can change this for a provided unlit shader.
LODGroup Management
If you tick the toggle 'LODGroup Setup' in the editor window, the impostor will be part of a LODGroup when the baking process ends.
From there, there are 3 possible scenarios:
- The target object is not part of a LODGroup : It will be created with the provided settings.
- The target is already part of a LODGroup in which there is no impostor : the impostor will be added in last position with the provided transition height value.
- The target is already part of a LODGroup in which there is already an impostor : The impostor will be replaced.
Tip: if you want to add an additionnal impostor in a LODGroup instead of replacing it, just delete the ImpostorReference component on the LODGroup holder before baking.
Presets
You can save and load presets by pressing the buttons "Load Preset" and "Save Preset" respectively. It will save/override the following settings:
- Resolution
- Latitude Samples
- Latitude Offset
- Latitude Angular Step
- Longitude Samples
- Sphere Type
How to bake several objects at once
Since version 3.4, there is a new component called "AutoLODImpostorsQueue". Here is how to use it:
- Create an empty GameObject in the scene.
- Add the component "AutoLODImpostorsQueue" from the bottom of the inspector.
- In the script editor, you can fill the array with the objects you want to bake.
- Click on the "Show settings" button. The AutoLOD Impostor window will dock next to the inspector.
- Tweak the settings as you want.
- Come back in the queue inspector and click on "Generate Impostors"
- Take a coffee while your objects are baked automatically
Warnings:
- Baking a lot of objects at once may take a long time (depending on your settings and hardware)
- Don't try to interrupt the process. It could lead to a corrupted scene.
- Keep the focus on the unity editor.
Contact
References
https://calcifer.org/kenneth-christiansen/ComputerScience/imposters.pdf