1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-30 15:15:31 +00:00

Support materials with no base (diffuse) texture (should be white). Support alternate UV set for diffuse texture.

This commit is contained in:
scrawl 2013-12-24 01:29:42 +01:00
parent a9e1e89bbc
commit 0050e6e67b
3 changed files with 24 additions and 4 deletions

View file

@ -324,6 +324,11 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
instance->setProperty("normalMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BumpTexture])); instance->setProperty("normalMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BumpTexture]));
instance->setProperty("detailMap", sh::makeProperty(texName[Nif::NiTexturingProperty::DetailTexture])); instance->setProperty("detailMap", sh::makeProperty(texName[Nif::NiTexturingProperty::DetailTexture]));
instance->setProperty("emissiveMap", sh::makeProperty(texName[Nif::NiTexturingProperty::GlowTexture])); instance->setProperty("emissiveMap", sh::makeProperty(texName[Nif::NiTexturingProperty::GlowTexture]));
if (!texName[Nif::NiTexturingProperty::BaseTexture].empty())
{
instance->setProperty("use_diffuse_map", sh::makeProperty(new sh::BooleanValue(true)));
instance->setProperty("diffuseMapUVSet", sh::makeProperty(new sh::IntValue(texprop->textures[Nif::NiTexturingProperty::BaseTexture].uvSet)));
}
if (!texName[Nif::NiTexturingProperty::GlowTexture].empty()) if (!texName[Nif::NiTexturingProperty::GlowTexture].empty())
{ {
instance->setProperty("use_emissive_map", sh::makeProperty(new sh::BooleanValue(true))); instance->setProperty("use_emissive_map", sh::makeProperty(new sh::BooleanValue(true)));
@ -347,7 +352,7 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
i == Nif::NiTexturingProperty::GlowTexture) i == Nif::NiTexturingProperty::GlowTexture)
continue; continue;
if(!texName[i].empty()) if(!texName[i].empty())
warn("Ignored texture "+texName[i]+" on layer "+Ogre::StringConverter::toString(i)); warn("Ignored texture "+texName[i]+" on layer "+Ogre::StringConverter::toString(i) + " in " + name);
} }
if (vertexColour) if (vertexColour)

View file

@ -10,8 +10,10 @@ material openmw_objects_base
emissiveMap emissiveMap
use_emissive_map false use_emissive_map false
use_detail_map false use_detail_map false
use_diffuse_map false
emissiveMapUVSet 0 emissiveMapUVSet 0
detailMapUVSet 0 detailMapUVSet 0
diffuseMapUVSet 0
use_parallax false use_parallax false
scene_blend default scene_blend default
@ -34,8 +36,10 @@ material openmw_objects_base
normalMap $normalMap normalMap $normalMap
emissiveMapUVSet $emissiveMapUVSet emissiveMapUVSet $emissiveMapUVSet
detailMapUVSet $detailMapUVSet detailMapUVSet $detailMapUVSet
diffuseMapUVSet $diffuseMapUVSet
emissiveMap $emissiveMap emissiveMap $emissiveMap
detailMap $detailMap detailMap $detailMap
diffuseMap $diffuseMap
env_map $env_map env_map $env_map
env_map_color $env_map_color env_map_color $env_map_color
use_parallax $use_parallax use_parallax $use_parallax
@ -55,8 +59,8 @@ material openmw_objects_base
texture_unit diffuseMap texture_unit diffuseMap
{ {
direct_texture $diffuseMap direct_texture $diffuseMap
create_in_ffp true create_in_ffp $use_diffuse_map
tex_coord_set $emissiveMapUVSet tex_coord_set $diffuseMapUVSet
} }
texture_unit normalMap texture_unit normalMap

View file

@ -17,13 +17,14 @@
#define NORMAL_MAP @shPropertyHasValue(normalMap) #define NORMAL_MAP @shPropertyHasValue(normalMap)
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap) #define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
#define DETAIL_MAP @shPropertyHasValue(detailMap) #define DETAIL_MAP @shPropertyHasValue(detailMap)
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
#define PARALLAX @shPropertyBool(use_parallax) #define PARALLAX @shPropertyBool(use_parallax)
#define PARALLAX_SCALE 0.04 #define PARALLAX_SCALE 0.04
#define PARALLAX_BIAS -0.02 #define PARALLAX_BIAS -0.02
// right now we support 2 UV sets max. implementing them is tedious, and we're probably not going to need more // right now we support 2 UV sets max. implementing them is tedious, and we're probably not going to need more
#define SECOND_UV_SET (@shPropertyString(emissiveMapUVSet) || @shPropertyString(detailMapUVSet)) #define SECOND_UV_SET (@shPropertyString(emissiveMapUVSet) || @shPropertyString(detailMapUVSet) || @shPropertyString(diffuseMapUVSet))
// if normal mapping is enabled, we force pixel lighting // if normal mapping is enabled, we force pixel lighting
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap)) #define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
@ -246,7 +247,9 @@
#endif #endif
SH_BEGIN_PROGRAM SH_BEGIN_PROGRAM
#if DIFFUSE_MAP
shSampler2D(diffuseMap) shSampler2D(diffuseMap)
#endif
#if NORMAL_MAP #if NORMAL_MAP
shSampler2D(normalMap) shSampler2D(normalMap)
@ -376,7 +379,15 @@
newUV += (TSeyeDir.xyxy * ( normalTex.a * PARALLAX_SCALE + PARALLAX_BIAS )).xyxy; newUV += (TSeyeDir.xyxy * ( normalTex.a * PARALLAX_SCALE + PARALLAX_BIAS )).xyxy;
#endif #endif
#if DIFFUSE_MAP
#if @shPropertyString(diffuseMapUVSet)
float4 diffuse = shSample(diffuseMap, newUV.zw);
#else
float4 diffuse = shSample(diffuseMap, newUV.xy); float4 diffuse = shSample(diffuseMap, newUV.xy);
#endif
#else
float4 diffuse = float4(1,1,1,1);
#endif
shOutputColour(0) = diffuse; shOutputColour(0) = diffuse;
#if DETAIL_MAP #if DETAIL_MAP