Hi all,

I have a very strange problem with my glsl shader and the setUniformParameter function. I have two shader chunks and every chunk gets the same parameters and the two fragment shaders are nearly the same. Here is how I set up the parameters:

// -------->

// first shader chunk
beginEditCP(_shlChunkNVP); {
  _shlChunkNVP->readFragmentProgram("shader/particles_nvp.frag");
  _shlChunkNVP->setUniformParameter("scale", _fScale);
  _shlChunkNVP->setUniformParameter("loga", _bLoga);

  if (state == DYNAMIC) {
     _shlChunkNVP->setUniformParameter("dynamic", true);
     _shlChunkNVP->setUniformParameter("ipVal", _fIpVal);
  }
  else {
     _shlChunkNVP->setUniformParameter("dynamic", false);
     _shlChunkNVP->setUniformParameter("ipVal", 0.0f);
  }
} endEditCP(_shlChunkNVP);

// second shader chunk
beginEditCP(_shlChunkFBODir); {
  _shlChunkFBODir->readFragmentProgram("shader/particles_fbo_dir.frag");
  _shlChunkFBODir->setUniformParameter("scale", _fScale);
  _shlChunkFBODir->setUniformParameter("loga", _bLoga);

  if (state == DYNAMIC) {
     _shlChunkFBODir->setUniformParameter("dynamic", true);
     _shlChunkFBODir->setUniformParameter("ipVal", _fIpVal);
  }
  else {
     _shlChunkFBODir->setUniformParameter("dynamic", false);
     _shlChunkFBODir->setUniformParameter("ipVal", 0.0f);
  }
} endEditCP(_shlChunkFBODir);

// <--------

But I get an error while runtime.
WARNING: Unknown parameter 'dynamic'!
and this is for the second chunk and I don't know why. The other parameters are also correct. And the parameters are marked as uniform in the shader (these entries are the same in both fragment programs):

// -------->

uniform bool  dynamic;
uniform bool  loga;
uniform float ipVal;
uniform float scale;

// <--------

The funny thing is, when I change the type from bool to float (in shader and program), it is the same. When I change the name in both files, it is the same. I have an ugly workaround, but it would be nice to have it correctly:

// -------->

if (state == DYNAMIC) {
  _shlChunkFBODir->setUniformParameter("params", Vec2f (1.0f,1.0f));
  _shlChunkFBODir->setUniformParameter("ipVal", _fIpVal);
}
else {
  _shlChunkFBODir->setUniformParameter("params", Vec2f (0.0f,0.0f));
  _shlChunkFBODir->setUniformParameter("ipVal", 0.0f);
}

// <--------

and in the shader:

// -------->

uniform vec2 params;
bool dynamic;

void main(void) {
  if (params.x == 0) dynamic = false;
  else dynamic = true;
  ...
}

// <--------

I wonder, if anyone has an idea?

regards,
Oliver


-------------------------------------------------------
This SF.Net email is sponsored by the JBoss Inc.
Get Certified Today * Register for a JBoss Training Course
Free Certification Exam for All Training Attendees Through End of 2005
Visit http://www.jboss.com/services/certification for more information
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to