shader uniform array initialization

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Terry
Posts: 55
Joined: Wed Jan 27, 2010 6:16 am
Location: Peking/China

shader uniform array initialization

Post 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
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post 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.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Terry
Posts: 55
Joined: Wed Jan 27, 2010 6:16 am
Location: Peking/China

Post 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]
Post Reply