From 998f92592a2f05d8b33feca90a92fd708db74c65 Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Fri, 7 Aug 2020 12:04:04 +0200 Subject: [PATCH] Directional lighting fix getLights modified to use points rather than triangles based on the configuration. This fixes point lights (with directional disabled) on AMD --- simgear/scene/tgdb/pt_lights.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/simgear/scene/tgdb/pt_lights.cxx b/simgear/scene/tgdb/pt_lights.cxx index c1bb3d61..b0c9ddf6 100644 --- a/simgear/scene/tgdb/pt_lights.cxx +++ b/simgear/scene/tgdb/pt_lights.cxx @@ -280,9 +280,19 @@ SGLightFactory::getLights(const SGDirectionalLightBin& lights) //stateSet->setRenderBinDetails(POINT_LIGHTS_BIN, "DepthSortedBin"); //stateSet->setMode(GL_LIGHTING, osg::StateAttribute::OFF); + + static SGSceneFeatures* sceneFeatures = SGSceneFeatures::instance(); + bool useTriangles = sceneFeatures->getEnableTriangleDirectionalLights(); + SG_LOG(SG_TERRAIN, SG_ALERT, "using triangles for lights " << useTriangles); + osg::DrawArrays* drawArrays; - drawArrays = new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, - 0, vertices->size()); + if (useTriangles) + drawArrays = new osg::DrawArrays(osg::PrimitiveSet::TRIANGLES, + 0, vertices->size()); + else + drawArrays = new osg::DrawArrays(osg::PrimitiveSet::POINTS, + 0, vertices->size()); + geometry->addPrimitiveSet(drawArrays); return geometry; }