mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-01 04:39:44 +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 #6443: NiStencilProperty is not fully supported
|
||||
Feature #6534: Shader-based object texture blending
|
||||
Feature #6541: Gloss-mapping
|
||||
Feature #6592: Missing support for NiTriShape particle emitters
|
||||
Feature #6600: Support NiSortAdjustNode
|
||||
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::DetailTexture:
|
||||
case Nif::NiTexturingProperty::DecalTexture:
|
||||
break;
|
||||
case Nif::NiTexturingProperty::GlossTexture:
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
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("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)
|
||||
{
|
||||
// This is only an inaccurate imitation of the original implementation,
|
||||
|
@ -1694,6 +1694,9 @@ namespace NifOsg
|
|||
case Nif::NiTexturingProperty::DecalTexture:
|
||||
texture2d->setName("decalMap");
|
||||
break;
|
||||
case Nif::NiTexturingProperty::GlossTexture:
|
||||
texture2d->setName("glossMap");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -244,7 +244,7 @@ namespace Shader
|
|||
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)
|
||||
{
|
||||
for (unsigned int i=0; i<sizeof(defaultTextures)/sizeof(defaultTextures[0]); ++i)
|
||||
|
@ -325,6 +325,14 @@ namespace Shader
|
|||
{
|
||||
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
|
||||
Log(Debug::Error) << "ShaderVisitor encountered unknown texture " << texture;
|
||||
|
|
|
@ -58,6 +58,11 @@ uniform vec2 envMapLumaBias;
|
|||
uniform mat2 bumpMapMatrix;
|
||||
#endif
|
||||
|
||||
#if @glossMap
|
||||
uniform sampler2D glossMap;
|
||||
varying vec2 glossMapUV;
|
||||
#endif
|
||||
|
||||
uniform bool simpleWater;
|
||||
|
||||
varying float euclideanDepth;
|
||||
|
@ -168,8 +173,14 @@ void main()
|
|||
envLuma = clamp(bumpTex.b * envMapLumaBias.x + envMapLumaBias.y, 0.0, 1.0);
|
||||
#endif
|
||||
|
||||
vec3 envEffect = texture2D(envMap, envTexCoordGen).xyz * envMapColor.xyz * envLuma;
|
||||
|
||||
#if @glossMap
|
||||
envEffect *= texture2D(glossMap, glossMapUV).xyz;
|
||||
#endif
|
||||
|
||||
#if @preLightEnv
|
||||
gl_FragData[0].xyz += texture2D(envMap, envTexCoordGen).xyz * envMapColor.xyz * envLuma;
|
||||
gl_FragData[0].xyz += envEffect;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -189,7 +200,7 @@ void main()
|
|||
gl_FragData[0].xyz *= lighting;
|
||||
|
||||
#if @envMap && !@preLightEnv
|
||||
gl_FragData[0].xyz += texture2D(envMap, envTexCoordGen).xyz * envMapColor.xyz * envLuma;
|
||||
gl_FragData[0].xyz += envEffect;
|
||||
#endif
|
||||
|
||||
#if @emissiveMap
|
||||
|
|
|
@ -47,6 +47,10 @@ varying vec2 bumpMapUV;
|
|||
varying vec2 specularMapUV;
|
||||
#endif
|
||||
|
||||
#if @glossMap
|
||||
varying vec2 glossMapUV;
|
||||
#endif
|
||||
|
||||
varying float euclideanDepth;
|
||||
varying float linearDepth;
|
||||
|
||||
|
@ -120,6 +124,10 @@ void main(void)
|
|||
specularMapUV = (gl_TextureMatrix[@specularMapUV] * gl_MultiTexCoord@specularMapUV).xy;
|
||||
#endif
|
||||
|
||||
#if @glossMap
|
||||
glossMapUV = (gl_TextureMatrix[@glossMapUV] * gl_MultiTexCoord@glossMapUV).xy;
|
||||
#endif
|
||||
|
||||
passColor = gl_Color;
|
||||
passViewPos = viewPos.xyz;
|
||||
passNormal = gl_Normal.xyz;
|
||||
|
|
Loading…
Reference in a new issue