Re: [osg-users] Image from shader

2019-10-03 Thread Chris Djali
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

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=76782#76782





___
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

2019-10-03 Thread Lucas Amparo
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

2019-10-03 Thread Glenn Waldron
I think you want:
gl_FragColor = color;

Or, if you'd rather use the built-ins, get rid of your "out vec4 color" and
write to gl_FrontColor in the vertex shader:
gl_FrontColor = gl_Color;

And read from gl_Color in the fragment shader:
gl_FragColor = gl_Color;

Glenn Waldron / osgEarth


On Thu, Oct 3, 2019 at 1:54 PM Lucas Amparo 
wrote:

> 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 mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Image from shader

2019-10-03 Thread Lucas Amparo
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

2019-10-03 Thread Lucas Amparo
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

2019-10-03 Thread Lucas Amparo
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


Re: [osg-users] Integrate Qt into OSG - not OSG into Qt osgQt

2019-10-03 Thread Raymond de Vries

Hi,

Wrt Qt: you might be interested in the upcoming rendering interface 
abstraction where no direct OpenGL calls are made anymore. Not sure if 
it helps, let us know!


Cheers, good luck,
Raymond


On 10/2/2019 8:02 PM, Jan Ciger wrote:

Hello,

On 02/10/2019 15:23, Trajce Nikolov NICK wrote:

Hi community,

I am struggling with the design of such a task. And I am a bit
familiar with Qt and other UI frameworks. The task is to embed the
whole Qt framework into OSG - including the event processing and let
OSG render ( through RTT ) the widgets content.

Any clue, hints what direction I should take?

Thanks a bunch as always!
Nick


Ufff, you are in for quite a battle, I am afraid. I have done this few
years ago when we were using Ogre and OSG for our virtual reality
simulators at work and we needed a proper UI framework to display user
interfaces inside the application.

You have basically two options:

a) Render the Qt widget/window into a texture/image, grab that and
display it as an OSG texture. Input from OSG can be fed into Qt's event
system by artificially creating and injecting events.

This works and it is how we have done it. Qt widgets can render
themselves into an image/texture directly, simply by calling their
render() method with proper arguments. We were able to display most Qt
widgets and render QML using OSG textures. Where things get very hairy
is the state management between OSG and Qt (Qt uses its own OpenGL
backend for rendering and assumes that it is in a certain state!) and
then input. When you aren't rendering Qt the usual way by showing
windows on screen but you only call render() and grab a texture, Qt will
not initialize some internal state relating to issues such as cursor,
keyboard focus, state of some widgets, etc.

The result is that you will have problems with cursor disappearing,
widgets not accepting keyboard input, keyboard shortcuts not working and
myriads of other problems like this. It can be solved to some degree by
digging into the Qt's source code, seeing which flags it is relying on
where and then manually calling the necessary functions to ensure that
they are set correctly. We have managed to get it to such shape that the
UIs were usable but if you need a very complex UI you will likely run
into problems. Also OSG's event system doesn't handle anywhere close to
the gamut of input events that Qt does, so a lot of things will have to
be emulated.

b) Implement a new Qt backend running on top of OSG.

Qt implements several of these backends, including a basic framebuffer
and OpenGL already, that is how they port Qt to different platforms,
such as phones or embedded hardware. This would be probably cleaner
approach if you really need the entire Qt to work but also a lot more
work than the above, because the API is fairly extensive, not super well
documented (this are really the dirty guts of Qt you aren't supposed to
normally see)  and may not have a completely straightforward mapping to OSG.

Good luck,

Jan






___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


---
This email has been checked for viruses by AVG.
https://www.avg.com


___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] How can I embed OSG into imgui as a widget ?

2019-10-03 Thread Riccardo Corsi
Hi Jishen,

if by ImGui you refer to the Dear Imgui library
, what you're after is pretty odd, as
ImGui is specifically designed to be embedded in other applications with
their own rendering backend.
This is why the library does create a window handle, nor is able to render
itself, but just provides you vertex buffers that you have to use in your
rendering backend.



On Sun, Sep 29, 2019 at 12:32 PM Jishen Li  wrote:

> Hi,
>
> I found people tried to embed ImGui into OSG, not vice verse. I am using
> OSG to render a scene in a separate thread. Since my main GUI is built by
> using ImGui, I want to embed OSG as a widget-like sub-window inside imgui.
>
> How can I do it ?
>
> Thanks!
>
> ...
>
> Thank you!
>
> Cheers,
> Jishen
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=76757#76757
>
>
>
>
>
> ___
> 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