Compositor: Add the LOD scale parameter to scene passes
This should allow us to change the LOD level for WS 3.0 on a per-pass basis.
This commit is contained in:
parent
910225532e
commit
6d3089ad6b
@ -148,7 +148,6 @@ Compositor::Compositor(osg::View *view,
|
||||
new osg::Uniform("fg_CameraPositionGeod", osg::Vec3f()),
|
||||
new osg::Uniform("fg_NearFar", osg::Vec2f()),
|
||||
new osg::Uniform("fg_Planes", osg::Vec3f()),
|
||||
new osg::Uniform("fg_Fcoef", 0.0f),
|
||||
new osg::Uniform("fg_SunDirection", osg::Vec3f()),
|
||||
new osg::Uniform("fg_SunDirectionWorld", osg::Vec3f()),
|
||||
}
|
||||
@ -237,10 +236,6 @@ Compositor::update(const osg::Matrix &view_matrix,
|
||||
case SG_UNIFORM_SUN_DIRECTION:
|
||||
u->set(osg::Vec3f(sun_dir_view.x(), sun_dir_view.y(), sun_dir_view.z()));
|
||||
break;
|
||||
case SG_UNIFORM_FCOEF:
|
||||
if (zFar != 0.0)
|
||||
u->set(2.0f / log2(float(zFar) + 1.0f));
|
||||
break;
|
||||
default:
|
||||
// Unknown uniform
|
||||
break;
|
||||
|
@ -59,7 +59,6 @@ public:
|
||||
SG_UNIFORM_CAMERA_POSITION_GEOD,
|
||||
SG_UNIFORM_NEAR_FAR,
|
||||
SG_UNIFORM_PLANES,
|
||||
SG_UNIFORM_FCOEF,
|
||||
SG_UNIFORM_SUN_DIRECTION,
|
||||
SG_UNIFORM_SUN_DIRECTION_WORLD,
|
||||
SG_TOTAL_BUILTIN_UNIFORMS
|
||||
@ -113,7 +112,7 @@ public:
|
||||
typedef std::array<
|
||||
osg::ref_ptr<osg::Uniform>,
|
||||
SG_TOTAL_BUILTIN_UNIFORMS> BuiltinUniforms;
|
||||
const BuiltinUniforms &getUniforms() const { return _uniforms; }
|
||||
const BuiltinUniforms &getBuiltinUniforms() const { return _uniforms; }
|
||||
|
||||
void addBuffer(const std::string &name, Buffer *buffer);
|
||||
void addPass(Pass *pass);
|
||||
|
@ -451,7 +451,7 @@ public:
|
||||
| osg::StateAttribute::PROTECTED);
|
||||
|
||||
osg::StateSet *ss = camera->getOrCreateStateSet();
|
||||
for (const auto &uniform : compositor->getUniforms())
|
||||
for (const auto &uniform : compositor->getBuiltinUniforms())
|
||||
ss->addUniform(uniform);
|
||||
|
||||
return pass.release();
|
||||
@ -743,6 +743,10 @@ public:
|
||||
osg::Camera *camera = pass->camera;
|
||||
camera->setAllowEventFocus(true);
|
||||
|
||||
const SGPropertyNode *p_lod_scale = root->getNode("lod-scale");
|
||||
if (p_lod_scale)
|
||||
camera->setLODScale(p_lod_scale->getFloatValue());
|
||||
|
||||
const SGPropertyNode *p_clustered = root->getNode("clustered-shading");
|
||||
ClusteredShading *clustered = nullptr;
|
||||
if (p_clustered) {
|
||||
@ -760,8 +764,7 @@ public:
|
||||
pass->update_callback = new SceneUpdateCallback(cubemap_face, zNear, zFar);
|
||||
|
||||
osg::StateSet *ss = camera->getOrCreateStateSet();
|
||||
auto &uniforms = compositor->getUniforms();
|
||||
ss->addUniform(uniforms[Compositor::SG_UNIFORM_FCOEF]);
|
||||
auto &uniforms = compositor->getBuiltinUniforms();
|
||||
ss->addUniform(uniforms[Compositor::SG_UNIFORM_SUN_DIRECTION]);
|
||||
ss->addUniform(uniforms[Compositor::SG_UNIFORM_SUN_DIRECTION_WORLD]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user