Re: [osg-users] EXTERNAL: Re: Value of a variable in shaders?

2018-09-28 Thread Robert Osfield
On Fri, 28 Sep 2018 at 14:48, Rowley, Marlin R 
wrote:

> LOL @ mis-reading my question. 😊
>

My best excuses is speed reading and trying to do too many things at once
:-)


> How would you check the values of vertices?  I just need to see the
> transformed values of a vertex.
>

One way would be to use a draw callback attached to the program
osg::Geometry that reports the current ModelView and Projection matrices
and the list of vertices, at least then you could double check the input
values.

Checking the vertices on GPU isn't don't something that is easy at runtime
without changing the rendering quite extensively such as using
Transfom_Feedback:

https://www.khronos.org/opengl/wiki/Transform_Feedback

The other possibility would be to see what tools are available on your
OS/hardware/driver combination.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] [ANN] Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web

2018-09-28 Thread Robert Osfield
On Fri, 28 Sep 2018 at 12:13, michael kapelko  wrote:
> But so far I've seen no problem with `this` approach.

Well it compiles... and technically it's valid C++.

I don't believe it's a good practice though, you can do lots of crazy
things in C++ and still have it compile.  The 6 extra characters that
I have to read that takes my concentration away from the important
stuff that has relevant meaning i.e. the variables names and methods
that are being called.  The code is less readable.  Code that is less
readable takes more effort to understand.

When writing a tutorial for others to learn from it's paramount that
the code is readable and represents best practice so those less
experienced in programming can learn it quicker and adopt those same
good practices.  Using this-> isn't best practice C++, it's not even a
good practice, it's a practice that's makes the code less readable.

It makes it hard to recommend users have a look at your tutorials as I
really don't want users adopting dubious practices in their own code.

Robert.




However, for an experienced engineer to come at the code my response
was "WTF is going on here with use of "this->" everywhere".  It
confused me what special glude
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EXTERNAL: Re: Value of a variable in shaders?

2018-09-28 Thread Rowley, Marlin R
Robert,

LOL @ mis-reading my question. 😊

How would you check the values of vertices?  I just need to see the transformed 
values of a vertex.

Thanks,

-M


Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

-Original Message-
From: osg-users  On Behalf Of 
Robert Osfield
Sent: Friday, September 28, 2018 3:41 AM
To: OpenSceneGraph Users 
Subject: EXTERNAL: Re: [osg-users] Value of a variable in shaders?

Hi Marlin,

On Fri, 28 Sep 2018 at 07:40, Robert Osfield  wrote:
> To pass data into shaders you have use a combination of uniforms 
> (osg::Unfiorm), textures (osg::Textre*) and vertex attributes.  With recent 
> 3.4.x onwards you also have the option of passing in constants via 
> #prama(tic) shader composition system that passes #define values into the 
> compilation of shaders.

Seems I mis-read your question :-)

Testing internal values in shader is an easy thing to do, what I end up doing 
is build up shaders bit by bit making sure each bit works on it's own before I 
assemble it into a more complex shader.  When I want to test values I usually 
just set the fragment colour value, though often this will have a processed 
version of the value to make it visible.  You can use #ifdef's in shaders to 
toggle the debug code paths and even toggle these paths on/off via the 
osg::StateSet::setDefine("ENABLE_DEBUG");

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


Re: [osg-users] EXTERNAL: Re: Value of a variable in shaders?

2018-09-28 Thread Rowley, Marlin R
Thanks, I'll look into that.


Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

-Original Message-
From: Sebastian Messerschmidt  
Sent: Friday, September 28, 2018 2:00 AM
To: OpenSceneGraph Users ; Rowley, Marlin R 
(US) 
Subject: EXTERNAL: Re: [osg-users] Value of a variable in shaders?

Hi,

Usually you can use the output-colors in case of a fragment shader to inspect 
the values per fragment. Rendering to a texture and inspecting the values in 
the image is also an option.

Another approach to display incoming/per state values is this nifty shader:

http://mew.cx/drawtext/drawtext.html

Appart from this, in case you're using a modern Nvidia-GPU and
Visual-Studio:

https://developer.nvidia.com/nsight-visual-studio-edition

Cheers
Sebastian



Am 27.09.2018 um 20:14 schrieb Rowley, Marlin R:
> All,
> 
> Is there a way to examine variable values in shader code? I cant 
> figure out this problem that we are having unless I can see the values 
> in the shaders.
> 
> Any help would be appreciated
> 
> 
> 
> Marlin Rowley
> 
> Software Engineer, Staff
> 
> cid:image002.jpg@01D39374.DEC5A2E0
> 
> /Missiles and Fire Control/
> 
> 972-603-1931 (office)
> 
> 214-926-0622 (mobile)
> 
> marlin.r.row...@lmco.com 
> 
> 
> 
> ___
> 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] EXTERNAL: Re: Value of a variable in shaders?

2018-09-28 Thread Rowley, Marlin R
Robert,

I’ve written the shaders already and am well-versed in writing them.  I just 
need a debugging tool that will allow me to see their values at runtime.


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users  On Behalf Of 
Robert Osfield
Sent: Friday, September 28, 2018 1:40 AM
To: OpenSceneGraph Users 
Subject: EXTERNAL: Re: [osg-users] Value of a variable in shaders?

Hi Marlin,
On Thu, 27 Sep 2018 at 19:30, Rowley, Marlin R 
mailto:marlin.r.row...@lmco.com>> wrote:
Is there a way to examine variable values in shader code? I can’t figure out 
this problem that we are having unless I can see the values in the shaders.

To pass data into shaders you have use a combination of uniforms 
(osg::Unfiorm), textures (osg::Textre*) and vertex attributes.  With recent 
3.4.x onwards you also have the option of passing in constants via #prama(tic) 
shader composition system that passes #define values into the compilation of 
shaders.

Shaders are a big topic so it's impossible for me to give you a full guide, 
there are plenty of reosurces online about GLSL shaders, within the OSG search 
for uses of osg::Program, osg::Shader, osg::Uniform.

Robert.

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


Re: [osg-users] [ANN] Cross-platform examples for Linux, macOS, Windows, Android, iOS, and Web

2018-09-28 Thread michael kapelko
Hi, Robert.

I agree with you that explicit usage of `this` is not something I see
frequently myself. That's a valid point. I've been on that side, too.
Probably, because I never asked myself about `this`.

My work is related to iOS development, so I've seen Apple ecosystem
migration from Objective-C to Swift. Objective-C requires `self` (aka
`this`), however, Swift does not. There have been debates about `self`
in Swift, too: https://github.com/raywenderlich/swift-style-guide/issues/7
This migration is what made me wonder if using `this` in C++ and
`self` in Swift has benefits.

I'd like to bring a few more thoughts why `this` is better than `_`,
`m`, or `m_`:
* altering variable names to reflect environment (member / local)
always seemed inappropriate to me
* `_`, `m`, or `m_` is really just a shortcut for using `this`

So, since everybody else was already distinguishing local variables
from memeber ones with some sort of Hungarian notation, I just tried
to be honest and use facilities provided by the language itself:
`this` pointer.
In case I find a serious drawback that would cost me hours of
development time, I would definitely go back to `this`less approach.
But so far I've seen no problem with `this` approach.

On Wed, 26 Sep 2018 at 17:17, Robert Osfield  wrote:
>
> Hi Michael,
>
> On Wed, 26 Sep 2018 at 09:16, michael kapelko  wrote:
> > I started to use explicit `this` to simplify reading and increase
> > "shareability" of code:
>
> Doing something that very few other developers do is likely to reduce
> "shareability", I'm experienced engineer and read lots of third party
> code and found myself wondering why the code was different.
>
> > * I don't need to rely on IDE to highlight member or local
> > variables/functions for me, so I can get away with simpler and faster
> > tools (VIM, in my case)
> > * I can paste such code blocks anywhere, and a reader won't need to
> > run IDE to know this is member or local variable/function/etc.
>
> If the code is well written then it should be relatively clear what a
> global functions and what a local method calls.  Most modern C++
> programs have few global variables and functions so if you see a
> function call it's generally safe to assume it's a local method, for
> variables then it's most likely the variable is a local or member
> variable.  For the OSG we just prefect with _ to make it clear it's a
> member variable rather than global, other codebases use m_ or keep the
> class/structs simple enough that it's clear.  Personally I don't use
> m_ as I find it distracting and reduces the flow of readability, and
> find this-> is even more verbose and distracting.
>
> > So far this approach looks better to me. When I see code referencing
> > member variables/functions without `this`, I need to know what
> > particular color IDE uses to tell member/local variables apart. And to
> > make things more complicated, different IDEs use different colors :)
>
> this-> is a lot of typing you keep having to do just to make your code
> intentions clear.  Developers are used to code without it and should
> be able to work out what is local or member variable/functions pretty
> easily if the class/structs are kept straight forward and the member
> function kepts small enough that you can see where local variables are
> being written.
>
> As for different IDE's doing different things.  Personally the first
> stop should be making the code clear enough that these bells and
> whistles aren't required, and if they are added then the developer
> will likely be just using one IDE for majority of their work and
> shouldn't end up confused.
>
> Personally I don't use IDE's, I just use the KDE kate editor and read
> the class interfaces and implementations, it does highlighting of many
> things by not discriminating between member vs local variables etc.  I
> don't have particular issues trying to read code.
>
> When writing code for others to digest I think it is probably best to
> avoid doing things that are unusual, and as a good practice the
> CppCoreGuindelines are probably a good place to start as any.
>
> Cheers,
> Robert.
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Value of a variable in shaders?

2018-09-28 Thread Robert Osfield
Hi Marlin,

On Fri, 28 Sep 2018 at 07:40, Robert Osfield  wrote:
> To pass data into shaders you have use a combination of uniforms 
> (osg::Unfiorm), textures (osg::Textre*) and vertex attributes.  With recent 
> 3.4.x onwards you also have the option of passing in constants via 
> #prama(tic) shader composition system that passes #define values into the 
> compilation of shaders.

Seems I mis-read your question :-)

Testing internal values in shader is an easy thing to do, what I end
up doing is build up shaders bit by bit making sure each bit works on
it's own before I assemble it into a more complex shader.  When I want
to test values I usually just set the fragment colour value, though
often this will have a processed version of the value to make it
visible.  You can use #ifdef's in shaders to toggle the debug code
paths and even toggle these paths on/off via the
osg::StateSet::setDefine("ENABLE_DEBUG");

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


Re: [osg-users] Value of a variable in shaders?

2018-09-28 Thread Werner Modenbach
Hi Marlin,

in case you want to know the value of a variable (not uniform) of a shader
there is no way (to my knowledge) inspecting it like in a debugger.
The usual workaround is visualizing things by coloring the output pixels.
If you want to "see" the "value" of a normal vector you can just take it
as a
color and set it in the fragment shader as the output color.
Be creative when "debugging" other values: Bools or thresholds go black
and white etc.
If you have to "debug" values in vertex or geometry shaders, just pass
colors to the fragment shader.

I hope this helps a little.

- Werner -

Am 28.09.2018 um 08:40 schrieb Robert Osfield:
> Hi Marlin,
>
> On Thu, 27 Sep 2018 at 19:30, Rowley, Marlin R
> mailto:marlin.r.row...@lmco.com>> wrote:
>
> Is there a way to examine variable values in shader code? I can’t
> figure out this problem that we are having unless I can see the
> values in the shaders.
>
>
> To pass data into shaders you have use a combination of uniforms
> (osg::Unfiorm), textures (osg::Textre*) and vertex attributes.  With
> recent 3.4.x onwards you also have the option of passing in constants
> via #prama(tic) shader composition system that passes #define values
> into the compilation of shaders.
>
> Shaders are a big topic so it's impossible for me to give you a full
> guide, there are plenty of reosurces online about GLSL shaders, within
> the OSG search for uses of osg::Program, osg::Shader, osg::Uniform.
>
> Robert.
>  
>
>
> ___
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

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


Re: [osg-users] Value of a variable in shaders?

2018-09-28 Thread Sebastian Messerschmidt

Hi,

Usually you can use the output-colors in case of a fragment shader to 
inspect the values per fragment. Rendering to a texture and inspecting 
the values in the image is also an option.


Another approach to display incoming/per state values is this nifty shader:

http://mew.cx/drawtext/drawtext.html

Appart from this, in case you're using a modern Nvidia-GPU and 
Visual-Studio:


https://developer.nvidia.com/nsight-visual-studio-edition

Cheers
Sebastian



Am 27.09.2018 um 20:14 schrieb Rowley, Marlin R:

All,

Is there a way to examine variable values in shader code? I can’t figure 
out this problem that we are having unless I can see the values in the 
shaders.


Any help would be appreciated



Marlin Rowley

Software Engineer, Staff

cid:image002.jpg@01D39374.DEC5A2E0

/Missiles and Fire Control/

972-603-1931 (office)

214-926-0622 (mobile)

marlin.r.row...@lmco.com 



___
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