How to avoid unnecessary full screen redraws on Unity?
Posted: 15 Jan 2016, 01:01
I currently have this setup for a mobile painting app in Unity:
1. Screen texture (e.g. 1280x720), Image texture (e.g. 2000x2000), noesis renderer to screen
2. A camera that never deletes the screen, I only redraw changes
This is what happens when the user paints: OnPaint:
1. Calculate dirty rects (those are the regions that have changes painted by the user)
2. Update ImageTexture with the new strokes
3. DrawOnScreen(ImageTexture, dirty rects) -> redraws only the changes
4. DrawNoesisXamlThatIsCurrentlyVisible()
The issue is that on Step 4, noesis ends up drawing overlaying text, especially when I have animations. That's because my camera never deletes the scene, and only draws the changes. I'd have to add a step 3.5 and change step 4:
3.5. noesisDirtyRects = GetNoesisDirtyRectsThisFrame()
4. If (noesisDirtyRects is not empty) { DrawOnScreen(ImageTexture, noesisDirtyRects); DrawNoesisXamlThatIsCurrentlyVisible(noesisDirtyRects); }
However, I don't know how to get dirty rects from Noesis (opened a bug.)
Without dirty rects, I'd have to redraw my texture on every frame and the XAML on every frame, which will impact battery life significantly.
Another possible simplification (not optimal but much better) could be:
4. If Noesis_HasChangedSinceLastFrame() { RedrawImageTexture(); DrawNoesisXamlThatIsCurrentlyVisible() }
Is there a better solution that I can currently use without having to redraw the whole screen twice on every frame? Or a way to know if there are visual changes since last XAML frame from Noesis?
1. Screen texture (e.g. 1280x720), Image texture (e.g. 2000x2000), noesis renderer to screen
2. A camera that never deletes the screen, I only redraw changes
This is what happens when the user paints: OnPaint:
1. Calculate dirty rects (those are the regions that have changes painted by the user)
2. Update ImageTexture with the new strokes
3. DrawOnScreen(ImageTexture, dirty rects) -> redraws only the changes
4. DrawNoesisXamlThatIsCurrentlyVisible()
The issue is that on Step 4, noesis ends up drawing overlaying text, especially when I have animations. That's because my camera never deletes the scene, and only draws the changes. I'd have to add a step 3.5 and change step 4:
3.5. noesisDirtyRects = GetNoesisDirtyRectsThisFrame()
4. If (noesisDirtyRects is not empty) { DrawOnScreen(ImageTexture, noesisDirtyRects); DrawNoesisXamlThatIsCurrentlyVisible(noesisDirtyRects); }
However, I don't know how to get dirty rects from Noesis (opened a bug.)
Without dirty rects, I'd have to redraw my texture on every frame and the XAML on every frame, which will impact battery life significantly.
Another possible simplification (not optimal but much better) could be:
4. If Noesis_HasChangedSinceLastFrame() { RedrawImageTexture(); DrawNoesisXamlThatIsCurrentlyVisible() }
Is there a better solution that I can currently use without having to redraw the whole screen twice on every frame? Or a way to know if there are visual changes since last XAML frame from Noesis?