Hi Hartwig,
On 12 May 2018 at 22:59, Hartwig Wiesmann <[email protected]> wrote: > In the example code one directional light computation can be injected. What > is the best solution if I like to inject 0 to N directional lights where N is > runtime dependent? > > I could do something like: > > Code: > > #ifdef LIGHTING0 > directionalLight( 0, gl_Normal.xyz, basecolor); > #endif > #ifdef LIGHTING1 > directionalLight( 1, gl_Normal.xyz, basecolor); > #endif > #ifdef LIGHTING2 > directionalLight( 2, gl_Normal.xyz, basecolor); > #endif > ... > > but this is not very elegant. Though I do not see any other possibility. Am I > missing a better solution? You could use the above approach, this kinda what the fixed function pipeline does with needing to enable/disable GL_LIGHT0, GL_LIGHT1, GL_LIGHT2 etc. Another approach is pass in the number of active lights and have a for loop iterator through the calls to directionalLight(i, gl_Normals, basecolor); The number of lights could be a uniform or supplied by #pragma(tic) shader composition. Robert. _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

