Monogame: Texture2D array in shader is not recognized by monogame

Created on 20 Aug 2019  路  2Comments  路  Source: MonoGame/MonoGame

Hello,

if an array of the form:
float4 floats[10]

is declared, effect.Parameters["floats"].Elements.Count returns 10 as value which is obviously correct.

However, when declaring
Texture2D textures[10] monogame does not recognize it as an array and .Elements.Count returns 0.

Is this a bug or are texture arrays not implemented yet?

Best wishes.

MGFX Question

All 2 comments

Texture arrays are supported in a different way. When constructing a Texture2D use the overload that takes an int array parameter. In your shader use Texture2DArray for the texture array type and when sampling use the z parameter as the index of the texture.

I don't know if you can ever use Texture2D[]. The compiler allows it at least. We could catch it in the parser and warn or error, and point users to Texture2DArray.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomspilman picture tomspilman  路  4Comments

tomspilman picture tomspilman  路  4Comments

dazinator picture dazinator  路  5Comments

Jjagg picture Jjagg  路  5Comments

willmotil picture willmotil  路  5Comments