Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Texture2D array in shader is not recognized by monogame #6868

Open
ghost opened this issue Aug 20, 2019 · 2 comments
Open

Texture2D array in shader is not recognized by monogame #6868

ghost opened this issue Aug 20, 2019 · 2 comments
Labels
MGFX Shader compilation tool Question

Comments

@ghost
Copy link

ghost commented Aug 20, 2019

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.

@Jjagg
Copy link
Contributor

Jjagg commented Aug 20, 2019

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.

@Jjagg Jjagg added the Question label Aug 20, 2019
@Jjagg
Copy link
Contributor

Jjagg commented Aug 21, 2019

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.

@Jjagg Jjagg added the MGFX Shader compilation tool label Jul 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
MGFX Shader compilation tool Question
Projects
None yet
Development

No branches or pull requests

1 participant