Tasharen Entertainment Forum
Support => NGUI 3 Support => Topic started by: Ugur on March 15, 2014, 01:40:48 PM
-
Will you ever add support for nested clipping?
Like a clipped panel area which in it contains a clipped scroll area (next to a header which should be clipped by the parent panel clip area but not the child scroll area) A pretty common use case for UI.
If not, could you at least change it so that one can have child panels inside a clipped panel and the clipping of the parent panel still works on the child panels if one has clipping turned off for the child panel? Not as nice at all as supporting nested clipping but at least it would give one some more flexibility in how one can nest panels.
-
Doing nested clipping is easy. The problem is that doing it in software will utterly kill performance. This means that it has to be done in the shader, just like it is done now. To do it in the shader, a matrix must be passed. Only one matrix means only one panel can clip. To support more, multiple matrices must be passed, implying multiple shader versions. So I may add support for 2, but then people will be like "why isn't my 3rd nested panel clipping!?"
I don't like hacks, so when an elegant and performant solution presents itself, I will do it.
Currently there is an alternative to clipping by simply using the Stencil buffers -- but as I keep answering this question roughly twice a week, I still simply haven't gotten around to making it into an example -- and when I do it will be limited to Unity Pro users only, and Unity 4.3+.
-
I see regarding the implementation difficulties, yeah, good thinking to do it the faster running gpu way where possible of course.
Regarding a stencil buffer example, yeah, that would be nice, too.
I know what you mean with when you add support for 2, some will ask for 3, when you add support for 3, some could ask for 4 =)
But yeah, still, i think lots of common scrollview in panel(s) or similar use cases for UI usage should be covered with two.
More than 2 would then be more useful if one would want to support more esoteric things like multiple nested layers of scrollviews or (more common) adding mask sprite support for all sprites (sorta in the vein of flash where one can just add mask layers or set an object as mask object and the other as masked, though there it ran on the cpu of course..)