Re: [osg-users] Image from shader
Guys, Thanks a lot for everyone. To solve my problem, I need to add Code: ... // In the cpp OSG file ss->addUniform(new osg::Uniform("uTextureMap", 0)); ... Code: ... // On the vertex shader gl_TexCoord[0] = gl_MultiTexCoord0; ... Code: ... // And this on the fragment shader color_data = texture2D( uTextureMap, gl_TexCoord[0].st ); ... Now I'm facing problems to render the light on the image hehe But it's scenes from the next chapter. Thank you all, again. Cheers, Lucas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76797#76797 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
AnyOldName3 wrote: > Hi, > > The name texUnit0 comes from the shader, which you're providing. The texture > unit index (which my example snippet sets to 0) comes from your scene graph, > which you said came from osgOcean, and will almost certainly be 0 for a > diffuse map. If I was trying to check that, I'd run the application through > APITrace and see which units have textures bound to them during the draw > calls for the meshes I'm interested in, but that might not be the simplest > approach. > > Cheers, > Chris Chris, I've achieved an improvement, using your approach. I've looking for a variable on osgocean and find uTextureMap. But, some textures on the model wasn't loaded yet. It isn't correct yet but is a little step forward. Thanks a lot. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76796#76796 Attachments: http://forum.openscenegraph.org//files/captura_de_tela_de_2019_10_07_10_35_58_121.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
AnyOldName3 wrote: > Hi, > > OSGOcean is probably setting up the necessary fixed-function stuff to put its > texture in texture unit zero, but you'll need to tell the fragment shader > that its texUnit0 uniform refers to that texture unit. It should be enough > just to add a uniform to the same stateset as you're adding your shader that > sets texUnit0 to 0 e.g. > > Code: > stateSet->addUniform(new osg::Uniform("texUnit0", 0)); > > > > Cheers, > Chris Chris, do you know some way to "debug" the variables to find the right name used on this texture? I'll try your approach and come back with the result. Thanks a lot. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76793#76793 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
Hi, Chris. Thanks for the answer. I've inserted "gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;" in my vertex shader before... and forgot to mention this here. Sorry. Thanks for the code but, with my poor knowledge about OSG and OpenGL I need to pass a texture for fragment shader, right? In the texUnit0? My simulation was a little bit complex (and confuse), not made by me. I'm just adding a feature to a finished plugin, made by the Older-Me haha All the texture, I believe are passed by the OSGOcean, because when I load my camera with the osg::Node without my shaders, it's works properly. But, when I load my node with shader, "brokes"... Thank you! Cheers, Lucas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76789#76789 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
Guys, It's possible to take a simples "screenshot" from an osg::Viewer? Thank you! Cheers, Lucas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76785#76785 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
AnyOldName3 wrote: > Hi, > > I'm pretty sure you're not using your shaders at all. You're not setting > gl_Position in the vertex shader, so it's not going to compile, and OSG will > fall back to either its basic shader or fixed-function mode depending on how > you've set it up. You should be seeing errors printed to the console when you > run your application. > > Cheers, > Chris Hi, thanks for your answer. The shader works for my purpose. Before, just a depthmap from simulation. The console don't show any error, just deprecated warnings. Do you believe if I set gl_Position, the colors could be solved? -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76784#76784 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
Hi, thanks for the answer. changing color = gl_Color to gl_FrontColor = gl_Color and gl_FragColor = color to gl_FragColor = gl_Color same results :( -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76781#76781 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
An information: The image1.png was produced when I make something wrong on my shader and the compilation brokes. I believe which the default shader, from OSG take their place and rendering this image. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76779#76779 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Image from shader
The depth works properly... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76778#76778 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Image from shader
Hi everyone, I'm trying to retrieve an image from a shader using OpenGL in OSG/OSGOcean. I can retrieve the depth from the simulation but can't access properly the color from each vertex. Using this code on *.vert Code: out vec3 pos out vec4 color void main() { pos = (gl_ModelViewMatrix * gl_Vertex).xyz; color = gl_Color; } and this in *.frag Code: in vec3 pos; in vec4 color; uniform float farPlane; void main() { float linearDepth = length(pos); float dist_ratio = linearDepth / farPlane; gl_FragDepth = dist_ratio; gl_FragColor = gl_FrontColor; } I'm achieving this image (image2.png on attachment) when I'm trying to produce that image (image1.png on attachment). Could someone bring me to light? I'm very lost on this... Thank you! Cheers, Lucas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76777#76777 Attachments: http://forum.openscenegraph.org//files/image1_169.png http://forum.openscenegraph.org//files/image2_731.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Rendering a Depthmap
Hi, everyone I'm trying to render a depthmap using shaders. Very simple, just using the distance from an arbitrary point P to the camera's eye. That map will be deprojected into a pointcloud. The problem is an unexpected (by me lol) behavior from the deprojection. Using a tutorial (can't post links yet), I've done the work but the result seems weird. For example, if I had a perfect wall on the scene, the depthmap is projected similar to a "rinnegan" (do you remember naruto? Is the best way to represent the problem ) Someone already did something similar to that? What's the best way to make a depthmap on OSG? Tutorials, examples, books are very welcomed. Thank you! Cheers, Lucas -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=76186#76186 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org