mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Support NIF detail maps
This commit is contained in:
parent
a5c868c9f5
commit
343e2027af
@ -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("diffuseMap", sh::makeProperty(texName[Nif::NiTexturingProperty::BaseTexture]));
|
||||||
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("emissiveMap", sh::makeProperty(texName[Nif::NiTexturingProperty::GlowTexture]));
|
instance->setProperty("emissiveMap", sh::makeProperty(texName[Nif::NiTexturingProperty::GlowTexture]));
|
||||||
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)));
|
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++)
|
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");
|
warn("Ignored texture "+texName[i]+" on layer "+Ogre::StringConverter::toString(i)+"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,10 @@ material openmw_objects_base
|
|||||||
normalMap
|
normalMap
|
||||||
emissiveMap
|
emissiveMap
|
||||||
use_emissive_map false
|
use_emissive_map false
|
||||||
|
use_detail_map false
|
||||||
emissiveMapUVSet 0
|
emissiveMapUVSet 0
|
||||||
|
detailMapUVSet 0
|
||||||
|
|
||||||
is_transparent false // real transparency, alpha rejection doesn't count here
|
|
||||||
scene_blend default
|
scene_blend default
|
||||||
depth_write default
|
depth_write default
|
||||||
depth_check default
|
depth_check default
|
||||||
@ -26,10 +27,11 @@ material openmw_objects_base
|
|||||||
shader_properties
|
shader_properties
|
||||||
{
|
{
|
||||||
vertexcolor_mode $vertmode
|
vertexcolor_mode $vertmode
|
||||||
is_transparent $is_transparent
|
|
||||||
normalMap $normalMap
|
normalMap $normalMap
|
||||||
emissiveMapUVSet $emissiveMapUVSet
|
emissiveMapUVSet $emissiveMapUVSet
|
||||||
|
detailMapUVSet $detailMapUVSet
|
||||||
emissiveMap $emissiveMap
|
emissiveMap $emissiveMap
|
||||||
|
detailMap $detailMap
|
||||||
}
|
}
|
||||||
|
|
||||||
diffuse $diffuse
|
diffuse $diffuse
|
||||||
@ -51,7 +53,7 @@ material openmw_objects_base
|
|||||||
|
|
||||||
texture_unit normalMap
|
texture_unit normalMap
|
||||||
{
|
{
|
||||||
direct_texture $normalMap
|
texture $normalMap
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_unit emissiveMap
|
texture_unit emissiveMap
|
||||||
@ -61,6 +63,14 @@ material openmw_objects_base
|
|||||||
direct_texture $emissiveMap
|
direct_texture $emissiveMap
|
||||||
tex_coord_set $emissiveMapUVSet
|
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
|
texture_unit shadowMap0
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,10 @@
|
|||||||
|
|
||||||
#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)
|
||||||
|
|
||||||
// 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)
|
#define SECOND_UV_SET (@shPropertyString(emissiveMapUVSet) || @shPropertyString(detailMapUVSet))
|
||||||
|
|
||||||
// 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))
|
||||||
@ -236,6 +237,10 @@
|
|||||||
shSampler2D(emissiveMap)
|
shSampler2D(emissiveMap)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if DETAIL_MAP
|
||||||
|
shSampler2D(detailMap)
|
||||||
|
#endif
|
||||||
|
|
||||||
shInput(float4, UV)
|
shInput(float4, UV)
|
||||||
|
|
||||||
#if NORMAL_MAP
|
#if NORMAL_MAP
|
||||||
@ -313,6 +318,14 @@
|
|||||||
{
|
{
|
||||||
shOutputColour(0) = shSample(diffuseMap, UV.xy);
|
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
|
#if NORMAL_MAP
|
||||||
float3 normal = normalPassthrough;
|
float3 normal = normalPassthrough;
|
||||||
float3 binormal = cross(tangentPassthrough.xyz, normal.xyz);
|
float3 binormal = cross(tangentPassthrough.xyz, normal.xyz);
|
||||||
@ -419,7 +432,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EMISSIVE_MAP
|
#if EMISSIVE_MAP
|
||||||
#if SECOND_UV_SET
|
#if @shPropertyString(emissiveMapUVSet)
|
||||||
shOutputColour(0).xyz += shSample(emissiveMap, UV.zw).xyz;
|
shOutputColour(0).xyz += shSample(emissiveMap, UV.zw).xyz;
|
||||||
#else
|
#else
|
||||||
shOutputColour(0).xyz += shSample(emissiveMap, UV.xy).xyz;
|
shOutputColour(0).xyz += shSample(emissiveMap, UV.xy).xyz;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user