Re: [osg-users] order of MatrixTransform
Ok thanks, I would have to recalculate the matrix every time the rotation changes I assume, but in the end that is probably more efficient than having 3 matrixtransforms in the scenegraph... right? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61037#61037 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] order of MatrixTransform
Thanks. Is there a way to make it a single node, but still being able to easily change the rotation around the point (the point on which to rotate doesn't change) ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61035#61035 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] order of MatrixTransform
Hi, I'm a little confused about something simple... the order in which to add MatrixTransform. For example I want to rotate something around x,y,z using 3 matrixtransforms. as I understand I can do this by: -translate(-x,-y,-z) -rotate -translate(x,y,z) when I add them, which is the correct order? -root-> translate(-x,-y,-z) -> rotate -> translate(x,y,z) -> geode or... -root-> translate(x,y,z) -> rotate -> translate(-x,-y,-z) -> geode thanks! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61032#61032 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] About HUD' projection
For a normal 2D HUD I suggest orthogonal. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61031#61031 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
I think making it two projects could be an advantage, specially if the docs are large, because you can check out the source code without having to transfer tons of data for doc-files, which might not be locally used by many. Any cons? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60936#60936 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Hi Robert, I would say that the hand written ones would best sit alongside the generated once, with some kind of suffix like 'discuss' or 'details'. It also seems to make sense to me to check in the generated docs as well, or else it could cause some confusion. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60904#60904 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
> So we have tried what you are suggesting and it didn't work out how you are > suggesting it could. Sort of true, except that those wiki's did not have a API-type structure, which might have made the difference. But obviously I cannot guarantee that. It's just a gut feeling I have, based on my experience of willing to contribute some pieces of knowledge to the docs, but not seeing a good way of doing this... and I THINK there might be more people like me, but again, I can't be sure about that either... perhaps I'm very special and one-of-a-kind ;) Another small thing that could be explored is trying to make it more clear THAT contributions to the docs from anyone are welcome and clear instructions on how to do it... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60898#60898 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Hi Robert, I guess as the creator of a well known open source project you are entitled to make claims about what all programmers should be capable of doing, but if the problem is that not enough people are contributing to the documentation, my first idea would be: try to make it easier to contribute, remove obstacles. For example, I do know how to use repositories, but that doesn't automatically mean that I checked out the source of OSG trough your repository, I downloaded a stable version. So if I would want to contribute to doxygen or readthedocs I would still have to set up the repository connection for that reason alone, and to be honest (if we weren't having this discussion) I would probably have thought: "oh never mind then, that's too much work for making some small contributions to the docs". But still I understand the dilemma of keeping the docs in sync, so I think ReadTheDocs would be a good alternative because it would allow contributions to the docs in a structured/API manner without messing around with the actual source code, which I believe to be the most valuable addition at this point. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60895#60895 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Glenn I don't understand what you are trying to say. Are you saying that everyone who uses OSG necessarily has to (learn to) checkout the source repository, and push changes? This is not the case, you can download the source and use the source and/or precompiled OSG without every learning or touching any repository system. And this is what I did too. But I might be misunderstanding what you mean. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60892#60892 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Hi Robert, One question: did the previous wikis offer a structure that somewhat covers most of OSG (like the api documentation)? Or was it a list of guides and articles? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60883#60883 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Sounds like a cool system... however can people add, edit or comment on anything in the documentation without learning github (or whatever is rep system is used) checking out the source and pushing changes? I think it is very important that this is possible, or else many people may find it too much trouble to contribute to the docs... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60878#60878 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Hi Björn, My idea is actually closely related with your point 2: the in depth documentation of OSG. As far as I know however, doxygen is generated from the comments in the source code, so everyone who wants to add or say something about any function would have to do it in the source code (please correct me if I'm wrong), which doesn't seem ideal to me. Also the doxygen seems to list absolutely everything and makes no distinction between functions/classes that are meant to be used by the user of OSG, and classes and functions that are more private and used inside OSG, and I think this is detrimental to understanding OSG from it. In my ideal view of the OSG documentation (besides good examples and tutorials), it would include an API documentation where it's clear what classes and functions are part of the interface of OSG and how you can use them. The level of details would be something like this (just an example): http://wiki.secondlife.com/wiki/LlSensor So instead of one or two lines per function, it could include explanations of when and how to use the function, examples of usage, details on the exact nature and limits of the arguments and return values of the function, caveats and discussion points. etc. Again correct me if I'm wrong, but I don't think this is possible in doxygen? I believe/hope that if the groundwork and basic structure for this is created and perhaps partially filled by a limited number of people, then this type of documentation can then further be generated and maintained by the community. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60876#60876 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
First, it is not my intention to offend the creators of the current help system, or to suggest they made bad decisions or something like that. I just have a different vision that I want to explain. My line of thought goes something like this: if you want to get a really extensive documentation, nobody is going to manage to do this on their own, or even with a few people. (A lot of kudo's to Jordi for doing all this work so far on the current help sections). To document something big like OSG extensively, the community needs to get involved. Then basically the system that you use to accommodate this can be seen as a social medium. And with social media, the exact details of how a social medium works, feels and looks are really important (just read any research on social media if you don't believe me). Therefore the choice between Joomla and Wiki or another system might be more important that some of you suggest, even if technically they have similar functionality. I don't know much of the details about the psychology of this all, but somehow, the system of wiki has proven itself over and over again. There seems to be something about it that allows community to build good and thorough documentation. I've seen it so often, that I'm kinda surprised by how negative you all react to the idea, like I'm suggesting something really weird. I could name many examples of excellent wiki's for many well known projects and games and what not, but I'll spare you the list... This is by the way the first time I ever suggest a wiki, or work with wiki's myself, so I'm not some kind of weird wiki supporter if you might think that :) I haven't worked with Joomla much, but I did program some exporters for it once, and I have a decent idea of how it works. For the purpose of a community build documentation it might be a bit too complex and I believe it is designed more for webmasters than for communities. Wiki's are a bit more simplistic and quicker to edit if I'm correct. Wiki pages are probably also easier to generate so that a good structure can be created that would accommodate guides and tutorials as well as in depth details of classes and functions (information that I, for example, would feel confident adding if I learn something specific about a class or function). Regarding you comment about finding documentation, the documentation button on the main page could link to the separate documentation system. Then all documentation could be placed there, in a single location. I think that would actually make it easier for people to find what they are looking for. It's really not uncommon to have a few separate sections for stuff like main pages, documentation and forums. I don't really agree that it is necessarily better to keep going with the current system. The more you add to it, the harder it will be to migrate to another system in the future. But I'm not here to push my ideas on to you. I'm not a developer of OSG and whatever you decide I'm fine with. I just try to explain my vision on it as good as I can, and then I'll shut up about it... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60866#60866 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
I believe it is better to separate the documentation from the main website. It's not really easy to explain, but try to look at it from my perspective, from a general user. It wouldn't cross my mind to ask you guys for full permission to edit your main website. I'm not involved with the development of the project and even not you offer it, I'm think "that's weird, I'm not going to edit the main website, I'm just a general user". If there is a wiki, or something similar, which is full devoted to be a repository of knowledge on OSG (which is pretty big), then I would consider editing or adding some information about a particular part of the OSG system that I dealt with and learned something about. For example something that took me a while to find out, but that I thought should be general knowledge. But not something that needs a separate article or guide. It's easy to argue that you can do anything with Joomla that you can do with wiki, but that's not a very strong argument I think: if you wouldn't use any content management system and gave users ftp permission to your website, then technically, you can STILL do anything that a wiki can do, which is making content. Community efforts are not only about the technical possibilities of the system that is used. It's about the user-friendliness and 'affordences' or whatever they call it, and I believe wiki is a system most people find perfectly suited for editing and adding small bits of information on particular subject. Important is then that there is a good structure that covers OSG well, so users also easily know WHERE to place information that they think needs sharing, without having to write a whole article or guide about it. Also users know that wiki's are meant to be edited by the community, while they probably don't know that they can get access to your main website to plac e information there. And even if they know, there is no structure that really covers OSG and all it's functions, so all you can do is add loosely coupled articles now. That's a well as I can explain it, and that's all I will say about it. I would do this as a hopefully useful contribution to OSG, but not without full support. If you truly believe that the way it is now is as good as can be, then there's nothing more to say... I'm not going to use Joomla to make a full documentation structure for OSG, sorry, I just don't think Joomla is the right technology for that, even if 'technically' everything is possible... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60864#60864 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] create a OSG wiki: (it was OpenSceneGraph Oculus Rift integration )
Hi Jordi (and others), I might be able to assist with the creation and maintenance of a wiki, but there are a few things: Con: -I'm not very familiar with creating and maintaining a wiki -I only use OSG in 1 project now so I only know a small part of it and that part not even that well. Pro: -I have a decent server at my disposal -I would probably enjoy (to some extend) maintaining the wiki. If anyone ELSE, preferably someone with a lot of knowledge on OSG and wiki's is willing to start this, that would probably be a better idea :) But if there is no one I might start one, but I have to think about it some more and find out how much support there is for creating this, I cannot fill the wiki on my own, I can tell you that... It's more of a community thing to actually fill out all details. I guess one thing to do first is to come up with a good structure for the wiki. One part should probably align with the class structure of OSG, where each class and each (important) function has it's own page. Perhaps there is a way to generate (parts) of this from the source code.. But obviously there is also a lot of existing knowledge in the form of guides and other types of articles, which also needs to be included and structured. And finally I think it would be useful to cover the fundamentals of OSG more. What I mean by that is that most documentation is written as tutorials, in the form: in order to ... do but a while ago, for example, there were some posts about renderbins and how to cull visitor works, and I think that sort of information is underrepresented. At the beginning state of learning OSG tutorials are the best way, because usually people want to start using it asap, but when you get past that and you try to understand OSG more and debug it, then there seems to be some 'holes' in the information that you can find. Only by looking at old forum posts can you start to understand how the whole system work. So we would also need a list of fundamental topics that would need to be explained to 'fully' understand OSG, written from the perspective of the OSG system itself, and the ideas behind it. Let me know what you think so far. Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60858#60858 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenSceneGraph Oculus Rift integration
Hopefully last post off topic: creating a good wiki with a good basic structure that has the possibility to cover all important classes and functions in OSG, and can be easily added to by all, is a huge difference from giving people who ask it full access to post whatever OSG related material he/she wants on the OSG website. In the first I would easily add some knowledge that i found on the forum which was hard to find, but if I want to add something to the OSG website I would have to write some kind of guide, but that's not the right format for the smaller things that I find out. I hope you can understand the difference I'm trying to explain. for example: http://wiki.secondlife.com/wiki/LSL_Portal/nl <- it had quite an extended page for each function in the script language. The creators make basic pages about the functionality, and the enthusiasts add their specific knowledge to it, and it works really well... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60816#60816 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OpenSceneGraph Oculus Rift integration
What sometimes helps is a good wiki where enthusiasts/independents can share all the information they got on the SDK and the workings of the OR. Actually might be good for OSG too. Lots and lots of information and knowledge on the forums, but sometimes it's hard to find it. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60805#60805 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transforming a directional vector into eye-space
ok thanks :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60636#60636 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] transforming a directional vector into eye-space
thanks I noticed I had to use the (vec3, matrix) version instead of the (matrix, vec3) version to make it work. So that does a v*M[0..2,0..2] However in the shader (glsl) it's gl_NormalMatrix * gl_Normal... seems to be the other way around. Any clarification on this? thanks! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60632#60632 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] transforming a directional vector into eye-space
Hi, In my shader I would like to have the direction of the light (sunlight) in eye-space, and since it doesn't vary per vertex I would like to pre-calculate it in OSG. I'm not sure how to do this, I thought it would make sense to multiply the view matrix with the direction of the light like this, but I feel like I'm not sure what I'm doing. Anyone can help me out with this? Code: //to set up osg::Vec3f lightDir(1.f,2.f,-2.f); lightDir.normalize(); //and then each step... osg::Vec4 lightDirEye = worldCamera->getViewMatrix() * osg::Vec4(lightDir,1); lightDirUniform->set(osg::Vec3(lightDirEye.x(), lightDirEye.y(), lightDirEye.z())); -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60630#60630 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] virtual ~TemplateArray() is protected
I use that all the time, so it shouldn't be a problem. What you could try is to explicitly include in your header. I have had problems before where I forgot to include the actual header file. The vec3array may have been declared (empty) in some other osg-file so it seems like everything in fine in the editor, but the compiler might need to full header file...? just a suggestion... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60608#60608 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Set color in fragment shader
don't forget to pass the color in the vertex shader: gl_FrontColor = gl_Color; for texture you use texture coordinates: usually gl_TexCoord[0] = gl_MultiTexCoord0; in the vertex shader and then for example use texture2D( sampler2D, vec2 [,float bias] ) to sample a color from the texture at the right texture coordinates. You also have to load and bind the texture ofcourse, but that is also explained in the OSG beginners guide -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60504#60504 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hard time with slave cameras and viewports.
a quote from Robert: "ABSOLTE_RF means that the when the cull traversal encounters a Transform node it ignores the inherited modelview matrix so that the local transform matrix on the Transform node becomes the new modelview matrix. This means that the Transform nodes subgraph is placed in new coordinate frame rather than that of it's parents. " This is probably what you want. This way your camera is not affected by any other nodes (it sort of resets the view-matrix) There are probably some situations where it might be useful to go for the relative reference frame, but in your case it isn't. about orthogonal and perspective, here is nice explanation, look at the pictures too. http://blender.stackexchange.com/questions/648/what-are-the-differences-between-orthographic-and-perspective-views basically orthogonal camera renders everything in a box, looking exactly from one side, without perspective correction (so stuff that's far away is not any smaller than stuff closer to the camera). In perspective there is a correction for depth, like in real life, where stuff in the distance looks smaller. For these axis of yours, I think perspective might look slightly better, specially if they have anything 3d to the look of them (if they are just 3 drawn lines, then it might be hard to see the perspective... In the case of orthogonal you set it to render a 300 by 300 area with setProjectionMatrix( osg::Matrix::ortho2D( 0, 300, 0, 300 ) ); , so to make sure the axes are rendered at the correct size, just make the axis the correct size (or pick a larger box to render) you set the viewport the same size as the orthogonal rendering box, so then it quite literary translates; if you draw a line from (0,0,0) to (10,10,0) you will see a line from (0,0) to (10,10) on your screen. if you go for perspective, you can also just choose re-size the axes to your liking, but you can also move the camera further away, because there is perspective correction. I personally use the camera->setViewMatrixAsLookAt(eye,center,up) to set up and move my camera the way I want. In my world z = up, so the up vector is always (0,0,1). The eye is the position of the camera, and the center is the place where you want to point your camera at. I don't really have a good book that I can recommend you, sorry, but there must be some good ones out there I guess. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60496#60496 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgParticle Emitter on Fast Moving Object
You could extrapolate, emitting tHe particles in front of your moving object, i.e. curpos + (curpos-lastpos)*k. I die that once in another environment and it can look wel if you tweak k, and you could make it dependent on the speed as well -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60475#60475 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] geometry and normals
First: In your example the coordinates are stored in an array of Vec3, but in the other code you posted, the oPoints is an array of float so there seems to be a bit of a contradiction there? Anyway you have indexed vertices obviously, but you can also use non-indexed vertices. In that case you just specify the vertices for each triangle separately. When I started working on my project I heard or read that this is better, because it can be handled faster by modern graphics card (something about the card not being able to use the fasted render path when indices are used), and the extra memory it takes is less important because modern graphics cards have plenty of memory. But I can't find a solid source on that now so I'm really starting to doubt if this is (still) true... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60460#60460 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] geometry and normals
Well to give better advice, I would need to understand what is exactly stored in float*& oPoints and int*& oConnections. What I assume is that oPoints (an array of floats) contains x1,y1,z1,x2,y2,z2, etc. and then oConnections (an array of ints) contains a serie of references to those points for example 2 refers to x2,y2,z2. Maybe you could first tell something about this (if this is correct or not) before I comment further... maybe I misunderstand what is in those arrays... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60458#60458 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] geometry and normals
it seems like you are using referenced vertices in your roads mesh? (at least that is what I understand from int*& oConnections (the int references vertices indexes right?) I think that if you want to use the accelerated drawing you should convert it to simple vertex arrays, where the vertices are not indexed. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60455#60455 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hard time with slave cameras and viewports.
I'm not a huge expert, but: 1. the slave should be post, because you want to render the cross/axes on top of the rest. 2. you can just use a perspective projection if you want a 3d looking axis or a orthogonal view if you want a 'less' 3d look to it. Be sure to set the near and far correct, I think a orthogonal might standard be limited to rendering z=0 only? 3. I think this is because you use a clear color on the slave cam. That means that each frame it will first clear the viewport (therefor your main model doesn't show it that area). For the axis: don't use a clear color, but instead use setClearMask to clear the zbuffer (or else it might use the zvalues from your main scene in the viewport and that doesn't make sense). Then it just should draw the axis on whatever you rendered in your main scene. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60454#60454 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Convert depth image to 3D model
Or use it in a heightfield: http://trac.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00364.html -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60453#60453 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgText::Text darker when rendered on frame buffer
It's fixed! Code: osg::ref_ptr blendFunc = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::DST_ALPHA, osg::BlendFunc::ZERO, osg::BlendFunc::ONE); label->getOrCreateStateSet()->setAttributeAndModes(blendFunc); I didn't know you could/should specify the alpha blending separately. Now it doesn't overwrite the alpha anymore. It also means I HAVE to draw a background for the label first, or else it will not be visible... but that's a minor inconvenience, I don't think my idea "only write alpha when it's higher than destination alpha" is actually possible in openGL. Somehow I assume that it worked that way because it seems intuitive in the situation I am working with.. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60388#60388 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgText::Text darker when rendered on frame buffer
I'm pretty sure I found the problem, but not sure how to fix it (probably easy for someone with more openGL knowledge ;) What I do: On the canvas I first draw a full solid background. Now all the alpha values are 1. Then I draw the text on top of that background. Now the problem is: it seems to replace the alpha values of the buffer with values lower than 1. Because if I render the canvas (quad) to the screen using: Code: gl_FragColor = vec4(color.a, 0,0,1); I can clearly see the text as darker than full red on screen. So then it makes sense that if I draw this quad to the screen, the lower alpha values make the text seem less bright... But why does it do this, the canvas is already filled with full solid color and alpha values of one (the rest of the canvas is indeed full red). Why does the text overwrite the alpha values in the buffer with lower values? Is this expected behavior or...? and also: how can I make sure this doesn't happen? thanks! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60376#60376 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgText::Text darker when rendered on frame buffer
I'll try the multiple viewer to see if that makes a difference. When I render a texture to the framebuffer, it seems exactly the same as when I render it to the screen, so it seems there is problem of rendering the quad to the screen, or else everything would be different. Could it be that the type of buffer is different between the viewer and the framebuffer object? What is the default 'buffer' type when you use the normal viewer? Maybe I should make sure that is exactly the same as the buffer that is used by the viewer? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60375#60375 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgText::Text darker when rendered on frame buffer
Hi Trajce Nikolov NICK, I just tried it, but made no difference unfortunately... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60366#60366 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgText::Text darker when rendered on frame buffer
I've tried to set the global defaults on the statesets of the camera's, but that didn't help. I'll try to give give a complete list of code that is used to set up the scene: in main: Code: //screen size int screenWidth = 1280; int screenHeight = 720; // construct the viewer osg::ref_ptr viewer = new osgViewer::Viewer(); viewer->setThreadingModel(osgViewer::ViewerBase::SingleThreaded); osg::ref_ptr ds = new osg::DisplaySettings(); ds->setScreenWidth(screenWidth); ds->setScreenHeight(screenHeight); ds->setNumMultiSamples(0); viewer->setDisplaySettings(ds); viewer->setUpViewInWindow(20,40,screenWidth,screenHeight,1); viewer->realize(); then the viewer is passed to a rendermanager class and it does this: Code: rootNode = new osg::Group; viewer->setSceneData(rootNode); rootNode->addChild(screenQuatGeode); //this is the quad used for the deffered rendering of the main scene rootNode->addChild(worldCamera); //camera used for main scene rootNode->addChild(waterCamera); //seperate camera for the water effects //set up the window camera osg::ref_ptr windowCamera = viewer->getCamera(); windowCamera->setReferenceFrame( osg::Camera::ABSOLUTE_RF ); windowCamera->setProjectionMatrixAsOrtho2D(0,1,0,1); //3 uniforms added to rootNode also ,but left them out here... Then the guiManager is created, which create a sperate camera for the GUI: Code: osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,width,height)); camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera->setRenderOrder(osg::Camera::POST_RENDER,0); camera->setProjectionMatrixAsOrtho2D(0,width,height,0); //camera->setViewMatrix(camera->getViewMatrix() * osg::Matrixd::scale(1,-1.f,1)); camera->getOrCreateStateSet()->setGlobalDefaults(); camera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); //blend camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED); camera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_FOG, osg::StateAttribute::OFF); and added to the rootNode: Code: renderManager->getRootNode()->addChild(guiManager->getGUICamera()); Then everything that is added to the list of gui elements is added to this camera: Code: element->addToParent(GUICamera,1); see this simple class: Code: GUIElement::GUIElement(int x, int y, int width, int height): x(x), y(y), width(width), height(height), depth(0) { createOSGNodes(); } GUIElement::~GUIElement(void) { } void GUIElement::createOSGNodes() { transform = new osg::MatrixTransform; widthUniform = new osg::Uniform( "width", (float)width); heightUniform = new osg::Uniform( "height", (float)height); transform->getOrCreateStateSet()->addUniform(widthUniform); transform->getOrCreateStateSet()->addUniform(heightUniform); } void GUIElement::addToParent(osg::ref_ptr parent, int depth) { this->depth = depth; transform->getOrCreateStateSet()->setRenderBinDetails(depth,"RenderBin"); transform->setMatrix( osg::Matrix::translate(osg::Vec3(x,y,0))); parent->addChild(transform); } then I have these derived classes GUICanvas and GUIPanel. GUICanvas makes a camera and attaches a framebuffer to render it to, and this framebuffer is rendered using a quad (which is attached to the GUI camera) Creating the camera for the canvas: Code: osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,width,height)); camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setClearColor(osg::Vec4(1,0,1,1)); camera->setRenderOrder(osg::Camera::PRE_RENDER,0); camera->setProjectionMatrixAsOrtho2D(0,width,height,0); camera->getOrCreateStateSet()->setGlobalDefaults(); camera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); //blend camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); //camera->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF); //camera->getOrCreateStateSet()->setMode(GL_FOG, osg::StateAttribute::OFF); camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFF
[osg-users] osgText::Text darker when rendered on frame buffer
Hi, I'm having a small issue with the osgText::Text that I can't figure out. There is difference in how bright the text looks when I compare a osgText::Text drawn on screen, and the same one, but then drawn on a framebuffer, and then (the buffer) drawn on screen. Should be exactly the same right, if the bg color is the same? I attached a small part of a screenshot to show the difference. Other things that I draw on the framebuffer do not appear darker, so it seems to be related to osgText::Text. Here are some parts of the code: camera for gui on screen: Code: osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,width,height)); camera->setClearMask(GL_DEPTH_BUFFER_BIT); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR); camera->setRenderOrder(osg::Camera::POST_RENDER,0); camera->setProjectionMatrixAsOrtho2D(0,width,height,0); //camera->setViewMatrix(camera->getViewMatrix() * osg::Matrixd::scale(1,-1.f,1)); camera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); //blend camera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF | osg::StateAttribute::PROTECTED); camera->getOrCreateStateSet()->setMode(GL_FOG, osg::StateAttribute::OFF); camera for rendering to a framebuffer: Code: osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,width,height)); camera->setClearMask(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setClearColor(osg::Vec4(0,0,0,0)); camera->setRenderOrder(osg::Camera::PRE_RENDER,0); camera->setProjectionMatrixAsOrtho2D(0,width,height,0); camera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); //blend camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_DEPTH_TEST, osg::StateAttribute::OFF); camera->getOrCreateStateSet()->setMode(GL_ALPHA_TEST, osg::StateAttribute::OFF); camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0), texture); texture used for framebuffer: Code: osg::ref_ptr rect = new osg::TextureRectangle; rect->setTextureSize(width, height); rect->setInternalFormat(GL_RGBA32F_ARB); rect->setSourceFormat(GL_RGBA); rect->setSourceType(GL_FLOAT); rect->setFilter(osg::TextureRectangle::MIN_FILTER,osg::TextureRectangle::NEAREST); rect->setFilter(osg::TextureRectangle::MAG_FILTER,osg::TextureRectangle::NEAREST); quad used to render the framebuffer onscreen: Code: osg::ref_ptr geode = new osg::Geode(); geode->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); osg::ref_ptr geom = new osg::Geometry(); geom->setSupportsDisplayList(false); osg::ref_ptr vertices = new osg::Vec3Array; osg::ref_ptr texcoords = new osg::Vec2Array; vertices->push_back(osg::Vec3d(0,0,0)); texcoords->push_back(osg::Vec2(0,height)); vertices->push_back(osg::Vec3d(0,height,0)); texcoords->push_back(osg::Vec2(0,0)); vertices->push_back(osg::Vec3d(width,height,0)); texcoords->push_back(osg::Vec2(width,0)); vertices->push_back(osg::Vec3d(width,0,0)); texcoords->push_back(osg::Vec2(width,height)); osg::ref_ptr colors = new osg::Vec4Array; colors->push_back(color); geom->setVertexArray(vertices); geom->setTexCoordArray(0,texcoords); geom->setColorArray(colors); geom->setColorBinding(osg::Geometry::BIND_OVERALL); geom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,vertices->size())); geode->addDrawable(geom); Does anyone have an idea what could cause this? I've looked at the source of osgText::Text, but it seems very complicated, and it also uses a custom rendering so it doesn't seem to be affected much by the render states (for example I don't think you can turn blending off trough the stateset when rendering text?), so I have no clue at this point... Thank you! Cheers, Bram Code: -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60357#60357 Attachments: http://forum.openscenegraph.org//files/textproblem_940.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgText::Text and screen
I had the exact same issue, but I tried to flip the view matrix as suggested, but I must be doing something wrong, because I don't see anything when I try this: Code: camera->setViewMatrix(camera->getViewMatrix() * osg::Matrixd::scale(1,-1.f,1)); Can anyone tell me the right way to flip the view matrix on the y? thanks! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60353#60353 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] creating HUD in seperate camera
It seems the problem goes away when I remove this line: Code: rootNode->getOrCreateStateSet()->setTextureAttributeAndModes(4, noiseTexture.get() ); noiseTexture is as the name suggest a noise texture (3d texture). I suppose I can move this texture up to the appropriate node instead of applaying it to the root node to solve my problem... but I'm still curious, why does the texture that i set at unit 4 mess up the fixed pipeline? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60352#60352 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] creating HUD in seperate camera
When I use the osgText:Text classes, I still get the problem that everything is very dark. I use vec4(1,0,0,1) as color, but the actual color of the text on screen is (0.309803921,0,0). Is there a good way to find out the complete stateset that is used for a certain node? That should be able to give me more information I hope. Besides lighting, is there anything else that could make everything in fixed pipeline darker? When i use a custom shader it works fine. I've tried turning lighting off at almost every node up till the label, I'm pretty sure that it's turned off... Thanks! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60351#60351 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] assume render order?
Thanks for your quick answer! What exactly does 'sorted by state order' mean? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60334#60334 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Very confused about plugins
Thanks Robertos and Farshid. Robertos, when I said: "What are the steps that are involved in building the libraries, and loading them as plugins? " I actually meant to ask this from the perspective of the 'system', and not the steps that a user has to take to make it work. This demonstrates what I mean very nicely though: most of the documentation involves a set of steps that you have to take. Not that tutorials are a bad thing, obviously this is exactly what most new users are looking for... but still it doesn't explain what is happening exactly happening in those steps, and if any of the steps fails (or even worse, you'll get an error at the end and you don't really know which step failed), you are stuck to asking other experts or trying random things :) > The OSG will search for osgPlugins-version/osgdb_extension.dll/.so directory > first by default to avoid issues with different versions of the OSG/plugins > being binary incompatible (and issue known widely in the compute industry as > DLL hell.) For this reason you should set the library path to the parent > directory where the osgPlugins-version directory rather than to the directory > itself, otherwise you could end up finding plugins for a different version of > the OSG. This is more the kind of information I was hoping to find, and the general note too, and the OSG_NOTIFY_LEVEL to DEBUG is also a very good tip, thanks!!! Farshid: thanks it was indeed a problem with the dll's, I copied them all again, and there must have been an older version of soms png dll in my project probably, cause I only overwritten already existing files, but still it made a difference :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60321#60321 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] assume render order?
Hi, I was wondering what kind of assumptions I can make about the rendering order. for example in kinda pseude code: rootnode->addChild(node1); rootnode->addChild(node2); node1->addChild(node3); node1->addChild(node4); node3->addChild(node5); would give: rootnode -> node1 -> node3 -> node4 -> node2 -> node5 can I assume either a depth-first traversal, breadth-first traversal or something else, or can I not assume anything (i.e. it might change at any time in a new OSG version because it is not 'defined') ? So basically: can I assume node2 is always rendered BEFORE node3 and node4? And nodes on the same level, like node3 and node4, can I assume that node3 is rendered first because it was added first? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60320#60320 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] creating HUD in seperate camera
I posted some code in my original post. However, the code is part of a project that I cannot post as a whole (and you probably don't want that either). Can you tell me what parts of the code you would like to see, besides the code that I pasted in my first post? Is there a way to print the stateset that is used for a certain node? Or the GL state or something like that? That would seem like to best way to track down what goes wrong... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60318#60318 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] creating HUD in seperate camera
Do you mean on the geometry object itself? I just tried that now but no change... any other ideas? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60315#60315 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] Very confused about plugins
Hi, I'm having issues with loading png. It just says: "Warning: Could not find plugin to read objects from file "GUI/canvas.png". The same line replaced with .jpg works fine. I built OSG 3.2 from source some time ago (using some tutorial, and CMake and such), and I recall that I tried to enable both jpg and png. Somehow png doesn't work. Now the real problem is: I have absolutely no clue to how this whole build system and plugin system works, and I can't seem to find decent information on it... only this: http://trac.openscenegraph.org/projects/osg//wiki/Support/UserGuides/Plugins also: when I try to load a non-existing file as an image, I get the exact same error. There is no way for a 'noob' like me (at least a noob in building systems) to understand or find out what the problem is. It looks like there is a libpng13d.lib in the lib dir, and I found a osgdb_png.dll and osgdb_png.dll somewhere that I copied to my projects working directory, but that doesn't seem to be enough... Honestly, I'm desperately confused. I have to admit that I just don't know that much about cmake, libraries and dll's etc. just know the basics, but there's a huge information gap between some very general information that you can find on cmake and osg plugins, and how the actual build system works in reality. There also doesn't seem info on how you can track down errors like plugins that are not loading. I also looked on the forums and there are some general tips like: you have to rebuild the png library... but then I'm like... ok ... how??? is that part of the osg source? I have no clue how to do this :( I know that with some random hints from users I may be able to fix this one problem this time, but then again I still wouldn't know what happened or how to fix the next problem with plugins. Isn't there more information on this? Or can someone explain it here how it all works? Like: -What are the steps that are involved in building the libraries, and loading them as plugins? -In each of these steps what files are supposed to be created and how can you check if that happened etc.? -how can you get more error information from the failing the loading of the plugin? I would be very very grateful for any information! Thank you! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60302#60302 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] creating HUD in seperate camera
Hi, I'm working on my own simple HUD/GUI system, and my idea was to use a seperate orthogonal camera for that, which is attached to the root node, and is set to post-render. It does to work so far, except that the quad that I'm drawing on screen is about 4 times more dark than it should be. For example when I try to make it white, it becomes color (63,63,63). I'v set lighting to off, use no shader, tried setting fog off, I tried setting blending off (but that should be turned on at some point anyway...), but whatever I do it still is much darker than it should be. Any idea what could be the cause of this? This is how I create the camera: Code: osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,width,height)); camera->setClearMask(GL_DEPTH_BUFFER_BIT); //camera->setClearColor(osg::Vec4(0,0,0,0)); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setRenderOrder(osg::Camera::POST_RENDER,0); camera->setProjectionMatrixAsOrtho2D(0,width,height,0); camera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::OFF); //blend camera->getOrCreateStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF); and this the quad: Code: rectGeom = new osg::Geometry(); rectGeom->setSupportsDisplayList(false); osg::ref_ptr vertices = new osg::Vec3Array; osg::ref_ptr texcoords = new osg::Vec2Array; vertices->push_back(osg::Vec3d(0,0,0)); texcoords->push_back(osg::Vec2(0,0)); vertices->push_back(osg::Vec3d(width,0,0)); texcoords->push_back(osg::Vec2(width,0)); vertices->push_back(osg::Vec3d(width,height,0)); texcoords->push_back(osg::Vec2(width,height)); vertices->push_back(osg::Vec3d(0,height,0)); texcoords->push_back(osg::Vec2(0,height)); rectGeom->setVertexArray(vertices); osg::ref_ptr colors = new osg::Vec4Array; colors->push_back(osg::Vec4(0,0,1,1)); colors->push_back(osg::Vec4(0,1,0,1)); colors->push_back(osg::Vec4(1,0,0,1)); colors->push_back(osg::Vec4(1,1,1,1)); rectGeom->setColorArray(colors); rectGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX); //rectGeom->setColorBinding(osg::Geometry::BIND_OVERALL); rectGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,vertices->size())); Any ideas? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60300#60300 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] ref_ptr issue
Thanks, your input led me to look at the gui event handler, and it turned out that one of my own classes that I made long ago (an input handler) was derived from an OSG class, but didn't use ref_ptr somewhere for that, and that messed it up somehow. fixed now :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60263#60263 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] ref_ptr issue
Hi, I have used the osg::ref_ptr quite a lot and never had much problems with them, but I'm having an issue with it now. In the main function I create a viewer (and also a DisplaySettings that is used by it): Code: osg::ref_ptr viewer = new osgViewer::Viewer(); osg::ref_ptr ds = new osg::DisplaySettings(); ... viewer->setDisplaySettings(ds); ... then I also have a new class called RenderManager, who needs to viewer object as well. I thought this was the correct way to do it: Code: class RenderManager { osg::ref_ptr viewer; osg::ref_ptr getViewer() { return viewer; } RenderManager(osg::ref_ptr viewer); } RenderManager::RenderManager(osg::ref_ptr): viewer(viewer) { } and I create one in main, and delete it at the end of main Code: RenderManager * renderManager = new RenderManager(viewer); delete renderManager; (I tried to simplify the code a.m.a.p.) Now the delete seems to go well, but at the very end of main it will give a access violation in the destructor of ref_ptr: world2.exe!osg::ref_ptr::~ref_ptr() Line 35 + 0x2e bytes C++ What did I do wrong? What is the correct way to do it? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60258#60258 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Reusing depth buffer for render targets
Thanks, that makes perfect sense. I didn't know it was normalized, so I just have to make sure the camera's have the same clipping planes, didn't need to increase it to 10 (my scene is much smaller than that :) The depth buffer is based on 32 bits floats right (just for my information)? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57223#57223 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Reusing depth buffer for render targets
Farshid, I should have been more clear about it, but that was actually my intention. The terrain and water are in the same world so i wanted to use the depth information from the terrain render to draw only visible portions of the water to the other buffer. Sebastian, I always get this error: "Warning: detected OpenGL error 'invalid framebuffer operation' at After Renderer::compile" but I got this from the very beginning of when I started on the project, when I didn't have any framebuffers or anything else for that matter, it was just always there from the first time I used OSG. I tried looking it up but nobody on the forum could help me with it, and it doesn't seem to do any harm... for the buffers and resulations, let me just paste the code here, this is how I set them up: Code: //set up fragment color raster osg::TextureRectangle* colorsRect; colorsRect = new osg::TextureRectangle; colorsRect->setTextureSize(screenWidth, screenHeight); colorsRect->setInternalFormat(GL_RGBA32F_ARB); colorsRect->setSourceFormat(GL_RGBA); colorsRect->setSourceType(GL_FLOAT); colorsRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); colorsRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); //set up fragement normal raster osg::TextureRectangle* normalsRect; normalsRect = new osg::TextureRectangle; normalsRect->setTextureSize(screenWidth, screenHeight); normalsRect->setInternalFormat(GL_RGBA32F_ARB); normalsRect->setSourceFormat(GL_RGBA); normalsRect->setSourceType(GL_FLOAT); normalsRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); normalsRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); //set up fragment coordinate raster osg::TextureRectangle* positionsRect; positionsRect = new osg::TextureRectangle; positionsRect->setTextureSize(screenWidth, screenHeight); positionsRect->setInternalFormat(GL_RGBA32F_ARB); positionsRect->setSourceFormat(GL_RGBA); positionsRect->setSourceType(GL_FLOAT); positionsRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); positionsRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); //set up fragment color raster 2 for water osg::TextureRectangle* waterRect; waterRect = new osg::TextureRectangle; waterRect->setTextureSize(screenWidth, screenHeight); waterRect->setInternalFormat(GL_RGBA32F_ARB); waterRect->setSourceFormat(GL_RGBA); waterRect->setSourceType(GL_FLOAT); waterRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); waterRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); //set up a depth buffer to be reused in two cameras osg::Texture2D* depthBuffer; depthBuffer = new osg::Texture2D; depthBuffer->setTextureSize(screenWidth, screenHeight); depthBuffer->setInternalFormat(GL_DEPTH_COMPONENT32); depthBuffer->setSourceFormat(GL_DEPTH_COMPONENT); depthBuffer->setSourceType(GL_FLOAT); > add the depth texture as input > sampler to the consecutive passes if they use it for writing. do you mean as a texture? I tried waterCamera->getOrCreateStateSet()->setTextureAttributeAndModes(0, depthBuffer, osg::StateAttribute::ON); but that didn't help. I was looking at it again and it looked like it was clipping when I moved the camera around, so I tried this (also for the other camera): worldCamera->setComputeNearFarMode(osg::CullSettings::ComputeNearFarMode::DO_NOT_COMPUTE_NEAR_FAR); worldCamera->setProjectionMatrixAsPerspective(30.0, 16.f/9.f, 0.1, 10); that seems to solve it! I suppose the clipping was causing it, but not sure how exactly. Would be helpful if I understood what was happening exactly, any idea? Thanks :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57221#57221 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Reusing depth buffer for render targets
Hi, I'm trying to reuse a depth buffer for rendering two different passes. The first one does terrain, the second one some water surface (to another output buffer, but that's not the issue here) Based on posts from the forum I though I had it figured out but it doesn't work well. Depending on how I move the camera in my application, it either looks like the depth buffer was not used at all (I see water everywhere), or it works as expected, or sometimes something in between, some parts seem to be non-rendered as they should but not everywhere. I wonder if I did anything wrong, here is the code I used, any comments would be useful, thanks! Code: //set up a depth buffer to be reused in two cameras osg::Texture2D* depthBuffer; depthBuffer = new osg::Texture2D; depthBuffer->setTextureSize(screenWidth, screenHeight); depthBuffer->setInternalFormat(GL_DEPTH_COMPONENT32); depthBuffer->setSourceFormat(GL_DEPTH_COMPONENT); depthBuffer->setSourceType(GL_FLOAT); //set up the world (scene) camera osg::ref_ptr worldCamera = new osg::Camera(); worldCamera->setViewport(new osg::Viewport(0,0,screenWidth,screenHeight)); worldCamera->setProjectionMatrixAsPerspective(30.0, 16.f/9.f, 0.5, 1); worldCamera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //camera->setClearColor(fog->getFogColor()); worldCamera->setClearColor(osg::Vec4(0,0,0,0)); worldCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); worldCamera->setRenderOrder(osg::Camera::PRE_RENDER,0); worldCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); worldCamera->addChild(worldNode); //add the world to the world camera worldCamera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0), colorsRect); worldCamera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER1), normalsRect); worldCamera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER2), positionsRect); worldCamera->attach(osg::Camera::DEPTH_BUFFER, depthBuffer); //set up the water surface camera osg::ref_ptr waterCamera = new osg::Camera(); waterCamera->setViewport(new osg::Viewport(0,0,screenWidth,screenHeight)); waterCamera->setProjectionMatrixAsPerspective(30.0, 16.f/9.f, 0.5, 1); waterCamera->setClearMask(GL_COLOR_BUFFER_BIT); waterCamera->setClearColor(osg::Vec4(0,0,0,0)); waterCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); waterCamera->setRenderOrder(osg::Camera::PRE_RENDER,1); waterCamera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); waterCamera->addChild(waterNode); waterCamera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0), waterRect); waterCamera->attach(osg::Camera::DEPTH_BUFFER, depthBuffer); ... rootNode->addChild(worldCamera); rootNode->addChild(waterCamera); Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57218#57218 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Setting breakpoints when using osg as library
Hi Sebastian, Yes I built OSG from source myself, using CMake and VC++ 2010 Express (I just followed the tutorial on this). The strange thing is: when I press f11 during debug in a call to OSG for example viewer->someFunction(), it first goes into the ref_ptr overloaded operator code, then back to the original line, and then if I press F11 one more time, it just jumps to the next line, without jumping to the osg function code or asking me to find the PDB. Any idea why that is? Is there something broken in my VC++? Anyway, the Debug->Windows->Modules tab is something that I was looking for: information on what is loaded and the possibility to manually load PDB's. Maybe that works, or at least it will give some error when it fails. I'll try it! Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57192#57192 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Setting breakpoints when using osg as library
It's not working. I keep getting these: 'world2.exe': Loaded 'D:\world2\world2\osg100-osgViewerd.dll', Cannot find or open the PDB file I put the PDB files in the same directory as where the DLL is, under the exact name. I ALSO set the directory where the PDB files were initially created (osg/bin dir) in the debugging option on where to look for PDB files. I even copied them into a temp directory that was set as 'cache symbols' directory. But still it keeps saying that it can't find or open the PDB file. Why is this still not working, what could be wrong? something wrong with the dll's ? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57183#57183 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Setting breakpoints when using osg as library
Thanks, I actually do have the pbd files loaded, but I read on the page you sent that you also have to specify where vc++ looks for debug source files, so I guess I'll have to add the directories with the OSG src files. I hope I can step into osg source code in debugging then and set breakpoints as well! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57163#57163 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Setting breakpoints when using osg as library
Hi, I have a (hopefully) easy question. I have compiled osg as a library from source, using the tutorials, and now I'm using visuall c++ 2010 as development tool. Is it possible to set breakpoints in the osg sourcecode somehow? I have tried to add some projects from osg to my solution, but it doesn't seem to the source code with the libraries. For example I can't step into OSG code when I'm debugging. Is is possible what I want to do or do I *not* have to use libraries for that? If it's possible, what steps would I need to take, and if it's not possible, what is the best option if you want to include osg code in debugging in MSVC++? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57161#57161 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] blending on multiple targets
ahh someone on the opengl forum pointed out that it was probably the alpha test, which is was. " The alpha test discards a fragment conditional on the outcome of a comparison between the incoming fragment's alpha value and a constant value. " finally it works! :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57152#57152 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] blending on multiple targets
I tried it with the blend functions set up properly but I still run into something. I will include some code: Code: //set up fragment color raster osg::TextureRectangle* colorsRect; colorsRect = new osg::TextureRectangle; colorsRect->setTextureSize(screenWidth, screenHeight); colorsRect->setInternalFormat(GL_RGBA32F_ARB); colorsRect->setSourceFormat(GL_RGBA); colorsRect->setSourceType(GL_FLOAT); colorsRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); colorsRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); //set up fragment color raster 2 for water osg::TextureRectangle* waterRect; waterRect = new osg::TextureRectangle; waterRect->setTextureSize(screenWidth, screenHeight); waterRect->setInternalFormat(GL_RGBA32F_ARB); waterRect->setSourceFormat(GL_RGBA); waterRect->setSourceType(GL_FLOAT); waterRect->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::NEAREST); waterRect->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::NEAREST); //create quad that will be rendered on screen osg::Geometry* polyGeom = new osg::Geometry(); polyGeom->setSupportsDisplayList(false); osg::Vec3Array* vertices = new osg::Vec3Array; osg::Vec2Array* texcoords = new osg::Vec2Array; vertices->push_back(osg::Vec3d(0,0,0)); texcoords->push_back(osg::Vec2(0,0)); vertices->push_back(osg::Vec3d(1,0,0)); texcoords->push_back(osg::Vec2(screenWidth,0)); vertices->push_back(osg::Vec3d(1,1,0)); texcoords->push_back(osg::Vec2(screenWidth,screenHeight)); vertices->push_back(osg::Vec3d(0,1,0)); texcoords->push_back(osg::Vec2(0,screenHeight)); polyGeom->setVertexArray(vertices); polyGeom->setTexCoordArray(0,texcoords); osg::Vec4Array* colors = new osg::Vec4Array; colors->push_back(osg::Vec4(1.0f,1.0f,1.0f,1.0f)); polyGeom->setColorArray(colors); polyGeom->setColorBinding(osg::Geometry::BIND_OVERALL); polyGeom->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS,0,vertices->size())); osg::Geode* geode = new osg::Geode(); geode->addDrawable(polyGeom); rootNode->addChild(geode); osg::StateSet* stateset = new osg::StateSet; stateset->addUniform(new osg::Uniform("colorsRect", 0)); stateset->addUniform(new osg::Uniform("normalsRect", 1)); stateset->addUniform(new osg::Uniform("positionsRect", 2)); stateset->addUniform(new osg::Uniform("waterRect", 3)); stateset->setTextureAttributeAndModes(0, colorsRect, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(1, normalsRect, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(2, positionsRect, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(3, waterRect, osg::StateAttribute::ON); stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF); polyGeom->setStateSet(stateset); //set up the scene camera osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,screenWidth,screenHeight)); camera->setProjectionMatrixAsPerspective(30.0, 16.f/9.f, 0.5, 1); camera->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //camera->setClearColor(fog->getFogColor()); camera->setClearColor(osg::Vec4(0,0,0,0)); camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF); camera->setRenderOrder(osg::Camera::PRE_RENDER); camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT); camera->addChild(worldNode); //add the world to the world camera //camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0), colorsRect, 0, 0, false, 4, 4); //camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER1), normalsRect, 0, 0, false, 4, 4); //camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER2), positionsRect, 0, 0, false, 4, 4); camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0), colorsRect); camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER1), normalsRect); camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER2), positionsRect); camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER3), waterRect); osg::ref_ptr blendFunct = new osg::BlendFunc(osg::BlendFunc::SRC_ALPHA, osg::BlendFunc::ONE_MINUS_SRC_ALPHA); camera->getOrCreateStateSet()->setAttributeAndModes(blendFunct, osg::StateAttribute::ON); camera->getOrCreateStateSet()->setMode(GL_BLEND, osg::StateAttribute::ON); //blend waterNode = new osg::Group; waterNode->getOrCreateStateSet()->setMode( GL_CULL_FACE, osg::StateAttribute::OFF); setupWaterTexture();
Re: [osg-users] blending on multiple targets
thank you very much for your help, I will look into it, I'm sure I can make it work, either with the correct blending, or with multiple passes. Hopefully someone will incorporate those blending in framebuffers extensions into OSG too some day :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57148#57148 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] blending on multiple targets
> You still can render to them in separate passes. > 1.pass: Render texture to FBO with color buffer1 > 2.pass: Render water to FBO with color buffer2 > 3.pass: Combine to result buffer (possibly framebuffer) hmm yeah interesting... two problems that I would need to overcome then: how to do multiple passes in OSg (possibly there is a tutorial for that) but another problem is: I need to reuse the zbuffer from the terrain render for the water render or else it will just render all water pixels, including the onces hidden behind the hills of the terrain and such... is that easy to do? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57146#57146 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] blending on multiple targets
> You're mixing up source and destination. Source is the incoming color > (i.e. the color written in the shader), destination the color in the > buffer (i,e, what was already in the target buffer). you are right, the word destination also makes more sense then :) > I asked this a while ago. There is no function prototype, so it has to > be added to the extensions somehow I guess I got this in a respons on the open gl forums: "If you don't need real blending for the buffers you do want to write to, you can simply enable and disable blending for each buffer (requires EXT_draw_buffers2, or GL3.0)" is that the extension? or actually that seems like it's only about disabling certain buffers (which would be great for my purpose) > If I got this correctly, you have your terrain-buffer in one texture and > your water result in another. hen you don't need hw-blending to combine > them. No and yes, indeed I do not need or use any Hw blending in the final shader, I just use mix() etc. in that shader, that is no problem. But I don't have the writing to seperate buffers working yet, as I described above, but it might be just that I need to activate the correct blending mode for all buffers as you said, and use a vec(0,0,0,0) as output when I want to leave a buffer as is. > But seriously, this seems a lot to swallow given your just starting to > use OSG/OpenGL. Start off with a simpler example to get the blending > things right ;-) I know what you mean, I do tend to disable almost all stuff in the shaders when I start working with something new, so I experiment with very simple shaders to investigate what is exactly happening :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57144#57144 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] blending on multiple targets
> Also, Do you setup a blendfunction and activate it for the stateset? No I didn't. The thing is, I made some other shaders for a volume light, and there I just enabled blending and it worked as I expected. And to clarify what I mean with that: I thought that normal 'standard' blending involved mixing the colors something like this: mix(source.rgb, dest.rgb, dest.a). so in other words, it would use the rgb in the framebuffer and mix the color of the new pixels based on the alpha of the new pixel (ignoring the alpha value from the source pixel). > I don't understand what you mean? Can you point to the blendfunction here? > There is no simple way to blend onyl gl_FragData[0] without touching the > other buffers. I guess, now I looked at the blend functions of opengl better (sorry I'm kinda new with opengl), that I would like a glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA); Does that make sense? that matched with I said above right? > As said before: Blending function is applied to all bound > buffers. > what about glBlendFunci, which enabled different blendings per buffer... or is that not supported? > So could try to post your buffer setup and your passes or at least > create a minimalistic example showing your problem? > A little more context on what you are trying to achieve would be helpful too I will try to post some code tonight if needed, don't have access to it right now. For context: I am rendering terrain with water. the surface of the water is partly transparant. for the part underwater I want to use some form of fog effect and for the part above water I use some other 3d fog effect. So if the camera is above water and look at the water it need to do the following for each pixel: -start with the terrain color (from rendered terrain) -apply underwater effect -apply the semi-transparent water-surface pixel (from rendered water) -apply above water fog effect So the thing is: I need both the original rendered terrain pixel and also the original rendered water-surface pixel. so that is why I want to render my terrain and my water-surface to two separate buffers, so that in the 'final' shader (the deffered one or however you call it) I have access to both the rendered water and the rendered terrain under that water and calculate the final pixel in a way that I find logical. I understand that there might be tons of other ways to do this, but as I'm pretty new I hope to do things first in a way which seems logical to me, before doing it some other way that is harder to understand for me. But still if you have a better idea on how to do what I want I'm open for it :) Hope I explained this clear enough! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57134#57134 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] blending on multiple targets
Hi, thanks for the reply! I get the undefined part, that makes sense, but what I still don't understand though: I just specify blending (GL_BLEND on) is on in the nodes. But then if I do gl_FragData[0] = vec4(0,0,0,0); then it doesn't seem to matter anymore what I write to gl_FragData[1[ trough gl_FragData[3], because it doesn't seem to write anything to the other buffers, or at least I noticed that the alpha value from fragdata 0 seems to have an effect on what happens with fragdate 3 in my tests. In my test if I set gl_FragData[0] = vec4(0,0,0,0);, then fragdata 3 is also not updated, even if I write a pixel with alpha value 1 to it, vec4(1,0,0,1) for example. to clarify further, what I would like is to use the destination blend, so it should only use the alpha from my new pixels to blend, and that goes for all buffers. And obviously the alpha value from the fragdata 0 should not effect the other buffers. What would I need to set in osg to make it so? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57124#57124 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] blending on multiple targets
Hi, I ran into something weird, or something that I don't know how it works exactly. What I want to do when rendering to multiple targets is that I selectively write to certain color buffers in my shader, but leave others alone. for example Code: gl_FragData[3] = vec4(0,1,0,1); without setting the fragment data for the first 3 buffers... This doesn't seem to go well. for example, if I don't explicity set a value in the color buffer 4, it seems to copy the color value from the first color buffer for some reason instead of leaving it alone. So I though: ok I HAVE to explicitly set all a value on all used color buffers, so then if I don't want to touch one of the buffers, I just use blending and I write a value with an alpha of 0, so it doesn't effect the buffer. This doesn't work as expected. It seems that the blending only looks at the color buffer 0 ? if I write a some color-value with an alpha of 0 to the color buffer 0, it doesn't seem to matter what I write to the other buffers, it doesn't write anything. So not sure if you can follow what I'm explaining, but bottom line is: I would like to selectively write to certain color buffers in my shaders, and leave the other alone. Any ideas on how to do that properly? Or am I trying something impossible and do I need another solution? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=57121#57121 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with Jpeg plugin
Hi, I know this has been asked before, but I could not find a decent answer in previous posts. The problem is that I compile osg, and I want to use the plugin for jpeg. Now I followed the directions exactly (I think) on the getting started sections. I downloaded the dependencies, put them in a seperate directory, use CMake, and it finds the libjpg. First thing that is not clear however: there are 2 dependencies packages for MSVC++ 10 that I can download. Of of them only contains a lib, bin etc., and the other one has x86 and x64 directories in them, each with lib bin etc. It doesn't say anywhere what I am supposed to do.. should I pick either one, or both, and what should I base my choice on? and if both, do I need to copy stuff from where to where exactly? Now I just downloaded the first dependency package (decision pretty much based on nothing, but it contains a jpeg library so I thought it would be ok). Cmake finds the jpeg library under D:/OpenSceneGraph_3.2_source/3rdparty/lib/libjpegD.lib. So far so good... Then I do what it tells me I compile OSG and I build the INSTALL project... OSG works fine, but no JPEG plugin (error when trying to use a .jpg about the plugin not being available. Also when I check the OSG workspace there is no project for the jpeg library I think, unless its names weird and I didn't see it. I tried CMake again but when generating I do not see any specific errors on the JPEG plugin. So any idea what is going on? Why is the jpeg plugin not built? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=56663#56663 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] HUD 2d animation
I would also suggest you place all images in 1 png. In total this will save space, reduce loading times and give you less files. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55463#55463 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Source files and PDB's
Thank you! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55134#55134 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Source files and PDB's
Nobody has any information or opinion about any of this??? To clarify: I just want to be able to set a breakpoint inside OSG because all I know is that the cull visitor sometimes starts to spit out errors (when it starts seems random) and I want to trace the first error. Could anyone tell me anything that might help in any way? thank you! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55107#55107 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Source files and PDB's
On a side node: In the manual it sais you have 2 ways of using OSG in MSVC++: -as a library -placing you own code in the workspace of OSG I also use Bullet Physics, and for their code, CMake generates project files for each part of library. Then, you can simply add the necessary projects into the workspaces of your own project and it works just like that (no environment variables etc.). For the avarage amateur programmer this is a very convenient way of working. You can still update easily to a new version, but you can also set breakpoints and debug their code easily, an no need to set environment variables and include libraries (debug and nondebug etc. etc.). Is this solution not possible for OSG? If not, why not? I think it would be great if OSG could be included in your own workspaces like that. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=55000#55000 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Source files and PDB's
Hi, I'm trying to find a bug, and a good way to do that is to set a breakpoint in the error message that OSG generated. But.. I use the premade binaries for MSVC++ 10. So now I also downloaded the PDB's and the source files. First thing I tried is stepping into a OSG function. Now it asks for (for example) the Viewer.cpp. I did enter 'C:\OpenSceneGraph-3.0.1\src' in the solution properties for 'directories containing source code' but it does not find it automatically. So now when I go to my the source file of Viewer.cpp, it sais it is not the original source code file, but I can continue anyway. It seems to work though. First thing I wonder: it is really a different source code file? It's all from version 3.0.1. So is this a normal message and should I ignore it? More importantly, how can I link all the source files with the PDB files so it can find source files automatically? And how am I exactly able to set breakpoints in the source code from OSG in this way. The source files are not in my project or solution right now... Or should I try a different kind of build, where I mix the OSG code with my own code in the same project, or same solution? I know this is not exactly OSG knowledge, but more MSVC++ knowledge, but it would really help me a lot of someone could explain a bit on how this is supposed to work (after all, the PDB files ARE supplied, so there should be a way to easily use the DLL and still link it to the source code right?) Any help would be appriciated, thanks! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54994#54994 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osg::ref ptr and memory leaks.
Another idea might be to use valgrind, memory doctor or some similar program to detect actuall memory leaks. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54491#54491 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Edge artifacts with multiple render targets
Hi, It was casued by the 3d buffer being LINEAR_MIPMAP_LINEAR, I didn't know that was the default, and I didn't quite understand how this could cause the problem I had, until someone at the opengl forum explained that. But it was still pretty hard to understand what the GPU exactly does with mipmapping and how it can affect the shader outcomes :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54472#54472 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Edge artifacts with multiple render targets
Does anyone know: what is the default texture filter mode (for 3d textures) when you do not explicitly set it? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54457#54457 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Edge artifacts with multiple render targets
Hi, I have switched my rendering stuff to deferred rendering, and I noticed some problems around the edges of the hills in the terrain (see attached picture) I write 3 buffers: -color -normal -position (fragment position in world coordinates) I tried finding a problem in the buffers around the edges, but there are none there, they are also aligned with each other. Then I noticed the thing causing the edge problem is the 3d fog. to make the 3d fog I sample multiple times from a 3d texture. The places where I sample from the 3d-texture are only dependent on the camera position (uniform variable) and the fragment positions (from the buffer), so it samples from a line going from camera to fragment positions in a 3d texture. Works really well, and in the non- deferred rendering that i started with I had no edge problems. I inspected the position buffer well, I even exported it to an excel sheet, but there is no edge problem inside that buffer. Also when I replace the 3d fog with linear fog (also based on the exact same camera position and fragment position), there are no problems on the edges anymore. So I can only conclude that when I start sampling from that 3d texture, that somehow influences the final results. It seem that is causes it to do multi-samples on the final quad too, instead of just doing it pixel by pixel. But that is just my idea for now, I'm in no way an expert on the subject. Does anyone understand what is going on, or has ANY tips on how I could try to fix this? I could also post my code on how I create and use the buffers and the 3d fog texture, or the shaders, if that helps. Thanks for any help! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54455#54455 Attachments: http://forum.openscenegraph.org//files/hilledges_982.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] setNumMultiSamples on render to FBO
thanks! option 3 seems to be an interesting one. I did try to search for it, but I might have been using the wrong keywords. I'll try to find more information on option 3 then! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54219#54219 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Spamming errors, view breaks
Thanks a lot for your great help! This will help me a lot, because I do feel like my lack of knowledge of visual c++ and debugging processes is keeping me back in the whole process, and indeed I should try to take an (hopefully online) course about this. I'll try to find more information about it. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54218#54218 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] setNumMultiSamples on render to FBO
When I switched from 'normal' rendering to deferred rendering (or how you call it) I noticed a difference in how it looked, while it should look the same. I believe now that it looks different because I use setNumMultiSamples Code: osg::DisplaySettings::instance()->setNumMultiSamples( 4 ); But in the render to multiple-textures it does not seem to do this. Is it even possible to do this? I write colors, normals and world coodinates to 3 different buffers, so I wouldn't really know if it's possible to do multi sampling on that (does it also multi sample the normals etc. then?) Anyone who can tell me more about this? Thanks a lot! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54201#54201 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Spamming errors, view breaks
Thanks! I have to admit I'm not very good at the whole setting up projects and debugging frameworks. My first question would be: In my projects I do not have the actual source code in my IDE. I just include the debug libraries and header files I think. I believe I used the permade ones. Could you give me some pointer on how I can 'link' the source code (which I also have) to the debug osg library in MS visual c++ 2010? That would be really helpful! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54200#54200 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Spamming errors, view breaks
Hi, I am walking around in my world and sometimes suddenly I only see an empty screen and I the console spams messages like these: CullVisitor::apply(Geode&) detected NaN, depth=-1.#IND, center=(64 64 18.2729), matrix={ 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN 1.#QNAN } Now I can't seem to find any action that triggers it always, seems kinda random. Also the program continues so I can't seem to find a way to debug it. Anyone had these kind of errors before? What could be the problem and how could I make the program break on these errors so I can debug the problem? Thanks a lot! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54197#54197 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Viewer default fov settings
Hi, Thanks yeah, I actually had screenWidth/screenHeight there and they were correct, but were also ints I changed it to 16.f/9.f and now it seems to work. I'm still unclear about what happens if you divide ints I had int screenWidth = 1280; int screenHeight = 720; Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54196#54196 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Viewer default fov settings
Hi, I recently changed from just setting up a viewer Code: viewer->setUpViewInWindow(500,300,1280,720,1); To making a custom camera, but I can't seem to get the same 'normal' view as I did in the default viewer camera. I use: osg::ref_ptr camera = new osg::Camera(); camera->setViewport(new osg::Viewport(0,0,screenWidth,screenHeight)); camera->setProjectionMatrixAsPerspective(30.0, 1.0, 0.5, 1000); but I get a streched out view in the horizonal direction, as if a 1:1 image is streched onto a 16:9. I tried looking into the code for viewer and viewerbase, and view, but it was getting a little too much. Hopefully someone has a good idea on what the default setup is and why I'm getting a streched out view. Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54190#54190 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Detecting windows focus
Thanks, i will have a look at it! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54010#54010 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Detecting windows focus
It's really not that much of a niche. If you work with windowes graphics and poll mouse information it will continue to do so and react to it even if you are no longer working in the osg application. Most games that run in a window disable event pulling when the window is no longer active. But since its not possible to check whether the window is active in osg... You dont know when should stop handling mouse events. As OSG mostly takes over all aspects of creating and handeling a windows, checking the focus should be part of it in my opinion, even if i'm the first one to publically ask.. It just makes it more complete. It rather suprises me that no one has asked for it to be honest. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=54008#54008 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Detecting windows focus
Ok, then at least I know that it's not in OSG then (might be a good idea to implement this?). I did notice there is a win32 implementation of the GraphicsWindow, GraphicsWindowWin32 I think, which can give the windows-handle, so I could possibly look up some win32 api calls to check this. It's just during the debugging process only that I need this. Thanks for the information! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53994#53994 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Detecting windows focus
Hi, I've been looking for a while on the forum and using google, and looking in the documentation and the code, but i can't seem to find: how can I detect if a window (osgViewer::GraphicsWindow) has lost focus? I see there is a function to GRAB focus, but isn't it possible to check whether or not the window HAS focus? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53990#53990 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Slowness in custom multithreading
Hi, I am porting a small project that is still in starting stages from using irrlicht to osg (because osg seems more professional) However I encountered a problem: I'm using some custom multithreading (windows thread + mutex + event), to start a second thread that handles the generation and/or loading of chunks, so that the main thread can keep running at normal speed. I have CPU cores in my PC. Now it used to work fine, the chunks would generate/load without slowing down the rendering etc. of the main thread, but currently when using OSG the main thread slows down when the second thread is generating/loading chunks. So it seems that it does not run it in a seperate thread at all, or that it runs it at the same core or something. Any idea why this is, or what I could do to check things, or fix it? Code: chunkRequest_mutex = CreateMutex( NULL,// no security attributes false, // BOOL bInitialOwner, we don't want the // thread that creates the mutex to // immediately own it. "ChunkRequestMutex" // lpName ); if ( chunkRequest_mutex == NULL ) { OutputDebugString("CreateMutex() failed for request\n" ); } else OutputDebugString("CreateMutex() success for request\n" ); chunkRequest_event = CreateEvent( NULL, // no security attributes FALSE,// auto-reset event FALSE,// initial state is non-signaled "ChunkRequestEvent" );// lpName if (chunkRequest_event == NULL) { OutputDebugString("CreateEvent() failed for request\n"); } else OutputDebugString("CreateEvent() success for request\n" ); chunkCreated_mutex = CreateMutex( NULL,// no security attributes false, // BOOL bInitialOwner, we don't want the // thread that creates the mutex to // immediately own it. "ChunkCreatedMutex" // lpName ); if ( chunkRequest_mutex == NULL ) { OutputDebugString("CreateMutex() 2 failed for request\n" ); } else OutputDebugString("CreateMutex() 2 success for request\n" ); //create and start thread HANDLE chunkHandle; unsigned chunkThreadID; DWORD dwExitCode; chunkHandle = (HANDLE)_beginthreadex( NULL, 0, handleChunkRequests, NULL, CREATE_SUSPENDED, // so we can later call ResumeThread() &chunkThreadID ); if ( chunkHandle == 0 ) printf("Failed to create consumer thread\n"); GetExitCodeThread( chunkHandle, &dwExitCode ); // should be STILL_ACTIVE = 0x0103 = 259 printf( "initial Consumer thread exit code = %u\n", dwExitCode ); ResumeThread( chunkHandle ); // Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52842#52842 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Vec3b/Vec4b for color array problem
Hi, To save some memory I am trying to use 3 unsigned bytes for the color of my vertices (they are generated) instead of the 4 floats I had before. Before it was set to Vec3Array, and now Vec3bArray. (actually last thing I tried is Vec4bArray), but I only get black colors. I'm sure I'm not passing black colors, even if I do this: Code: colors->push_back( osg::Vec4b((unsigned char)255, (unsigned char)255, (unsigned char)255, (unsigned char)255) ); for each vertex, I still get black only. Is there some problem with using vec3b or vec4b for the color array for the vertices? It seems logical to do cause textures also use 1 byte per color, and not 1 float per color. Oh and it does work when I switch back to Vec4fArray, so I didn't mess anything else up... So any idea what could be the problem here? Thank you! Cheers, Bram -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52838#52838 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org