OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Value of a variable in shaders?


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Rowley, Marlin R
Guest





PostPosted: Thu Sep 27, 2018 6:14 pm    Post subject:
Value of a variable in shaders?
Reply with quote

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

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Fri Sep 28, 2018 6:40 am    Post subject:
Value of a variable in shaders?
Reply with quote

Hi Marlin,

On Thu, 27 Sep 2018 at 19:30, Rowley, Marlin R < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
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.

 

------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
SMesserschmidt (Sebastian Messerschmidt)
Forum Moderator


Joined: 10 Sep 2013
Posts: 823

PostPosted: Fri Sep 28, 2018 7:00 am    Post subject:
Value of a variable in shaders?
Reply with quote

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:
Quote:
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:

/Missiles and Fire Control/

972-603-1931 (office)

214-926-0622 (mobile)

<mailto:>







------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
wernerM
Appreciator


Joined: 06 Feb 2013
Posts: 103

PostPosted: Fri Sep 28, 2018 8:23 am    Post subject:
Value of a variable in shaders?
Reply with quote

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:

Quote:
Hi Marlin,

On Thu, 27 Sep 2018 at 19:30, Rowley, Marlin R < (
Only registered users can see emails on this board!
Get registred or enter the forums!
)> wrote:

Quote:
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.

 




Quote:
_______________________________________________
osg-users mailing list
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
robertosfield
OSG Project Lead


Joined: 18 Mar 2009
Posts: 12145

PostPosted: Fri Sep 28, 2018 8:41 am    Post subject:
Value of a variable in shaders?
Reply with quote

Hi Marlin,

On Fri, 28 Sep 2018 at 07:40, Robert Osfield <> wrote:
Quote:
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.


------------------
Post generated by Mail2Forum
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts EXTERNAL: Re: Value of a variable in... Rowley, Marlin R General 3 Fri Sep 28, 2018 1:39 pm View latest post
No new posts Shaders with multiple views using Vie... robertosfield General 5 Wed May 09, 2018 9:20 am View latest post
No new posts EXTERNAL: Re: Getting a callback to u... Rowley, Marlin R General 1 Tue Apr 10, 2018 6:58 pm View latest post
No new posts Getting a callback to update shaders? Rowley, Marlin R General 2 Tue Apr 10, 2018 12:49 pm View latest post
No new posts RTT and Shaders using vertex attribut... moet General 0 Fri Mar 16, 2018 10:59 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP