WS30: Road shader - add required Uniforms

This commit is contained in:
Stuart Buchanan 2022-01-12 21:31:47 +00:00
parent 0459406f84
commit a95b531409
2 changed files with 13 additions and 4 deletions

View File

@ -1322,7 +1322,7 @@ void VPBTechnique::applyColorLayers(BufferData& buffer, Locator* masterLocator)
osg::Texture2D* texture = SGLoadTexture2D(SGPath(orthotexture), _options, true, true); osg::Texture2D* texture = SGLoadTexture2D(SGPath(orthotexture), _options, true, true);
osg::StateSet* stateset = buffer._landGeode->getOrCreateStateSet(); osg::StateSet* stateset = buffer._landGeode->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture); stateset->setTextureAttributeAndModes(0, texture);
stateset->addUniform(new osg::Uniform("fg_photoScenery", true)); stateset->addUniform(new osg::Uniform(VPBTechnique::PHOTO_SCENERY, true));
} else { } else {
SG_LOG(SG_TERRAIN, SG_DEBUG, "Unable to find " << orthotexture); SG_LOG(SG_TERRAIN, SG_DEBUG, "Unable to find " << orthotexture);
photoScenery = false; photoScenery = false;
@ -1378,9 +1378,9 @@ void VPBTechnique::applyColorLayers(BufferData& buffer, Locator* masterLocator)
osg::StateSet* stateset = buffer._landGeode->getOrCreateStateSet(); osg::StateSet* stateset = buffer._landGeode->getOrCreateStateSet();
stateset->setTextureAttributeAndModes(0, texture2D, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(0, texture2D, osg::StateAttribute::ON);
stateset->setTextureAttributeAndModes(1, atlas.image, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(1, atlas.image, osg::StateAttribute::ON);
stateset->addUniform(new osg::Uniform("fg_photoScenery", false)); stateset->addUniform(new osg::Uniform(VPBTechnique::PHOTO_SCENERY, false));
stateset->addUniform(new osg::Uniform("fg_zUpTransform", osg::Matrixf(osg::Matrix::inverse(makeZUpFrameRelative(loc))))); stateset->addUniform(new osg::Uniform(VPBTechnique::Z_UP_TRANSFORM, osg::Matrixf(osg::Matrix::inverse(makeZUpFrameRelative(loc)))));
stateset->addUniform(new osg::Uniform("fg_modelOffset", (osg::Vec3f) buffer._transform->getMatrix().getTrans())); stateset->addUniform(new osg::Uniform(VPBTechnique::MODEL_OFFSET, (osg::Vec3f) buffer._transform->getMatrix().getTrans()));
matCache->addAtlasUniforms(stateset); matCache->addAtlasUniforms(stateset);
//SG_LOG(SG_TERRAIN, SG_ALERT, "modeOffset:" << buffer._transform->getMatrix().getTrans().length() << " " << buffer._transform->getMatrix().getTrans()); //SG_LOG(SG_TERRAIN, SG_ALERT, "modeOffset:" << buffer._transform->getMatrix().getTrans().length() << " " << buffer._transform->getMatrix().getTrans());
} }
@ -1761,6 +1761,11 @@ void VPBTechnique::applyLineFeatures(BufferData& buffer, Locator* masterLocator)
geode->setEffect(mat->get_one_effect(0)); geode->setEffect(mat->get_one_effect(0));
geode->runGenerators(geometry); geode->runGenerators(geometry);
geode->setNodeMask(SG_NODEMASK_TERRAIN_BIT); geode->setNodeMask(SG_NODEMASK_TERRAIN_BIT);
osg::StateSet* stateset = geode->getOrCreateStateSet();
stateset->addUniform(new osg::Uniform(VPBTechnique::Z_UP_TRANSFORM, osg::Matrixf(osg::Matrix::inverse(makeZUpFrameRelative(loc)))));
stateset->addUniform(new osg::Uniform(VPBTechnique::MODEL_OFFSET, (osg::Vec3f) buffer._transform->getMatrix().getTrans()));
buffer._transform->addChild(geode); buffer._transform->addChild(geode);
addRandomObjectsConstraint(geode); addRandomObjectsConstraint(geode);

View File

@ -223,6 +223,10 @@ class VPBTechnique : public TerrainTechnique
inline static std::list<BucketCoastlineBinList> _coastFeatureLists; inline static std::list<BucketCoastlineBinList> _coastFeatureLists;
inline static std::mutex _coastFeatureLists_mutex; // protects the _areaFeatureLists; inline static std::mutex _coastFeatureLists_mutex; // protects the _areaFeatureLists;
inline static const char* Z_UP_TRANSFORM = "fg_zUpTransform";
inline static const char* MODEL_OFFSET = "fg_modelOffset";
inline static const char* PHOTO_SCENERY = "fg_photoScenery";
}; };
}; };