Hi guys,
I change blendshape value of my fbx model at runtime, and placed a camera to render this model. For some purpose, I need capture the camera texture after changing blendshape of this model immediately.
However, The camera texture can only show the mesh before changing blendshape. I know this mesh will update in next frame, but I can’t wait until that time. Is there any method to update this mesh for rendering right now?
human.GetComponentInChildren<SkinnedMeshRenderer>().SetBlendShapeWeight(0, 100);
human.GetComponentInChildren<SkinnedMeshRenderer>().SetBlendShapeWeight(1, 100);
CaptureCameraTexture();
this is my function for capture camera texture.
public Texture2D CaptureCameraTexture(string path = null)
{
Texture2D camTex = new Texture2D(cameraWidth, cameraHeight, TextureFormat.RGBAFloat, false);
RenderTexture rt = new RenderTexture(Screen.width, Screen.height, 1);
cam.targetTexture = rt;
cam.Render();
RenderTexture.active = rt;
camTex.ReadPixels(new Rect(0, 0, cameraWidth, cameraHeight), 0, 0);
Debug.Log(camTex.GetPixel(cameraWidth / 2, cameraHeight / 2));
Debug.Log(camTex.GetPixel(cameraWidth / 2+1, cameraHeight / 2));
cam.targetTexture = null;
RenderTexture.active = null;
UnityEngine.Object.Destroy(rt);
SaveImg(camTex, path);
return camTex;
}