glprogs:
interaction.vfp and test.vfp posted below:
interaction.vfp
test.vfp:
these go in the glprogs folder, try them out and see.
these are modified .vfp's to get the extra gloss effect.
and are used for post processing.
of course make backups first
before testing!
edit:
you'll notice in your posted .vfp its a Custom Blinn-Phong Lighting Model (Isotropic)
where this one is a Cook-Torrance Lighting Model w/ Relief Mapping (Isotropic)
however it needs the modified test.vfp to work in tandem as they wont work without the other to have the gloss render properly.
it may or may not have issues with ATI cards but on Nvidia it works great.
interaction.vfp and test.vfp posted below:
interaction.vfp
Code Select
###==============================================================================
# Doom 3 Interaction Vertex/Fragment Program
#
# Cook-Torrance Lighting Model w/ Relief Mapping (Isotropic)
###==============================================================================
#
# --------------------------------------
# input:
#
# attrib[8] = texture coordinates
# attrib[9] = global tangent
# attrib[10] = global bitangent
# attrib[11] = global normal
#
# env[0] = diffuse modifier
# env[1] = specular modifier
# env[2] = ?
# env[3] = ?
# env[4] = localLightOrigin
# env[5] = localViewOrigin
# env[6] = lightProjection S
# env[7] = lightProjection T
# env[8] = lightProjection Q
# env[9] = lightFalloff S
# env[10] = bumpMatrix S
# env[11] = bumpMatrix T
# env[12] = diffuseMatrix S
# env[13] = diffuseMatrix T
# env[14] = specularMatrix S
# env[15] = specularMatrix T
# env[16] = vertex color modulate
# env[17] = vertex color add
#
#--------------------------------------
# output:
#
# texture 0 = normalization cube map
# texture 1 = per-surface normal map
# texture 2 = 1D light falloff texture
# texture 3 = 2D light projection texture
# texture 4 = per-surface diffuse map
# texture 5 = per-surface specular map
# texture 6 = specular lookup table
#
#--------------------------------------
###==============================================================================
!!ARBvp1.0
OPTION ARB_position_invariant;
# Instruction Count: 25
PARAM defaultTexCoord = { 0.0, 0.5, 0.0, 1.0 };
PARAM projMatrix[4] = { state.matrix.projection };
TEMP R0;
# calculate vector to light in R0
SUB R0, program.env[4], vertex.position;
# put into texture space for TEX0
DP3 result.texcoord[0].x, vertex.attrib[9], R0;
DP3 result.texcoord[0].y, vertex.attrib[10], R0;
DP3 result.texcoord[0].z, vertex.attrib[11], R0;
# texture 1 takes the base coordinates by the texture matrix
MOV result.texcoord[1], defaultTexCoord;
DP4 result.texcoord[1].x, vertex.attrib[8], program.env[10];
DP4 result.texcoord[1].y, vertex.attrib[8], program.env[11];
# texture 2 has one texgen
MOV result.texcoord[2], defaultTexCoord;
DP4 result.texcoord[2].x, vertex.position, program.env[9];
# texture 3 has three texgens
DP4 result.texcoord[3].x, vertex.position, program.env[6];
DP4 result.texcoord[3].y, vertex.position, program.env[7];
DP4 result.texcoord[3].w, vertex.position, program.env[8];
# texture 4 takes the base coordinates by the texture matrix
MOV result.texcoord[4], defaultTexCoord;
DP4 result.texcoord[4].x, vertex.attrib[8], program.env[12];
DP4 result.texcoord[4].y, vertex.attrib[8], program.env[13];
# texture 5 takes the base coordinates by the texture matrix
MOV result.texcoord[5], defaultTexCoord;
DP4 result.texcoord[5].x, vertex.attrib[8], program.env[14];
DP4 result.texcoord[5].y, vertex.attrib[8], program.env[15];
# calculate vector to viewer in R0
SUB R0, program.env[5], vertex.position;
# put into texture space for TEX6
DP3 result.texcoord[6].x, vertex.attrib[9], R0;
DP3 result.texcoord[6].y, vertex.attrib[10], R0;
DP3 result.texcoord[6].z, vertex.attrib[11], R0;
# transform world space normal vector
DP3 result.texcoord[7].x, vertex.attrib[9], projMatrix[2];
DP3 result.texcoord[7].y, vertex.attrib[10], projMatrix[2];
DP3 result.texcoord[7].z, vertex.attrib[11], projMatrix[2];
# generate the vertex color, which can be 1.0, color, or 1.0 - color
# for 1.0 : env[16] = 0.0, env[17] = 1.0
# for color : env[16] = 1.0, env[17] = 0.0
# for 1.0 - color : env[16] = -1.0, env[17] = 1.0
MAD result.color, vertex.color, program.env[16], program.env[17];
END
#==================================================================================
!!ARBfp1.0
OPTION ARB_precision_hint_fastest;
# Instruction Count: ALU: 145 TEX: 27 Total: 172
OUTPUT oColor = result.color;
ATTRIB vColor = fragment.color;
ATTRIB lightVecTC = fragment.texcoord[0];
ATTRIB normalTC = fragment.texcoord[1];
ATTRIB lightFallTC = fragment.texcoord[2];
ATTRIB lightProjTC = fragment.texcoord[3];
ATTRIB diffuseTC = fragment.texcoord[4];
ATTRIB specularTC = fragment.texcoord[5];
ATTRIB viewVecTC = fragment.texcoord[6];
ATTRIB wNormal = fragment.texcoord[7];
PARAM lightColor = program.env[0];
PARAM constval = { 1.0, 2.0, 4.0, 5.0 };
PARAM constval2 = { 0.125, 0.25, 0.5, 0.75 };
PARAM grayscale = { 0.3, 0.59, 0.11 };
PARAM hemiLight = { 0.25, 0.25, -1.0 };
PARAM skyColor = { 0.5, 0.5, 0.5 };
PARAM grndColor = { 1.0, 1.0, 1.0 };
PARAM epsilon = { 1.0, 0.0, 0.0 };
PARAM specParm = { 0.2, 0.1, 0.425 };
PARAM e = { 2.7182818284590452353602874713527 };
PARAM reliefParm = { 0.0425, 0.0625 };
TEMP RT;
TEMP lightVec, viewVec, halfVec, normalVec, wNormalVec;
TEMP diffuse, specular, gloss, color, ambient;
TEMP light, hemi, atten, rim, lightFall, lightProj;
TEMP geometric, roughness, fresnel;
TEMP NdotA, NdotL, NdotV, NdotH, VdotH, VdotL;
TEMP R1, R2;
#[FPO] relief mapping: view vector with depth factor
###======================================================================
DP3 viewVec, viewVecTC, viewVecTC;
RSQ viewVec, viewVec.x;
MUL viewVec, viewVec.x, viewVecTC;
RCP R1.x, viewVec.z; # R1 = 1.0 / viewVec.z
MUL viewVec.xy, viewVec, reliefParm.x; # viewVec.xy *= depth
MUL viewVec, viewVec, -R1.x; # viewVec *= -R1
MUL viewVec, viewVec, reliefParm.y; # viewVec /= 16.0
MOV RT, normalTC; # RT = texcoord
MOV RT.z, constval.x; # RT.z = 1.0
#[FPO] relief mapping: linear search (15 steps)
###======================================================================
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MAD RT, viewVec, R2.w, RT; # RT += viewVec;
#[FPO] relief mapping: binary search (6 steps)
###======================================================================
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
MUL viewVec, viewVec, constval2.z; # viewVec *= 0.5
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MUL R2, viewVec, R2.w; #
MAD RT, R2, constval.y, RT; # RT += viewVec * 2;
SUB RT, RT, viewVec; # RT -= viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
MUL viewVec, viewVec, constval2.z; # viewVec *= 0.5
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MUL R2, viewVec, R2.w; #
MAD RT, R2, constval.y, RT; # RT += viewVec * 2;
SUB RT, RT, viewVec; # RT -= viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
MUL viewVec, viewVec, constval2.z; # viewVec *= 0.5
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MUL R2, viewVec, R2.w; #
MAD RT, R2, constval.y, RT; # RT += viewVec * 2;
SUB RT, RT, viewVec; # RT -= viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
MUL viewVec, viewVec, constval2.z; # viewVec *= 0.5
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MUL R2, viewVec, R2.w; #
MAD RT, R2, constval.y, RT; # RT += viewVec * 2;
SUB RT, RT, viewVec; # RT -= viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
MUL viewVec, viewVec, constval2.z; # viewVec *= 0.5
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MUL R2, viewVec, R2.w;
MAD RT, R2, constval.y, RT; # RT += viewVec * 2;
SUB RT, RT, viewVec; # RT -= viewVec;
TEX R1, RT, texture[5], 2D; # R1 = tex(RT)
MUL viewVec, viewVec, constval2.z; # viewVec *= 0.5
SLT R2.w, R1.w, RT.z; # if ( R1.w < RT.z )
MUL R2, viewVec, R2.w; #
MAD RT, R2, constval.y, RT; # RT += viewVec * 2;
SUB RT, RT, viewVec; # RT -= viewVec;
###======================================================================
# calculate texcoords for diffuse and specular maps
SUB R1, diffuseTC, normalTC;
SUB R2, specularTC, normalTC;
ADD R1, R1, RT;
ADD R2, R2, RT;
# load texture maps
TEX ambient, lightVecTC, texture[0], CUBE;
TEX normalVec, RT, texture[1], 2D;
TXP lightFall, lightFallTC, texture[2], 2D;
TXP lightProj, lightProjTC, texture[3], 2D;
TEX diffuse, R1, texture[4], 2D;
TEX gloss, R2, texture[5], 2D;
# normalize the vector to the light
DP3 lightVec.x, lightVecTC, lightVecTC;
RSQ lightVec.x, lightVec.x;
MUL lightVec.xyz, lightVec.x, lightVecTC;
# normalize the vector to the viewer
DP3 viewVec.x, viewVecTC, viewVecTC;
RSQ viewVec.x, viewVec.x;
MUL viewVec.xyz, viewVec.x, viewVecTC;
# calculate the half angle vector and normalize
ADD halfVec, lightVec, viewVec;
DP3 R1.x, halfVec, halfVec;
RSQ R1.x, R1.x;
MUL halfVec.xyz, halfVec, R1.x;
# scale normal vector to -1.0<->1.0 range and normalize
MAD normalVec.xyz, normalVec.wyzx, constval.y, -constval.x;
DP3 R1.x, normalVec, normalVec;
RSQ R1.x, R1.x;
MUL normalVec.xyz, normalVec, R1.x;
# transform surface normal into world space
XPD R1, wNormal, epsilon;
XPD R2, wNormal, R1;
DP3 wNormalVec.x, normalVec, R1;
DP3 wNormalVec.y, normalVec, R2;
DP3 wNormalVec.z, normalVec, wNormal;
# calculate vector dot products
DP3 NdotL.x, normalVec, lightVec;
DP3 NdotV.x, normalVec, viewVec;
DP3 NdotH.x, normalVec, halfVec;
DP3 VdotH.x, viewVec, halfVec;
DP3_SAT VdotL.x, viewVec, -lightVec;
# calculate roughness parm using specular map
DP3 R1.x, gloss, grayscale;
SUB R1.x, constval.x, R1.x;
MAD R1.x, R1.x, specParm.x, specParm.y;
# calculate microfacet distribution term (Beckmann Distribution)
MAX NdotH.x, NdotH.x, 0.00001; # sikk - Ambient lighting fix
MUL R1.z, R1.x, R1.x;
POW R1.x, NdotH.x, constval.z;
MUL R1.y, R1.z, constval.z;
MUL R1.x, R1.x, R1.y;
RCP roughness.x, R1.x;
MUL R1.x, NdotH.x, NdotH.x;
SUB R1.y, constval.x, R1.x;
MUL R1.x, R1.x, R1.z;
RCP R1.x, R1.x;
MUL R1.x, R1.x, R1.y;
POW roughness.y, e.x, -R1.x;
MUL roughness.w, roughness.x, roughness.y;
# calculate geometric attenuation term
MUL R1.x, NdotH.x, constval.y;
RCP R1.y, VdotH.x;
MUL geometric.x, R1.x, NdotV.x;
MUL geometric.y, R1.x, NdotL.x;
MUL geometric.x, geometric.x, R1.y;
MUL geometric.y, geometric.y, R1.y;
MIN geometric.w, geometric.x, geometric.y;
MIN geometric.w, geometric.w, constval.x;
# calculate Fresnel term (Schlick approximation)
SUB_SAT R1.x, constval.x, NdotV.x;
POW fresnel.x, R1.x, constval.w;
LRP fresnel.w, specParm.z, constval.x, fresnel.x;
# calculate final specular term
MUL R1.x, roughness.w, geometric.w;
MUL R1.x, R1.x, fresnel.w;
MUL R1.y, NdotV.x, NdotL.x;
RCP R1.y, R1.y;
MUL specular, R1.x, R1.y;
# modulate specular by gloss map and add diffuse color
MAD color, specular, gloss, diffuse;
# calculate self shadowing
MAD_SAT R1.x, normalVec.z, lightVec.z, constval2.x;
MUL_SAT R1.x, R1.x, constval.z;
MUL light, R1.x, NdotL.x;
# calculate hemisphere lighting ambient term
DP3 hemi.x, wNormalVec, hemiLight;
MAD hemi.x, hemi.x, constval2.z, constval2.z;
LRP hemi, hemi.x, skyColor, grndColor;
SUB R1.x, ambient.w, constval2.w;
CMP light, R1.x, hemi, light;
# calculate attenuation using the light falloff and projection maps
MUL atten, lightFall, lightProj;
# modulate light by attenuation
MUL light, light, atten;
# rim light
MUL_SAT rim, fresnel.x, VdotL.x;
ADD color, color, rim;
# modulate by light and light color
MUL color, color, light;
MUL color, color, lightColor;
# modify by the vertex color
MUL oColor.xyz, color, vColor;
END
test.vfp:
Code Select
###==============================================================================
# Doom 3 Interaction Vertex/Fragment Program
#
# Blinn-Phong Lighting Model w/ Parallax Occlusion Mapping (Isotropic)
###==============================================================================
#
# --------------------------------------
# input:
#
# attrib[8] = texture coordinates
# attrib[9] = global tangent
# attrib[10] = global bitangent
# attrib[11] = global normal
#
# env[0] = diffuse modifier
# env[1] = specular modifier
# env[2] = ?
# env[3] = ?
# env[4] = localLightOrigin
# env[5] = localViewOrigin
# env[6] = lightProjection S
# env[7] = lightProjection T
# env[8] = lightProjection Q
# env[9] = lightFalloff S
# env[10] = bumpMatrix S
# env[11] = bumpMatrix T
# env[12] = diffuseMatrix S
# env[13] = diffuseMatrix T
# env[14] = specularMatrix S
# env[15] = specularMatrix T
# env[16] = vertex color modulate
# env[17] = vertex color add
#
#--------------------------------------
# output:
#
# texture 0 = normalization cube map
# texture 1 = per-surface normal map
# texture 2 = 1D light falloff texture
# texture 3 = 2D light projection texture
# texture 4 = per-surface diffuse map
# texture 5 = per-surface specular map
# texture 6 = specular lookup table
#
#--------------------------------------
###==============================================================================
!!ARBvp1.0
OPTION ARB_position_invariant;
# Instruction Count: 25
PARAM defaultTexCoord = { 0.0, 0.5, 0.0, 1.0 };
PARAM hemiLightVec = { 0.25, 0.25, -1.0 };
TEMP R0;
# calculate vector to light in R0
SUB R0, program.env[4], vertex.position;
# put into texture space for TEX0
DP3 result.texcoord[0].x, vertex.attrib[9], R0;
DP3 result.texcoord[0].y, vertex.attrib[10], R0;
DP3 result.texcoord[0].z, vertex.attrib[11], R0;
# texture 1 takes the base coordinates by the texture matrix
MOV result.texcoord[1], defaultTexCoord;
DP4 result.texcoord[1].x, vertex.attrib[8], program.env[10];
DP4 result.texcoord[1].y, vertex.attrib[8], program.env[11];
# texture 2 has one texgen
MOV result.texcoord[2], defaultTexCoord;
DP4 result.texcoord[2].x, vertex.position, program.env[9];
# texture 3 has three texgens
DP4 result.texcoord[3].x, vertex.position, program.env[6];
DP4 result.texcoord[3].y, vertex.position, program.env[7];
DP4 result.texcoord[3].w, vertex.position, program.env[8];
# texture 4 takes the base coordinates by the texture matrix
MOV result.texcoord[4], defaultTexCoord;
DP4 result.texcoord[4].x, vertex.attrib[8], program.env[12];
DP4 result.texcoord[4].y, vertex.attrib[8], program.env[13];
# texture 5 takes the base coordinates by the texture matrix
MOV result.texcoord[5], defaultTexCoord;
DP4 result.texcoord[5].x, vertex.attrib[8], program.env[14];
DP4 result.texcoord[5].y, vertex.attrib[8], program.env[15];
# calculate vector to viewer in R0
SUB R0, program.env[5], vertex.position;
# put into texture space for TEX6
DP3 result.texcoord[6].x, vertex.attrib[9], R0;
DP3 result.texcoord[6].y, vertex.attrib[10], R0;
DP3 result.texcoord[6].z, vertex.attrib[11], R0;
# put hemi-light vector into texture space for TEX7
DP3 result.texcoord[7].x, vertex.attrib[9], hemiLightVec;
DP3 result.texcoord[7].y, vertex.attrib[10], hemiLightVec;
DP3 result.texcoord[7].z, vertex.attrib[11], hemiLightVec;
# generate the vertex color, which can be 1.0, color, or 1.0 - color
# for 1.0 : env[16] = 0.0, env[17] = 1.0
# for color : env[16] = 1.0, env[17] = 0.0
# for 1.0 - color : env[16] = -1.0, env[17] = 1.0
MAD result.color, vertex.color, program.env[16], program.env[17];
END
#==================================================================================
!!ARBfp1.0
OPTION ARB_precision_hint_fastest;
# Instruction Count: ALU: 129 TEX: 32 Total: 161
OUTPUT oColor = result.color;
ATTRIB vColor = fragment.color;
ATTRIB lightVecTC = fragment.texcoord[0];
ATTRIB normalTC = fragment.texcoord[1];
ATTRIB lightFallTC = fragment.texcoord[2];
ATTRIB lightProjTC = fragment.texcoord[3];
ATTRIB diffuseTC = fragment.texcoord[4];
ATTRIB specularTC = fragment.texcoord[5];
ATTRIB viewVecTC = fragment.texcoord[6];
ATTRIB hemiLight = fragment.texcoord[7];
PARAM lightColor = program.env[0];
PARAM specColor = program.env[1];
PARAM const = { 1.0, 2.0, 4.0, 5.0 };
PARAM const2 = { 0.25, 0.5, 0.75, 0.1 };
PARAM skyColor = { 0.5, 0.5, 0.5 };
PARAM grndColor = { 1.0, 1.0, 1.0 };
PARAM lumVec = { 0.212671, 0.715160, 0.072169 };
PARAM specExp = { 64.0, 0.00001 };
PARAM Scale = 0.0625;
PARAM Steps = 16.0;
PARAM invSteps = 0.0625;
PARAM ssStrength = 3.0;
TEMP lightVec, viewVec, halfVec, normalVec;
TEMP diffuse, specular, gloss, color, ambient, shadow;
TEMP light, hemi, atten, lightFall, lightProj;
TEMP NdotL, NdotV, NdotH, VdotL;
TEMP TC, shadowTC, delta, delta0, delta1, H0, H1;
TEMP R1, R2;
# normalize the vector to the viewer
DP3 viewVec.w, viewVecTC, viewVecTC;
RSQ viewVec.w, viewVec.w;
MUL viewVec.xyz, viewVecTC, viewVec.w;
# normalize the vector to the light
DP3 lightVec.w, lightVecTC, lightVecTC;
RSQ lightVec.w, lightVec.w;
MUL lightVec.xyz, lightVecTC, lightVec.w;
###======================================================================
# parallax occlusion mapping: linear search (16 steps)
###======================================================================
MUL R1.xy, viewVec, Scale;
MUL R1.z, -viewVec.z, Steps;
RCP R1.z, R1.z;
MUL delta.xy, R1, R1.z;
MOV delta.z, -invSteps;
TEX H0, specularTC, texture[5], 2D;
ADD TC, specularTC, delta;
MOV TC.z, 0.9375; # 1.0 - invSteps
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
TEX H1, TC, texture[5], 2D;
SLT R1.x, H1.w, TC.z;
CMP H0, -R1.x, H1.w, H0.w;
MAD TC, R1.x, delta, TC;
###======================================================================
# parallax occlusion mapping: intersection calculation
###======================================================================
MOV R1.y, TC.z;
ADD R1.x, R1.y, invSteps;
ADD delta0, R1.x, -H0.w;
ADD delta1, R1.y, -H1.w;
MUL R2.x, R1.y, delta0;
MAD R2.x, R1.x, delta1, -R2.x;
ADD R2.y, delta1, -delta0;
RCP R2.y, R2.y;
MUL R2, R2.x, R2.y;
MUL R1.xy, delta, Steps;
MAD R1.zw, delta.xyxy, Steps, specularTC.xyxy;
MAD TC, -R2, R1.xyxy, R1.zwzw;
###======================================================================
# self shadowing
###======================================================================
MUL delta.xy, lightVec, Scale;
TEX H0, TC, texture[5], 2D;
MAD shadowTC, delta, 1.0, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, 0.0, R1.w;
MAD shadowTC, delta, 0.875, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
MAD shadowTC, delta, 0.750, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
MAD shadowTC, delta, 0.625, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
MAD shadowTC, delta, 0.500, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
MAD shadowTC, delta, 0.375, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
MAD shadowTC, delta, 0.250, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
MAD shadowTC, delta, 0.125, TC;
TEX R1, shadowTC, texture[5], 2D;
MAX H1, H1, R1.w;
ADD R1, H1, -H0.w;
MAD_SAT shadow, R1, -ssStrength, 1.0;
###======================================================================
# calculate texcoords for diffuse and specular maps
SUB R1, diffuseTC, specularTC;
SUB R2, normalTC, specularTC;
ADD R1, R1, TC;
ADD R2, R2, TC;
# load texture maps
TEX ambient, lightVecTC, texture[0], CUBE;
TEX normalVec, R2, texture[1], 2D;
TXP lightFall, lightFallTC, texture[2], 2D;
TXP lightProj, lightProjTC, texture[3], 2D;
TEX diffuse, R1, texture[4], 2D;
TEX gloss, TC, texture[5], 2D;
# calculate the half angle vector and normalize
ADD halfVec, lightVec, viewVec;
DP3 R1.x, halfVec, halfVec;
RSQ R1.x, R1.x;
MUL halfVec.xyz, halfVec, R1.x;
# scale normal vector to -1.0<->1.0 range and normalize
MAD normalVec.xyz, normalVec.wyzx, const.y, -const.x;
DP3 R1.x, normalVec, normalVec;
RSQ R1.x, R1.x;
MUL normalVec.xyz, normalVec, R1.x;
# calculate vector dot products
DP3 NdotL.x, normalVec, lightVec;
DP3 NdotV.x, normalVec, viewVec;
DP3_SAT NdotH.x, normalVec, halfVec;
DP3_SAT VdotL.x, viewVec, -lightVec;
# calculate specular exp using specular map
DP3 R1.x, gloss, lumVec;
MAD R1.x, R1.x, specExp.x, specExp.y;
MUL R1.x, R1.x, const.z;
# calculate specular term
POW specular, NdotH.x, R1.x;
# scale the specular map * 2
MUL gloss, gloss, const.y;
# modulate specular by gloss map and add diffuse color
MAD color, specular, gloss, diffuse;
# calculate self shadowing
ADD R1.x, lightVec.z, const2.x;
MUL_SAT R1.x, R1.x, const.z;
MUL light, R1.x, NdotL.x;
# calculate hemisphere lighting ambient term
DP3 hemi.x, normalVec, hemiLight;
MAD hemi.x, hemi.x, const2.z, const2.z;
LRP hemi, hemi.x, skyColor, grndColor;
SUB R1.x, ambient.w, const2.z;
CMP light, R1.x, hemi, light;
CMP shadow, R1.x, const.x, shadow;
# calculate attenuation using the light falloff and projection maps
MUL atten, lightFall, lightProj;
# modulate light by attenuation
MUL light, light, atten;
# modulate by light and light color
MUL color, color, light;
MUL color, color, lightColor;
MUL color, color, shadow;
# modify by the vertex color
MUL oColor.xyz, color, vColor;
END
these go in the glprogs folder, try them out and see.
these are modified .vfp's to get the extra gloss effect.
and are used for post processing.
of course make backups first

edit:
you'll notice in your posted .vfp its a Custom Blinn-Phong Lighting Model (Isotropic)
where this one is a Cook-Torrance Lighting Model w/ Relief Mapping (Isotropic)
however it needs the modified test.vfp to work in tandem as they wont work without the other to have the gloss render properly.
it may or may not have issues with ATI cards but on Nvidia it works great.