CG question, How to access an array element in for loop?

Started by
-1 comments, last by Daniel Wilson 11 years, 10 months ago
Hi folks, I have a cg shader in which I have the following loop:

float currentLayer = 0;
float4 myVec;
const float4x4 myMatrix=
(2.6, 1.6, 1.6, 0,
6.6, 3.6, 2.6, 0,
1.5, 1.5, 2.5, 0,
0, 0, 0, 1);

for(int i = 0; i < num_samples; i++)
{
currentLayer = FindLayer(depthM, umvm, sstm); //This results in an value between 1 and 4

myVec= myMatrix[currentLayer];
//..
//..
//..much more code...
}


This throws up the error:
(395) : error C6013: Only arrays of texcoords may be indexed in this profile, and only with a loop index variable
I am using ps_3_0, but what I'm actually trying to do should be possible in earlier profiles I think I am just doing it wrong.
So my noob question is how might I get the vector I need based on the current layer number that my FindLayer() function returns, all inside a for loop. The error seems to suggest I can only say myVec = myMatrix, which I don't need to do!

This topic is closed to new replies.

Advertisement