Page 1 of 1

Modifiable rendering order

Posted: Thu Oct 06, 2016 7:37 am
by Rado1
Obviously, in my projects I use (or at least would like to use) ZApplication.OnRender for drawing background of the whole application, AppState.OnRender to draw an overlay specific for given application state, Model.OnRender to render model's basic shape and ModelState.OnRender to render model state's specific overlay parts. So more specific OnRender section should add more specific rendering artifacts. Unfortunately, ZGE uses different rendering order, so for instance, when someone tries to render transparent model sprites on top of background rendered by ZApplication.OnRender, he obtains sprite squares where alpha channel is drawn with application's ClearColor, because models are rendered before ZApplication.OnRender. Therefore, it is necessary to render background as a Model. This is not so convenient.

I'm suggesting the following rendering order which for many cases is more logical:

1. ZApplication.OnRender
2. AppState.OnRender if it is active
3. Model.OnRender for each model instance depending on Model.RenderOrder
4. ModelState.OnRender if it is active

Because we do not want to corrupt backward compatibility, the best solution is to add the Application.RenderOrder property with a dropdown for choosing between "ModelsBeforeApp" or "AppBeforeModels", and the default is ModelsBeforeApp. This proposal has been discussed already with Ville who agrees, but we would like to know your opinion. Do you agree with the proposal?

Re: Modifiable rendering order

Posted: Sun Oct 09, 2016 7:28 am
by Imerion
Sound logical, yes. And a drop down for choosing, so backwards compatibility is kept sounds like a good solution!

Re: Modifiable rendering order

Posted: Tue Oct 11, 2016 4:33 am
by rrTea
Yes it makes sense, but please don't forget to keep the option to select the rendering order ;) (I'm in the middle of a project that relies heavily on the current method.)

Re: Modifiable rendering order

Posted: Tue Oct 11, 2016 6:21 am
by Rado1
Sure, all we have older and current projects; so backward compatibility is a must.

Re: Modifiable rendering order

Posted: Fri Oct 14, 2016 1:02 pm
by VilleK
I've implemented this feature now. Please download latest beta and give it a try.

Re: Modifiable rendering order

Posted: Fri Oct 14, 2016 1:17 pm
by Rado1
Great! Ville, thank you. I'll test it this evening.

Re: Modifiable rendering order

Posted: Sun Oct 30, 2016 11:24 pm
by Imerion
Tested it! Both modes seemed to work fine, though there were no difference for my project. I was thinking it might help with one of the rendering errors in the Android-version of my latest game, but it didn't help. Though I realize now that I misunderstood what this was supposed to do, so it wasn't strange nothing happened. ;)

Nice!

Posted: Mon Oct 31, 2016 3:59 am
by rrTea
Works here! It's definitely nice to have both options (the old rendering method was very useful for rendering HUDs for example). Thanks Ville :)