Hi Glenn et. al.

Today I've been revisiting the osgTerrain::DisplacementMappingTechnique,
GeometryPool and associated shaders to make better use of the new
#pragma(tic) shader composition.  I haven't completed this work yet, but
attached are the two main shaders I'm working on, these are where the bulk
of the different options are for handling different numbers of colour
layers, optional height fields etc. are.  I have been able to replace
combine two original vertex main shaders into one, and four different
fragment main shaders into one.    I have attached the shaders to
illustrate my work in progress.

Previously the GeometryPool had to manage the selection between the
different combinations of shaders and create a different osg::Program for
each combination, while now I will be able to remove all this C++ code for
management of shaders and replace with simply StateSet::setDefine(..) to
toggle the various features on/off.  This toggle on/off of features can be
generic - just needing to know the name of the feature to toggle, it won't
need to know about GeometryPool or where it's attached different Programs.
This is big advantage as it decouples the C++ implementation details from
the interface.  The C++ implementation is also simpler so will be easier to
understand and maintain going forward.

Once I've got the DisplacementMapping/GeometryPool code sorted (hopefully
by end of tomorrow) I'll check it all in and provide others a more complex
illustration of how to use the new form shader composition.

The work I did on osgVolume in 2013/14 managed it's own local management of
different shader combinations - osg::ShaderComposition just didn't fit the
problem I was trying to solve so ended up creating a local code to solve
the problem.  However, this work would be an ideal candidate for converting
to use #pragma(tic) shader composition, implementing it should be able to
remove C++ code and make the shaders easier to manage.  Once I've done this
it should also be an example that members of the community can use as
inspiration.

A note for Glenn, could you give me an example of what type of
modifications to the attached shaders you'd like to add in - just sticking
the GLSL code you want to add directly into the GLSL without any of the
#ifdef etc. would be fine.  Knowing what type of GLSL you want to inject
will help me know what entry points would be useful to add to the shaders
to give you the ability to customize them.

Cheers,
Robert.

Attachment: terrain_displacement_mapping.vert
Description: Binary data

Attachment: terrain_displacement_mapping_CCC.frag
Description: Binary data

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to