• Advertisement
Sign in to follow this  

[HLSL] How to use arrays of textures in hlsl?

This topic is 2189 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to load bunch of similar textures on to the gpu, and then access them from the cpu.
SSo in my .fx file I have

Texture2D letters[26];

But when it comes time to map that to the ShaderResourceVariable, which is declared like this:

ID3D10EffectShaderResourceVariable* pShaderLetters[26];


I get an error saying something like can't convert * to an array (even though both are arrays).

Any suggestions?

Share this post


Link to post
Share on other sites
Advertisement

use Texture2DArray instead

Now it's saying can't conver implicitly from float 2 to float3? Can you give me an example of how this is done. The line where I get the error is this (in .fx file):

if(letterCode == 1) color = letterTextures[0].Sample(linearSampler, input.t); return color;

Share this post


Link to post
Share on other sites
With a Texture2DArray, you index into the texture array with the z coordinate when calling .Sample - you don't [] index.

e.g.

Texture2DArray myTextures : register(t0);

then later..

float4 color = myTextures.Sample( sampler, float3( u, v, textureIndex ) );

A Texture2DArray is created differently though. You have to give it an array size in the texture desc, and when creating the SRV set the TEXTURE2DARRAY view dimension and Texture2DArray.* variables.

Share this post


Link to post
Share on other sites

I'm trying to load bunch of similar textures on to the gpu, and then access them from the cpu.
SSo in my .fx file I have
Texture2D letters[26];
But when it comes time to map that to the ShaderResourceVariable, which is declared like this:
ID3D10EffectShaderResourceVariable* pShaderLetters[26];

I get an error saying something like can't convert * to an array (even though both are arrays).

Any suggestions?


Paste some more code please, for example the place where you try to bind the texture.

Cheers!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement