[osg-users] Geometry shader results in OGL error in OSG 3.2
Hello, First time posting. We developed an OSG based viewer using OSG 3.0.1. Recently, I upgraded to using OSG 3.2. We have a geometry shader that implements a billboard for trees. Even though I can still see the trees, they are no longer aligned with the line of sight (i.e. don't rotate to align normal with los). OSG does issue a warning when it renders with this geometry shader: OGL error is 1282 (i.e. generic INVALID operation error). Now nothing in our code has changed before I upgraded to OSG 3.2. I did notice that the offending call seems to be EmitVertex(), since if I omit that from the shader, I don't get the 1282 error, but obviously no billboards either. Would anybody in this forum be able to provide some hints on how I can fix this issue? May be something that needs to be done differently when using OSG 3.2? Thanks in advance, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=58666#58666 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem loading RGB values when alpha = 0 on mac osx
Hi Stephan, thanks for the tip. I'll look into the cmake-files to see if I can select libpng instead. cheers, Paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem loading RGB values when alpha = 0 on mac osx
Ok, let me make a small update, I was able to get osg-3.2 to load the example image using the code in attach. I can't be precise in what worked, but I guess updating libpng helped. Now it output: 0 0 0 0 0 0 0 1 0 128 128 2 64 128 191 4 64 128 191 8 64 128 191 16 64 128 191 32 64 128 191 64 64 128 191 128 64 128 192 255 Which is still not the desired result, but it is different from the old result 0 0 0 0 0 0 0 1 0 127 127 2 63 127 191 4 63 127 191 8 63 127 191 16 63 127 191 32 63 127 191 64 63 127 191 128 64 128 192 255 Weird, weird. I guess I'll have to separate channels into several images as a workaround - at least for now. tschüss ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem loading RGB values when alpha = 0 on mac osx
Hi Robert, thanks for the tip. I didn't realize that osg had a new site. I just compiled osg-3.2 but now it won't even load pngs. GraphicsContext::setWindowingSystemInterface() 0x102914e90 0x10057eea8 itr='/Users/paulo/usr/lib' FindFileInPath() : trying /Users/paulo/usr/lib/osgPlugins-3.2.0/osgdb_imageio.so ... FindFileInPath() : USING /Users/paulo/usr/lib/osgPlugins-3.2.0/osgdb_imageio.so Opened DynamicLibrary osgPlugins-3.2.0/osgdb_imageio.so Warning: Could not find plugin to read objects from file "pixel10x1.png". I think I came across this problem before, but I can't remember what I did to solve it... I'll try to solve it and then I'll post the answer here as soon as I find it. But if anyone know the answer please go ahead and post. Thanks, Paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem loading RGB values when alpha = 0 on mac osx
Ok, here's a better version with the alphas {0, 1, 2, 4, 8, 16, 32, 64, 128, 255} for the same rgb values {64, 128, 192}. ~> ./catpx pixel10x1.png 0 0 0 0 0 0 0 1 0 127 127 2 63 127 191 4 63 127 191 8 63 127 191 16 63 127 191 32 63 127 191 64 63 127 191 128 64 128 192 255 There seems to be some pre-multiplication as long as alpha != 0. But every single value should actually be "64 128 192 alpha". Best. #include #include #include #include typedef unsigned char byte; struct Pixel { byte c0; byte c1; byte c2; byte alpha; }; typedef osg::ref_ptr ImagePtr; int main(int n, char** c) { if(n == 1) { std::cout << "Usage: " << c[0] << " image.png" << std::endl; return 0; } const ImagePtr img(osgDB::readImageFile(c[1])); if(img == 0) { std::cout << "Failed to load: " << c[1] << std::endl; return 1; } const GLenum pxf(img->getPixelFormat()); if(not (pxf == GL_RGBA or pxf == GL_BGRA)) { std::cout << "Image must be RGBA or BGRA, found: " << pxf << std::endl; return 1; } const Pixel* px(reinterpret_cast(img->data())); const unsigned N(img->s() * img->t()); for(unsigned i(0); i != N; ++i, ++px) std::cout << unsigned(px->c0) << ' ' << unsigned(px->c1) << ' ' << unsigned(px->c2) << ' ' << unsigned(px->alpha) << std::endl; return 0; } <>___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem loading RGB values when alpha = 0 on mac osx
Hi Robert, Well, I would even try to search for it, but right now I'm so busy I'll have to just skip it and use a hack. But if anyone out there has a bit more time, here's a piece of code and data to test it. I don't remember if osg comes with the pkg-config script, but if not maybe I added mine by hand. In that case just replace that part by the include and lib paths. Compile with: c++ catpx.cpp -o catpx `PKG_CONFIG_PATH=/path/to/pkgconfig/dir pkg-config --cflags --libs openscenegraph openthreads` Runing with: OSG_NOTIFY_LEVEL=debug ./catpx pixel.png GraphicsContext::setWindowingSystemInterface() 0x10262cc30 0x10055db08 itr='/Users/paulo/usr/lib' FindFileInPath() : trying /Users/paulo/usr/lib/osgPlugins-3.0.0/osgdb_imageio.so ... FindFileInPath() : USING /Users/paulo/usr/lib/osgPlugins-3.0.0/osgdb_imageio.so Opened DynamicLibrary osgPlugins-3.0.0/osgdb_imageio.so FindFileInPath(pixel.png): returning pixel.png imageio readImageFile: pixel.png 0 0 0 0 GraphicsContext::setWindowingSystemInterface() 0 0x10055db08 So the plugin used is imageio and the result should be: 64 128 192 0 Somewhere in the loading some sort of alpha pre-multiplying is going on. :/ #include #include #include #include typedef unsigned char byte; struct Pixel { byte c0; byte c1; byte c2; byte alpha; }; typedef osg::ref_ptr ImagePtr; int main(int n, char** c) { if(n == 1) { std::cout << "Usage: " << c[0] << " image.png" << std::endl; return 0; } const ImagePtr img(osgDB::readImageFile(c[1])); if(img == 0) { std::cout << "Failed to load: " << c[1] << std::endl; return 1; } const GLenum pxf(img->getPixelFormat()); if(not (pxf == GL_RGBA or pxf == GL_BGRA)) { std::cout << "Image must be RGBA or BGRA, found: " << pxf << std::endl; return 1; } const Pixel* const px(reinterpret_cast(img->data())); std::cout << unsigned(px->c0) << ' ' << unsigned(px->c1) << ' ' << unsigned(px->c2) << ' ' << unsigned(px->alpha) << std::endl; return 0; } <>___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem loading RGB values when alpha = 0 on mac osx
Hi there, I just happen to have an RGBA texture with some alpha values equal to 0. Unfortunately, at least on mac osx, the image that I get from osgDB::readImageFile has the RGB values set to 0 for pixels that have alpha = 0. I did load the image on gimp and confirmed that the RGB values are maintained in the file, so the problem seems to be in the way the osg plugin handles the file. As far as I can understand, the image loading is done by the quicktime plugin, so I would argue that this is the evil doing of apple's code. Does anyone know more about this issue? Where it originates? How to fix it? I already have a fix (changing alpha = 0 to 1 and remapping after I load the image). But I would like to avoid that if possible. Thanks, Paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problems cloning images (osg 3.0.0)
Hi Robert, well I didn't run the code in debug mode because that would require me to recompile osg in debug, and I thought since no one else seems to be complaining maybe, as you say, it's something on my part. Now, as I understand it, cloning an image should be an straightforward operation. But for some reason I'm getting different results using Image* a = osgDB::readImageFile("a.png"); tex->setImage(a); // shows image "a.png" on screen ... Image* b = osgDB::readImageFile("b.png"); Image* new_image = dynamic_cast(b->clone(CopyOp::DEEP_COPY_ALL)); tex->setImage(new_image); // still shows image "a.png" ... Image* c = new Image; c->allocateImage(b->s(), b->t(), b->r(), b->getPixelFormat(), b->getDataType()); memcpy(c->data(), b->data(), b->getTotalSizeInBytes()); tex->setImage(c); // now displays "b.png" correctly Now, I wonder what could be wrong in that usage of clone. I guess it could be the lack of a call to dirty() as you have in allocateImage, but I think I tried to add that after the clone and if I remember correctly it made no difference. As far as I am concerned, since I have one method working I'll skip the debugging for now. What I can say is that maybe the clone/copy constructor should be implemented in terms of allocateImage. Code duplication only leeds to maintenance problems down the road. Thanks, Paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Draw varying number of elements with DrawElementsUByte
Hi, not really an expert here, in terms of what is the logic behind the implementation, but looking at the code I would say you're correct. The number of elements passed to the constructor is not kept: DrawElementsUShort(GLenum mode, unsigned int no, const GLushort* ptr, int numInstances=0) : DrawElements(DrawElementsUShortPrimitiveType,mode,numInstances), vector_type(ptr,ptr+no) {} An since the vector size is used all over the place, that would only leave you the non-option of changing it. glDrawElements(mode, size(), GL_UNSIGNED_SHORT, &front()); Recreating the object doesn't sound reasonable, given the extra copy necessary. I would say the only option is to customize the code to add that extra functionality, as it is not available at least in the version that I'm using (3.0.0). Good luck ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problems cloning images (osg 3.0.0)
Hi again, well this might not work > _image = dynamic_cast(source().image()->clone(CopyOp::DEEP_COPY_ALL)); > > ... > > _tex->setImage(_image.get()); // replace the texture source > > But the following does. I wonder why? Image* const img(source().image().get()); _image = new Image; _image->allocateImage(img->s(), img->t(), img->r(), img->getPixelFormat(), img->getDataType()); memcpy(_image->data(), img->data(), img->getTotalSizeInBytes()); ... _tex->setImage(_image.get()); // replace the texture source I guess I'll use that for the time being. But it is strange... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Fwd: Problems cloning images (osg 3.0.0)
Hi, I have several images that I'm replacing on the same texture. All works great but if I clone an image, the clone image will no display. For example something like _image = source().image(); // assign some image loaded from a file ... _tex->setImage(_image.get()); // replace the texture source Works as expected. However, _image = dynamic_cast(source().image()->clone(CopyOp::DEEP_COPY_ALL)); ... _tex->setImage(_image.get()); // replace the texture source does absolutely nothing. Basically the texture will just keep on showing the last loaded (non cloned) image. Now, I still didn't do much debug, but I did test that the Image member variables are the same. Everything is equal but getAllocationMode() which is free/malloc in the original and new/delete in the cloned, and I didn't check the contents of data(). Am I using this wrong? For me it kind of looks right though. Thanks Paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Navigation - Walk at 6 feets.
Hi, Magnus Kessler: Thanks a lot for your help. I will try it. Best Regards: Nilton -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=40714#40714 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] How does accept(simplifier) works?
Hi, everybody: Into my code, I am trying to set sample ratio as half, for example, same as written bellow: osg::ref_ptr model3ds = osgDB::readNodeFile("C:\\OpenSceneGraph-2.8.0\\Z_File_To_Test\\Casa_Pronta.3DS"); osgUtil::Simplifier simplifier; simplifier.setSampleRatio(0.5); model3ds->accept(simplifier); viewer.setSceneData(model3ds); But it stays in loop into the line "model3ds->accept(simplifier);" and does not return... Does anybody have used "accept(simplifier)" and could help me undertanding what is happening? Thank you! Cheers, Nilton -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=40703#40703 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Navigation - Walk at 6 feets.
Hi, everybody: I am writing a software to walk into a 3D image from a 3DS file. To control the camera, I am using the code below: osg::Vec3f translacao; osg::Quat rotacao; osg::Vec3f escala; osg::Quat so; osg::Matrix mView = this->camera->getViewMatrix(); mView.decompose(translacao, rotacao, escala, so); this->camera->setViewMatrix(mView * osg::Matrix::translate( pontoRef.x() * -40, pontoRef.z() * 40, pontoRef.y() * 40 ) * osg::Matrix::rotate(varPosCamera.x()/3, osg::Y_AXIS , varPosCamera.z()/3, osg::Y_AXIS , varPosCamera.y()/3, osg::Y_AXIS) ); The issue is that I need to walk thru the scene always at 6 feets, for exemple. Does anybody know how to do so? Thank you! Cheers, Nilton -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=40702#40702 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] TRAVERSE features.
Hi everybody, I am not sure that the class "TRAVERSE" could control the transpass of the building walls. I would like not to pass by the walls while navigating with the camera. My source code is: nodePath[c]->setUpdateCallback( new SetTransverse() ); ... class SetTransverse : public osg::NodeCallback { public: SetTransverse() { } virtual void operator()( osg::Node* node, osg::NodeVisitor* nv ) { osg::MatrixTransform* mt = dynamic_cast( node ); nv->setTraversalMode(osg::NodeVisitor::TRAVERSE_NONE); } }; Does anybody could help me how to use "traverse" properlly? Thank you! Cheers, Nilton -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=40701#40701 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] BoundingBox
Hi, everybody! I am looking to use BoudingBox into my application. I want to avoid collison or transverse the walls of the buildings, when navigating with the camera. Here are my test using BoundingSphere: const osg::BoundingSphere& bs1 = viewer.getCamera()->getBound(); const osg::BoundingSphere& bs2 = nodePath[c]->getBound(); if(bs1.intersects(bs2)) { // Do something } This test does not work properly and IF always return TRUE. Does anybody know how to verify the collision into the walls? (I want that the camera does not transpass the walls). Thank you! Cheers, Nilton -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=40700#40700 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Plugin Error
Hi, How do I build them? I used CMake for Windows XP for this. He created only DLLs that have the names of the namespaces of OSG (osg, osgUtil, osdDB, osgViewer, etc.). How do I build DLLs for jpeg and others textures? Thank you! Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=25975#25975 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Plugin Error
Hi, Didn't someone understand my question? Please, tell me and I fix! Thank you! Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=25869#25869 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] Plugin Error
Hi, My name is Paul and I am Brazilian. I'm still a beginner in programming with OSG. I can not go through the Tutorial 3 (texturedGeometry) because I can not read no files. Plugin error occurs. It appears that a plugin reading was not found and the following condition is always true and the program ends. //lines 123-129// if (!klnFace) { cout << " couldn't find texture, quitting." << endl; return -1; } Commenting this part, the program runs normally, but without success, no textures. I have tried various textures as jpg, but it did not work. I use Windows XP Service Pack 3 with Visual Studio 2008 Professional Edition. Thank you! Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=25569#25569 Attachments: http://forum.openscenegraph.org//files/texturedgeometry_191.cpp ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Howto generate debug sources linux cmake?
Hi, Thank to everyone, that did the trick. After a few hours of debug I was able to understand many things about OSG that are unfortunately can't be read anywhere else. Thank you! Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19601#19601 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Phong and Gouraud Shader question
Hi, GL by default uses either GL_SMOOTH http://www.opengl.org/sdk/docs/man/xhtml/glShadeModel.xml Probably osg also uses the default value. GL_SMOOTH calculates the light at each vertex and interpolates the value in the primitive, also called Gouraud shading http://en.wikipedia.org/wiki/Gouraud_shading While the Phong shading interpolates not the color but the normals in the primitive http://en.wikipedia.org/wiki/Phong_reflection_model I do happen to have a phong shader lying around, but only for one light. But you can find it anywhere, both books and web... (vert) varying vec3 v_V; varying vec3 v_N; void main() { gl_Position = ftransform(); v_V = (gl_ModelViewMatrix * gl_Vertex).xyz; v_N = gl_NormalMatrix * gl_Normal; } (frag) varying vec3 v_V; varying vec3 v_N; void main() { vec3 N = normalize(v_N); vec3 V = normalize(v_V); vec3 R = reflect(V, N); vec3 L = normalize(vec3(gl_LightSource[0].position)); vec4 ambient = gl_FrontMaterial.ambient; vec4 diffuse = gl_FrontMaterial.diffuse * max(dot(L, N), 0.0); vec4 specular = gl_FrontMaterial.specular * pow(max(dot(R, L), 0.0), gl_FrontMaterial.shininess); gl_FragColor = ambient + diffuse + specular; } Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19598#19598 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Repeatable rendering of subgraphs, ideas?
Hi, can I add something here? What about a simple multipass (unknown until the draw stage), with rendering done by a glsl shader, and shader variable update in function of the pass, like: void render() { setGlslProg(prog); //which uses uniform_x for(i(0); i != num_of_passes; ++i) { //change the same uniform in function of the pass i uniform_x->set(i / num_of_passes); render(node); //actually render pass i! } } This is somewhat similar to what is being discussed here, and also conceptually incredibly simple, but apparently very complicated to implement with osg. Apparently you cannot change the uniform in your own implementation of the cull_draw traversal, as suggested early, because in the end all passes will be rendered with the same uniform value!? As if the cull_draw did not actually submit the geometry to GL between passes. (still have to check it out in the code). Ideas? Thank you! Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19575#19575 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Howto update shared uniforms between passes?
Hi, Thank you I'll check it out. Cheers, Paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19573#19573 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Howto generate debug sources linux cmake?
Hi, how can I compile the sources in linux with debug enabled. I used "cmake d ." in the osg dir, the files got "fat" but I still can't get any debug info. Could anyone help me on this? Thank you! Cheers, paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19533#19533 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Howto update shared uniforms between passes?
Hi, I'm trying to do a multipass effect, which uses only one shared shader program among all passes, but between passes the uniforms need to be updated. The way I found to do this was to create n statesets, and n times the same uniforms, one per sate. This is a bit awkward, since I think I should be able to share the uniforms, and just update them once per pass in a callback. The problem is that as far as the source tells me, the update traversal is done before all the passes, as something like: event(); update(); //update all nodes/statesets/uniforms cull(); draw(); //draw all nodes/statesets So, there's no way that I can update an shared uniform, if it needs to be updated between passes? Thank you! Cheers, paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19532#19532 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Uniform callback not being called. Why?
Hi, I added a callback to an uniform, which is added to a osgFX node in my graph. The node's geometry is drawn, but the uniform is never updated. Could there be a reason why? Right now I can't debug, still trying to build osg code in debug. (any help here is also welcome. Thank you! Cheers, paulo -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=19534#19534 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Sharing programs and uniforms among state sets
Hi, thank you for your help. Just another thing. So if I have a osgFX that performs N passes, I can share the same stateset between all of them as I understand. And then at the uniforms update callback I can set it's value according to the pass being executed? And for each pass they will have a different value right? Thank you again. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9258#9258 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Sharing programs and uniforms among state sets
Hi, Is it ok to share program and uniform objects among stateset objects? no problems when updating the same uniform for each state set? If a state set is equal for several passes is it ok to share it among them? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9244#9244 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Blend Equation and multipasses
Hi, To use a mutipass I need to turn on blending. (at least with open gl) Is it also needed with osgFX or is it automatic? I tried adding a BlendEquation object to my stateset, but I could not figure out which symbolic constant corresponds to the gl functions glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); Anyone? Thank you. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=9231#9231 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Howto perform a dynamic number of shader passes in a osgFX::Effect
Hi, I'm trying to control the number of "passes" that I need for my particular objective. please consider the code for the traversal of the only technique: void DefaultTechnique::traverse(osg::NodeVisitor& nv, osgFX::Effect* fx) { osgUtil::CullVisitor* cv = dynamic_cast(&nv); if(!cv) { osgFX::Technique::traverse(nv, fx); return; } //TODO: where? once here or once for every loop step? //cv->pushStateSet(getPassStateSet(0)); osg::Node* override = getOverrideChild(0); const uint num_passes(computeNeededPasses()); for(uint i(0); i != num_passes; ++i) { cv->pushStateSet(getPassStateSet(0)); //This tech uses a shader. (just as an example we do some assignments here) uniform_a->set(i + 2.0f); uniform_b->set(i * 2.0f); if(override) override->accept(*cv); else fx->inherited_traverse(*cv); cv->popStateSet(); } //cv->popStateSet(); } Not only I don't really know where to place the push and pop of the sate, but I also don't know if this is overall correct. Should I place the state's push and pop inside or outside of the loop? If neither, then where? Both inside and outside I get: Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,) I can't use the callbacks, since I need to update the uniforms once per pass, and I don't know how many passes I will have to do since it's a user parameter changed interactively. I would appreciate you help please. It would avoid me digging code for hours to try to understand how to use the osgFX passes. Thank you -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8882#8882 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgFX nodes with shaders with variables
Well, from reading Technique.cpp I'm able to guess that I have to re-implement the traverse traverse method. The best idea seems to be just copy paste the Technique::traverse_implementation and for each pass implement a specific behavior. For what I want, apply the same shader(s) several times, first each shader should be associated with a specific pass/state set. Then loop around the traverse of the Technique's children. I think that here I can freely modify the shaders parameters, but I'm not sure. Another problem is that I don't know for which kind of visitor I should do this. (Or even if this is the right way to do it - as there's no doc) Someone? [Question] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=8847#8847 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgFX nodes with shaders with variables
Hi, I have a osgFX that needs to apply two pass technique. On the second pass I need to apply one or more shaders one or more times. (controlled by the user parameters) I looked at the osgFX::Scribe which covers the osgFX creation. For the shaders I looked at the code from osgshaders. Now my problem is that a simple callback to set the Uniform will not be enough for what I need. I need to control what shaders are enabling/disable, how many times each is applied for a pass and I need to be able to change the Uniforms for each of those applications. Any ideas how to do this with osg? I'm sure it's not complicated, but I'm kind of new to this. Thank you paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] iterate node primitive set elements howto
Hi, is there an obvious way to know which element a node is composed of (dots, lines, triangles, quads, polygons,) and iterate over them in a loop? In an attempt to answer my question, I would say no. Since a node can be 1 or more models of possibly different characteristics, I would probably need to pass a visitor, and search for all the geometry nodes. Then for every one of those geometry nodes I can check the primitive set and iterate over its elements. Can anyone shed some light over my clouded mind and free me of my doubts? thanks paulo ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Arrays GPU memory - system memory selection.
Hi, I'm imagining that there is a way to select if I want a vertex array to be on the GPU memory or on the main memory. RIght? If so, how can I select that? And while on ram, do we still need to make a call to "dirty" to update it? Thanks. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OpenSceneGraph-Data on hg source
Hi, I just noticed that version 2.8 (and the hg source) does not include the Data files. (gentoo ebuild) Any reason for this? Am I suppose to download it separately? Thanks ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] dynamic vertex array howto
Hi, it worked just fine. I guessed so, because I noticed the dirty method not on the geometry but on the vertex array autocomplete, I was asking because sometimes the documentation has only the code listing and not an actual explanation. I guess I could have tried it, but it was also to confirm that I was doing the right thing. Thank you =) Jean-Sébastien Guay wrote: Hi Paulo, What am I doing wrong? Do I need to call some method to flag that the array changed? Yep, good intuition: _geometry->dirty(); Also, since you're changing the vertices each frame, set _geometry->setUseDisplayList(false); or otherwise you'll get bad performance. Hope this helps, J-S ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] dynamic vertex array howto
Hi, I have a vertex array that I would like to draw. The data can change from frame to frame so I did _points = new osg::DrawArrays(osg::PrimitiveSet::POINTS); _points->setDataVariance(osg::Object::DYNAMIC); I added that and some vertices to my geometry. I kept a pointer to the vertices to reuse it each frame. To draw it I was doing: if(some_number != _vertices->size()) { _vertices->resize(some_number, osg::Vec3()); _points->setCount(some_number); } for(unsigned i(0); i != some_number; ++i) //copy data into the vertex array Should be rather intuitive what the variables are... Thing is, though the array changes the contents are not redrawn... Yet if I do each frame: _vertices = new osg::Vec3Array(some_number); _geometry->setVertexArray(_vertices.get()); _points->setCount(some_number); for(unsigned i(0); i != some_number; ++i) //copy data into the vertex array Then the contents are drawn correctly. But I thing it does not make sense to create a new array every frame. osg::Vec3Array even has the vector methods for resizing etc... What am I doing wrong? Do I need to call some method to flag that the array changed? Thank you ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Qt mouse wheel zoom howto
Hi, I was writing an application using Qt and osg. I would like to zoom in and out on mouse scroll. I could not find a good way to do this, so I came up with: void osgWidget::wheelEvent(QWheelEvent *event) { const float delta(event->delta() / (8.0f * 15.0f)); const float x(event->x()); const float y(event->y()); const float ydy(y + delta); const int b(osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON | osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON); _gw->getEventQueue()->mouseButtonPress(x, y, b); _gw->getEventQueue()->mouseMotion(x, ydy); _gw->getEventQueue()->mouseButtonRelease(x, ydy, b); } which actually works but it's not so elegant. Is there a obj->zoom(0.9f); to get 10% closer or obj->zoom(1.1f); to get 10% further for example? thank you. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Focus/zoom in a node.
Thank you that was exactly what I needed. =) Paulo Robert Osfield wrote: HI Paulo, What you need to do is to tell the active CameraManipulator that you've updated the model it should be referring to and then call viewer.home(); viewer.getCameraManipulator()->setNode(myNode); viewer.getCameraManipulator()->computeHomePosition(); viewer.home(); Robert. On Sun, Feb 8, 2009 at 4:38 PM, Paulo Jnkml wrote: Hi, thank you for replying. Well maybe. Imagine that I load a model so big or so small that with the current camera parameters I can see a thing. I want to adapt the camera automagically so that my current loaded/selected scene/node will fit just nicely on screen. =) Paulo Robert Osfield wrote: HI Paulo, On Sun, Feb 8, 2009 at 9:23 AM, Paulo Jnkml wrote: is there a tutorial where I can see how make the camera focus a particular node, such that the node's bounding box will fit the viewer window? Do you mean setting the home position of the camera position? Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Server migration
Error: Forbidden FILE_VIEW privileges are required to perform this operation on Path /OpenSceneGraph/trunk/examples/osgspacewarp/osgspacewarp@6941 There's also this problem. cheers Jose Luis Hidalgo wrote: Hi Paul, I'm adjusting the apache, and restarting it from time to time, maybe you got me in the middle of one of them. :P Jose-L. On Sun, Feb 8, 2009 at 4:55 PM, Paul Melis wrote: Jose Luis Hidalgo wrote: Hi Paul, I had changed DNS entries, so it's possible it takes a while to spread around all ISP's DNS. The "final" server will be http://158.42.9.50/projects/osg In at most few hours, everybody should access using http://www.openscenegraph.org. I can indeed login with my svn account on the new server, and editing works, so that's good. But http://158.42.9.50/projects/osg does not seem to respond all the time, at least, it doesn't right now. Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Focus/zoom in a node.
Hi, thank you for replying. Well maybe. Imagine that I load a model so big or so small that with the current camera parameters I can see a thing. I want to adapt the camera automagically so that my current loaded/selected scene/node will fit just nicely on screen. =) Paulo Robert Osfield wrote: HI Paulo, On Sun, Feb 8, 2009 at 9:23 AM, Paulo Jnkml wrote: is there a tutorial where I can see how make the camera focus a particular node, such that the node's bounding box will fit the viewer window? Do you mean setting the home position of the camera position? Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Focus/zoom in a node.
Hi, is there a tutorial where I can see how make the camera focus a particular node, such that the node's bounding box will fit the viewer window? Thank you. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org