mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 23:06:41 +00:00
Disable specularity for negative lights
This commit is contained in:
parent
debc37d93a
commit
e0e4b84e40
3 changed files with 16 additions and 4 deletions
|
@ -41,6 +41,7 @@ namespace SceneUtil
|
|||
if (mType == LT_Normal)
|
||||
{
|
||||
light->setDiffuse(mDiffuseColor);
|
||||
light->setSpecular(mSpecularColor);
|
||||
traverse(node, nv);
|
||||
return;
|
||||
}
|
||||
|
@ -65,10 +66,10 @@ namespace SceneUtil
|
|||
mPhase = mPhase <= 0.5f ? 1.f : 0.25f;
|
||||
}
|
||||
|
||||
osg::Vec4f result = mDiffuseColor * mBrightness * node->getActorFade();
|
||||
const float result = mBrightness * node->getActorFade();
|
||||
|
||||
light->setDiffuse(result);
|
||||
light->setSpecular(result);
|
||||
light->setDiffuse(mDiffuseColor * result);
|
||||
light->setSpecular(mSpecularColor * result);
|
||||
|
||||
traverse(node, nv);
|
||||
}
|
||||
|
@ -78,4 +79,9 @@ namespace SceneUtil
|
|||
mDiffuseColor = color;
|
||||
}
|
||||
|
||||
void LightController::setSpecular(const osg::Vec4f& color)
|
||||
{
|
||||
mSpecularColor = color;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,12 +27,14 @@ namespace SceneUtil
|
|||
void setType(LightType type);
|
||||
|
||||
void setDiffuse(const osg::Vec4f& color);
|
||||
void setSpecular(const osg::Vec4f& color);
|
||||
|
||||
void operator()(SceneUtil::LightSource* node, osg::NodeVisitor* nv);
|
||||
|
||||
private:
|
||||
LightType mType;
|
||||
osg::Vec4f mDiffuseColor;
|
||||
osg::Vec4f mSpecularColor;
|
||||
float mPhase;
|
||||
float mBrightness;
|
||||
double mStartTime;
|
||||
|
|
|
@ -117,19 +117,23 @@ namespace SceneUtil
|
|||
configureLight(light, radius, isExterior);
|
||||
|
||||
osg::Vec4f diffuse = esmLight.mColor;
|
||||
osg::Vec4f specular = esmLight.mColor; // ESM format doesn't provide specular
|
||||
if (esmLight.mNegative)
|
||||
{
|
||||
diffuse *= -1;
|
||||
diffuse.a() = 1;
|
||||
// Using specular lighting for negative lights is unreasonable
|
||||
specular = osg::Vec4f();
|
||||
}
|
||||
light->setDiffuse(diffuse);
|
||||
light->setAmbient(ambient);
|
||||
light->setSpecular(diffuse); // ESM format doesn't provide specular
|
||||
light->setSpecular(specular);
|
||||
|
||||
lightSource->setLight(light);
|
||||
|
||||
osg::ref_ptr<SceneUtil::LightController> ctrl(new SceneUtil::LightController);
|
||||
ctrl->setDiffuse(light->getDiffuse());
|
||||
ctrl->setSpecular(light->getSpecular());
|
||||
if (esmLight.mFlicker)
|
||||
ctrl->setType(SceneUtil::LightController::LT_Flicker);
|
||||
if (esmLight.mFlickerSlow)
|
||||
|
|
Loading…
Reference in a new issue