Jump to content

  • Log In with Google      Sign In   
  • Create Account

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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

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

#1 Daniel Wilson   Members   -  Reputation: 159

Like
0Likes
Like

Posted 13 June 2012 - 07:14 PM

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[i], which I don't need to do!

Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS