can someone tell me how to fix this problem i wanted to replicate doom 3 texturing but when i finished all textures and applied them to the model, i get this result
all textures are 256x256 and are only half of the face like in doom 3.
this is the shader
//------------------------------------------------
// ParallaxMapping with Specular mask and Emissive
//------------------------------------------------
// By Evolved
// http://www.evolved-software.com/
// Modified by Revenant_Chaos (Again)
//------------------------------------------
//-----------------
// un-tweaks
//-----------------
matrix WorldVP : WorldViewProjection;
matrix World : World;
matrix ViewInv : ViewInverse;
//-----------------
// tweaks
//-----------------
float4 Ambient = {0.0f, 0.0f, 0.0f, 0.0f};
float4 LightPosition_1 = {150.0f, 0.0f,150.0f, 1.0f};
float4 LightColor_1 = {1.0f, 1.0f, 1.0f, 1.0f};
float LightRange_1 = 500.0f;
float U = 1.0f;
float V = 1.0f;
float SpecularPow = 16.0f;
float EmissPower = 1.0f;
float SpecBright = 1.0f;
float Heightvec = 0.03f;
float BiasHeight = 0.1f;
//-----------------
// Textures
//-----------------
texture BaseTX
<
string Name="";
>;
sampler2D Base = sampler_state
{
texture = <BaseTX>;
};
texture NormalTX
<
string Name="";
>;
sampler2D Normal = sampler_state
{
texture = <NormalTX>;
};
texture HeightTX
<
string Name="";
>;
sampler2D Height = sampler_state
{
texture = <HeightTX>;
};
texture SpecTX
<
string Name="";
>;
sampler2D SpecMap = sampler_state
{
texture = <SpecTX>;
};
texture EmissiveTX
<
string Name="";
>;
sampler2D EmissiveMap = sampler_state
{
texture = <EmissiveTX>;
};
//-----------------
// structs
//-----------------
struct input
{
float4 Pos:POSITION;
float2 UV:TEXCOORD;
float3 Normal:NORMAL;
float3 Tangent:TANGENT;
float3 Binormal:BINORMAL;
};
struct output
{
float4 OPos:POSITION;
float2 Tex:TEXCOORD0;
float3 LightVec:TEXCOORD1;
float3 Attenuation:TEXCOORD2;
float3 ViewVec:TEXCOORD3;
};
//-----------------
// vertex shader
//-----------------
output VS(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV*float2(U,V);
OUT.LightVec=0;
OUT.Attenuation=0;
float3 WNor=mul(IN.Normal,World); WNor=normalize(WNor);
float3 Wtan=mul(IN.Tangent,World); Wtan=normalize(Wtan);
float3 Wbin=mul(IN.Binormal,World); Wbin=normalize(Wbin);
float3 WPos=mul(IN.Pos,World);
float3x3 TBN={Wtan,Wbin,WNor}; TBN=transpose(TBN);
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.ViewVec=mul(ViewPos,TBN);
return OUT;
}
output VS_L1(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV*float2(U,V);
float3 WNor=mul(IN.Normal,World); WNor=normalize(WNor);
float3 Wtan=mul(IN.Tangent,World); Wtan=normalize(Wtan);
float3 Wbin=mul(IN.Binormal,World); Wbin=normalize(Wbin);
float3 WPos=mul(IN.Pos,World);
float3x3 TBN={Wtan,Wbin,WNor}; TBN=transpose(TBN);
float3 LightPos=LightPosition_1-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange_1;
OUT.ViewVec=mul(ViewPos,TBN);
return OUT;
}
//-----------------
// pixel shader
//-----------------
float4 PS(output IN) : COLOR
{
float3 View=normalize(IN.ViewVec);
float HeightTex=tex2D(Height,IN.Tex).x+BiasHeight;
float2 NewUv=(Heightvec*HeightTex-0.02)*View+IN.Tex;
float4 Texture=tex2D(Base,NewUv);
float4 Emissive=tex2D(EmissiveMap,NewUv);
return (Texture*Ambient)+Emissive;
}
float4 PS_L1(output IN) : COLOR
{
float3 View=normalize(IN.ViewVec);
float HeightTex=tex2D(Height,IN.Tex).x+BiasHeight;
float2 NewUv=(Heightvec*HeightTex-0.02)*View+IN.Tex;
float4 Texture=tex2D(Base,NewUv);
float4 SpecTex=tex2D(SpecMap,NewUv);
float4 Emissive=tex2D(EmissiveMap,NewUv);
float3 NormalMap=tex2D(Normal,NewUv)*2-1;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(NormalMap,LightV));
float Specular=saturate(dot(reflect(-View,NormalMap),LightV));
Specular=pow(Specular,SpecularPow)*(SpecTex*SpecBright);
float4 DiffuseLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float4 Light=DiffuseLight*LightColor_1;
return (Texture*(((Normal+Specular)*Light)+Ambient))+(Emissive*EmissPower);
}
//-----------------
// techniques
//-----------------
technique Ambient
{
pass p1
{
vertexShader = compile vs_2_0 VS();
pixelShader = compile ps_2_0 PS();
}
}
technique Light1
{
pass p1
{
vertexShader = compile vs_2_0 VS_L1();
pixelShader = compile ps_2_0 PS_L1();
}
}
adn this is the code
sync on
set display mode 1024,768,32,1
set window position 0,0
hide light 0
backdrop on
Obj1 = 1
`make object cube Obj1,50
load object "head.x",Obj1
rotate object Obj1,0,90,0
position object Obj1,0,0,0
Diff = 1
load image "head_d.jpg",Diff,1
`load image "body_d.tga",Diff,1
Heig = 2
load image "head_h.jpg",Heig,1
`load image "body_h.tga",Heig,1
Norm = 3
load image "head_n.jpg",Norm,1
`load image "body_n.tga",Norm,1
Spec = 4
load image "head_s.jpg",Spec,1
`load image "body_s.tga",Spec,1
Emis = 5
load image "black.jpg",Emis,1
`load image "body_g.tga",Emis,1
texture object Obj1,0,Diff
texture object Obj1,1,Heig
texture object Obj1,2,Norm
texture object Obj1,3,Spec
texture object Obj1,4,Emis
load effect "dnhse.fx",1,1
set effect technique 1,"Light1"
set object effect Obj1,1
null=make vector4(1) : `Light Position
null=make vector4(2) : `Light Color
null=make vector4(3) : `Camera Position
Light1Red#=1.0
Light1Grn#=1.0
Light1Blu#=1.0
LightRange#=100000.0
SpecularPow#=1.0
SpecBright#=1.0
EmissPower#=0.2
Heigvec#=0.03
BiasHeig#=0.1
set vector4 2,Light1Red#,Light1Grn#,Light1Blu#,Light1Fall#
set effect constant vector 1,"LightColor_1",2
set effect constant float 1,"LightRange_1",LightRange#
set effect constant float 1,"SpecularPow",SpecularPow#
set effect constant float 1,"SpecBright",SpecBright#
set effect constant float 1,"EmissPower",EmissPower#
set effect constant float 1,"Heightvec",Heigvec#
set effect constant float 1,"BiasHeight",BiasHeig#
light1#=0.0
camera#=0.0
position camera 0,object position x(1)-50,object position y(1),object position z(1)-15
move camera 0,35
move camera up 0,25
set vector4 1,camera position x(0),camera position y(0),camera position z(0)-300,0.0
set effect constant vector 1,"LightPosition_1",1
while not escapekey()
text 10,10,"FPS : "+str$(screen fps())
if upkey()
inc EmissPower#,0.01
if EmissPower#>1.0 then EmissPower#=1.0
endif
if downkey()
dec EmissPower#,0.01
if EmissPower#<0.0 then EmissPower#=0.0
endif
if leftkey()
dec SpecularPow#,0.1
if SpecularPow#<1.0 then SpecularPow#=1.0
endif
if rightkey()
inc SpecularPow#,0.1
if SpecularPow#>100 then SpecularPow#=100
endif
if keystate(201)
inc SpecBright#,0.1
if SpecBright#>15.0 then SpecBright#=15.0
endif
if keystate(209)
dec SpecBright#,0.1
if SpecBright#<1.0 then SpecBright#=1.0
endif
if keystate(17)
inc Heigvec#,0.1
if Heigvec#>1.0 then Heigvec#=1.0
endif
if keystate(31)
dec Heigvec#,0.1
if Heigvec#<0.03 then Heigvec#=0.03
endif
if keystate(30)
inc BiasHeig#,0.1
if BiasHeig#>10.0 then BiasHeig#=10.0
endif
if keystate(32)
dec BiasHeig#,0.1
if BiasHeig#<0.1 then BiasHeig#=0.1
endif
text 10,25,"Emissive : "+str$(EmissPower#,2)+" down = decrease / up = increase"
text 10,40,"Specular : "+str$(SpecularPow#,2)+" left = decrease / right = increase"
text 10,55,"Spec Brite : "+str$(SpecBright#,2)+" pg dwn = decrease / pg up = increase"
text 10,70,"Height : "+str$(Heigvec#,2)+" s = decrease / w = increase"
text 10,85,"Bias Height : "+str$(BiasHeig#,2)+" a = decrease / d = increase"
set effect constant float 1,"SpecularPow",SpecularPow#
set effect constant float 1,"SpecBright",SpecBright#
set effect constant float 1,"EmissPower",EmissPower#
set effect constant float 1,"Heightvec",Heigvec#
set effect constant float 1,"BiasHeight",BiasHeig#
light1#=wrapvalue(light1#+0.25)
set vector4 1,sin(light1#)*450,25,cos(light1#)*450,0.0
`set vector4 1,camera position x(0),camera position y(0),camera position z(0),0.0
`set vector4 1,50,50,50,0.0
set effect constant vector 1,"LightPosition_1",1
`camera#=wrapvalue(camera#+0.5)
`set vector4 3,sin(camera#)*35,25,cos(camera#)*35,0.0
`position camera 0,x vector4(3),y vector4(3),z vector4(3)
point camera 0,object position x(1),object position y(1),object position z(1)
sync
endwhile
btw can someone modify this shader to use more then one light?