Hi osg-Forum,
I'm kind of stuck with a problem in how to combine a tesslation shader in osg
with a normal model right now. I really searched over google a couple of times
and over the osg forum. I can't find an answer to my problem. Normally i prefer
to not ask and just resolve it myself because thats my problem and not yours.
As you can see this is my first post and i just registered here to ask that.
I'm really sry for that.
The thing is that I'm currently working on is an application that will just
display a model. The model i'm working on is a huge bunch of GroupNodes that
resolve down in the tree to geode-group-nodes and then geometrynodes. I guess
thats pretty normal. With default osg shaders everty thing works nice and
smooth.
Now comes the problem. I have to tesselate the Model.
I admit that im not used to programm shaders and only did it with DirectX 11.
But the easy things worked back then.
For this project i used the "osgtesselateshaders" example of yours and did just
copy the shaders there. I know that now all the texture, material and own
lightning won't work with this shaders. I just want to see if the wireframe
will get tesselated. For that i create the osg::Program variable in a ref_ptr
and then set the pointer of it to all geometrynodes of the model. Every
Geometrynode will get his own uniform with "innerTesselation",
"outerTesselation" variables and so own. I also created hotkeys for "+" and "-"
that will change the values of all Geoemtrynode as pleased.
The default shader of osg works perfectly fine with my programm but of course
no tesselation will hapen. Now if i start the programm with the osg
tesselateion shaders of "osgtesselateshaders" it will just print this in Visual
Studio:
"Warning: detected OpenGL error 'invalid operation' at after
RenderBin::draw(..)"
This warning pretty much says nothing as far as i have googeld it. Just says
"some Problem ist here". Of course the viewer will show nothing of my model.
So now my question what do i have to change to make the shaders of the example
work with a loaded model? Is it even possible to make this example work with a
model? Isn't a model just a bunch of triangles (+ texture and materials) as the
Icosahedron in the example? Whats the difference here?
It would be cool if somebody allready has an example on how to use an
tesselation shader with a simpel model that he can (is allowed) to post here.
I'm sry for the post if the problem is just a simple coding error.
Code:
// init of the programm
this->mShader = new osg::Program();
this->mShader->addShader(new osg::Shader(osg::Shader::VERTEX,
shader::Shader::vertSource));
this->mShader->addShader(new osg::Shader(osg::Shader::TESSCONTROL,
shader::Shader::tessControlSource));
this->mShader->addShader(new osg::Shader(osg::Shader::TESSEVALUATION,
shader::Shader::tessEvalSource));
this->mShader->addShader(new osg::Shader(osg::Shader::GEOMETRY,
shader::Shader::geomSource));
this->mShader->addShader(new osg::Shader(osg::Shader::FRAGMENT,
shader::Shader::fragSource));
this->mShader->setParameter(GL_GEOMETRY_VERTICES_OUT_EXT, 3);
this->mShader->setParameter(GL_GEOMETRY_INPUT_TYPE_EXT, GL_TRIANGLES);
this->mShader->setParameter(GL_GEOMETRY_OUTPUT_TYPE_EXT, GL_TRIANGLE_STRIP);
n->setShader(this->mShader.get());
Code:
void scene::GroupNode::setShader(osg::Program * p) {
NodeIDMap::iterator itr;
for (itr = this->mChildren.begin(); itr != this->mChildren.end(); ++itr)
itr->second->setShader(p);
}
Code:
void scene::GeometryNode::setShader(osg::Program * p) {
auto *ss = this->mOSGNode->getOrCreateStateSet();
ss->setAttribute(p);
}
Code:
scene::GeometryNode::GeometryNode(osg::Geometry * ptrOSGNode) {
....
this->mTessInnerU = new osg::Uniform("TessLevelInner", 1.0f);
this->mTessOuterU = new osg::Uniform("TessLevelOuter", 1.0f);
osg::StateSet * state;
state = ptrOSGNode->getOrCreateStateSet();
state->addUniform(new osg::Uniform("AmbientMaterial", osg::Vec3(0.04f,
0.04f, 0.04f)));
state->addUniform(new osg::Uniform("DiffuseMaterial", osg::Vec3(0.0f,
0.75f, 0.75f)));
state->addUniform(new osg::Uniform("LightPosition", osg::Vec3(0.25f,
0.25f, 1.0f)));
state->addUniform(this->mTessInnerU.get());
state->addUniform(this->mTessOuterU.get());
state->setAttribute(new osg::PatchParameter(3));
}
Thank you!
Cheers,
NoxxKn[/code]
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=66608#66608
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org