Hey Rainy,
Not sure why the Iris is missing in the "Scene" view in Play mode. The iris appears in the "Game" view for the main camera for the basic case even when it is not visible in the "Scene" view.
Missing Iris in Scene:
Iris in Game:
When I select the iris component and drag it away from the face. It is invisible in the scene view, while things like the eye white/ eyebrows are still visible.
The main problem arises when I am rendering the Live2D via a Raw Image using a separate (Secondary) camera so that I can overlay the Live2D in my game. When I do this, the "Game" view is also missing the Iris.
I found that the MainCamera had "command" buffers, which might be the reason that the main camera can see the Iris? However, my "Secondary" does not get these command buffers and I am not sure how to make it so that the secondary Camera renders the Iris.
In the basic case (Main Camera), the iris only disappears in play mode for the "Scene" view. It exists in the "Scene" preview when the editor is not in Play mode.
Wondering what mechanics control this/ how I can fix it?
Best Regards,
Clement
Hi!
If the character only connects to one camera when "Camera.allCameras" is entered, it seems to be caused by the "Multi Cameras" option in the Bake Dialog not working properly while there are multiple cameras with Culling Masks rendering the character.
But we're not sure exactly.
Anyway, glad that the issue is now resolved!
Feel free to post if you encounter similar issues or other difficulties!
Thank you.
Hey Rainy, So I did try with the "Camera.allCameras" originally, but it didn't work for me - and the Iris doesn't render (both with/ without the Initialize). Maybe all the Cameras are valid, so it's just selecting the first valid one. I have two (seperate) Cameras for Live2D and then the third Camera is the "main" camera. Taking your feedback that the "FindGameObjectWithTag" is inefficient, I did update the code to use a [SerializeField] so I don't have the "FindGameObjectWithTag" lines anymore though. So thanks for that! Best Regards,
Clement
It is good to hear that issue has been resolved! :)
We add a comment to give you a little hint.
1.
The "GameObject.FindGameObjectWithTag" function becomes very poor in performance as the scene becomes more complex.
So, it would work just as well if you wrote it like this:
live2DObject.GetComponent<apPortrait>().SetRenderingCameras(Camera.allCameras);
(Even if all cameras are entered as arguments, invalid cameras are automatically excluded.)
2.
And if no camera is added, deleted, activated or deactivated while in-game, the character will automatically search for a camera upon initialization.
So maybe it works fine without calling apPortrait's SetRenderingCameras function after Instantiate is executed.
(If the problem occurs again, just call SetRenderingCameras function again.)
Anyway, the above advice is an optional tip to avoid performance issues and unnecessarily long scripts.
You can write it as you need.
If you encounter any other issues, please feel free to post!
Thanks
Sweet appreciate the details and the links to the manuals. They have provided me enough to resolve the problem (at least so far), and the eyes appear to be rendering properly in the game view now.
The process that I'm using is as follows:
I instantiate the prefab of the AnyPortrait GameObject via a different script (so it's created at runtime). The prefab is on a specific layer just for the Live2D characters and have a dedicated Camera for that to send to a RenderTexture that I then display on a RawImage (So that I can have a display for the Live2D character in the UI).
In order to get the eyes working (following the manuals that Rainy linked), I had to explicitly set the render Camera to the Secondary Camera that was created to handle Live2D characters. In addition, since I instantiate the character in the scene - I had to also manually "Initialize" the anyportrait image (otherwise there is a
"AnyPortrait - The camera module has not been initialized yet."
error). The script excerpt:
Live2DCamera = GameObject.FindGameObjectWithTag("Live2DCameraPC").GetComponent<Camera>(); GameObject live2DObject = Instantiate(Live2DPrefab, Live2DPanel.transform, false); live2DObject.GetComponent<apPortrait>().Initialize(); live2DObject.GetComponent<apPortrait>().SetRenderingCameras(Live2DCamera);
Hi!
The character's iris is a "Clipped Mesh" that is rendered by a "Clipping Mask".
The "Clipping Mask" uses a Command Buffer and a Render Texture to work.
Since the Command Buffer is data belonging to the camera, in order for the character's Clipping Mask to work, the character must be aware of the "camera currently rendering the character."
For this reason, there are cases where Clipping Mask does not work:
Clipping Mask does not work in Scene View because the character does not recognize the editor's secret camera that renders the Scene View.
The default option recognizes only one camera, so Clipping Mask does not work on cameras other than the main camera.
First, you can ignore the issue of Clipping Mask not working in Scene View.
The important thing is that Clipping Mask does not work on the secondary camera.
There are a few steps to fix this.
1. You need to change the options so that the character creates a Command Buffers for more than one camera.
In the "Settings" tab of the "Bake Dialog", change the value of "VR / Multi-Cameras" to "Multi Cameras" and run Bake.
2. You need to re-create the Command Buffer when a camera is added or removed.
You need to write a script that notifies the character when the camera changes, or set an option to automatically recognize it.
For a more detailed explanation of the script code and options, please see the following manual covering this issue:
https://rainyrizzle.github.io/en/AdvancedManual/AD_MultipleCameras.html
Additionally, it looks like you want to create a Render Texture and put it into a RawImage to output it to your 2D UI.
It is possible, but there are some issues when rendering AnyPortrait characters to Render Textures as Render Targets.
The following manual contains information on issues and solutions related to Alpha in Render Texture.
https://rainyrizzle.github.io/en/AdvancedManual/AD_RenderTexture.html
The best way to solve this issue is to write your own Command Buffer.
The following manual, "Rendering the Render Texture with a Transparent background", covers this issue.
(This manual is quite difficult, so you don't have to try it.)
https://rainyrizzle.github.io/en/AdvancedManual/AD_CommandBuffer.html
The issue with multi-camera is a bit complicated, so please read the above manuals carefully and try to solve the problem.
If the problem is not solved, please leave a comment!
Thank you.