All Projects → aflesher → Entitypostprocessor2d

aflesher / Entitypostprocessor2d

Licence: mit
A unity package for applying post-processing effects to assembled 2D assets

Projects that are alternatives of or similar to Entitypostprocessor2d

Standardgeometryshader
An example of a geometry shader with Unity's standard lighting model support.
Stars: ✭ 303 (+1682.35%)
Mutual labels:  unity, effects
Kinocontour
Contour line filter for Unity
Stars: ✭ 400 (+2252.94%)
Mutual labels:  unity, effects
Postprocessing
Post Processing Stack
Stars: ✭ 3,524 (+20629.41%)
Mutual labels:  unity, effects
Isaura
An attempt at making a aura thingie with a isoline shader.
Stars: ✭ 187 (+1000%)
Mutual labels:  unity, effects
Super Blur
Screen and UI gaussian blur for Unity
Stars: ✭ 543 (+3094.12%)
Mutual labels:  unity, effects
skyline
Some canvas experiments... like drawing a procedurally generated skyline. Also featuring fun explosions :D
Stars: ✭ 24 (+41.18%)
Mutual labels:  effects, 2d
Futile
A super simple Unity 2D framework
Stars: ✭ 770 (+4429.41%)
Mutual labels:  unity, 2d
2d Unity Experiments
A collection of visual Unity experiments with latest packages (URP, Shader Graph, Cinemachine, etc).
Stars: ✭ 107 (+529.41%)
Mutual labels:  unity, effects
Kinomotion
Motion blur post-processing effect for Unity
Stars: ✭ 484 (+2747.06%)
Mutual labels:  unity, effects
Unitybookpagecurl
Page curl effect for Unity3d using UGUI
Stars: ✭ 464 (+2629.41%)
Mutual labels:  unity, effects
Unity Aseprite Importer
An aseprite-file importer for unity written in C#, built upon the experimental AssetImporter API
Stars: ✭ 177 (+941.18%)
Mutual labels:  unity, 2d
Unityplayground
A collection of simple scripts to create 2D physics game, intended for giving workshops to a young audience
Stars: ✭ 603 (+3447.06%)
Mutual labels:  unity, 2d
Kinotube
An image effect simulating analog video artifacts in Unity.
Stars: ✭ 142 (+735.29%)
Mutual labels:  unity, effects
Machinelearningroguelike
A small Roguelike game that uses Machine Learning to power its entities. Originally used in talks by Ciro & Alessia.
Stars: ✭ 270 (+1488.24%)
Mutual labels:  unity, 2d
Shurikenplus
A collection of custom shaders for Unity particle system (Shuriken).
Stars: ✭ 121 (+611.76%)
Mutual labels:  unity, effects
Navmeshplus
Unity NavMesh 2D Pathfinding
Stars: ✭ 347 (+1941.18%)
Mutual labels:  unity, 2d
Spriteglow
A sprite glow effect for Unity game engine
Stars: ✭ 1,287 (+7470.59%)
Mutual labels:  unity, 2d
Particleeffectforugui
Render particle effect in UnityUI(uGUI). Maskable, sortable, and no extra Camera/RenderTexture/Canvas.
Stars: ✭ 1,941 (+11317.65%)
Mutual labels:  unity, effects
Skeletalgeometriceffects
Experiments on geometry shader instancing with skeletal animations
Stars: ✭ 436 (+2464.71%)
Mutual labels:  unity, effects
Spritedicing
Unity extension for reusing sprite texture areas
Stars: ✭ 589 (+3364.71%)
Mutual labels:  unity, 2d

Entity Post-Processor 2D

Description

This tool allows developers to easily run filters and effects on multi-image, assembled mesh or 3D objects. See a demonstration here.

The Problem

2D skeleton animation tools like Spine 2D are fantastic for creating 2D artwork in games. They allow for smooth animations while reducing the amount of assets required for each object. A drawback of these assets is that they are comprised of multiple images. Any effects that are applied to the asset are applied to the individual images and not the assembled mesh that you see on screen.

Let's take a look at an example of when this becomes an issue. Say you want to apply an outline effect. We start with following images

which are assembled into the following mesh at runtime

when we attach a simple outline shader we get the following

not only is there some clipping issues based on the bounds of our sample images but you can see that each individual piece is outlined. What we want is this

The Solution

A common technique to solve this problem is to use a multi camera setup that captures the assembled mesh and renders it to a texture.

This can be a lot to manage though. Entity Post-Processor 2D seeks to automate the setup and management of this multi camera solution for you.

Getting Started

Setup

  1. Create a new layer named EntityPostProcessor. You should treat this as a reserved layer and never directly add anything to it
  2. Remove this new layer your main camera Culling Mask.
  3. Select the Main Camera from your Scene Hierarchy
  4. Open the Culling Mask drop down in the camera component in the Inspector
  5. Select EntityPostProcessor to remove it from the Culling Mask

Create an EntityController

  1. Right click on the scene Hierarchy and select EntityPostProcessor2D->Controller
  2. Attach any 2D assets you want to display to the child object EntityRenderSource of your new EntityController gameObject. (note: you can replace this RenderSouce object with your own gameObject instead of making it a child object. Just be sure to attach an EntityRenderSource component to your object)
  3. Position the EntityRenderSource relative to the parent EntityController however you want.
  4. Set the Sorting Layer and Order In Layer that you want your EntityRenderSource to appear on.
  5. Check Show Camera Rect is checked
  6. You should see a blue square around the asset(s) you used in your render source. This represents the area that will be captured by the post processing camera. The goal is to make this as small possible without your asset(s) going outside this blue box.
  7. You can change this capture size by changing the Render Texture Size Width and Height.
  8. You can also change how your asset is positioned within the camera with Source Capture Offset
  9. Play around with Render Texture Size and Source Capture Offset until you've found the best fit. Also remember, this has to account for animations.

Create an EntityPostProcessor

  1. Right click on the scene Hierarchy and select EntityPostProcessor2D->PostProcessor
  2. Drag this object into your Project hierarchy and delete it from the scene
  3. Assign this EntityPostProcessor prefab to the PostProcessor field of the EntityController component you previously created

Note: A single EntityPostProcessor prefab can be used by many/all of your EntityController objects. Each EntityController will always create an its own instance of the EntityPostProcessor though.

Test it

At this point when you run your scene your new EntityController shold be displayed as if nothings changed. If you look at the EntityController the EntityRenderSouce should have be replaced with a Render Texture.

Add some effects to your Entity

Any scripts attached to your EntityPostProcessor can apply post-processing effects to your entity using the OnRenderImage function. See the docs for more details.

To see a few sample effects you can attach EntityPostProcessor2D/Examples/Scripts/EntityEffects scripts to your EntityPostProcessor prefab

Troubleshooting

Issue

My asset(s) appears cut off

Solution

Enable Show Capture Rect and then change the values of Source Capture Offset until the character fits within the blue box. Increase the Render Texture Size if needed.


Issue

A character appears twice on the screen

Solution

Make sure that your main camera and other cameras have the EntityPostProcessor layer removed the Culling Mask.


Issue

How do I refence the EntityRenderSource from the EntityController and vice versa?

Solution

Both components keep a reference to the other. If you have a attach a script MyEntity to your entity and a script MyRenderSource to your render source

MyEntity

using EntityPostProcessor;
public class MyEntity : MonoBehaviour
{
    MyRenderSource renderSource;
    void Start () {
        renderSource = GetComponent<EntityController>().renderSource.GetComponent<MyRenderSource>();
    }
}

MyRenderSource

using EntityPostProcessor;
public class MyRenderSource : MonoBehaviour
{
    MyEntity entity;
    void Start () {
        entity = GetComponent<EntityRenderSource>().controller.GetComponent<MyEntity>();
    }
}

Issue

I can't get 3rd party effects libraries like 2DxFX to work with this tool.

Solution

This tool renders your assets to a MeshRenderer + MeshFilter "Quad" and a lot of these effects expect a SpriteRenderer. So although they might not work out of the box it might be possible to modify them to work.

With 2DxFX a lot effects simply require a search and replace on SpriteRenderer for MeshRenderer on the effect script file. Once you've done this attach the script to the EntityRenderOutput child object of your EntityController

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].