osg模型调整光照以及模型闪烁问题[z-lighting]
0 模型闪烁原因推测
- 1 关于模型闪烁的问题,很可能是由于坐标的值的有效位数超过了7位,目前的opengl的gpu渲染(老一点的显卡以及gl)都是以单精度来渲染点的位置的,所以如果坐标很大,很可能导致单精度无法精确表示有效位数超过7位的数据,然后发生截断。
- 2 关于z-lighting的问题,尝试了网上大多数的方法:可以使用osg封装的polygonOffset来避免重叠面片交替出现的问题,当然最好的方案是找的模型本身重叠面片就少
1 meshlab手动调模型
filters->Normals,curve,orientations->transform…
2 使用osg降低模型的点的坐标大小
osg::Vec3f center1 = TerrainM1->getBound().center();
float radius1 = TerrainM1->getBound().radius();
osg::Vec3f center2 = TerrainM2->getBound().center();
float radius2 = TerrainM2->getBound().radius();
TerrainM1->setMatrix(
osg::Matrix::translate(-center1.x(), -center1.y(), -center1.z()) *
osg::Matrix::rotate(osg::DegreesToRadians(180.0), 1, 0, 0) *
osg::Matrix::translate(center1.x(), center1.y(), center1.z()) *
osg::Matrix::translate(0, 0, radius2 * 0.80 + radius1)
);
// to modify the model's points render value
mRoot->getChild(0)->asTransform()->asMatrixTransform()->setMatrix(
osg::Matrix::translate(-center1.x(), -center1.y(), -center1.z())
);
osgDB::writeNodeFile(*(mRoot->getChild(0

本文探讨了OSG模型在渲染过程中出现的闪烁问题及其解决方案,通过调整模型坐标和使用polygonOffset来减少重叠面片的影响。此外,还介绍了如何通过修改材质属性和光照效果来提升模型渲染质量。
最低0.47元/天 解锁文章

512

被折叠的 条评论
为什么被折叠?



