1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-04-01 22:20:45 +00:00

Merge branch 'falloutfalloffnthtimesthecharm' into 'master'

BSEffectShader/NoLighting fixes

See merge request OpenMW/openmw!3211
This commit is contained in:
psi29a 2023-07-10 07:51:53 +00:00
commit d9027f7eef
3 changed files with 14 additions and 28 deletions

View File

@ -232,6 +232,8 @@ namespace Nif
std::string mGreyscaleTexture; std::string mGreyscaleTexture;
void read(NIFStream* nif) override; void read(NIFStream* nif) override;
bool useFalloff() const { return (flags >> 6) & 1; }
}; };
struct NiDitherProperty : public Property struct NiDitherProperty : public Property

View File

@ -2177,6 +2177,7 @@ namespace NifOsg
{ {
auto texprop = static_cast<const Nif::BSShaderNoLightingProperty*>(property); auto texprop = static_cast<const Nif::BSShaderNoLightingProperty*>(property);
bool shaderRequired = true; bool shaderRequired = true;
bool useFalloff = false;
node->setUserValue("shaderPrefix", std::string(getBSShaderPrefix(texprop->type))); node->setUserValue("shaderPrefix", std::string(getBSShaderPrefix(texprop->type)));
node->setUserValue("shaderRequired", shaderRequired); node->setUserValue("shaderRequired", shaderRequired);
osg::StateSet* stateset = node->getOrCreateStateSet(); osg::StateSet* stateset = node->getOrCreateStateSet();
@ -2200,16 +2201,13 @@ namespace NifOsg
const unsigned int uvSet = 0; const unsigned int uvSet = 0;
stateset->setTextureAttributeAndModes(texUnit, texture2d, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(texUnit, texture2d, osg::StateAttribute::ON);
boundTextures.push_back(uvSet); boundTextures.push_back(uvSet);
if (mBethVersion >= 27)
{
useFalloff = true;
stateset->addUniform(new osg::Uniform("falloffParams", texprop->falloffParams));
}
} }
if (mBethVersion >= 27) stateset->addUniform(new osg::Uniform("useFalloff", useFalloff));
{
stateset->addUniform(new osg::Uniform("useFalloff", true));
stateset->addUniform(new osg::Uniform("falloffParams", texprop->falloffParams));
}
else
{
stateset->addUniform(new osg::Uniform("useFalloff", false));
}
handleTextureControllers(texprop, composite, imageManager, stateset, animflags); handleTextureControllers(texprop, composite, imageManager, stateset, animflags);
if (texprop->doubleSided()) if (texprop->doubleSided())
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::OFF); stateset->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
@ -2236,6 +2234,7 @@ namespace NifOsg
{ {
auto texprop = static_cast<const Nif::BSEffectShaderProperty*>(property); auto texprop = static_cast<const Nif::BSEffectShaderProperty*>(property);
bool shaderRequired = true; bool shaderRequired = true;
// TODO: implement BSEffectShader as a shader
node->setUserValue("shaderPrefix", std::string("bs/nolighting")); node->setUserValue("shaderPrefix", std::string("bs/nolighting"));
node->setUserValue("shaderRequired", shaderRequired); node->setUserValue("shaderRequired", shaderRequired);
osg::StateSet* stateset = node->getOrCreateStateSet(); osg::StateSet* stateset = node->getOrCreateStateSet();
@ -2277,8 +2276,10 @@ namespace NifOsg
stateset->setTextureAttributeAndModes(texUnit, texMat, osg::StateAttribute::ON); stateset->setTextureAttributeAndModes(texUnit, texMat, osg::StateAttribute::ON);
} }
} }
stateset->addUniform(new osg::Uniform("useFalloff", false)); // Should use the shader flag bool useFalloff = texprop->useFalloff();
stateset->addUniform(new osg::Uniform("falloffParams", texprop->mFalloffParams)); stateset->addUniform(new osg::Uniform("useFalloff", useFalloff));
if (useFalloff)
stateset->addUniform(new osg::Uniform("falloffParams", texprop->mFalloffParams));
handleTextureControllers(texprop, composite, imageManager, stateset, animflags); handleTextureControllers(texprop, composite, imageManager, stateset, animflags);
if (texprop->doubleSided()) if (texprop->doubleSided())
stateset->setMode(GL_CULL_FACE, osg::StateAttribute::OFF); stateset->setMode(GL_CULL_FACE, osg::StateAttribute::OFF);
@ -2469,11 +2470,6 @@ namespace NifOsg
} }
break; break;
} }
case Nif::RC_BSShaderNoLightingProperty:
{
mat->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(1.f, 1.f, 1.f, 1.f));
break;
}
case Nif::RC_BSLightingShaderProperty: case Nif::RC_BSLightingShaderProperty:
{ {
auto shaderprop = static_cast<const Nif::BSLightingShaderProperty*>(property); auto shaderprop = static_cast<const Nif::BSLightingShaderProperty*>(property);
@ -2485,13 +2481,6 @@ namespace NifOsg
specStrength = shaderprop->mSpecStrength; specStrength = shaderprop->mSpecStrength;
break; break;
} }
case Nif::RC_BSEffectShaderProperty:
{
auto shaderprop = static_cast<const Nif::BSEffectShaderProperty*>(property);
mat->setEmission(osg::Material::FRONT_AND_BACK, osg::Vec4f(shaderprop->mBaseColor));
emissiveMult = shaderprop->mBaseColorScale;
break;
}
default: default:
break; break;
} }

View File

@ -21,7 +21,6 @@ varying float passFalloff;
uniform vec2 screenRes; uniform vec2 screenRes;
uniform bool useFalloff; uniform bool useFalloff;
uniform float emissiveMult;
uniform float far; uniform float far;
uniform float alphaRef; uniform float alphaRef;
@ -45,10 +44,6 @@ void main()
if (useFalloff) if (useFalloff)
gl_FragData[0].a *= passFalloff; gl_FragData[0].a *= passFalloff;
vec4 emissionColor = getEmissionColor();
gl_FragData[0].rgb *= emissionColor.rgb * emissiveMult;
gl_FragData[0].a *= emissionColor.a * emissionColor.a; // sic
gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef); gl_FragData[0].a = alphaTest(gl_FragData[0].a, alphaRef);
gl_FragData[0] = applyFogAtDist(gl_FragData[0], euclideanDepth, linearDepth, far); gl_FragData[0] = applyFogAtDist(gl_FragData[0], euclideanDepth, linearDepth, far);