mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-25 15:11:33 +00:00
Implement DarkTexture slot. Fix an issue with incorrect transparency override when base texture is empty.
This commit is contained in:
parent
0050e6e67b
commit
e68e2f82a2
3 changed files with 55 additions and 17 deletions
|
@ -324,6 +324,7 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
|
||||||
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("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]));
|
||||||
|
instance->setProperty("darkMap", sh::makeProperty(texName[Nif::NiTexturingProperty::DarkTexture]));
|
||||||
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)));
|
||||||
|
@ -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("use_detail_map", sh::makeProperty(new sh::BooleanValue(true)));
|
||||||
instance->setProperty("detailMapUVSet", sh::makeProperty(new sh::IntValue(texprop->textures[Nif::NiTexturingProperty::DetailTexture].uvSet)));
|
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()
|
bool useParallax = !texName[Nif::NiTexturingProperty::BumpTexture].empty()
|
||||||
&& texName[Nif::NiTexturingProperty::BumpTexture].find("_nh.") != std::string::npos;
|
&& 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 ||
|
if(i == Nif::NiTexturingProperty::BaseTexture ||
|
||||||
i == Nif::NiTexturingProperty::DetailTexture ||
|
i == Nif::NiTexturingProperty::DetailTexture ||
|
||||||
|
i == Nif::NiTexturingProperty::DarkTexture ||
|
||||||
i == Nif::NiTexturingProperty::BumpTexture ||
|
i == Nif::NiTexturingProperty::BumpTexture ||
|
||||||
i == Nif::NiTexturingProperty::GlowTexture)
|
i == Nif::NiTexturingProperty::GlowTexture)
|
||||||
continue;
|
continue;
|
||||||
|
@ -358,7 +365,9 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
|
||||||
if (vertexColour)
|
if (vertexColour)
|
||||||
instance->setProperty("has_vertex_colour", sh::makeProperty(new sh::BooleanValue(true)));
|
instance->setProperty("has_vertex_colour", sh::makeProperty(new sh::BooleanValue(true)));
|
||||||
|
|
||||||
// Add transparency if NiAlphaProperty was present
|
// Override alpha flags based on our override list (transparency-overrides.cfg)
|
||||||
|
if (!texName[0].empty())
|
||||||
|
{
|
||||||
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName[0]);
|
NifOverrides::TransparencyResult result = NifOverrides::Overrides::getTransparencyOverride(texName[0]);
|
||||||
if (result.first)
|
if (result.first)
|
||||||
{
|
{
|
||||||
|
@ -366,7 +375,9 @@ Ogre::String NIFMaterialLoader::getMaterial(const Nif::ShapeData *shapedata,
|
||||||
alphaTest = result.second;
|
alphaTest = result.second;
|
||||||
depthFlags = (1<<0) | (1<<1); // depth_write on, depth_check on
|
depthFlags = (1<<0) | (1<<1); // depth_write on, depth_check on
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add transparency if NiAlphaProperty was present
|
||||||
if((alphaFlags&1))
|
if((alphaFlags&1))
|
||||||
{
|
{
|
||||||
std::string blend_mode;
|
std::string blend_mode;
|
||||||
|
|
|
@ -8,12 +8,15 @@ material openmw_objects_base
|
||||||
diffuseMap black.png
|
diffuseMap black.png
|
||||||
normalMap
|
normalMap
|
||||||
emissiveMap
|
emissiveMap
|
||||||
|
darkMap
|
||||||
use_emissive_map false
|
use_emissive_map false
|
||||||
use_detail_map false
|
use_detail_map false
|
||||||
use_diffuse_map false
|
use_diffuse_map false
|
||||||
|
use_dark_map false
|
||||||
emissiveMapUVSet 0
|
emissiveMapUVSet 0
|
||||||
detailMapUVSet 0
|
detailMapUVSet 0
|
||||||
diffuseMapUVSet 0
|
diffuseMapUVSet 0
|
||||||
|
darkMapUVSet 0
|
||||||
use_parallax false
|
use_parallax false
|
||||||
|
|
||||||
scene_blend default
|
scene_blend default
|
||||||
|
@ -37,9 +40,11 @@ material openmw_objects_base
|
||||||
emissiveMapUVSet $emissiveMapUVSet
|
emissiveMapUVSet $emissiveMapUVSet
|
||||||
detailMapUVSet $detailMapUVSet
|
detailMapUVSet $detailMapUVSet
|
||||||
diffuseMapUVSet $diffuseMapUVSet
|
diffuseMapUVSet $diffuseMapUVSet
|
||||||
|
darkMapUVSet $darkMapUVSet
|
||||||
emissiveMap $emissiveMap
|
emissiveMap $emissiveMap
|
||||||
detailMap $detailMap
|
detailMap $detailMap
|
||||||
diffuseMap $diffuseMap
|
diffuseMap $diffuseMap
|
||||||
|
darkMap $darkMap
|
||||||
env_map $env_map
|
env_map $env_map
|
||||||
env_map_color $env_map_color
|
env_map_color $env_map_color
|
||||||
use_parallax $use_parallax
|
use_parallax $use_parallax
|
||||||
|
@ -70,12 +75,13 @@ material openmw_objects_base
|
||||||
num_mipmaps 4
|
num_mipmaps 4
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_unit emissiveMap
|
texture_unit darkMap
|
||||||
{
|
{
|
||||||
create_in_ffp $use_emissive_map
|
create_in_ffp $use_dark_map
|
||||||
colour_op add
|
colour_op_ex modulate src_current src_texture
|
||||||
direct_texture $emissiveMap
|
alpha_op_ex modulate src_current src_texture
|
||||||
tex_coord_set $emissiveMapUVSet
|
direct_texture $darkMap
|
||||||
|
tex_coord_set $darkMapUVSet
|
||||||
}
|
}
|
||||||
|
|
||||||
texture_unit detailMap
|
texture_unit detailMap
|
||||||
|
@ -86,6 +92,14 @@ material openmw_objects_base
|
||||||
tex_coord_set $detailMapUVSet
|
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
|
texture_unit envMap
|
||||||
{
|
{
|
||||||
create_in_ffp $env_map
|
create_in_ffp $env_map
|
||||||
|
|
|
@ -18,13 +18,14 @@
|
||||||
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
|
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
|
||||||
#define DETAIL_MAP @shPropertyHasValue(detailMap)
|
#define DETAIL_MAP @shPropertyHasValue(detailMap)
|
||||||
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
|
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
|
||||||
|
#define DARK_MAP @shPropertyHasValue(darkMap)
|
||||||
|
|
||||||
#define PARALLAX @shPropertyBool(use_parallax)
|
#define PARALLAX @shPropertyBool(use_parallax)
|
||||||
#define PARALLAX_SCALE 0.04
|
#define PARALLAX_SCALE 0.04
|
||||||
#define PARALLAX_BIAS -0.02
|
#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
|
// 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
|
// if normal mapping is enabled, we force pixel lighting
|
||||||
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
|
#define VERTEX_LIGHTING (!@shPropertyHasValue(normalMap))
|
||||||
|
@ -255,14 +256,18 @@
|
||||||
shSampler2D(normalMap)
|
shSampler2D(normalMap)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EMISSIVE_MAP
|
#if DARK_MAP
|
||||||
shSampler2D(emissiveMap)
|
shSampler2D(darkMap)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if DETAIL_MAP
|
#if DETAIL_MAP
|
||||||
shSampler2D(detailMap)
|
shSampler2D(detailMap)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if EMISSIVE_MAP
|
||||||
|
shSampler2D(emissiveMap)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if ENV_MAP
|
#if ENV_MAP
|
||||||
shSampler2D(envMap)
|
shSampler2D(envMap)
|
||||||
shUniform(float3, env_map_color) @shUniformProperty3f(env_map_color, env_map_color)
|
shUniform(float3, env_map_color) @shUniformProperty3f(env_map_color, env_map_color)
|
||||||
|
@ -388,16 +393,24 @@
|
||||||
#else
|
#else
|
||||||
float4 diffuse = float4(1,1,1,1);
|
float4 diffuse = float4(1,1,1,1);
|
||||||
#endif
|
#endif
|
||||||
shOutputColour(0) = diffuse;
|
|
||||||
|
|
||||||
#if DETAIL_MAP
|
#if DETAIL_MAP
|
||||||
#if @shPropertyString(detailMapUVSet)
|
#if @shPropertyString(detailMapUVSet)
|
||||||
shOutputColour(0) *= shSample(detailMap, newUV.zw)*2;
|
diffuse *= shSample(detailMap, newUV.zw)*2;
|
||||||
#else
|
#else
|
||||||
shOutputColour(0) *= shSample(detailMap, newUV.xy)*2;
|
diffuse *= shSample(detailMap, newUV.xy)*2;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if DARK_MAP
|
||||||
|
#if @shPropertyString(darkMapUVSet)
|
||||||
|
diffuse *= shSample(darkMap, newUV.zw);
|
||||||
|
#else
|
||||||
|
diffuse *= shSample(darkMap, newUV.xy);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
shOutputColour(0) = diffuse;
|
||||||
|
|
||||||
#if !VERTEX_LIGHTING
|
#if !VERTEX_LIGHTING
|
||||||
float3 viewPos = shMatrixMult(worldView, float4(objSpacePositionPassthrough.xyz,1)).xyz;
|
float3 viewPos = shMatrixMult(worldView, float4(objSpacePositionPassthrough.xyz,1)).xyz;
|
||||||
|
|
Loading…
Reference in a new issue