Hi Fabian,
You need to set the size of the uniform, preferably using the constructor:
Uniform( Type type, const std::string& name, int numElements=1 );
Or use setNumElements(num);
Note, Uniform doesn't allow you to change the size of the array after
its been set for the first time.
Robert.
On Tue, Sep 2, 2008 at 6:26 AM, Fabian Bützow <[EMAIL PROTECTED]> wrote:
> Hello,
> i want to pass a uniform vec2 array as convolution mask to a image
> processing shader.
> A former post says I should use setElement.. here my trial (it doesent work
> ;) ):
>
> osg:
> Uniform* filter= new Uniform();
> filter->setName("kernel"); filter->setElement(0, Vec2(-1,1));
> ...
> filter->setElement(8, Vec2(1,-1));
> meanStateSet->addUniform(filter);
>
> shader:
> uniform sampler2DRect inTex;
> uniform vec2 kernel[9];
> void main(){
> int i; float sum= 0.0;
> for (i = 0; i < 9; ++i){
> sum+= (texture2DRect(inTex, gl_TexCoord[0].st + kernel[i])).r;
> }
> gl_FragColor = (sum/9);
> }
>
> when i change kernel[i] to (for instance) vec2(0,0) it works...
>
> any ideas?
> what do i forget to set?
>
> cheers,
> Fabian
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org