- Home /
Best approach for alpha blending multiple webcamtexture is renderTexture?
Hi, I want to blend multiple webcamtextures from multiple webcameras to be viewed by a user in VR.
The blend should be able to
Fullscreen alpha blend, e.g. 50% cameraA + 25% cameraB + 25% cameraC
Area blend, e.g. leftmost 25% is CameraA + middle 50% cameraB + rightmost 25% is cameraC
I am wondering what is the best approach for implementation.
Each webcamera is different in resolution so cannot use one single cameraPlane with multiple materials and shader for blending.
I think each webcam must be rendered to each's own cameraPlane, e.g. cameraPlaneA cameraPlaneB cameraPlaneC and have 3 unity camera camA camB camC each looking at the cameraPlane.
Then render each to a renderTexture, and attach the 3 renderTextures to a single blendedCameraPlane with custom shader to be displayed to the user.
The custom shader then handles the blending of the 3 materials.
Is this the correct approach? Thank you.
What about z- ordering? Usually each camera will render everything in it's view, via Z-order, so that object X shows up "in front of or behind" object Y. If you THEN blend together multiple camera results, you will, effectively, be apply a new z-ordering, by camera, (rather than by Z- "distance from camera position").
Otherwise, I think it's good plan, I like using shaders for processing images like that.
Hi, thanks for your response. I also considered about z-ordering. If I understand you correctly, you mean setting the clear flag of the game cameras ABC to depth only, then setting the z-ordering of each camera so they render overlay each other. The question I had about this approach is that it seems it will be rendering the whole view by each camera, but sometimes I want to render part, e.g. only render leftmost 50% of cameraB to overlay cameraA, so what is seen is left 50% of viewport is leftmost 50% of B and right 50% is 50% of A. I wonder if this can be done by only changing the z-order. And thanks for ensuring that shaders is a good approach.
Your answer
Follow this Question
Related Questions
Unity crashes - multiple cameras with image effects and fade to black 0 Answers
blending colors on a texture: shader, render texture, or other 2 Answers
U.I. rendering multiple cameras in VR 2 Answers
RenderTexture Painting - color blending issues 1 Answer
RenderTexture of VR output in 5.4 beta 0 Answers