Re: [osg-users] How to Preserve FBX baked in textures when running running hardware skinning
Hi Chris, It's not possible to determine what error you have made from the snippets included. The snippet of code you did include didn't show how or whether you added the osg::Program to the StateSet, or whether you attached a vertex shader. I would recommend starting from one of the examples like osgshaders and the shaders in the OpenSceneGraph-Data/shaders set. Robert. On 26 January 2015 at 14:51, Chris Hidden ch...@erghis.com wrote: Hey Robert, thanks for answer, hope you had a great weekend! I've been trying to read up on vertex shaders and fragment shaders and maybe I am not quite understanding. Im trying to attach a very basic fragment shader, but I can't seem to get it to work and I am not sure why. I keep getting the error Duplicate function definitions for main; prototype: main() found. I've looked at 2 or 3 of the examples and it seems perfectly fine to attach two shader files, one .vert and one .frag to a single program. Specifically the program in osghardwareanimation example. I only added these lines of code to the existing example to get the duplicate main error: Code: osg::ref_ptrosg::Shader fragshader; osg::ref_ptrosg::Image image = osgDB::readImageFile(Images/PNG/Erghis_Hands_Texture.png); osg::ref_ptrosg::Texture2D texture = new osg::Texture2D(); texture-setImage(image); osg::ref_ptrosg::StateSet ss = new osg::StateSet; ss-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); osg::ref_ptrosg::Uniform unifo = new osg::Uniform(Hand_Texture, texture.get()); fragshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, C:/OpenSceneGraph/files/shaders/rain.frag); if (!fragshader.valid()) osg::notify(osg::WARN) RigTransformHardware can't load FragmentShader std::endl; program-addShader(fragshader.get()); ss-addUniform(unifo); I added this block right before the state change applications at the end of the init() function. I must be missing something stupid because I've googled the error and looked at the other examples and no one seems to be having this problem. What am I doing wrong? This happens with any .frag shader I load. Not just the one I wrote which for the sake of showing you is simply: uniform sampler2D myTexture; void main(void) { vec4 color = texture2D(myTexture, gl_TexCoord[0].st); gl_FragColor = color; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62482#62482 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Strange mouse behavior
Hi, all Guys, do you have met this kind of mouse behavior? Thats what I do: Build QTOSG application that add few object in scene (comupositeview). When I highlight object mouse stands exactly at point where it have to be. Like in this picture. [Image: http://i.imgur.com/9bRy3Mj.png ] (word mouse is actual cursor position, to highlight it have to be in yellow square area). So all is perfect. But! When I add new item to scene in already builded application via same code (button) it starts act like this. [Image: http://i.imgur.com/KI59HkO.png ]. To highlight it i have to move mouse in that point as mentioned on second picture. And this behavior is applied only to new objects that was added by button in already running application. With old ones that was added during building mouse acting normal as on first picture. Can it be because of composite view? Or its because of objects was added after event handler for mouse was added? Or it's qt weird interaction? Just give direction to me and I'll try fix it. But I have searched a lot and didn't found anythi ng about it(except old report about same bug in osg 2.4). OSG 3.2, QT 5.4. Thank you! Cheers, Drake[/img] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62481#62481 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to Preserve FBX baked in textures when running running hardware skinning
Hey Robert, thanks for answer, hope you had a great weekend! I've been trying to read up on vertex shaders and fragment shaders and maybe I am not quite understanding. Im trying to attach a very basic fragment shader, but I can't seem to get it to work and I am not sure why. I keep getting the error Duplicate function definitions for main; prototype: main() found. I've looked at 2 or 3 of the examples and it seems perfectly fine to attach two shader files, one .vert and one .frag to a single program. Specifically the program in osghardwareanimation example. I only added these lines of code to the existing example to get the duplicate main error: Code: osg::ref_ptrosg::Shader fragshader; osg::ref_ptrosg::Image image = osgDB::readImageFile(Images/PNG/Erghis_Hands_Texture.png); osg::ref_ptrosg::Texture2D texture = new osg::Texture2D(); texture-setImage(image); osg::ref_ptrosg::StateSet ss = new osg::StateSet; ss-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); osg::ref_ptrosg::Uniform unifo = new osg::Uniform(Hand_Texture, texture.get()); fragshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, C:/OpenSceneGraph/files/shaders/rain.frag); if (!fragshader.valid()) osg::notify(osg::WARN) RigTransformHardware can't load FragmentShader std::endl; program-addShader(fragshader.get()); ss-addUniform(unifo); I added this block right before the state change applications at the end of the init() function. I must be missing something stupid because I've googled the error and looked at the other examples and no one seems to be having this problem. What am I doing wrong? This happens with any .frag shader I load. Not just the one I wrote which for the sake of showing you is simply: uniform sampler2D myTexture; void main(void) { vec4 color = texture2D(myTexture, gl_TexCoord[0].st); gl_FragColor = color; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62482#62482 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to Preserve FBX baked in textures when running running hardware skinning
Aha, ok, I wasn't clear enough. I literally injected that code snippet into the osganimationhardware.cpp example. I just thougt it would be redundant to repost the entire example. If you shove my code right at in around line 122, thats where I have made the edits. Otherwise my entire init() method looks like this as in osganimationhardware but with my edits: Code: bool Erghis::HardwareController::init(osgAnimation::RigGeometry geom) { osg::Vec3Array* pos = dynamic_castosg::Vec3Array*(geom.getVertexArray()); if (!pos) { osg::notify(osg::WARN) RigTransformHardware no vertex array in the geometry geom.getName() std::endl; return false; } if (!geom.getSkeleton()) { osg::notify(osg::WARN) RigTransformHardware no skeleton set in geometry geom.getName() std::endl; return false; } osgAnimation::BoneMapVisitor mapVisitor; geom.getSkeleton()-accept(mapVisitor); osgAnimation::BoneMap bm = mapVisitor.getBoneMap(); if (!createPalette(pos-size(), bm, geom.getVertexInfluenceSet().getVertexToBoneList())) return false; int nbAttribs = getNumVertexAttrib(); // use a global program for all avatar if (!program.valid()) { program = new osg::Program; program-setName(HardwareSkinning); if (!_shader.valid()) _shader = osg::Shader::readShaderFile(osg::Shader::VERTEX, C:/OpenSceneGraph/files/shaders/skinning.vert); if (!_shader.valid()) { osg::notify(osg::WARN) RigTransformHardware can't load VertexShader std::endl; return false; } // replace max matrix by the value from uniform { std::string str = _shader-getShaderSource(); std::string toreplace = std::string(MAX_MATRIX); std::size_t start = str.find(toreplace); std::stringstream ss; ss getMatrixPaletteUniform()-getNumElements(); str.replace(start, toreplace.size(), ss.str()); _shader-setShaderSource(str); osg::notify(osg::INFO) Shader str std::endl; } program-addShader(_shader.get()); for (int i = 0; i nbAttribs; i++) { std::stringstream ss; ss boneWeight i; program-addBindAttribLocation(ss.str(), attribIndex + i); osg::notify(osg::INFO) set vertex attrib ss.str() std::endl; } for (int i = 0; i nbAttribs; i++) { std::stringstream ss; ss boneWeight i; geom.setVertexAttribArray(attribIndex + i, getVertexAttrib(i)); } osg::ref_ptrosg::StateSet ss = new osg::StateSet; ### # MY EDITS ### osg::ref_ptrosg::Image image = osgDB::readImageFile(Images/PNG/Erghis_Hands_Texture.png); osg::ref_ptrosg::Texture2D texture = new osg::Texture2D(); texture-setImage(image); ss-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); osg::ref_ptrosg::Uniform unifo = new osg::Uniform(Hand_Texture, texture.get()); fragshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, C:/OpenSceneGraph/files/shaders/rain.frag); if (!fragshader.valid()) osg::notify(osg::WARN) RigTransformHardware can't load FragmentShader std::endl; program-addShader(fragshader.get()); ss-addUniform(unifo); ### # END MY EDITS ss-addUniform(getMatrixPaletteUniform()); ss-addUniform(new osg::Uniform(UNIFORM, getNumBonesPerVertex())); ss-setAttributeAndModes(program.get()); geom.setStateSet(ss.get()); _needInit = false; return true; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62484#62484 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to Preserve FBX baked in textures when running running hardware skinning
Hi Chris, Still can't spot what might be wrong. Try running the application with the OSG_NOTIFY_LEVEL env var set to DEBUG and then capture the output to the console. The shader strings passed to OpenGL should be printed out. This might give some clues. Robert. On 26 January 2015 at 15:18, Chris Hidden ch...@erghis.com wrote: Aha, ok, I wasn't clear enough. I literally injected that code snippet into the osganimationhardware.cpp example. I just thougt it would be redundant to repost the entire example. If you shove my code right at in around line 122, thats where I have made the edits. Otherwise my entire init() method looks like this as in osganimationhardware but with my edits: Code: bool Erghis::HardwareController::init(osgAnimation::RigGeometry geom) { osg::Vec3Array* pos = dynamic_castosg::Vec3Array*(geom.getVertexArray()); if (!pos) { osg::notify(osg::WARN) RigTransformHardware no vertex array in the geometry geom.getName() std::endl; return false; } if (!geom.getSkeleton()) { osg::notify(osg::WARN) RigTransformHardware no skeleton set in geometry geom.getName() std::endl; return false; } osgAnimation::BoneMapVisitor mapVisitor; geom.getSkeleton()-accept(mapVisitor); osgAnimation::BoneMap bm = mapVisitor.getBoneMap(); if (!createPalette(pos-size(), bm, geom.getVertexInfluenceSet().getVertexToBoneList())) return false; int nbAttribs = getNumVertexAttrib(); // use a global program for all avatar if (!program.valid()) { program = new osg::Program; program-setName(HardwareSkinning); if (!_shader.valid()) _shader = osg::Shader::readShaderFile(osg::Shader::VERTEX, C:/OpenSceneGraph/files/shaders/skinning.vert); if (!_shader.valid()) { osg::notify(osg::WARN) RigTransformHardware can't load VertexShader std::endl; return false; } // replace max matrix by the value from uniform { std::string str = _shader-getShaderSource(); std::string toreplace = std::string(MAX_MATRIX); std::size_t start = str.find(toreplace); std::stringstream ss; ss getMatrixPaletteUniform()-getNumElements(); str.replace(start, toreplace.size(), ss.str()); _shader-setShaderSource(str); osg::notify(osg::INFO) Shader str std::endl; } program-addShader(_shader.get()); for (int i = 0; i nbAttribs; i++) { std::stringstream ss; ss boneWeight i; program-addBindAttribLocation(ss.str(), attribIndex + i); osg::notify(osg::INFO) set vertex attrib ss.str() std::endl; } for (int i = 0; i nbAttribs; i++) { std::stringstream ss; ss boneWeight i; geom.setVertexAttribArray(attribIndex + i, getVertexAttrib(i)); } osg::ref_ptrosg::StateSet ss = new osg::StateSet; ### # MY EDITS ### osg::ref_ptrosg::Image image = osgDB::readImageFile(Images/PNG/Erghis_Hands_Texture.png); osg::ref_ptrosg::Texture2D texture = new osg::Texture2D(); texture-setImage(image); ss-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); osg::ref_ptrosg::Uniform unifo = new osg::Uniform(Hand_Texture, texture.get()); fragshader = osg::Shader::readShaderFile(osg::Shader::FRAGMENT, C:/OpenSceneGraph/files/shaders/rain.frag); if (!fragshader.valid()) osg::notify(osg::WARN) RigTransformHardware can't load FragmentShader std::endl; program-addShader(fragshader.get()); ss-addUniform(unifo); ### # END MY EDITS ss-addUniform(getMatrixPaletteUniform()); ss-addUniform(new osg::Uniform(UNIFORM, getNumBonesPerVertex())); ss-setAttributeAndModes(program.get()); geom.setStateSet(ss.get()); _needInit = false; return true; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62484#62484 ___
Re: [osg-users] How to Preserve FBX baked in textures when running running hardware skinning
Ok I solved my problem with the fragment shader. Stupid but I realized that if I didn't instanciate the fragment shader within the if conditional where it checks to make sure the program is valid or not it will add the same fragment shader twice to the program, hence the duplicate main error. I guess it was a bit of a dumb error. Yay mondays! Now I just need to figure out why the texture is still not showing up on my hand models... in fact the model doesn't show up at all :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62486#62486 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Texture Not Found For ive, but is for osg
I am working on updating our modeling to simulation model pipeline and have ran in to an issue. If we export to a .ive file, when loaded in our program or osgviewer, there are no textures. I set the OSG_NOTIFY_LEVEL to DEBUG and it never attempts to find them. If I do an osgconv to a .osg file, the textures show up just fine. The textures themselves are .png currently (issue with nvidia texture tools to make them .dds for now). They are located in the OSG_FILE_PATH, and I would presume correctly if they get loaded by the .osg. What could I be missing that has them not showing up in the .ive? If I do our export directly to .osg, it works as well and produces the exact same file as an osgconv from .ive. Thanks in advance. Karl Cary ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] compositeView in multithreaded Win32 MFC MDI application
I have found an answer for my own question. I don't know, whether it is complete or not, but... It is an app in OSG examples, named osgviewerMFC, that demonstrates almost exactly what I need. The app doesn't use CompositeView class. And things are much simpler then. Will investigate further... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62487#62487 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] GLES 2 and models loaded from files without any shader definition
Hi, I'm trying to develop apps for iOS using GLES 2, so far I managed to build OSG 3.2.1 to use GLES 2 and as long as I create some geometry and manually load/apply GLES 2 shaders everything is fine. On the other hand I am experiencing some issues when I try to load models from files (not containing any shader definition - OBJ, FBX and some OSG/OSGT). I know that when I use such kind of models then I should provide GLES 2 shaders in order to display them and, to my understanding, there are 3 possibilities: 1) manually apply shaders to the loaded model 2) use ShaderGenVisitor that generates shaders automatically 3) use Shader Composition I tried using ShaderGenVisitor, but it looks like that the shaders that are generated are not GLES 2 compliant (because of missing pre-built attributes), and even though attribute aliasing is applied, not every gl_ attribute is translated to the corresponding osg_ version. For instance in the converted version I have a row like this: gl_Position = osg_ModelViewProjectionMatrix * gl_Vertex; Note that only gl_ModelViewProjectionMatrix has been converted but for some reason gl_Vertex has not changed. Also, there are attributes that are not translated at all, like gl_TexCoord and gl_LightSource. Searching the forum, it looks like that the ShaderGen approach should be replaced by Shader Composition, so I wanted to try it but I'd need some directions to start with it...so far I only managed to enable it like this: state-SetShaderCompositionEnabled(true); Where state comes from the viewer's window. But no model is displayed by the viewer. Actually I am not sure at all that I should use Shader Composition, so my question is: if in my GLES 2 app I want to display models loaded from files (not containing any shader definition), what should I use and where should I look at to get started? Thanks. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62475#62475 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ANN] [General Purpose Graphical Introspection]
You could try the bitcoin based Lighthouse crowdfunding platform, authored by Mike Hearn. It is currently in a public beta phase. However crowdfunding for such a specialized project might be hard (consider the pool of potentially interested people quite small, then consider the even smaller subgroup of people who also happen to browse your crowdfunding platform of choice). Maybe you manage to build a few convincing demo applications on top of your framework to actually illustrate why your framework creates added value. Christian Buchner . 2015-01-16 10:50 GMT+01:00 Julien Valentin julienvalenti...@gmail.com: Hello dear OSG-community, http://youtu.be/yAYs5-lYj7k Is anyone know how to raise money for this kind of project? Best regards, Julien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62343#62343 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GLES 2 and models loaded from files without any shader definition
Hi Alessandro, ShaderComposition still requires you to put together the shaders so won't instantly give you what you after. The ShaderComposition functionality is also experimental. In your case it's probably best just to implement your own shaders. Something I am working on right now is a means for mapping OpenGL old style glEnable/glDisable to #define's inserted into a shaders when they are compiled. If I can get this to work it'll probably a simpler means for emulating the fixed function pipeline by provided a uber osg::Program that contains all the key functionality you'll need for your scene graph and then have the different parts enabled/disabled via osg::StateSet::setMode(..). This will reduce the need for having lots of different osg::Program and shaders for different parts of your scene graph i.e. textured, non textured, light, no light etc. My plan for the week is to wrap up this new functionality and get it released in the next dev release, and part of OSG-3.4 thereafter. Robert. On 26 January 2015 at 11:16, Alessandro Terenzi a.tere...@gmail.com wrote: Hi, I'm trying to develop apps for iOS using GLES 2, so far I managed to build OSG 3.2.1 to use GLES 2 and as long as I create some geometry and manually load/apply GLES 2 shaders everything is fine. On the other hand I am experiencing some issues when I try to load models from files (not containing any shader definition - OBJ, FBX and some OSG/OSGT). I know that when I use such kind of models then I should provide GLES 2 shaders in order to display them and, to my understanding, there are 3 possibilities: 1) manually apply shaders to the loaded model 2) use ShaderGenVisitor that generates shaders automatically 3) use Shader Composition I tried using ShaderGenVisitor, but it looks like that the shaders that are generated are not GLES 2 compliant (because of missing pre-built attributes), and even though attribute aliasing is applied, not every gl_ attribute is translated to the corresponding osg_ version. For instance in the converted version I have a row like this: gl_Position = osg_ModelViewProjectionMatrix * gl_Vertex; Note that only gl_ModelViewProjectionMatrix has been converted but for some reason gl_Vertex has not changed. Also, there are attributes that are not translated at all, like gl_TexCoord and gl_LightSource. Searching the forum, it looks like that the ShaderGen approach should be replaced by Shader Composition, so I wanted to try it but I'd need some directions to start with it...so far I only managed to enable it like this: state-SetShaderCompositionEnabled(true); Where state comes from the viewer's window. But no model is displayed by the viewer. Actually I am not sure at all that I should use Shader Composition, so my question is: if in my GLES 2 app I want to display models loaded from files (not containing any shader definition), what should I use and where should I look at to get started? Thanks. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62475#62475 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] GLES 2 and models loaded from files without any shader definition
Hi Robert, ShaderComposition still requires you to put together the shaders so won't instantly give you what you after. The ShaderComposition functionality is also experimental. In your case it's probably best just to implement your own shaders. In order to follow your suggestion, can you point me to an example (if available) that shows how to use ShaderComposition with my own shaders implementation? If I understood correctly this would make my life a little easier but I still would need to do some manual work (ie just to provide custom GLES 2 shaders source code), am I correct? I guess that this would be fine in my case. Thank you. Alessandro -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62477#62477 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org