Confused about Texture Units

Hi,

I’m having trouble understanding how texture units are counted. Is it only masked objects (scrollviews and containers) or is it groups and text and images as well?

For example if I have:

dispaly.newText  -->  placed in a group --> then place the group in a scrollview

how many texture units would that use?

Hi @dkla27,

Are you referring to the “nested masking limit”? Items that apply to this are listed under the “Gotchas” section of this document, for example:

http://docs.coronalabs.com/api/library/graphics/newMask.html

Note that this doesn’t apply to standard display groups… you can nest as many of those as you want, as long as you don’t specifically mask them using graphics.newMask().

Best regards,

Brent

Yes, that’s what I’m referring to.  Also : http://docs.coronalabs.com/api/library/display/newContainer.html (Limitations)

How about the example on my original post?

The document you mentioned says that newText and newScrollview count against the masking limit, and like you said standard groups don’t. Based on the above, my example uses 2 texture units, right?

The reason I’m asking is that exceeding the limit leads to unpredictable behavior and bugs may not be obvious. Especially considering that many devices, even new ones, have a limit of 2 and not 3 as mentioned in the documents.

The texture unit limit issue only comes up when you have nesting, e.g. you are applying masks on a group (or are using containers which implicitly use a mask), and a child in that group also uses a mask. 

For example, let’s say you place a text object inside a group. If you then apply a mask on the group, then your texture unit nesting is 2: one for the text object, one for the mask on the group.

Hi @dkla27,

Are you referring to the “nested masking limit”? Items that apply to this are listed under the “Gotchas” section of this document, for example:

http://docs.coronalabs.com/api/library/graphics/newMask.html

Note that this doesn’t apply to standard display groups… you can nest as many of those as you want, as long as you don’t specifically mask them using graphics.newMask().

Best regards,

Brent

Yes, that’s what I’m referring to.  Also : http://docs.coronalabs.com/api/library/display/newContainer.html (Limitations)

How about the example on my original post?

The document you mentioned says that newText and newScrollview count against the masking limit, and like you said standard groups don’t. Based on the above, my example uses 2 texture units, right?

The reason I’m asking is that exceeding the limit leads to unpredictable behavior and bugs may not be obvious. Especially considering that many devices, even new ones, have a limit of 2 and not 3 as mentioned in the documents.

The texture unit limit issue only comes up when you have nesting, e.g. you are applying masks on a group (or are using containers which implicitly use a mask), and a child in that group also uses a mask. 

For example, let’s say you place a text object inside a group. If you then apply a mask on the group, then your texture unit nesting is 2: one for the text object, one for the mask on the group.