seems to be working...maybe you can help me with a problem... my texture is like this:


here is the code i'm using...just this applied as an action.
EDIT!: I replaced this code with the fixed version.

Code:
 //Matt_Aufderheide's modified ventilator shader

//Important! generate a normal map from your greyscale hightmap. You can do this via ATI's "TGAtoDOT3" tool
// it uses the models regular map as a clor map and the normal map as a bump
//here is the function i use to get the ight positions:

bmap zombiebump=<bumpmapDOT3.tga>;//normal map

function find_nearest_light()

{
temp.pan =360;
temp.tilt=360;
temp.z=3000;
you=scan_entity(my.x,temp);

if your.light==ON
{

temp.x = your.x;
temp.y = your.y;
temp.z = your.z;
my.skill41=float(temp.x);
my.skill42=float(temp.y);
my.skill43=float(temp.z);
my.skill44=float(1);

return ;
}
}


material mat_bumpmapping
{
skin2 = zombiebump;
flags = tangent;
effect =
"
texture texSkin1;
texture texSkin2;
matrix matWorldViewProj;
matrix matWorld;
matrix matWorldView;
vector vecSkill41;
vector vecFog;

technique bumpmapping
{
pass p0
{
Texture[0]=<texSkin1>;
Texture[1]=<texSkin2>;

VertexShaderConstant[0]=<matWorldViewProj>;
VertexShaderConstant[4]=<matWorld>;
VertexShaderConstant[8]=<matWorldView>;
VertexShaderConstant[16]=<vecSkill41>;
VertexShaderConstant[17]=<vecFog>;
VertexShaderConstant[95]=(0.5f,0.0f,0.0f,0.0f);


VertexShader=
decl
{
stream 0;
float v0[3]; //position
float v3[3]; //normal
float v7[3]; //uv
float v8[3]; //tangent
}
asm
{
vs.1.1

m4x4 oPos,v0,c0
mov oT0,v7
mov oT1,v7

m3x3 r5,v8,c4 // transform tangent to world space
m3x3 r7,v3,c4 // transform normal to world space

mul r0,r5.zxyw,-r7.yzxw // tangent x normal -> binormal
mad r6,r5.yzxw,-r7.zxyw,-r0

// dp3 r8.x,r5,-c16 // transform light vector to texture space
// dp3 r8.y,r6,-c16
// dp3 r8.z,r7,-c16
// mad oD0.xyz,r8.xyz,c95.x,c95.x

//new code for point lights

m4x4 r10,v0,c4 // transform position to world space
sub r10,v0,c16 // lightdir=vertexpos-lightpos
dp3 r10.w,r10,r10 // renormalize it
rsq r10.w,r10.w
mul r10,r10,r10.w

dp3 r8.x,r5,r10 // transform light vector to texture space
dp3 r8.y,r6,r10
dp3 r8.z,r7,r10
mad oD0.xyz,r8.xyz,c95.x,c95.x


mov r1.w,c17.w // r1.w=1
dp4 r0,v0,c10 // distance to camera position
add r0,r0,-c17.x // distance-fog_start
mad r0.x,-r0.x,c17.z,r1.w // 1-(distance-fog_start)*(1/(fog_end-fog_start))
max oFog.x,r0.x,c95.w // clamp with custom max value

};

PixelShader=
asm
{
ps.1.3
tex t0 // sample colormap
tex t1 // sample normalmap
dp3_sat r1,t1_bx2,v0_bx2 // normal . light


mul r0,t0,r1 // modulate against base color

};
}
}
";
}

action Shaders_Bump
{
//bmap_to_normals(bmap_for_entity(my,10),16); //1,16 convert the bumpmap to a normal map with scale factor 16
my.material=mat_bumpmapping;
//... // causes error but leave it here
my.pan=random(360); //rotate for testing
my.tilt=random(360); //rotate for testing
my.roll=random(360); //rotate for testing
while(1) { //rotate for testing
my.pan+=sin(my.tilt)/2*time; //rotate for testing
my.tilt+=cos(my.roll)/2*time; //rotate for testing
my.roll+=sin(my.pan)/2*time; //rotate for testing
wait(1); //rotate for testing
}
}



Last edited by Dr. Jelly; 10/26/03 16:32.

Drew Medina
Game Developer (Artist)
Personal & professional website
Deviant Art
My Blogspot