combining segmentation with post effect and face sprite
I'm building a lens for my AR art project GREY MATTER,
containing a portrait shoulder segmentation texture.
Now I also want to attach a face sprite to the head
and apply a post effect to the non-segmented part of the camera.
Problems:
- The post effect only gets applied to the segmented part ( which I don't want) - I want it only applied everywhere else but the segmented part.
- The face sprite is not visible and looks it doesn't function combined with a segmentation texture.
Solutions?
I fear i need to daisy chain multiple camera's to get there?
What is the best method?
Hi Image!
You're right, you'll need to change the way the camera is chained. But you should be able to just redirect what the Segmentation template comes with.
By default the chain is Orthographic Camera Masked -> Camera Masked -> Camera -> Orthographic.
Since we only want the Post Effect to render below the Segmentation we'll do: Camera -> Camera Masked -> Orthographic Camera Masked -> Orthographic.
(The result of this guide is linked at the bottom)
So first we'll have the post effect apply over everything. To do this, in the Objects panel, drag the "Post Effect" object to under the Camera object. Then we'll set it's layer to the camera layer. Press the gray circle, and choose default layer.
Then, what we want to do is render the Segmentation camera output AFTER the Camera output, so it is not affected by the Post effect. To do this, first select the Camera object. In the Inspector panel, set its input to Device Camera Texture by selecting the field and choosing Device Camera Texture inside the Default Texture folder in the pop up. Additionally set its render order to 0, since this is what we want to render first.
Then select Camera Masked, and set its Input to Camera Output with a Render Order of 1
Then, select the Orthographic Camera Mask, and in its Inspector panel, set its Input to Camera Masked Output under the Default Texture folder.
Finally, select the Orthographic Camera, and set Orthographic Camera Masked as as its Input
To add the Face Sprite, in the Objects panel, press Add New > Face Sprite. You'll notice that the Post Effect renders on everything again since the camera is set to the Default Layer. Press the blue circle to open the Layer panel, then press Add New. Set the sprite to the same layer so it can be rendered by that camera. You'll also want to select the Perspective Camera, and in its Inspector panel, set its Render Order to 4, since it should be rendered after Orthographic Camera.
Take a look at this modified project as an example. Can't wait to see what you come up with.
Let me know if you need any clarification!
Jon
Hi Jon,
Thanks sooo much for this detailed explanation.
I will attack this lens once more in the coming days.
I'll keep you updated of course.
Hi Jon,
I got it working. Thanks a zillion for the example project too. The whole daisy chaining of camera's and layer render order could use some more in depth explanations in your guide. Or some more examples of use cases.Still just on the cusp of understanding this.
I did notice, what I think is a BUG. When I add the face sprite, I lose the post effect. Or so it seems. When I just change one texture for another (say the sepia fx for BW) the post fx appears again.
I have lots lenses to create over the next 2 weeks so hopefully you are out there when I get stuck.
;)
Karen
ha well, got it kind of working using your segmentation template.
The post effect can be turned on/off thanks to your script,
but when adding my image texture I miss the ability to place the texture in it's right place.
(it's a gif by the way).
I'm using a shoulder segmentation texture, and my image texture is way up in the neck (so the centre of the image is shifted way upwards).
How can i get around this using the templat/the standard segmentation controller script)?
i figured it out finally.
So here is the lens (part of a AR art series called Grey Matter, 52 original lenses done, and more to come in the next months)
GREYMA univers
https://www.snapchat.com/unlock/?type=SNAPCODE&uuid=afe91800218f40f283c18f30b3f5df1e&metadata=01