Implement DarkTexture slot. Fix an issue with incorrect transparency override when base texture is empty.

actorid
scrawl 11 years ago
parent 0050e6e67b
commit e68e2f82a2

@ -324,6 +324,7 @@ 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]));
instance->setProperty("darkMap", sh::makeProperty(texName[Nif::NiTexturingProperty::DarkTexture]));
if (!texName[Nif::NiTexturingProperty::BaseTexture].empty())
{
instance->setProperty("use_diffuse_map", sh::makeProperty(new sh::BooleanValue(true)));
@ -339,6 +340,11 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
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::DarkTexture].empty())
{
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)));
}
bool useParallax = !texName[Nif::NiTexturingProperty::BumpTexture].empty()
&& texName[Nif::NiTexturingProperty::BumpTexture].find("_nh.") != std::string::npos;
@ -348,6 +354,7 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
{
if(i == Nif::NiTexturingProperty::BaseTexture ||
i == Nif::NiTexturingProperty::DetailTexture ||
i == Nif::NiTexturingProperty::DarkTexture ||
i == Nif::NiTexturingProperty::BumpTexture ||
i == Nif::NiTexturingProperty::GlowTexture)
continue;
@ -358,15 +365,19 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
if (vertexColour)
instance->setProperty("has_vertex_colour", sh::makeProperty(new sh::BooleanValue(true)));
// Add transparency if NiAlphaProperty was present
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName[0]);
if (result.first)
// Override alpha flags based on our override list (transparency-overrides.cfg)
if (!texName[0].empty())
{
alphaFlags = (1<<9) | (6<<10); /* alpha_rejection enabled, greater_equal */
alphaTest = result.second;
depthFlags = (1<<0) | (1<<1); // depth_write on, depth_check on
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName[0]);
if (result.first)
{
alphaFlags = (1<<9) | (6<<10); /* alpha_rejection enabled, greater_equal */
alphaTest = result.second;
depthFlags = (1<<0) | (1<<1); // depth_write on, depth_check on
}
}
// Add transparency if NiAlphaProperty was present
if((alphaFlags&1))
{
std::string blend_mode;

@ -8,12 +8,15 @@ material openmw_objects_base
diffuseMap black.png
normalMap
emissiveMap
darkMap
use_emissive_map false
use_detail_map false
use_diffuse_map false
use_dark_map false
emissiveMapUVSet 0
detailMapUVSet 0
diffuseMapUVSet 0
darkMapUVSet 0
use_parallax false
scene_blend default
@ -37,9 +40,11 @@ material openmw_objects_base
emissiveMapUVSet $emissiveMapUVSet
detailMapUVSet $detailMapUVSet
diffuseMapUVSet $diffuseMapUVSet
darkMapUVSet $darkMapUVSet
emissiveMap $emissiveMap
detailMap $detailMap
diffuseMap $diffuseMap
darkMap $darkMap
env_map $env_map
env_map_color $env_map_color
use_parallax $use_parallax
@ -70,12 +75,13 @@ material openmw_objects_base
num_mipmaps 4
}
texture_unit emissiveMap
texture_unit darkMap
{
create_in_ffp $use_emissive_map
colour_op add
direct_texture $emissiveMap
tex_coord_set $emissiveMapUVSet
create_in_ffp $use_dark_map
colour_op_ex modulate src_current src_texture
alpha_op_ex modulate src_current src_texture
direct_texture $darkMap
tex_coord_set $darkMapUVSet
}
texture_unit detailMap
@ -86,6 +92,14 @@ material openmw_objects_base
tex_coord_set $detailMapUVSet
}
texture_unit emissiveMap
{
create_in_ffp $use_emissive_map
colour_op add
direct_texture $emissiveMap
tex_coord_set $emissiveMapUVSet
}
texture_unit envMap
{
create_in_ffp $env_map

@ -18,13 +18,14 @@
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
#define DETAIL_MAP @shPropertyHasValue(detailMap)
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
#define DARK_MAP @shPropertyHasValue(darkMap)
#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) || @shPropertyString(diffuseMapUVSet))
#define SECOND_UV_SET (@shPropertyString(emissiveMapUVSet) || @shPropertyString(detailMapUVSet) || @shPropertyString(diffuseMapUVSet) || @shPropertyString(darkMapUVSet))
// if normal mapping is enabled, we force pixel lighting
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
@ -255,14 +256,18 @@
shSampler2D(normalMap)
#endif
#if EMISSIVE_MAP
shSampler2D(emissiveMap)
#if DARK_MAP
shSampler2D(darkMap)
#endif
#if DETAIL_MAP
shSampler2D(detailMap)
#endif
#if EMISSIVE_MAP
shSampler2D(emissiveMap)
#endif
#if ENV_MAP
shSampler2D(envMap)
shUniform(float3, env_map_color) @shUniformProperty3f(env_map_color, env_map_color)
@ -388,16 +393,24 @@
#else
float4 diffuse = float4(1,1,1,1);
#endif
shOutputColour(0) = diffuse;
#if DETAIL_MAP
#if @shPropertyString(detailMapUVSet)
shOutputColour(0) *= shSample(detailMap, newUV.zw)*2;
diffuse *= shSample(detailMap, newUV.zw)*2;
#else
diffuse *= shSample(detailMap, newUV.xy)*2;
#endif
#endif
#if DARK_MAP
#if @shPropertyString(darkMapUVSet)
diffuse *= shSample(darkMap, newUV.zw);
#else
shOutputColour(0) *= shSample(detailMap, newUV.xy)*2;
diffuse *= shSample(darkMap, newUV.xy);
#endif
#endif
shOutputColour(0) = diffuse;
#if !VERTEX_LIGHTING
float3 viewPos = shMatrixMult(worldView, float4(objSpacePositionPassthrough.xyz,1)).xyz;

Loading…
Cancel
Save