Implement Clamp mode for NiTexturingProperty (Fixes #2050)

report
scrawl 10 years ago
parent c684c99a95
commit 077c619611

@ -54,6 +54,28 @@ static const char *getTestMode(int mode)
return "less_equal"; return "less_equal";
} }
static void setTextureProperties(sh::MaterialInstance* material, const std::string& textureSlotName, const Nif::NiTexturingProperty::Texture& tex)
{
material->setProperty(textureSlotName + "UVSet", sh::makeProperty(new sh::IntValue(tex.uvSet)));
const std::string clampMode = textureSlotName + "ClampMode";
switch (tex.clamp)
{
case 0:
material->setProperty(clampMode, sh::makeProperty(new sh::StringValue("clamp clamp")));
break;
case 1:
material->setProperty(clampMode, sh::makeProperty(new sh::StringValue("clamp wrap")));
break;
case 2:
material->setProperty(clampMode, sh::makeProperty(new sh::StringValue("wrap clamp")));
break;
case 3:
default:
material->setProperty(clampMode, sh::makeProperty(new sh::StringValue("wrap wrap")));
break;
}
}
Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata, Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
const Ogre::String &name, const Ogre::String &group, const Ogre::String &name, const Ogre::String &group,
const Nif::NiTexturingProperty *texprop, const Nif::NiTexturingProperty *texprop,
@ -294,22 +316,22 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
if (!texName[Nif::NiTexturingProperty::BaseTexture].empty()) if (!texName[Nif::NiTexturingProperty::BaseTexture].empty())
{ {
instance->setProperty("use_diffuse_map", sh::makeProperty(new sh::BooleanValue(true))); 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))); setTextureProperties(instance, "diffuseMap", texprop->textures[Nif::NiTexturingProperty::BaseTexture]);
} }
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)));
instance->setProperty("emissiveMapUVSet", sh::makeProperty(new sh::IntValue(texprop->textures[Nif::NiTexturingProperty::GlowTexture].uvSet))); setTextureProperties(instance, "emissiveMap", texprop->textures[Nif::NiTexturingProperty::GlowTexture]);
} }
if (!texName[Nif::NiTexturingProperty::DetailTexture].empty()) if (!texName[Nif::NiTexturingProperty::DetailTexture].empty())
{ {
instance->setProperty("use_detail_map", sh::makeProperty(new sh::BooleanValue(true))); instance->setProperty("use_detail_map", sh::makeProperty(new sh::BooleanValue(true)));
instance->setProperty("detailMapUVSet", sh::makeProperty(new sh::IntValue(texprop->textures[Nif::NiTexturingProperty::DetailTexture].uvSet))); setTextureProperties(instance, "detailMap", texprop->textures[Nif::NiTexturingProperty::DetailTexture]);
} }
if (!texName[Nif::NiTexturingProperty::DarkTexture].empty()) if (!texName[Nif::NiTexturingProperty::DarkTexture].empty())
{ {
instance->setProperty("use_dark_map", sh::makeProperty(new sh::BooleanValue(true))); instance->setProperty("use_dark_map", sh::makeProperty(new sh::BooleanValue(true)));
instance->setProperty("darkMapUVSet", sh::makeProperty(new sh::IntValue(texprop->textures[Nif::NiTexturingProperty::DarkTexture].uvSet))); setTextureProperties(instance, "darkMap", texprop->textures[Nif::NiTexturingProperty::DarkTexture]);
} }
bool useParallax = !texName[Nif::NiTexturingProperty::BumpTexture].empty() bool useParallax = !texName[Nif::NiTexturingProperty::BumpTexture].empty()

@ -73,6 +73,7 @@ material openmw_objects_base
direct_texture $diffuseMap direct_texture $diffuseMap
create_in_ffp $use_diffuse_map create_in_ffp $use_diffuse_map
tex_coord_set $diffuseMapUVSet tex_coord_set $diffuseMapUVSet
tex_address_mode $diffuseMapClampMode
} }
texture_unit normalMap texture_unit normalMap
@ -89,6 +90,7 @@ material openmw_objects_base
alpha_op_ex modulate src_current src_texture alpha_op_ex modulate src_current src_texture
direct_texture $darkMap direct_texture $darkMap
tex_coord_set $darkMapUVSet tex_coord_set $darkMapUVSet
tex_address_mode $darkMapClampMode
} }
texture_unit detailMap texture_unit detailMap
@ -97,6 +99,7 @@ material openmw_objects_base
colour_op_ex modulate_x2 src_current src_texture colour_op_ex modulate_x2 src_current src_texture
direct_texture $detailMap direct_texture $detailMap
tex_coord_set $detailMapUVSet tex_coord_set $detailMapUVSet
tex_address_mode $detailMapClampMode
} }
texture_unit emissiveMap texture_unit emissiveMap
@ -105,6 +108,7 @@ material openmw_objects_base
colour_op add colour_op add
direct_texture $emissiveMap direct_texture $emissiveMap
tex_coord_set $emissiveMapUVSet tex_coord_set $emissiveMapUVSet
tex_address_mode $emissiveMapClampMode
} }
texture_unit envMap texture_unit envMap

Loading…
Cancel
Save