Adam's Lair Forum

game development and casual madness
It is currently 2019/11/20, 22:42

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
PostPosted: 2016/01/26, 16:42 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
Hello everyone. I have some content in my game which needs rendered but does not change regularly so the overhead involved in redoing all of the rendering calculations every frame seems unnecessary. I know that when using winforms it is possible to render to a pixmap and then render that pixmap to the screen whenever the image is needed. What is the best way to do something like that with Duality?

Even with the Canvas wrapper, Duality feels like a lower level graphics api then anything I have worked with and can be a little intimidating! I hope to learn a bit more about how opengl works in the process of working with Duality.

Just for the sake of adding detail the content is the ui/menu system I am making. As a side note, any general advice on making good menu systems?


Top
 Profile  
 
PostPosted: 2016/01/26, 18:17 
Veteran Member
Veteran Member
User avatar

Joined: 2016/01/10, 10:56
Posts: 151
Location: Budapest
Role: Hobbyist
Hi!
First of all, are you sure, that your performance issues really originate from rendering too much objects on screen? Correct me, if I'm wrong, but I think if you work with reasonable number of sprites, materials, and default shaders, then most graphics hardware from the decade can handle Duality's challanges pretty well.
Anyway, if you still want to do this: here's the way: (may not be the most efficient, since I'm new to the engine, too :] )

Every step below is done in the editor, except the last one.
  1. Set the "static" object's SpriteRenderer's visibility group other than default Group0.
  2. Create a new Camera, in it's 0th render pass, set the visibility mask to the group assigned previously. By this, the new camera will only render the "static" objects.
  3. Create a new RenderTarget and Texture resource (context menu in Project View). Set the texture's size to what's needed for your purpose. Assign the texture to your RenderTarget's Target.
  4. Assign the RenderTarget to the new camera's output (located in passes).
  5. Create a Material using that newly created Texture. By now, you can use this material like any other, it's texture will contain the pixel information viewed by the new Camera. You can assign it to a SpriteRenderer.
  6. Disable your camera object from code, in order to save system resources (though IMO it's not really necessary, as mentioned)

zakila wrote:
Just for the sake of adding detail the content is the ui/menu system I am making. As a side note, any general advice on making good menu systems?

Check out the Basic Menu Sample package, if you haven't done it already. It helped me a lot :]

I hope I could help, good luck! If I wasn't really clear, feel free to ask!


Top
 Profile  
 
PostPosted: 2016/01/26, 18:30 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
Hi Loeller. Thanks for your response, I will definitely check out that sample. Do you know how that might be done progmatically? It seems like anything that the editor can do should be doable in a core plugin.


Top
 Profile  
 
PostPosted: 2016/01/26, 20:27 
Forum Addict
Forum Addict
User avatar

Joined: 2013/09/19, 14:31
Posts: 883
Location: Italy
Role: Hobbyist
zakila wrote:
Just for the sake of adding detail the content is the ui/menu system I am making. As a side note, any general advice on making good menu systems?


If you want you can use my UI plugin here or even just have a look at its source on GitHub. Maybe it will give you a hand. ^^

_________________
Come on Duality's Discord channel. We have cookies! :mrgreen:


Top
 Profile  
 
PostPosted: 2016/01/26, 20:37 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
I will definitely look at your source SirePi. I looked into using the plugin as well but it didn't quite fit my use case, although it does look very good.


Top
 Profile  
 
PostPosted: 2016/01/26, 22:00 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
I'll have to second what loeller said and mention that some more research on the exact cause of your performance problems might pay off. Duality should be able to handle a bit of user interfaces, and it doesn't need a super modern graphics card for this either - unless you're dealing with really a lot of data. For diagnostic purposes, you can add a new ProfileRenderer to your test scene to get some live time values on rendering and other things that happen each frame. You can also add your own profile measurements in code by using Profile.BeginMeasure("CounterName") and Profile.EndMeasure("CounterName").

Also, if you test it in the standalone launcher and not the editor, make sure to either disable VSync in the application settings or run it in profiling mode - otherwise, you'll see at least 16 ms per frame (when rendering), because the application will always wait at least that amount of time each frame.

That said, you can render to texture programmatically as well. Take a look at Duality's rendering unit test, which renders some stuff onto a texture, downloads the pixel data and then compares it. In your case, you would of course keep the RenderTarget and Texture around instead of re-creating them each frame, and you also wouldn't need to download any pixel data from the GPU. You could also check if you can keep the DrawDevice around as well.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
PostPosted: 2016/01/26, 22:18 
Junior Member
Junior Member

Joined: 2016/01/09, 22:52
Posts: 35
Role: Hobbyist
Thanks Adam. I guess I wasn't entirely clear in my original post, I am not actually having performance problems with the Ui I just saw a potential inefficiency and started looking after a solution. In addition to the Ui I thought this technique might be helpful with other rendering tasks such as drawing backgrounds or tile maps. I don't think I will be implementing this unless I start running into problems.


Top
 Profile  
 
PostPosted: 2016/01/26, 22:36 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 2073
Location: Germany
Role: Professional
zakila wrote:
Thanks Adam. I guess I wasn't entirely clear in my original post, I am not actually having performance problems with the Ui I just saw a potential inefficiency and started looking after a solution. In addition to the Ui I thought this technique might be helpful with other rendering tasks such as drawing backgrounds or tile maps. I don't think I will be implementing this unless I start running into problems.


I probably misunderstood the intention behind your posting a bit, forum support bias and all that ^^ Carry on!

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group