Manually update Render Texture

Hi guys

As from what I understand now, the render textures in unity is updated automatically. can we somehow manually set the update timing?

Thanks

Sure
you can use the on render xxx callback to find out when the camera would render, assign the render texture, call Camera Render and then unassign it again.

as you do the assign, unassign and rendering manually its all up to you on the frames on which you update the render texture :slight_smile:

you can also skip the additional render and hook / unhook it before and after the render

thanks for ur reply. but since i’m a newbie, i really don’t know much. how can i achieve what u just said? a step by step maybe… thank you very much.

You would use Camera.OnPreRender to set the render texture if you want to render to it and use Camera.OnPostRender to unassign it again for example

ok. will try that asap. thanks again.

Hi. I’m sorry but i still don’t get it. Can you describe more on how its done?

I’m building an arena screen, had a camera and render-textured it to the screen. now the screen is showing what the camera sees, but instead of real time, i want it to show the images every 0.5 seconds. i’m no scripter and what i’ve done till now is based on the documentation.

if you want to show it all 0.5 seconds ensure that you make the camera only render to rendertexture all 0.5s :slight_smile:

and how do i achieve that? i do have to do some scripting right?

right, you basically just set the cameras render texture to the RT you want to render to, call Render on the camera or set it to null if you don’t want to render to it.

ok…for your information, i have 0 knowledge in scripting. so how do i start?

function OnPreCull () 
{
  camera.ResetWorldToCameraMatrix ();
  camera.ResetProjectionMatrix ();
}

…and then? is there any tutorial on this?

Please see here: http://answers.unity3d.com/questions/16012/how-to-save-a-picture-take-screenshot-from-a-camera-in-game

This contains more than what you need as it also grabs a screenshot which you don’t want. but the rest of the setup is widely equal, you would just add an additional check to see if enough time hast passed since the last rendertexture update or not.

And no, there is no tutorial. But if you aren’t that versed in programming yet I would potentially do the regular tutorials and focus on learning the basics before you try to do medium to advanced stuff that not only requires programming knowledge but also solid knowledge on how unity and 3d works …

ok. i’ll check it out. thank you so much for your time dreamora. really appreciate it.