# AutoBlend

AutoBlend is a tool to automatically calculate the blend masks of projectors or throwers.

If we have several projectors projecting onto the same objects with overlaps, the overlaps would be visible in the projection. That’s why *softedge blending* is applied and AutoBlend can calculate them for you automatically. So let’s say we have 2 projectors and 3 primitives in the scene from chapter *Map your 3D objects to projectors.*

<div align="left"><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2Fgit-blob-575b93e98e4b068cab5b423c0fb97498cdabdd8c%2F3%20primitives%20and%202%20projectors.png?alt=media" alt=""></div>

To AutoBlend the 2 projectors, you should open the **AutoBlend** window by either pressing the F8 shortcut or by going to **Tools** -> **AutoBlend**.

<div align="left"><figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2Fgit-blob-049315aa55d2115a389c030e14f6e07876d4c878%2F090424-ToolTopBarAutoblend.png?alt=media" alt=""><figcaption></figcaption></figure></div>

Make sure to select all 3 primitives and click on **Blend** button. After this, the blend masks should appear on the right.

<figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2Fz9GLwxNJEG6YjTRjwmQ3%2Fimage.png?alt=media&#x26;token=70fd4eed-a9fd-423b-b9f4-2f77d0fa368c" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
Please make sure that all the projected objects have render mode set to *Unshaded*. Otherwise blending might not be perfect.
{% endhint %}

## AutoBlend settings

AutoBlend has a few settings that will allow you to fine-tune the blending, especially when you project on complex 3D projection objects:

* **Blend on open**: if checked, AutoBlend will recalculate blend masks when you open the project file.
* **Blend every frame**: if checked, AutoBlend will recalculate blend masks every frame. Should be checked only when projectors or projection objects are moving.
* **Mute all AutoBlend nodes**: disables AutoBlend on the outputs.&#x20;

{% hint style="info" %}
**Good to know**: if you want to automatically trigger AutoBlend you can use **Run Autoblend** node.

![](https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2F0eu4bIMGVdyhPSqU04EI%2Fimage.png?alt=media\&token=cf38b528-2348-4cfb-8a99-4181d874e6cf)
{% endhint %}

{% hint style="info" %}
**Good to know**: when we say a 'complex' 3D object we mean a 3D object whose faces (or normals) face in a lot of different directions. This means you will need an array of projectors to cover every face of the object, that these projectors will have a lot of overlap and that the incident light of these projectors will fall onto projection object at angles ranging from perpendicular (90°to the surface) to very shallow (close to 0°)
{% endhint %}

### Blend with distance

If your projectors are positioned at different distances from the projection object, you have an option to check **Blend with distance** checkbox.&#x20;

{% hint style="info" %}
**Good to know**: In most projection projects, it is highly recommended that when you project on a single object or a single set of objects, that you use identical projectors which are positioned at a roughly similar distance from the projection object. Otherwise it will be harder to blend them together.
{% endhint %}

See below the differences in how AutoBlend calculates blend masks with and without *Blend with distance* enabled when one of the projectors is moving back and forth.

<figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2FzHrpQB8S04dIb9fl6r8C%2FAutoBlend-BlendWithoutDistance.gif?alt=media&#x26;token=a345a12f-5f2b-4d4d-877e-ba74125b2e8b" alt=""><figcaption><p>AutoBlend with Blend with distance disabled</p></figcaption></figure>

When **Blend with distance** is **disabled**, you see that the blend mask on the actual objects hardly changes when the projector is moving.

<figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2FegKTfxOMrMpRMplcbSq9%2FAutoBlend-BlendWithDistance.gif?alt=media&#x26;token=8b01ebc9-3daf-44ef-9409-4c99a2aa577e" alt=""><figcaption><p>AutoBlend with Blend with distance enabled.</p></figcaption></figure>

When **Blend with distance** is **enabled**, AutoBlend takes the distance fully into account when calculating the blend mask.

### Angle cutoff

{% hint style="info" %}
**Good to know**: the purpose of *Angle cutoff* feature is to reduce pixel stretching as much as possible.
{% endhint %}

Angle cutoff is a very useful feature that eliminates pixel stretching as much as possible, which is a problem when you are projecting on a complex 3D object.&#x20;

It does that by calculating the incident angle of light rays from all the projectors and then:

* **apply the least blending** to the projectors which project light on a particular face with **the most perpendicular angle** and
* **apply the most blending** to the ones which project light on a particular face with **the sharpest angle**.

{% hint style="info" %}
**Good to know**: if you project on an object with a perpendicular angle, the pixels will have the least stretching. If you project with a shallow angle, there will be alot of stretching. Use [Projection study ](https://docs.lightact.com/projection-mapping/projection-study)feature to analyze that.
{% endhint %}

To explain how angle cutoff works, let's look at our projection mapping setup again where we have 2 projectors and 3 projection objects.

<figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2F42gDQAMlYHlpIcNuS75X%2Fimage.png?alt=media&#x26;token=caf96417-9b70-4c34-847c-785cb0537b73" alt=""><figcaption><p>AutoBlend with Angle cutoff disabled</p></figcaption></figure>

With **Angle cutoff disabled** you get these sharp cutoffs between blend masks. These sharp edges usually don't look so good in reality.

<figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2FBYSP4HocI95Hbr3hx6S8%2Fimage.png?alt=media&#x26;token=099e3c47-4caa-4dc4-aec0-9d4ff4b59105" alt=""><figcaption><p>AutoBlend with Angle cutoff enabled</p></figcaption></figure>

With **Angle cutoff enabled** there are fewer sharp edges between blend masks.

{% hint style="warning" %}
Please note, sharp edges in blend masks that originate from projector shadows will not be removed by *Angle cutoff* feature. To reduce these you might want to optimize the position of the projectors using [Projection study](https://docs.lightact.com/projection-mapping/projection-study).

![](https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2FyqJLb1MqLNqpZdDzzWRZ%2Fimage.png?alt=media\&token=de68f61f-d07e-42f9-936e-fd6583e5550d)
{% endhint %}

## Modifying the masks manually

Now, where are these blend masks applied? If you double click on one of the projectors, you will open its Layout.

<figure><img src="https://3312042618-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVaJpWJhPbmscipukhh%2Fuploads%2FOnGApdsjNnnnniQNmShg%2Fimage.png?alt=media&#x26;token=00a14af2-2a8f-4172-8bfe-2e1404c7f5ce" alt=""><figcaption></figcaption></figure>

On the bottom left part of the layout you can see the **AutoBlend** node, which outputs the blend mask. This is then connected to **Texture Blend** node, which blends it with the content itself (the **Input** node).

If you want, you can further adjust the blend masks manually using the nodes.
