Search Unity

Question How to use multiple render textures and cameras?

Discussion in 'General Graphics' started by ayseaktas, Sep 14, 2022.

  1. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    58
    Hi, I simply need to write text on 3D sphere. But I want to change it at runtime as I want. So, using a premade material is not an option.
    I tried to make this with render texture it works pretty well but when it comes to multiple objects with multiple different text I noticed I need multiple render textures, cameras and layers so that the texts in front of the cameras do not interfere with each other. But unity gives only 32 layers. I don't know how many object will be generated and create layer. It doesn't seem like a good practice.
    Is there another way like render texture or is there a way to use render texture for different texts?
    Screenshot 2022-09-13 160525.png
     
    Last edited: Sep 14, 2022
  2. orionsyndrome

    orionsyndrome

    Joined:
    May 4, 2014
    Posts:
    3,113
    I don't know if you've solved this, but you need just one camera to render to a render texture. You basically snap a photo with it (by blitting to temporary render texture, see RenderTexture.GetTemporary, and check out how to Blit with your rendering pipeline), then use CopyTexture to copy that into another texture on the GPU.
    If you need another texture, you go through this process again, change the text, snap another photo, use CopyTexture etc. One camera, one render texture (not as an asset, you don't need an asset), one layer.

    If you want to save some of these textures back to a file (normally you don't, because in the run-time it just works), you'll need to transfer them back to CPU, I guess with ReadPixels, because CopyTexture works only on the GPU side.
     
  3. ayseaktas

    ayseaktas

    Joined:
    Jan 18, 2021
    Posts:
    58
    No I couldn't solved it yet. I tried almost 5 different technique to achieve this look but none of them worked. Finally I ended up using 3D text.
    Your solution seems interesting and I am definitely going to try. If it works, I'll post it here. Thank you for the answer.