Page 1 of 1

shader uniform array initialization

Posted: Tue Aug 24, 2010 7:20 am
by Terry
In my shader,uniform array like this was used:

Code: Select all

uniform vec4 WaveData[5];
i found irrlicht can not initialize this array,just only vector waveData[0] could be set using:setVertexShaderConstant() function.
so in my opinion,i must declare like:

Code: Select all

uniform matrix4 waveData1;
uniform vector4 waveData2;
hope for array supporting!
if there are some good methods to set array constants out of my view?

Thanks

Posted: Tue Aug 24, 2010 9:52 am
by BlindSide
It works in Direct3D9 with any video card, and OpenGL with NVidia in my experience but not AMD, unless they updated their drivers.

You can just do it by using the name of the array and passing in a pointer to an array of floats.

Posted: Tue Aug 24, 2010 11:16 am
by Terry
Thank you very much!

Code: Select all

GLSL
uniform vec4 waveData[5];

irrlicht
f32 waveData[20] = {0.766f,0.643f,200.0f,2.0f,
							0.174f,0.985f,240.0f,2.4f,
							-0.985f,0.174f,184.0f,1.82f,
							-0.643f,-0.766f,120.0f,1.2f,
							0.174f,-0.985f,160.0f,1.6f};

services->setVertexShaderConstant("waveData",waveData,20);
It works~~~~[/color]