Page 1 of 1

Color Masking - support for sprites?

PostPosted: Mon Feb 16, 2015 2:36 pm
by PGAKelly
Hello,

I'm currently evaluating Amplify Color for use in a 2D mobile game. Essentially what we want to do is edit the colors of a few select objects in the scene to match the background.

I've taken the color mask sample and copied the setup into my own project. Unfortunately the sample does not take the Alpha of the sprite into account - leading to color correction being applied to transparent areas of the texture.

see below image for the problem (using an invert lut texture).

Image

Any ideas what I could do to fix this?

Thanks :)

Re: Color Masking - support for sprites?

PostPosted: Wed Feb 18, 2015 1:45 pm
by Diogo Teixeira
Hi PGAKelly,

It's perfecly possible, and fairly quick to implement using our dynamic color mask as a basis:
http://amplify.pt/wp-content/download/A ... Sample.zip

In this project, we're rendering unfocused objects as white, a focused object as black, both on a white background render texture, in order to create a grading mask that excludes the focused object only.

In your case you want to write the alpha value to the mask, and also exclude pixels that aren't visible (cutout) to avoid sprite overlapping issues. Here's a modified version of the shader that supports alpha and cutout. It assumes that the opacity is in Base texture alpha channel:
https://dl.dropboxusercontent.com/u/140 ... der.shader

This should be all you need to create dynamic masks that are sensible to alpha.

Hope this helps.

Cheers

Color Masking SteamVR/Vive

PostPosted: Sun Oct 01, 2017 4:12 am
by gregdowning
I found that these scripts do not work with SteamVR and Vive using the standard [CameraRig] prefab from SteamVR and unity 2017.1.

I set up a volume and I tried re-creating what was in the example using the ColorMask script on the Camera(eye) removing my target object from the layers then duplicating the Camera(eye) and putting it under primary Camera(eye) and dropping it into the Mask camera field. The scene worked but would not respond to the color volume.

If instead I create duplicate camera (head)s and have each (eye) renderer a different layer it does put the two layers together but even if I remove amplify from one of the (eye)s it still applies the LUT to the whole scene. This is not how I would expect it to behave, why is the script having an effect on a camera that it is not attached to?

UPDATE, The whole camera rig had to be duplicated rather than just the head, now I can get the lut to only effect the objects on a given layer.

Re: Color Masking - support for sprites?

PostPosted: Sun Oct 01, 2017 2:58 pm
by Ricardo Teixeira
Thank you for getting in touch. Is the problem completely resolved?

Thanks!

Re: Color Masking - support for sprites?

PostPosted: Mon Oct 02, 2017 1:44 am
by gregdowning
Hmmm, think I tricked myself into thinking I had it working but it clearly is not.

Re: Color Masking - support for sprites?

PostPosted: Mon Oct 02, 2017 1:48 am
by gregdowning
One other bug to report. I tried to work around the problem of the LUT being applied to cameras that did not have the script attached by using the depth masking. When Depth masking is on it will not apply the lut to an unlit texture. I tried a few different shaders and found it happening consistently.

Re: Color Masking - support for sprites?

PostPosted: Mon Oct 02, 2017 12:56 pm
by Ricardo Teixeira
gregdowning wrote:One other bug to report. I tried to work around the problem of the LUT being applied to cameras that did not have the script attached by using the depth masking. When Depth masking is on it will not apply the lut to an unlit texture. I tried a few different shaders and found it happening consistently.


Hello,

Thank you for elaborating, can you share a simple example with the problem present for further testing on our side? if you have not already I recommend picking up the revamped masking sample from our website.

We recently updated our masking technique, I'll share a sample with you via pm as the current version is not yet available via our website.

Apologies for the inconvenience.