Hi,
not clear on exactly what the question is.
imho shaders are about flexibility and expressive power, not necessarily raw
speed. it is easy to create very complex shaders that run slowly (even infinite
loops that need a hardware watchdog) On top of that some GLSL implementations
will fall back to a software path if certain language features are used,
resulting in extreme performance penalties.
-- mew
belthil wrote:
> Hi!
>
> Well, i don't understand why but the shaders are working now on my
> laptop... And i didn't change my code! Maybe my laptop had an update
> about shaders...
> So now, i don't have any errors anymore. :) I thank you anyway!
>
> But still, i have another question. Shaders are made above all for
> 3D real time, so that an application is even faster, more powerful,
> right? But i tested my application to see the difference without and
> with shaders. So i created lots of GL_POINT (1 000 000) in a cube of
> size 1e10. When there are no shaders, the frame rate can drop to 20fps
> and the GPU can go up til 37, and it's exactly the same with shaders. I
> can understand those numbers without shaders, but with shaders... i do
> not understand. And why does the GPU work so much without any shaders?
> Here is my code for shaders:
>
> osg::ref_ptr<osg::StateSet> sset = new osg::StateSet;
> sset->setMode(GL_VERTEX_PROGRAM_POINT_SIZE, osg::StateAttribute::ON);
> osg::ref_ptr<osg::Program> program = new osg::Program;
> program->addShader(new osg::Shader(osg::Shader::VERTEX,
> _vertexShaderProgram));
> program->addShader(new osg::Shader(osg::Shader::FRAGMENT,
> _fragmentShaderProgram));
> sset->setAttributeAndModes(program.get(), osg::StateAttribute::ON);
> osg::ref_ptr<osg::Uniform> _starAlpha = new osg::Uniform("starAlpha", 1.0f);
> osg::ref_ptr<osg::Uniform> _pointSize = new osg::Uniform("pointSize",1.0f);
> sset->addUniform(_starAlpha.get());
> sset->addUniform(_pointSize.get());
>
> And then i assign sset to the Geode that contains the Geometry with all
> the GL_POINT.
>
> And here are the code for GLSL shaders:
>
> const std::string CStars::_vertexShaderProgram =
> "uniform float starAlpha;"
> "uniform float pointSize;"
> "varying vec4 starColor;"
> "void main()"
> "{"
> " starColor = gl_Color - 1.0 + starAlpha;"
> " gl_PointSize = pointSize;"
> " gl_ClipVertex = gl_ModelViewProjectionMatrix * gl_Vertex;"
> " gl_Position = ftransform();"
> "}";
>
> const std::string CStars::_fragmentShaderProgram =
> "varying vec4 starColor;"
> "void main()"
> "{"
> " gl_FragColor = starColor;"
> "}";
>
> I want to precise that these shaders are exactly the same that in
> osgEphemeris for the stars, and i took the shaders code to test in my
> application.
>
> If you have any idea to help me that would be great.
>
> I thank you very much in advance!
>
> Belthil
>
>
> /Créez votre adresse électronique [EMAIL PROTECTED]
> 1 Go d'espace de stockage, anti-spam et anti-virus intégrés./
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://openscenegraph.net/mailman/listinfo/osg-users
> http://www.openscenegraph.org/
--
Mike Weiblen -- Austin Texas USA -- http://mew.cx/
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/