Custom shader parameters

Home / Forums / Marmalade Archive / IwGx / Custom shader parameters
2 replies [Last post]
by: MorreFG
Status: Offline
Joined: 2010-02-23
Points: 640

Hi,

I'm having a little trouble understanding the documentation here:
https://www.airplaysdk.com/docs.php?url=/api/api/group__IwGxShaderTechnique.html

What's the "components" part of a custom parameter? I was trying to define a custom fixed-size vector uniform parameter, say, 'uniform mediump vec3 lightVectors[4]'. Assuming components meant array size, I defined my parameter as such: 'param "lightVectors" vec4 4 no_default'. When I do this, Airplay fires the following assertion:

Expression: type == m_Type
Message: Changing type of shader parameter 'lightVectors'

The data was set using the following code:

if(lightsParam) {
float val[12] = { 1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
1.0, 1.0, 0.0,
1.0, 0.0, 1.0 };
lightsParam->Set(CIwGxShaderUniform::VEC3, 0, val);
}

No doubt I'm going about this the wrong way, but I'm afraid the documentation doesn't help me here. Any help would be greatly appreciated.

EDIT:

Sorry - turns out I'd actually made a typo in the shader code and put lightVectors as vec4 in one place.

Now it's *mostly* working. I can set the values and the shader compiles and runs, but I get only 0-vectors when I try to access any array element other than the first one.

by: Mark S
Status: Offline
Joined: 2009-10-23
Points: 81040
Hi Morre, The problem is that

Hi Morre,

The problem is that the Set function only sets one member of the array.

You need to do:

if(lightsParam) {
float val[12] = { 1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
1.0, 1.0, 0.0,
1.0, 0.0, 1.0 };
for(int i = 0; i < 4; i++) {
lightsParam->Set(CIwGxShaderUniform::VEC3, i, val+i*3);
}
}

I'll clarify that in the docs.

Mark.

by: MorreFG
Status: Offline
Joined: 2010-02-23
Points: 640
Thanks, that did the trick.

Thanks, that did the trick. :)

Latest Posts

Latest Comments

Top Contributors

  • Chris D : 27,010
  • MonRoyals : 26,970
  • Salman : 26,720
  • Jez Hammond : 20,130
  • pjan : 11,150
  • gjw : 10,350
  • Paolo Oliverio : 9,640
  • Beaker_2 : 8,390
  • Kite : 8,210
  • bluescrn : 7,810