From 4ed559d5a9fac17b11b737f4afaee0630f8863b7 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sat, 15 Jan 2022 14:52:33 +0000 Subject: [PATCH] WS30: Pass material parameter/edge-hardness to shader --- simgear/scene/material/matlib.cxx | 2 +- simgear/scene/tgdb/VPBTechnique.cxx | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/simgear/scene/material/matlib.cxx b/simgear/scene/material/matlib.cxx index 6065f1f4..acca6dc9 100644 --- a/simgear/scene/material/matlib.cxx +++ b/simgear/scene/material/matlib.cxx @@ -397,7 +397,7 @@ SGMaterialCache::Atlas SGMaterialLib::getMaterialTextureAtlas(SGVec2f center, co continue; } - atlas.dimensions->setElement(materialLookupIndex, osg::Vec4f(mat->get_xsize(), mat->get_ysize(), mat->get_shininess(), 1.0f)); + atlas.dimensions->setElement(materialLookupIndex, osg::Vec4f(mat->get_xsize(), mat->get_ysize(), mat->get_shininess(), mat->get_parameter("edge-hardness"))); atlas.ambient->setElement(materialLookupIndex, mat->get_ambient()); atlas.diffuse->setElement(materialLookupIndex, mat->get_diffuse()); atlas.specular->setElement(materialLookupIndex, mat->get_specular()); diff --git a/simgear/scene/tgdb/VPBTechnique.cxx b/simgear/scene/tgdb/VPBTechnique.cxx index 53e8c14e..6b5406fd 100644 --- a/simgear/scene/tgdb/VPBTechnique.cxx +++ b/simgear/scene/tgdb/VPBTechnique.cxx @@ -1438,6 +1438,12 @@ void VPBTechnique::applyMaterials(BufferData& buffer, Locator* masterLocator) const osg::Array* vertices = buffer._landGeometry->getVertexArray(); const osg::Array* texture_coords = buffer._landGeometry->getTexCoordArray(0); osgTerrain::Layer* colorLayer = _terrainTile->getColorLayer(0); + + if (!colorLayer) { + SG_LOG(SG_TERRAIN, SG_ALERT, "No landclass image for " << _terrainTile->getTileID().x << " " << _terrainTile->getTileID().y << " " << _terrainTile->getTileID().level); + return; + } + osg::Image* image = colorLayer->getImage(); if (!image || ! image->valid()) {