- Home /
Problem using RenderTexture
initial declaration
RenderTexture rtMine;
creation
rtMine = new RenderTexture(ttTexture.width, ttTexture.height, 0);
rtMine.Create();
the later in the draw code
RenderTexture.active = rtMine;
GUI.DrawTexture(new Rect(0, 0, ttTexture.width, ttTexture.height), ttTexture);
RenderTexture.active = null;
ttTexture is a Texture2D that has been assigned to, and is size 64x64.
The RenderTexture is then applied to a plane's material texture. Should ttTexture not be drawn on the RenderTexture, thereby appearing on my plane? or am I missing something?
Edit: So, in attempt to figure this out, I decided to tryn render the contents of rtMine to my camera, and whereas something did render, it wasn't ttTexture, it was just random data that got rendered, so either drawing RenderTexture flat out lik that is wrong, or the data isn't properly being written to the RenderTexture.
Answer by robertbu · Jan 11, 2013 at 11:05 AM
I assume you have Unity Pro. Though it is not show in the code above I assume you are setting camera.targetTexture and calling camera.Render(); I wrote some RenderTexture code a couple of weeks ago. My starting point was the code in this post:
http://answers.unity3d.com/questions/27968/getpixels-of-rendertexture.html
Also I ended up with some strange garbage when I had the camera set to Depth Only and did not write the complete background.
Your answer
Follow this Question
Related Questions
Cut mask rendertexture like we see it through glasses. 0 Answers
How to save a RenderTexture as a 1-channel 8-bit grayscale PNG? 0 Answers
,Can camera output negative values to render texture? 0 Answers
Convert Texture2D to Rendertotexture and swap it 0 Answers
how to initialize camera render target with RenderTexture 0 Answers