- Home /
Using screencapture to reduce expensive draw calls.
I'm creating a game that involves drawing on the screen with the mouse. I'm doing this by storing all the information about where the textures that have been painted onto the screen are located (their x, y, alpha, scale, etc.). Basically, after the array contains information for about 1500 textures (they're paintsplats, meant to simulate chinese calligraphic drawing), it understandably slows the game down a bit. I see TWO potential solutions to this, and I'd like to know if you know of any more, or if this is it:
1) I can limit the number of times the game records the texture positions, hoping to rely on the overlap of textures to still allow for a good-looking drawing.
2) Take a screen capture after a certain part of the drawing is completed, and use that instead of doing all the hundreds of draw calls it represented. Then replace the texture in front of the camera with that screen capture.
If these are the only solutions, which one do you like the best? Why?
Answer by jonas-echterhoff · Sep 23, 2011 at 04:53 AM
3) Use a RenderTexture. Much faster then reading the screen.
Thanks, I think this is exactly the solution I'm looking for...I'll have to check it out the next time I'm in the studio, and am using Pro!
I assume that I'll have to put an object to put the rendertexture on right in front of the camera...because it doesn't look like you can use a rendertexture right to the GUI. Non?
You should be able to use a RenderTexture in the GUI like any other texture. Check http://unity3d.com/support/documentation/ScriptReference/GUI.DrawTexture.html.
Answer by roamcel · Sep 23, 2011 at 04:52 AM
I believe that you should consider merging the meshes into one rather than going another way. There's a script in unify wiki that should lead you in the right direction.
http://www.unifycommunity.com/wiki/index.php?title=MeshMerger
I believe you could arrange to actually create a new mesh after as much strokes as you allow UNDO, to keep things fluent.
hmmm...thanks for the lead! I checked out the script, but I couldn't get it working, regrettably. I think the rendertexture solution will work, however, considering I have access to Pro. Cheers.