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

actorid
scrawl 11 years ago
parent a9e1e89bbc
commit 0050e6e67b

@ -324,6 +324,11 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
instance->setProperty("normalMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BumpTexture]));
instance->setProperty("detailMap", sh::makeProperty(texName[Nif::NiTexturingProperty::DetailTexture]));
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())
{
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)
continue;
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)

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

@ -17,13 +17,14 @@
#define NORMAL_MAP @shPropertyHasValue(normalMap)
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
#define DETAIL_MAP @shPropertyHasValue(detailMap)
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
#define PARALLAX @shPropertyBool(use_parallax)
#define PARALLAX_SCALE 0.04
#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
#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
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
@ -246,7 +247,9 @@
#endif
SH_BEGIN_PROGRAM
#if DIFFUSE_MAP
shSampler2D(diffuseMap)
#endif
#if NORMAL_MAP
shSampler2D(normalMap)
@ -376,7 +379,15 @@
newUV += (TSeyeDir.xyxy * ( normalTex.a * PARALLAX_SCALE + PARALLAX_BIAS )).xyxy;
#endif
#if DIFFUSE_MAP
#if @shPropertyString(diffuseMapUVSet)
float4 diffuse = shSample(diffuseMap, newUV.zw);
#else
float4 diffuse = shSample(diffuseMap, newUV.xy);
#endif
#else
float4 diffuse = float4(1,1,1,1);
#endif
shOutputColour(0) = diffuse;
#if DETAIL_MAP

Loading…
Cancel
Save