Shader Composition questions

classic Classic list List threaded Threaded
5 messages Options
GameCodingNinja GameCodingNinja
Reply | Threaded
Open this post in threaded view
|

Shader Composition questions

I'm just trying to wrap my head around this concept of combining shader functions on the fly to foster shader modularizing.

1) Are we basically using string replace (or insertion) to build the shader on the fly prior to it being compiled?

2) Are these shader pieces being added or removed from the same one vertex and fragment shaders maintaining one master program shader?

3) Assuming number 2 is correct, adding and removing shader pieces on the fly during the execution of the program would be detrimental to speed.

Thanks for your help!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Shader Composition questions

Hi Mr. Ninja,

1. Basically. See osgEarth/ShaderFactory.cpp for the implementation.

2. No; the VP framework constructs a separate osg::Program for each unique combination of VirtualProgram components encountered in the scene graph traversal. Each program is compiled once, cached, and then used when needed in the scene graph.

Hope this helps.
Glenn Waldron / Pelican Mapping
GameCodingNinja GameCodingNinja
Reply | Threaded
Open this post in threaded view
|

Re: Shader Composition questions

Thanks Glenn! Yep, I have been looking over osgEarth/ShaderFactory.cpp.

Is the VP framework the only way (or perhaps the preferred or most straight forward way) to implement shading into osgEarth?

The reason I ask is in our program, we have our own ROAM implementation which over the years (and many sticky fingers) has become a problem. I'm in the process of replacing our ROAM with your osgEarth. So far I have osgEarth working in-place or our legacy ROAM implementation but there is still the matter of the shaders how best to proceed.

What would you suggest?

Thanks!
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|

Re: Shader Composition questions

Yes, you must use the VP framework if you wish to modify the rendering of osgEarth geometry.

Glenn Waldron / Pelican Mapping
GameCodingNinja GameCodingNinja
Reply | Threaded
Open this post in threaded view
|

Re: Shader Composition questions

Thank you again for your quick response and help!