Deferred rendering is now the de-facto standard rendering technique in many modern game engines, hence I think it is important to have this technique demonstrated in an osg code example.
This particular sample adds soft shadows as well as bump mapping into the rendering pipeline. The image files whitemetal_diffuse.jpg and whitemetal_normal.jpg from OpenSceneGraph-Data images folder are required (The OSG_FILE_PATH environment variable must be set correctly)
Two additional osgt models are included with the demo (best to also put them into OpenSceneGraph-Data, I think.
The shaders are currently defined in separate .frag and .vert files.
implementations being registered at the same time.
One usage case for this functionality to support usage of Wayland and X11 in the same version of the osgViewer.
As part of the new functionality there is now a osg::GraphicsContext::Traits::windowingSystemPreferrence string
that default to empty, but if defined will ensure that a specific WindowingSystemInterface is utilized when
you do a generic call like osg::createGraphicsContext().
Also implemented is standard proxy object for registering the new contexts and removing them automatically, and
declaration of standard graphicswindow_name() C entry point to help with static build linking.
This feature makes it easier to editor an presentation that is already running in Present3D, once the edits are done
pressing 'u' in Present3D then loads the file again.
"From I think that this piece of code in StateSet::setTextureAttributeAndModes is a copy&paste mistake:
OSG_NOTICE<<"Warning: non texture attribute '"<<attribute->className()<<"' passed to setTextureAttributeAndModes(unit,attr,value), "<<std::endl;
OSG_NOTICE<<" assuming setAttributeAndModes(attr,value) instead."<<std::endl;
OSG_NOTICE<<" please change calling code to use appropriate call."<<std::endl;
setAttribute(attribute,value);
As per the warning message it should be calling setAttributeAndModes(attribute,value); ."
The file osg-OpenSceneGraph-3.4.0\include\osg\Types
typedefs int8_t, int16_t, int32_t and int64_t
These are typedefed as signed __intX in several other places.
With VS2008, this causes an error "int8_t redifined, different basic types"
Explicitly declaring them signed fixes the error."
As for motivation behind the change, I think it makes more sense that way because only the CullVisitor cares about rendering. Say an intersection visitor or update visitor only needs to traverse the subgraph once, not once for each pass. For these visitors there is no point in traversing the subgraph more than once, since it's exactly the same graph. Another motivation is the performance improvement had when an intersection visitor tests against a multipass Technique."
Note about mods by Robert Osfield, "Changed dyanmic_cast<> and check against getTraversalType() to utilize the new asCullVisitor() instead to improve efficiency."
The change I made is to check GL_QUERY_RESULT_AVAILABLE before retrieving the query, to ensure that there won't be a stall. If the query result is not available yet, we'll leave it alone and try again in the next frame.
Had to make a few more changes than I'd liked, mostly because the TestResult mechanism wasn't designed for holding on to query objects for more than one frame. As well, I'm thinking that RetrieveQueriesCallback and ClearQueriesCallback could be merged together, if we wanted to go for more refactoring. For though now my strategy is to make as little changes as possible. Let me know what you think of the patch."
In OSG 3.4, osgText::Text( ::_quadIndices) uses DrawElementsUInt that will fail on these devices and no text will appear - tested on Samsung Galaxy Trend 2 SM-G313HN.
When DrawElementsUInt is replaced with DrawElementsUShort it works, although I'm not sure if this can cause other problems with some fonts.
Fix:
- In include\osgText\Text, line 316:
replace: "osg::ref_ptr< osg::DrawElementsUInt > _quadIndices;"
with: "osg::ref_ptr< osg::DrawElementsUShort > _quadIndices;"
- In src\osgText\Text.cpp, line 2094:
replace: "_quadIndices = new DrawElementsUInt(PrimitiveSet::TRIANGLES);"
with: "_quadIndices = new DrawElementsUShort(PrimitiveSet::TRIANGLES);"
"