Jump to content
  • Advertisement
Sign in to follow this  
Daniel Wilson

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

This topic is 2223 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

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!

Share this post

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!