Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Set array of vectors via SetEffectParam  (Read 1128 times)
Shadowsong
Customers
Community Member
*****
Posts: 328


« on: December 22, 2009, 10:22:08 AM »

Basically what I am trying to do is let my shader have access to an array of vectors.

So I define the array inside the shader:
Code:
float3 VectorArray[20];

Now during runtime, I want to fill this array with data. I tried the following:
Code:
cTV_3DVECTOR *vectors[20];
for(int i=0; i<20; i++)
    vectors[i] = new cTV_3DVECTOR(12, 34, 56);
MyShader->SetEffectParamVectorArray3("VectorArray", vectors[0], 20);

This compiles and all, but during runtime, nothing happens. It seems like the shader can't access the data, thus I guess it doesn't get filled correctly. Maybe I am not using the correct SetEffectParam method?

I hope someone can help Smiley
Logged
Aki
Customers
Community Member
*****
Posts: 82


« Reply #1 on: December 22, 2009, 11:55:04 AM »

Code:
MyShader->SetEffectParamVectorArray3("VectorArray", vectors[0], 20);

I've never used the VectorArray method, and instead, did the following:

Code:
MyShader->SetEffectParamVector3("VectorArray["+i.ToString()+"]", vectors[i]);
Logged

jviper
Community Member
*
Posts: 2127

Discipline in training


« Reply #2 on: December 22, 2009, 12:26:57 PM »

Perhaps a better way to test whether the data went through is check GetEffectParamVectorArray3
Logged

JAbstract.....Don't just imagine, make it happen!
Toaster
Community Member
*
Posts: 378


WWW
« Reply #3 on: December 22, 2009, 12:29:48 PM »

This is wrong:

Code:
MyShader->SetEffectParamVectorArray3("VectorArray", vectors[0], 20);

It should be:

Code:
MyShader->SetEffectParamVectorArray3("VectorArray", vectors, 20);

It needs to be outside of the loop and after you set the vectors data.

I cant imagine this would ever work:

Code:
MyShader->SetEffectParamVector3("VectorArray["+i.ToString()+"]", vectors[i]);

but I guess it could in some weird way.

-Toaster
Logged

Visit my site at: Unknown Abstraction
AriusEso
Customers
Community Member
*****
Posts: 940

Esoteric


« Reply #4 on: December 22, 2009, 02:44:35 PM »

vectors[0] is not incorrect in C++. He will likely get type errors if he does it your way. Something like "error convert parameter from float (*)[20] to float *".

Do this:

Code:
cTV_3DVECTOR vectors[20];

vectors[i] = Vector3(etc, etc, etc);

MyShader->SetEffectParamVectorArray3("VectorArray", &vectors[0], 20);

Merry Ragemass. Wink

« Last Edit: December 22, 2009, 02:46:28 PM by AriusEso » Logged

-...-

Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks