Previously, I asked about displaying a model shown on Unity as a RawImage using a RenderTexture, and I was taught how to obtain the rendering result of the “entire model” as a RenderTexture.
As an extension of that, I now need to receive only the rendering result of a “specific art mesh (Drawable)” into a separate RenderTexture. (In previous SDK versions, this could be achieved by changing the Drawable’s Layer and matching the camera’s CullingMask, but this method is no longer applicable with the custom render path approach in the current version.) Is this still possible to achieve in the current version?
My intended configuration is as follows:
Art meshes A, B, C… → RenderTexture1
All other art meshes → RenderTexture2
The final goal is to output the rendering results in this configuration, apply an effect to the opaque area of RenderTexture1 within the shader, composite it with RenderTexture2, and then display the composite result on the RawImage as RenderTexture3.
(Currently, I am pseudo-implementing this by duplicating the model and camera to separate the Drawable display states, and assigning the TargetTexture of each camera to RenderTexture1 and RenderTexture2 respectively. However, since duplicating the model has caused performance issues, I am asking this question.)
Thank you very much for your continued support of our products.
This is the Live2D staff.
We sincerely apologize for the delayed response.
It may be possible to address this by customizing the CubismRenderPassFeature on the user side.
In the URP version of the Cubism SDK for Unity, models are not rendered directly into the scene. Instead, they are rendered off-screen to a RenderTexture, and the resulting image is displayed.
This off-screen rendering process is handled by CubismRenderPassFeature.DrawObjects().
Please customize this section to switch the RenderTexture target for mesh rendering using CommandBuffer.SetRenderTarget() according to your desired criteria.
// Set render target with depth buffer for proper depth testing
buffer.SetRenderTarget(RenderController.CurrentFrameBuffer, passData.CameraDepthTextureHandle);
appears to set the RenderTexture target.
Therefore, by receiving branching conditions from outside via event handlers, etc., and changing the target using buffer.SetRenderTarget() at the timing when the specified Drawable is being drawn, I was able to implement the originally intended behavior. I will mark this topic as resolved.
The content requested in this topic may also be resolved by the above modification (excluding optimization, implementation-wise). I hope this serves as a reference for others facing similar issues.