Unity Products:Amplify Impostors/Manual

From Amplify Creations Wiki
Revision as of 18:31, 24 February 2021 by ampwiki>AmplifyWiki (→‎FAQ)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Product Page - Manual - Custom Baking - Lightmap Baking - Roadmap

Description

Amplify Impostors is a small but powerful tool that allows the creation of different types of Impostors, which are substitutes of complex high polycount objects made from flat and simple polygons, that render a fake version of the original object (hence the name). Much like traditional sprites, they usually consist of a single flat quad polygon or simple polygonal shapes and, like classic billboards, always face the camera. Think of them as a camera facing cardboard version of the object you want to render. The common purpose of using such technique is to be able to represent far distant objects with a very low polycount, for instance, trees, bushes, rocks, ruins, buildings, props, etc.

There are various ways these impostors can be created, each with their own advantages and disadvantages. This tool intends to provide the most useful and popular techniques while making the process of creating them as simple as possible.

Installation

  1. Open AmplifyImpostors.unitypackage
  2. After Unity loads it will display the "Importing package" window, select All and click Import
  3. Warning - If you're using Amplify Shader Editor in the same project, please make sure that you have both packages up-to-date; check your console for any errors pertaining to it.

Quick Start Instructions

  1. Select a game object in the scene or a prefab in your project
  2. In the inspector window search for and add the "Amplify Impostor" component
  3. Press "Bake Impostor" and select where you want to save the impostor files

Current Features

Impostor Types

Three pre-baked Impostor types are currently supported

(Real mesh on the left, impostor on the right)

SphericalExample.gif Spherical.png
  • Spherical: Takes multiple shots in a typical latitude-longitude format. The shader is simpler and faster and the impostor looks mostly okay from close distances, but popping between frames is fairly noticeable. This can be mitigated somewhat by increasing the axis frame count at expense of resolution.
OctahedronExample.gif Octahedron.png
  • Octahedron [1]: Takes multiple shots in a icosphere format. This is done to guarantee a fixed neighbor count of three, so that at any given position relative to the camera we can blend the nearest three frames. This has the benefit of removing popping between frames. On the other hand the shader complexity is higher and, when looking at closes distances, the blending becomes too obvious with noticeable ghosting artifacts.
HemiOctahedronExample.gif HemiOctahedron.png
  • HemiOctahedron [1]: The hemi variant is similar to regular octahedron, with the difference on taking the same amount of shots but only from the upper hemisphere of the object, effectively doubling the precision of the blending. The downside though is that, by not baking the lower hemisphere, it produces incorrect results when looking from below. This approach is typically used only if you know the object will always be viewed from above (ie: top-down cameras).

Realtime Rendering

Each one of these pre-baked solutions render surface component maps in order to support realtime lighting. This comes with support for:

  • Scriptable Render Pipeline (HD and LW) (v4.9.0+)
  • Standard/Legacy Forward and Deferred rendering
  • Dynamic Lights and Shadows
  • Depth writing for object intersections
  • Global Illumination
  • Baked Lightmaps (via custom baking)
  • GPU instancing
  • Dithering cross fade

Others

  • Custom Packed Maps: Render up to 4 maps and a custom material for standard material baking and up to 8 different maps using custom baking (support for PNG and uncompressed TGA)
    • Albedo (RGB) | Alpha Mask (A)
    • Specular (RGB) | Smoothness (A)
    • Object Normals (RGB) | Depth (A)
    • Emission (RGB) | Ambient Occlusion (A)
  • Custom Shape Editor: Automatically generates a custom shape to remove most of the transparent areas of the impostor to reduce overdraw. Also supports manual editing.
  • Baking Presets: Defines presets for baking impostors which also contain various import and export options.

Scriptable Render Pipeline

In order to use Amplify Impostors with SRP, be sure to import the required package( AmplifyImpostors\Plugins\EditorResources\RenderPipelinePackages ).

Please not that for HDRP there are two available packages since the latest HDRP 10 changed quite a bit and a new set of shaders and baking tools had to be created.
When using HDRP versions up to 9.x.x then the correct package to import is:

  • AmplifyImpostors\Plugins\EditorResources\RenderPipelinePackages\Legacy\ImpostorsHDRP 9xx (Legacy).unitypackage

For HDRP 10 version please import:

  • AmplifyImpostors\Plugins\EditorResources\RenderPipelinePackages\ImpostorsHDRP.unitypackage

The Inspector

The inspector for the impostor is divided in two main sections, one is to setup its basic definitions and the other gives access to more advanced bake settings.

Here's the main inspector:

SimpleInspector.png
  • Impostor Asset: This is a reference to the asset that will hold most of the impostor data so if you have multiple impostor of the same object this data will be shared among them. This asset is created automatically for you with the create or bake button but you can also right-click in the project folder and create an empty one.
  • LOD Group: This a reference for a LOD Group in case it exists. This allows to automatically setup the impostor in the given LOD Group. The inspector will try to fill this reference for you when you add the component.
  • References: These are the references to the renderers that will be used to bake the impostor. You can limit what you bake to the impostor by changing these references accordingly. The inspector will try to fill this reference for you when you add the component.
  • Plus Button: Open the file browser and creates an impostor asset and automatically assigns it to the component. Doing this also makes the baking settings available.
  • Bake Impostor: Bakes the impostor using the current data asset and given path.

When an impostor asset is assigned to the component you can configure the advance bake settings:

ExtraOptions.png
  • Bake Type: Technique used for both baking and rendering the impostor. Three different techniques are currently supported with more coming in the future. See Impostor Types.
  • Texture Size: The texture size in pixels for the final baked images. Higher resolution images provides better results at closer ranges, but are heavier in both storage and runtime. Big texture sizes are rarely necessary considering the purpose of the impostor is being rendered at far distances. Various presets are offered and, if a custom resolution is necessary, press the lock icon at the right to allow for custom size fields.
  • Axis Frames: The amount frames per axis. For instance, a value of 16 represents a total 256 different shots for a single impostor (16 x 16 = 256). For spherical impostors it's possible to have different number of frames per axis by pressing the lock button at the right.
  • Pixel Padding: The bleeding size in pixels. Bleeding/padding expands the edge pixels of the individual shots to avoid rendering artifacts caused by mipmapping. A value of 32 means the image will expand to every direction by 32 pixels.
  • LOD Insert Mode: A rule of how the impostor will be automatically included in the LOD Group. This is only available on first bake and it will automatically change the renderers in the References field appropriately.
    • Do Nothing: Does nothing.
    • Replace Culled: Replaces the culled part of LOD Group to an impostor. Uses Last LOD as reference.
    • Replace Last: Replaces the last LOD of LOD Group to an impostor. Uses the previous LOD as reference.
    • Replace All Except First: Replaces all LODs of LOD Group to an impostor except the first. Uses the first LOD as reference.
    • Replace Specific: Replaces the target index LOD of LOD Group to an impostor. Uses the previous LOD as reference.
    • Replace After Specific: Replaces all LODs after the target index LOD of LOD Group to an impostor. Uses that LOD as reference.
    • Insert After: Inserts a new LOD as an impostor after the target index LOD. Uses that LOD as reference.
  • LOD Target Index: It's the index target for the insert mode. Only available if the current insert mode supports changing the target.

Billboard Mesh

The baker uses unity's built in shape editor to find a good approximation of the shape in place. This approximation might still need improvements in terms of polycount and shape, so some additional options are provided to better control it. Usually there's no need to touch these settings, but there might exist some odd cases where even the manual mode is necessary for some finer adjustments.

MaxVerts.gif
  • Max Vertices [4,16]: By defining a maximum number of vertices it ensures the final created amount does not exceed it. If that happens, each vertex that contribute with the smallest area to the shape will be removed until the specified value is met.
OutlineTol.gif
  • Outline Tolerance [0,1]: This parameter allows the final shape to more tightly fit the object by increasing its number or vertices. A tolerance of 0 will make sure the generated shape encapsulates the entire object, even if it means a more loose and simplified mesh, while a value of 1 will try to fit the shape as close as possible with a reasonable number of vertices.
NormalScale.gif
  • Normal Scale [0,1]: This scales the vertices out according to the shape normals. If the shape touches the preview quad borders, they get clamped and vertices are eliminated if necessary. A quick way to produce a quad is to max this value out.
ManualMesh.gif
  • In the manual mode you can still use the automatic tools but you can further tweak each vertex position individually.


Bake Preset

Sometimes you want to bake an impostor with standard settings but with one or two changes, this bake preset allows you to create and use a preset of configurations to customize the baking result. This is particular useful for custom baking, as it's also used to link the shader and baked textures to the final impostor material.

With the first field you can select your previously created preset or you can create a new one. Do note that you can only change the preset itself in the preset inspector when you select the preset file. Otherwise, all changes done in the impostor inspector are just individual overrides that are saved per impostor. This is reason that, by default, all other fields are greyed out and locked.

BakePresetOptions.png
  • Bake Shader: This is the shader used to bake the impostor. When empty it uses the deferred pass of the same shader the original object has automatically.
  • Runtime Shader: This is the shader that actually uses the baked result and renders the impostor. When empty it uses the default shaders that come with the package automatically.


  • RT#: The numbered Render Texture output file. Which can be toggled ON and OFF in case you only need to rebake some maps.
  • Suffix: The texture file suffix and material property reference. This will be used to correctly link the output texture to the proper field in the final material.
  • Scale: This is a relative scale parameter that allows to automatically configure the texture import settings to resize the texture into half, quarter and eighth of the original size. Useful to reduce individual texture size if you don't need all maps to be at full resolution.
  • sRGB: This marks the texture importer to use color sRGB standard or Linear information. As a rule of thumb, set it to true if the information is color and false if it's just data.
  • Compression: Changes the texture importer compression setting. Higher compression means smaller textures but also longer baking times and lower texture quality.
  • Format: Final file format, for now only PNG and uncompressed TGA. TGA is faster to bake and save to disk but takes more disk space. This does not affect the compression and quality of the texture.
  • Ov (Override Mask): This is a multi select mask field that allows you to control which parameters you want to override. You can override just one parameter or the whole texture output setup.

Global Preferences

Some behaviors of the inspector and resulting bakes can be changed globally. You can find these settings in Edit > Preferences > Impostors.

GlobalPreferences.png
  • New Impostor Default Path: At the first bake, and if not set, the editor will suggest a relative folder when the object is a prefab or an instance of one. It will then remember the path for every subsequent bake. You can change the proposed folder here by using a relative valid path. If you want to keep all your impostors at the same place and don't be bothered again, you can also set them in a global folder by changing the option to Global, you can then use the right browse button.
  • Texture Importer Settings: When rebaking the impostor with a different texture resolution you can change how the inspector behaves here (options are self-explanatory):
    • Ask if resolution is different
    • Don't ask, always change
    • Don't ask, never change
  • Create LODGroup if not present: Setting this ON will automatically create a hierarchy with LOD Groups and setup the original object with the impostor in it. Only works if original object doesn't already has a LOD Group.
  • Suffixes: By default the files generated share the same name as the original object with an added suffix, you can change the suffixes here.

Known Issues

HDRP Custom Diffusion profile bakes can result in incorrect bakes, we're looking into this.

FAQ

Q: Does it support Scriptable Render Pipeline like Universal(URP) or HighDefinition (HDRP) SRP?

A: Yes, as of version 0.9.3 both Render Pipelines are supported, just make sure to import the corresponding package(AmplifyImpostors\Plugins\EditorResources\RenderPipelinePackages) before creating an impostor and that your SRP of choices uses any version >=4.9.0. Render pipeline used is automatically detected. If you are using your own render pipeline you'll need to create the appropriate bake and runtime shaders using custom baking.


Q: I can see some artifacts at the edge of my impostor, how do I fix it?

Artifacts.PNG

A: This issue rarely happens because it's dependent on the original object shape. Those artifacts are actually the neighboring frames peeking through, in order to remove it you can't try to adjust the mesh to more tightly fit the object. If that still doesn't help, you can activate a shader define that removes it at a cost of a few extra instructions:

  1. Search and open for the AmplifyImpostorsConfig.cginc file.
  2. At the top find the #define AI_CLIP_NEIGHBOURS_FRAMES 0 entry and activate it by changing it to #define AI_CLIP_NEIGHBOURS_FRAMES 1 and saving.


Q: Does it work with Amplify Shader Editor?

A: Yes, specifically in regards to the creation of custom Bake and Runtime Impostor shaders. Be sure to use the latest version available, otherwise you will likely encounter a few errors. Check your console after importing AI or ASE for any possible issues.

Q: Does this replaces LODs?

A: Mainly no. Don't think of this as a replacement of regular LODs since impostors look progressively worse at close range, but more as an extension of it by replacing the last LOD level. For close to medium ranges you still want to use regular LOD meshes.


Q: Does it support unity LOD groups?

A: Yes, and also supports cross-fading. Just make sure to bake an impostor that matches the previous LOD level object for the best match when transitioning between the LOD levels.


Q: Why are impostor shadows so weird? Especially up-close.

A: It's partially due to the blending done between the frames which doesn't always match the binary nature of shadows, and also the differences in the depth between what lights "see" and what the camera renders. We'll try to improve this in the future, meanwhile you can try to refine how the shadow looks by changing the "Shadow Bias" and "Shadow View" in the light settings and/or in the impostor material property. The first pushes the shadow further away and the second flattens the shadow depth according to the view.


Q: Does it supports Anti-Aliasing?

A: Mostly. Just like regular sprites MSAA is not supported because it only helps the edges of geometry, but other screen space solutions do work, like FXAA or TXAA.


Q: Does it support Image Effects?

A: In most cases it should. There might be some precision issues if the effect is depth dependent, like SSAO, but for the most part it should work properly.


Q: Does it support metallic and specular pipelines?

A: Yes. Currently the baker generates a specular map regardless of the input materials for standard materials. This ensures both pipelines are supported, as metallic maps are transformed into specular ones. However you can use custom baking to specify the use of metallic pipeline and even pack it together with other maps reducing the overall texture count.


Q: Does it support skinned mesh objects?

A: No. It does however support animation of objects like moving, rotating and scaling, but not animated skinned meshes like characters. We do plan to provide a realtime baking variant that allows for animated objects to be rendered as impostors at some specified rate.


Q: Does it support SpeedTree assets?

A: Yes, and also supports hue variation. By default hue variation is off but you can turn it on in the impostor material.


Q: What can I do to improve the quality at close range?

A: Unfortunately the only thing you can do right now is to increase the texture resolution. This usually isn't enough to properly render an impostor at close range since other artifacts start to become obvious. Please notice that impostors are NOT intended to be rendered at close range, they are not a substitute for "real meshes", but rather an improvement of performance when rendering them from afar. So it's recommended that you use resolutions that are good enough for long distances. 2k maps are usually okay for that, and for mobile you can even get away with 1k maps.

Technical Considerations

Note that currently, standard baking, is only supported if the shader exposes a Deferred path, such as Unity Standard shaders. However, the Impostors created can be used in both Forward and Deferred modes. If the original mesh has a custom forward-only shader(e.g. Cartoon Custom Lighting) like many assets from the asset store do, you'll need to bake it using a custom baking shader.

When using Amplify Impostors in conjunction with Amplify Shader Editor, be sure to use the latest versions available as not doing so will result in a few errors.

References

  1. Octahedral Impostors by Ryan Brucks
  2. Chapter 21. True Impostors by Eric Risser
  3. Real-time Realistic Rendering and Lighting of Forests by Eric Bruneton, Fabrice Neyret