forked from teamnwah/openmw-tes3coop
Support NIF detail maps
This commit is contained in:
parent
a5c868c9f5
commit
343e2027af
3 changed files with 42 additions and 6 deletions
|
@ -749,16 +749,29 @@ static Ogre::String getMaterial(const Nif::NiTriShape *shape, const Ogre::String
|
|||
|
||||
instance->setProperty("diffuseMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BaseTexture]));
|
||||
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::GlowTexture].empty())
|
||||
{
|
||||
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)));
|
||||
}
|
||||
if (!texName[Nif::NiTexturingProperty::DetailTexture].empty())
|
||||
{
|
||||
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)));
|
||||
}
|
||||
if (!texName[Nif::NiTexturingProperty::BumpTexture].empty())
|
||||
{
|
||||
// force automips on normal maps for now
|
||||
instance->setProperty("normalMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BumpTexture] + " 4"));
|
||||
}
|
||||
|
||||
|
||||
for(int i = 1;i < 7;i++)
|
||||
{
|
||||
if(!texName[i].empty())
|
||||
if(!texName[i].empty() && (i == Nif::NiTexturingProperty::DarkTexture || i == Nif::NiTexturingProperty::DecalTexture
|
||||
|| i == Nif::NiTexturingProperty::GlossTexture))
|
||||
warn("Ignored texture "+texName[i]+" on layer "+Ogre::StringConverter::toString(i)+"\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -9,9 +9,10 @@ material openmw_objects_base
|
|||
normalMap
|
||||
emissiveMap
|
||||
use_emissive_map false
|
||||
use_detail_map false
|
||||
emissiveMapUVSet 0
|
||||
detailMapUVSet 0
|
||||
|
||||
is_transparent false // real transparency, alpha rejection doesn't count here
|
||||
scene_blend default
|
||||
depth_write default
|
||||
depth_check default
|
||||
|
@ -26,10 +27,11 @@ material openmw_objects_base
|
|||
shader_properties
|
||||
{
|
||||
vertexcolor_mode $vertmode
|
||||
is_transparent $is_transparent
|
||||
normalMap $normalMap
|
||||
emissiveMapUVSet $emissiveMapUVSet
|
||||
detailMapUVSet $detailMapUVSet
|
||||
emissiveMap $emissiveMap
|
||||
detailMap $detailMap
|
||||
}
|
||||
|
||||
diffuse $diffuse
|
||||
|
@ -51,7 +53,7 @@ material openmw_objects_base
|
|||
|
||||
texture_unit normalMap
|
||||
{
|
||||
direct_texture $normalMap
|
||||
texture $normalMap
|
||||
}
|
||||
|
||||
texture_unit emissiveMap
|
||||
|
@ -61,6 +63,14 @@ material openmw_objects_base
|
|||
direct_texture $emissiveMap
|
||||
tex_coord_set $emissiveMapUVSet
|
||||
}
|
||||
|
||||
texture_unit detailMap
|
||||
{
|
||||
create_in_ffp $use_detail_map
|
||||
colour_op_ex modulate_x2 src_current src_texture
|
||||
direct_texture $detailMap
|
||||
tex_coord_set $detailMapUVSet
|
||||
}
|
||||
|
||||
texture_unit shadowMap0
|
||||
{
|
||||
|
|
|
@ -16,9 +16,10 @@
|
|||
|
||||
#define NORMAL_MAP @shPropertyHasValue(normalMap)
|
||||
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
|
||||
#define DETAIL_MAP @shPropertyHasValue(detailMap)
|
||||
|
||||
// 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)
|
||||
#define SECOND_UV_SET (@shPropertyString(emissiveMapUVSet) || @shPropertyString(detailMapUVSet))
|
||||
|
||||
// if normal mapping is enabled, we force pixel lighting
|
||||
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
|
||||
|
@ -236,6 +237,10 @@
|
|||
shSampler2D(emissiveMap)
|
||||
#endif
|
||||
|
||||
#if DETAIL_MAP
|
||||
shSampler2D(detailMap)
|
||||
#endif
|
||||
|
||||
shInput(float4, UV)
|
||||
|
||||
#if NORMAL_MAP
|
||||
|
@ -313,6 +318,14 @@
|
|||
{
|
||||
shOutputColour(0) = shSample(diffuseMap, UV.xy);
|
||||
|
||||
#if DETAIL_MAP
|
||||
#if @shPropertyString(detailMapUVSet)
|
||||
shOutputColour(0) *= shSample(detailMap, UV.zw)*2;
|
||||
#else
|
||||
shOutputColour(0) *= shSample(detailMap, UV.xy)*2;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if NORMAL_MAP
|
||||
float3 normal = normalPassthrough;
|
||||
float3 binormal = cross(tangentPassthrough.xyz, normal.xyz);
|
||||
|
@ -419,7 +432,7 @@
|
|||
#endif
|
||||
|
||||
#if EMISSIVE_MAP
|
||||
#if SECOND_UV_SET
|
||||
#if @shPropertyString(emissiveMapUVSet)
|
||||
shOutputColour(0).xyz += shSample(emissiveMap, UV.zw).xyz;
|
||||
#else
|
||||
shOutputColour(0).xyz += shSample(emissiveMap, UV.xy).xyz;
|
||||
|
|
Loading…
Reference in a new issue