mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 07:39:47 +00:00
Merge branch 'gloss' into 'master'
Gloss-mapping Closes #6541 See merge request OpenMW/openmw!1552
This commit is contained in:
commit
1542a0392c
5 changed files with 41 additions and 10 deletions
|
@ -137,6 +137,7 @@
|
||||||
Feature #6419: Topics shouldn't be greyed out if they can produce another topic reference
|
Feature #6419: Topics shouldn't be greyed out if they can produce another topic reference
|
||||||
Feature #6443: NiStencilProperty is not fully supported
|
Feature #6443: NiStencilProperty is not fully supported
|
||||||
Feature #6534: Shader-based object texture blending
|
Feature #6534: Shader-based object texture blending
|
||||||
|
Feature #6541: Gloss-mapping
|
||||||
Feature #6592: Missing support for NiTriShape particle emitters
|
Feature #6592: Missing support for NiTriShape particle emitters
|
||||||
Feature #6600: Support NiSortAdjustNode
|
Feature #6600: Support NiSortAdjustNode
|
||||||
Task #6201: Remove the "Note: No relevant classes found. No output generated" warnings
|
Task #6201: Remove the "Note: No relevant classes found. No output generated" warnings
|
||||||
|
|
|
@ -1552,14 +1552,8 @@ namespace NifOsg
|
||||||
case Nif::NiTexturingProperty::BumpTexture:
|
case Nif::NiTexturingProperty::BumpTexture:
|
||||||
case Nif::NiTexturingProperty::DetailTexture:
|
case Nif::NiTexturingProperty::DetailTexture:
|
||||||
case Nif::NiTexturingProperty::DecalTexture:
|
case Nif::NiTexturingProperty::DecalTexture:
|
||||||
break;
|
|
||||||
case Nif::NiTexturingProperty::GlossTexture:
|
case Nif::NiTexturingProperty::GlossTexture:
|
||||||
{
|
break;
|
||||||
// Not used by the vanilla engine. MCP (Morrowind Code Patch) adds an option to use Gloss maps:
|
|
||||||
// "- Gloss map fix. Morrowind removed gloss map entries from model files after loading them. This stops Morrowind from removing them."
|
|
||||||
// Log(Debug::Info) << "NiTexturingProperty::GlossTexture in " << mFilename << " not currently used.";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Log(Debug::Info) << "Unhandled texture stage " << i << " on shape \"" << nodeName << "\" in " << mFilename;
|
Log(Debug::Info) << "Unhandled texture stage " << i << " on shape \"" << nodeName << "\" in " << mFilename;
|
||||||
|
@ -1651,6 +1645,12 @@ namespace NifOsg
|
||||||
stateset->addUniform(new osg::Uniform("bumpMapMatrix", bumpMapMatrix));
|
stateset->addUniform(new osg::Uniform("bumpMapMatrix", bumpMapMatrix));
|
||||||
stateset->addUniform(new osg::Uniform("envMapLumaBias", texprop->envMapLumaBias));
|
stateset->addUniform(new osg::Uniform("envMapLumaBias", texprop->envMapLumaBias));
|
||||||
}
|
}
|
||||||
|
else if (i == Nif::NiTexturingProperty::GlossTexture)
|
||||||
|
{
|
||||||
|
// A gloss map is an environment map mask.
|
||||||
|
// Gloss maps are only implemented in the object shaders as well.
|
||||||
|
stateset->setTextureMode(texUnit, GL_TEXTURE_2D, osg::StateAttribute::OFF);
|
||||||
|
}
|
||||||
else if (i == Nif::NiTexturingProperty::DecalTexture)
|
else if (i == Nif::NiTexturingProperty::DecalTexture)
|
||||||
{
|
{
|
||||||
// This is only an inaccurate imitation of the original implementation,
|
// This is only an inaccurate imitation of the original implementation,
|
||||||
|
@ -1694,6 +1694,9 @@ namespace NifOsg
|
||||||
case Nif::NiTexturingProperty::DecalTexture:
|
case Nif::NiTexturingProperty::DecalTexture:
|
||||||
texture2d->setName("decalMap");
|
texture2d->setName("decalMap");
|
||||||
break;
|
break;
|
||||||
|
case Nif::NiTexturingProperty::GlossTexture:
|
||||||
|
texture2d->setName("glossMap");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ namespace Shader
|
||||||
addedState->setName("addedState");
|
addedState->setName("addedState");
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap", "decalMap", "bumpMap" };
|
const char* defaultTextures[] = { "diffuseMap", "normalMap", "emissiveMap", "darkMap", "detailMap", "envMap", "specularMap", "decalMap", "bumpMap", "glossMap" };
|
||||||
bool isTextureNameRecognized(const std::string& name)
|
bool isTextureNameRecognized(const std::string& name)
|
||||||
{
|
{
|
||||||
for (unsigned int i=0; i<sizeof(defaultTextures)/sizeof(defaultTextures[0]); ++i)
|
for (unsigned int i=0; i<sizeof(defaultTextures)/sizeof(defaultTextures[0]); ++i)
|
||||||
|
@ -325,6 +325,14 @@ namespace Shader
|
||||||
{
|
{
|
||||||
mRequirements.back().mShaderRequired = true;
|
mRequirements.back().mShaderRequired = true;
|
||||||
}
|
}
|
||||||
|
else if (texName == "glossMap")
|
||||||
|
{
|
||||||
|
mRequirements.back().mShaderRequired = true;
|
||||||
|
if (!writableStateSet)
|
||||||
|
writableStateSet = getWritableStateSet(node);
|
||||||
|
// As well as gloss maps
|
||||||
|
writableStateSet->setTextureMode(unit, GL_TEXTURE_2D, osg::StateAttribute::ON);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Log(Debug::Error) << "ShaderVisitor encountered unknown texture " << texture;
|
Log(Debug::Error) << "ShaderVisitor encountered unknown texture " << texture;
|
||||||
|
|
|
@ -58,6 +58,11 @@ uniform vec2 envMapLumaBias;
|
||||||
uniform mat2 bumpMapMatrix;
|
uniform mat2 bumpMapMatrix;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if @glossMap
|
||||||
|
uniform sampler2D glossMap;
|
||||||
|
varying vec2 glossMapUV;
|
||||||
|
#endif
|
||||||
|
|
||||||
uniform bool simpleWater;
|
uniform bool simpleWater;
|
||||||
|
|
||||||
varying float euclideanDepth;
|
varying float euclideanDepth;
|
||||||
|
@ -168,8 +173,14 @@ void main()
|
||||||
envLuma = clamp(bumpTex.b * envMapLumaBias.x + envMapLumaBias.y, 0.0, 1.0);
|
envLuma = clamp(bumpTex.b * envMapLumaBias.x + envMapLumaBias.y, 0.0, 1.0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
vec3 envEffect = texture2D(envMap, envTexCoordGen).xyz * envMapColor.xyz * envLuma;
|
||||||
|
|
||||||
|
#if @glossMap
|
||||||
|
envEffect *= texture2D(glossMap, glossMapUV).xyz;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if @preLightEnv
|
#if @preLightEnv
|
||||||
gl_FragData[0].xyz += texture2D(envMap, envTexCoordGen).xyz * envMapColor.xyz * envLuma;
|
gl_FragData[0].xyz += envEffect;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -189,7 +200,7 @@ void main()
|
||||||
gl_FragData[0].xyz *= lighting;
|
gl_FragData[0].xyz *= lighting;
|
||||||
|
|
||||||
#if @envMap && !@preLightEnv
|
#if @envMap && !@preLightEnv
|
||||||
gl_FragData[0].xyz += texture2D(envMap, envTexCoordGen).xyz * envMapColor.xyz * envLuma;
|
gl_FragData[0].xyz += envEffect;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if @emissiveMap
|
#if @emissiveMap
|
||||||
|
|
|
@ -47,6 +47,10 @@ varying vec2 bumpMapUV;
|
||||||
varying vec2 specularMapUV;
|
varying vec2 specularMapUV;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if @glossMap
|
||||||
|
varying vec2 glossMapUV;
|
||||||
|
#endif
|
||||||
|
|
||||||
varying float euclideanDepth;
|
varying float euclideanDepth;
|
||||||
varying float linearDepth;
|
varying float linearDepth;
|
||||||
|
|
||||||
|
@ -120,6 +124,10 @@ void main(void)
|
||||||
specularMapUV = (gl_TextureMatrix[@specularMapUV] * gl_MultiTexCoord@specularMapUV).xy;
|
specularMapUV = (gl_TextureMatrix[@specularMapUV] * gl_MultiTexCoord@specularMapUV).xy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if @glossMap
|
||||||
|
glossMapUV = (gl_TextureMatrix[@glossMapUV] * gl_MultiTexCoord@glossMapUV).xy;
|
||||||
|
#endif
|
||||||
|
|
||||||
passColor = gl_Color;
|
passColor = gl_Color;
|
||||||
passViewPos = viewPos.xyz;
|
passViewPos = viewPos.xyz;
|
||||||
passNormal = gl_Normal.xyz;
|
passNormal = gl_Normal.xyz;
|
||||||
|
|
Loading…
Reference in a new issue