Jump to content



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

  • You cannot reply to this topic
4 replies to this topic

#1 VanillaSnake21   GDNet+   -  Reputation: 100

Like
0Likes
Like

Posted 25 February 2012 - 05:24 PM

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?

Time flies like an arrow; fruit flies like a banana.

Ad:

#2 Asesh   Members   -  Reputation: 128

Like
0Likes
Like

Posted 25 February 2012 - 08:18 PM

use Texture2DArray instead

#3 VanillaSnake21   GDNet+   -  Reputation: 100

Like
0Likes
Like

Posted 25 February 2012 - 11:20 PM

View PostAsesh, on 25 February 2012 - 08:18 PM, said:

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;


Time flies like an arrow; fruit flies like a banana.

#4 relaxok   Members   -  Reputation: 104

Like
0Likes
Like

Posted 27 February 2012 - 12:40 AM

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.

#5 kauna   Members   -  Reputation: 384

Like
0Likes
Like

Posted 28 February 2012 - 03:45 AM

View PostVanillaSnake21, on 25 February 2012 - 05:24 PM, said:

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!






We are working on generating results for this topic
PARTNERS