68 lines
2.1 KiB
Plaintext
68 lines
2.1 KiB
Plaintext
{
|
|
parms {
|
|
stageSort sortLight
|
|
}
|
|
state {
|
|
blend GL_ONE GL_ONE
|
|
depthfunc GL_LEQUAL
|
|
depthmask
|
|
}
|
|
hlsl_vp {
|
|
#include "includes/vertex.inc"
|
|
|
|
CALC_TEXCOORDS( result.texcoord0 );
|
|
float4 position;
|
|
float4 normal;
|
|
float4 tangent;
|
|
float3 worldPosition;
|
|
CALC_PNT( position, normal, tangent );
|
|
CALC_SKINNED_POSITION_NORMALS( result.position, result.texcoord1, result.texcoord2, result.texcoord3, result.texcoord4, position, normal, tangent, worldPosition );
|
|
}
|
|
hlsl_fp {
|
|
|
|
#include "includes/vmtr.inc"
|
|
|
|
half4 sampleSpecular;
|
|
half4 sampleNormal;
|
|
half3 fromViewerN;
|
|
half3 globalNormal;
|
|
half4 globalReflection;
|
|
half4 color;
|
|
|
|
sampleSpecular = tex2D( $spareSpecularMap, fragment.texcoord0.xy );
|
|
sampleNormal = tex2D( $spareBumpMap, fragment.texcoord0.xy );
|
|
|
|
half3 specular = sampleSpecular.xyz;
|
|
half power = 1.0;
|
|
|
|
CALC_FROM_VIEWER( fromViewerN, fragment.texcoord4.xyz );
|
|
CALC_GLOBAL_NORMAL( globalNormal, sampleNormal, fragment.texcoord1.xyz, fragment.texcoord2.xyz, fragment.texcoord3.xyz );
|
|
CALC_GLOBAL_REFLECTION( globalReflection, globalNormal, fromViewerN );
|
|
|
|
APPLY_SPECULAR_REFLECTION( specular, power, globalReflection );
|
|
{
|
|
half3 cameraLightV = normalize( -fragment.texcoord4.xyz + half3( 0.0, 0.0, 6.5 ) );
|
|
half cameraDot = saturate( dot3( globalNormal, cameraLightV ) );
|
|
specular += _half3( saturate( pow( cameraDot, $eyeHighlightPowLevel.x ) * $eyeHighlightPowLevel.y ) );
|
|
}
|
|
APPLY_SCALING_SPECULAR( specular );
|
|
|
|
{
|
|
half primeLightFactor = saturate( dot3( $primeLightDir, globalNormal ) - 0.2 );
|
|
half3 primeLight = $primeLightColor.xyz * primeLightFactor;
|
|
half3 channelLight =
|
|
+ max( globalNormal.x * $channelLight0.xyz, 0 )
|
|
+ max( -globalNormal.x * $channelLight1.xyz, 0 )
|
|
+ max( globalNormal.y * $channelLight2.xyz, 0 )
|
|
+ max( -globalNormal.y * $channelLight3.xyz, 0 )
|
|
+ max( globalNormal.z * $channelLight4.xyz, 0 )
|
|
+ max( -globalNormal.z * $channelLight5.xyz, 0 );
|
|
half3 light = primeLight + channelLight;
|
|
|
|
color.xyz = light * specular;
|
|
color.w = 0.0;
|
|
}
|
|
|
|
result.color = color;
|
|
}
|
|
} |