Support separate specular maps

actorid
scrawl 11 years ago
parent 90b55c8d4b
commit d97615d5d8

@ -8,6 +8,7 @@ material openmw_objects_base
diffuseMap black.png
normalMap
emissiveMap
specMap
darkMap
use_emissive_map false
use_detail_map false
@ -44,6 +45,7 @@ material openmw_objects_base
emissiveMap $emissiveMap
detailMap $detailMap
diffuseMap $diffuseMap
specMap $specMap
darkMap $darkMap
env_map $env_map
env_map_color $env_map_color
@ -107,6 +109,11 @@ material openmw_objects_base
anim_texture2 textures\magicitem\caust.dds 32 2
colour_op add
}
texture_unit specMap
{
direct_texture $specMap
}
texture_unit shadowMap0
{

@ -14,11 +14,14 @@
#define NEED_DEPTH
#endif
#define SPECULAR 1
#define NORMAL_MAP @shPropertyHasValue(normalMap)
#define EMISSIVE_MAP @shPropertyHasValue(emissiveMap)
#define DETAIL_MAP @shPropertyHasValue(detailMap)
#define DIFFUSE_MAP @shPropertyHasValue(diffuseMap)
#define DARK_MAP @shPropertyHasValue(darkMap)
#define SPEC_MAP @shPropertyHasValue(specMap) && SPECULAR
#define PARALLAX @shPropertyBool(use_parallax)
#define PARALLAX_SCALE 0.04
@ -38,8 +41,6 @@
#define ENV_MAP @shPropertyBool(env_map)
#define SPECULAR 1
#define NEED_NORMAL (!VERTEX_LIGHTING || ENV_MAP) || SPECULAR
#ifdef SH_VERTEX_SHADER
@ -273,6 +274,10 @@
shUniform(float3, env_map_color) @shUniformProperty3f(env_map_color, env_map_color)
#endif
#if SPEC_MAP
shSampler2D(specMap)
#endif
#if ENV_MAP || SPECULAR || PARALLAX
shUniform(float3, cameraPosObjSpace) @shAutoConstant(cameraPosObjSpace, camera_position_object_space)
#endif
@ -511,8 +516,20 @@
float NdotL = max(dot(normal, light0Dir), 0);
float3 halfVec = normalize (light0Dir + eyeDir);
float3 specular = pow(max(dot(normal, halfVec), 0), matShininess) * lightSpec0 * matSpec;
shOutputColour(0).xyz += specular * shadow * diffuse.a;
float shininess = matShininess;
#if SPEC_MAP
float4 specTex = shSample(specMap, UV.xy);
shininess *= (specTex.a);
#endif
float3 specular = pow(max(dot(normal, halfVec), 0), shininess) * lightSpec0 * matSpec;
#if SPEC_MAP
specular *= specTex.xyz;
#else
specular *= diffuse.a;
#endif
shOutputColour(0).xyz += specular * shadow;
#endif
#if FOG

Loading…
Cancel
Save