I'm trying to put the anyportrait animation inside my UI Image, I'm using Raw Image component to do this
I have a camera in my scene render to a render texture and put it inside my raw texture and then put the raw texture inside my raw image. Problem is it's not showing anything unless there's another image inside the camera (i think this is a shader problem)
Look at how it's rendered inside camera without a problem
but when I put it inside a render texture and put it inside raw image, it becomes like this
notice how only a small part of the character is visible, this is because there's a square image behind the character. It doesn't render anything if I don't put anything behind the character, but If I put a big square behind the character then the background won't be visible like this
Is there any way to render anyportrait inside Unity UI?
Hi!
It seems that you are burdened with writing shaders.
So, we deliver the Shader script files introduced in the Sprite Mask example.
Attach the attached "Unitypackage" file to your project and apply it as the following description.
(1) A scene was created for the explanation.
There are an object with "Sprite Renderer + Sprite Mask" and an "AnyPortrait character object".
(2) If you import the attached package, 8 Shader files will be added as above.
(1) Select a character and open it with AnyPortrait editor, and select "Root Unit".
(2) Click the "Material Library" button.
(3) We will duplicate "Unlit (Default)", which is set by default. Choose it
(4) Click the "Duplicate" button.
(5) Now, an "Unlit (Default) Copy" will be created as above.
This Material Set is a set of Shaders that render the character.
By modifying this, you can change the shaders applied to the character.
(1) Select the duplicated "Unlit (Default) Copy".
(2) Rename the Material Set appropriately.
(3) Press the "Default Material" button to make it "ON". Only in this state will this material set be applied when baking.
Now we will replace the Shaders.
If you do not use "Linear Color Space", you can replace 8 Shaders in "1. Color Space : Gamma". (If you are in a hurry, you only need to replace 2 of Alpha Blend.)
(4) Let's replace the Shader file in "Basic Rendering > Alpha Blend".
(5) Since there are many files, you can easily find them by entering "Stencil", the common keyword of the attached files.
(6) Select the "Stencil_Transparent_AlphaBlend" file corresponding to the selected item.
Repeat the same process to replace all 8 Shaders as above.
You now configured the Material Set to apply the Sprite Mask.
Note that.
If you want to apply this material set to other characters, you can save it as a "Material Preset".
Just click the "Register as a Preset" button. Check the "Material Library" manual for details.
https://rainyrizzle.github.io/en/AdvancedManual/AD_MaterialLibrary.html
When complete, run Bake to apply it to the Unity Scene.
Go back to your Unity Scene.
To use a Sprite as a mask, it must be set as above.
(1) Select a Sprite object to use as a mask.
(2) The "Sprite Mask" component must be added to the object.
(3) If all tasks are completed, you can see the AnyPortrait character with Mask applied as above.
This process is all introduced in the manual.
https://rainyrizzle.github.io/en/AdvancedManual/AD_SpriteMask.html
Note that since the Sprite Mask uses a stencil, blur or translucent are not applied to the edges of the mask.
We hope our explanation was helpful to you.
Thank you