Does the glsl_simple.osg example datafile work for you?  It
demonstrates one shader w/ different values for the "Color1" uniform.
-- mew



On Thu, May 15, 2008 at 2:01 PM, Dorosky, Christopher G
<[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am having problems with a uniform value getting trumped in a shader.
>
> Here is most of the shader fragment:
>
> ___________________________________________________________________
>
>  os << "\nuniform bool PreMultipliedAlpha;\n";
>  os << "uniform vec4 FogUniform;\n";
>  os << "   vec3 FogColor;\n";
>        os << "   vec3 FogUniformColor;\n";
>
>        os << "void main()\n";
>        os << "{\n";
>
>        os << "   if (PreMultipliedAlpha) {\n";
>        os << "      FogColor = gl_Fog.color.rgb * gl_FragColor.a;\n";
>        if (aFogType == EXP2_FOG)
>            os << "      FogUniformColor = FogUniform.rgb *
> gl_FragColor.a;\n";
>        os << "   } else {\n";
>        os << "      FogColor = gl_Fog.color.rgb;\n";
>        if (aFogType == EXP2_FOG)
>            os << "      FogUniformColor = FogUniform.rgb;\n";
>        os << "   }\n";
> ______________________________________________________________________
>
> Now, to use it, I have this code...
>
> osg::Group *Topgroup = new osg::Group; // real code this has more stuff
> attached.
> osg::Group *group = new osg::Group;
>
> Topgroup->addChild(group);
>
> // modelA and modelB groups already exist.
>
> modelA->getOrCreateStateSet()->getOrCreateUniform("PreMultipliedAlpha",
> osg::Uniform::BOOL)->set(true);
> modelB->getOrCreateStateSet()->getOrCreateUniform("PreMultipliedAlpha",
> osg::Uniform::BOOL)->set(false);
>
>
> group->addChild(modelA);
> group->addChild(modelB);
>
> // Then the Fragment shader is added to the Topgroup node.
> // Didn't include code here because it is long, and it works as shown
> below.
>
> Here is what happens.
> When modelA and modelB are added to the group as shown above, the
> uniform is always false.
>
> If I comment out the line:
> //group->addChild(modelB);
>
> Then I have the uniform set correctly to true.
>
> Reinserting that line, and commenting out
> group->addChild(modelA);
> Has the uniform set correctly to false.
>
> It seems that I can't have both models added with different uniform
> values without one trumping the other.
>
> Am I doing something wrong or is this a bug?
>
> I've tried more obvious things conditional on the uniform value, like
> making the model red or blue with same results.
>
> OSG 1.2, Windows XP
>
> Thanks,
>
> Chris
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>



-- 
Mike Weiblen -- Austin Texas USA -- http://mew.cx/
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to