sorry, i was never able to post a video, if you want to see it though it's implemented in our game, PreVa, here's a video of the game that shows the shader off (on the mechs and some buildings)

Here is the video

to get a better understanding of the shader(s), just apply them to a model, the cubemapping shader is this one: Cube Mapping shader with Alpha as a glossmap

by the way here's the updated code (with the cubemapping shader using alpha as a gloss map):

Code:

float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f};

// Application fed data:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldInv;

float4 vecAmbient;
float4 vecLightPos;
float4 vecLight;
float vecLightColor;
float3 vecViewDir;
float3 vecViewPos;

float4 vecFog;

texture entSkin1;
texture entSkin2;

samplerCUBE CubeMapSampler = sampler_state
{
Texture=<entSkin2>;
};
sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};

void SpecularCubeVS(in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutTexCube : TEXCOORD1,
out float3 OutNormal: TEXCOORD2,
out float3 OutViewDir: TEXCOORD3,
out float Fog_out : FOG)
{
OutPos = mul(InPos, matWorldViewProj);

OutNormal = normalize(mul(InNormal,matWorld));

OutViewDir = mul(InPos, matWorld);

OutTex = InTex;

float3 V = normalize(vecViewDir);
float3 N = normalize(mul(InNormal, matWorld));
OutTexCube = reflect(V,N);

//Fog
Fog_out = 1 - (distance(OutViewDir, vecViewPos) - vecFog.x) * (vecFog.z);
}


float4 SpecularCubePS( in float2 InTex : TEXCOORD0,
in float3 InTexCube : TEXCOORD1,
in float3 InNormal : TEXCOORD2,
in float4 InViewDir : TEXCOORD3) : COLOR
{
InNormal = normalize(InNormal);
float4 Ambient = vecLight;

float4 Diffuse = saturate(dot(vecLightColor, InNormal));

float4 texColor = tex2D(ColorMapSampler, InTex);
float4 cubeColor = texCUBE(CubeMapSampler, InTexCube);
float4 Color = lerp(texColor, cubeColor, 1 - texColor.a);

float3 R = normalize(2 * dot(InNormal, vecLightColor + SpecularIntensity) * InNormal - SpecularIntensity);

InViewDir = vecLightColor + SpecularIntensity *vecLight;

float Specular = saturate(dot(R, InViewDir));
return (Ambient + Diffuse + Specular) * Color;
}

technique SpecularCubeTechnique
{
pass P0
{
AlphaBlendEnable = False;
ZWriteEnable = True;
VertexShader = compile vs_2_0 SpecularCubeVS();
PixelShader = compile ps_2_0 SpecularCubePS();
}
}



here's the one without the cube mapping:

Code:

float4 SpecularIntensity = {2.0f, 2.0f, 2.0f, 2.0f};

// Application fed data:
float4x4 matWorldViewProj;
float4x4 matWorld;
float4x4 matWorldInv;

float4 vecAmbient;
float4 vecLightPos;
float4 vecLight;
float vecLightColor;
float3 vecViewDir;
float3 vecViewPos;

float4 vecFog;

texture entSkin1;

sampler ColorMapSampler = sampler_state
{
Texture = <entSkin1>;
AddressU = Clamp;
AddressV = Clamp;
};

void SpecularCubeVS(in float4 InPos : POSITION,
in float3 InNormal : NORMAL,
in float2 InTex : TEXCOORD0,

out float4 OutPos : POSITION,
out float2 OutTex : TEXCOORD0,
out float3 OutNormal: TEXCOORD2,
out float3 OutViewDir: TEXCOORD3,
out float Fog_out : FOG)
{
OutPos = mul(InPos, matWorldViewProj);

OutNormal = normalize(mul(InNormal,matWorld));

OutViewDir = mul(InPos, matWorld);

OutTex = InTex;

float3 V = normalize(vecViewDir);
float3 N = normalize(mul(InNormal, matWorld));

//Fog
Fog_out = 1 - (distance(OutViewDir, vecViewPos) - vecFog.x) * (vecFog.z);
}


float4 SpecularCubePS( in float2 InTex : TEXCOORD0,
in float3 InTexCube : TEXCOORD1,
in float3 InNormal : TEXCOORD2,
in float4 InViewDir : TEXCOORD3) : COLOR
{
InNormal = normalize(InNormal);
float4 Ambient = vecLight;

float4 Diffuse = saturate(dot(vecLightColor, InNormal));

float4 Color = tex2D(ColorMapSampler, InTex);

float3 R = normalize(2 * dot(InNormal, vecLightColor + SpecularIntensity) * InNormal - SpecularIntensity);

InViewDir = vecLightColor + SpecularIntensity *vecLight;

float Specular = saturate(dot(R, InViewDir));
return (Ambient + Diffuse + Specular) * Color;
}

technique SpecularTechnique
{
pass P0
{
VertexShader = compile vs_2_0 SpecularCubeVS();
PixelShader = compile ps_2_0 SpecularCubePS();
}
}



i regret that i never got it working with dynamic lights as i wanted...


- aka Manslayer101