@GG if you really want to check it out that would be awesome! With the shader on the scale limb texture command has no effect whatsoever, and with the shader turned off I get what the screenshot above shows, unless I use set object texture, which doesn't work with the shader on.
Here's the full code:
set dir "c:\limbs\"
set window off
set display mode 1024, 768, 32, 1
Sync on
Sync Rate 60
REM for evolved normal shader
#constant LIGHTPOSITION 1
#constant LIGHTCOLOR 2
REM for evolved normal shader
hide mouse
load effect "shader/Relief.fx",1,0
rem set effect technique 1, "Light1"
rem make player light for evolved's shader
null = make vector4(LIGHTPOSITION)
null = make vector4(LIGHTCOLOR)
set vector4 LIGHTCOLOR, 1.2, 1.2, 1.0, 0.0
set effect constant vector 1, "LightColor", LIGHTCOLOR
set effect constant float 1, "LightRange", 5210.0
rem make player light for evolved's shader
load object "limbs2.dbo", 1
perform checklist for object limbs 1
load image "rockwall.png", 1
load image "rockwall_NRM.png", 2
load image "rockwall_HGHT.png", 3
load image "limbs0.png", 4
scale limb texture 1, 2, 0, 500, 500
scale limb texture 1, 2, 2, 500, 500
scale limb texture 1, 2, 3, 500, 500
texture object 1, 1, 4
texture limb 1, 2, 0, 1
texture limb 1, 2, 2, 2
texture limb 1, 2, 3, 3
set object effect 1, 1
position object 1, 0, 0, 0
position camera 0, 0, 0
do
REM set light to camera position in realtime
set vector4 LIGHTPOSITION, camera position x(), camera position y(), camera position z(), 0.0
set effect constant vector 1, "LightPosition", LIGHTPOSITION
REM set light to camera position in realtime
If KeyState( 17 )
Move Camera 0, 1
EndIf
If KeyState( 30 )
yrotate camera wrapvalue(camera angle y()-90) : move camera 1 : yrotate camera wrapvalue(camera angle y()+90)
EndIf
If KeyState( 31 )
Move Camera -1
EndIf
If KeyState( 32 )
yrotate camera wrapvalue(camera angle y()+90) : move camera 1 : yrotate camera wrapvalue(camera angle y()-90)
EndIf
yrotate camera wrapvalue( camera angle y() + mousemovex() / 4.0 )
xrotate camera wrapvalue( camera angle x() + mousemovey() / 4.0 )
sync
loop
And here's the shader I'm using which works with light maps:
//====================================================
// Relief Mapping
//====================================================
// By EVOLVED
// www.evolved-software.com
//====================================================
// Modified by Xystus to acept Darklights lightmaps
//--------------
// un-tweaks
//--------------
matrix WorldVP:WorldViewProjection;
matrix World:World;
matrix ViewInv:ViewInverse;
//--------------
// tweaks
//--------------
float3 Ambient={0.5f,0.5f,0.5f};
float3 LightPosition={150.0f,150.0f,0.0f};
float3 LightColor={1.0f,1.0f,1.0f};
float LightRange=200.0f;
float SpecularPow=32.0f;
float depth=0.03;
float4 FogColor={0.8f,0.8f,0.8f,1.0f};
float FogRange=250000.0f;
float Alpha=1.0f;
//--------------
// Textures
//--------------
texture BaseTX <string Name="";>;
sampler2D Base = sampler_state
{
texture = <BaseTX>;
};
texture LightTX <string Name="";>;
sampler2D Lighting = sampler_state
{
texture = <LightTX>;
};
texture NormalTX <string Name="";>;
sampler2D Normal = sampler_state
{
texture = <NormalTX>;
};
texture HeightMTX <string Name="";>;
sampler2D HeightM = sampler_state
{
texture = <HeightMTX>;
};
//--------------
// structs
//--------------
struct input
{
float4 Pos:POSITION;
float2 UV:TEXCOORD0;
float2 UV1:TEXCOORD1;
float3 Normal:NORMAL;
float3 Tangent:TANGENT;
float3 Binormal:BINORMAL;
};
struct output
{
float4 OPos:POSITION;
float2 Tex:TEXCOORD0;
float2 LM:TEXCOORD1;
float3 LightVec:TEXCOORD2;
float3 Attenuation:TEXCOORD3;
float3 ViewVec:TEXCOORD4;
float3 ViewPos:TEXCOORD5;
float3 VNormal:TEXCOORD6;
float Fog:FOG;
};
//--------------
// vertex shader
//--------------
output VS(input IN)
{
output OUT;
OUT.OPos=mul(IN.Pos,WorldVP);
OUT.Tex=IN.UV;
OUT.LM=IN.UV1*float2(1.0,1.0);
float3x3 TBN={IN.Tangent,IN.Binormal,IN.Normal};
TBN=transpose(mul(TBN,World));
float3 WPos=mul(IN.Pos,World);
float3 LightPos=LightPosition-WPos;
float3 ViewPos=ViewInv[3].xyz-WPos;
OUT.LightVec=mul(LightPos,TBN);
OUT.Attenuation=-LightPos/LightRange;
OUT.ViewVec=mul(ViewPos,TBN);
OUT.ViewPos=-ViewPos;
OUT.VNormal=mul(IN.Normal,World);
OUT.Fog=1-saturate(dot(ViewPos/FogRange,ViewPos/FogRange));
return OUT;
}
//--------------
// pixel shader
//--------------
float GetDepth(in float2 Uv,in float2 Displace)
{
float Height=0.0;
float depth=1.0;
float Inc=0.125f;
for( int i=0;i<8;i++ )
{
Height+=Inc;
float HeightTex=1-tex2D(HeightM,Uv+Displace*Height);
if (depth>0.995)
if (Height>=HeightTex) depth=Height;
}
Height=depth;
for( int i=0;i<4;i++ )
{
Inc*=0.5;
float HeightTex=1-tex2D(HeightM,Uv+Displace*Height);
if (Height>=HeightTex)
{
depth=Height;
Height-=2*Inc;
}
Height=Height+Inc;
}
return depth;
}
float4 PS(output IN) : COLOR
{
float2 Uv=IN.Tex;
float3 View=normalize(IN.ViewVec);
float ViewN=dot(IN.VNormal,normalize(IN.ViewPos));
float2 Displace=((View*depth)/ViewN).xy;
float Ray=GetDepth(Uv,Displace);
float2 NewUv=(Uv+Displace*Ray);
float4 Texture=tex2D(Base,NewUv);
float4 LightMap=(tex2D(Lighting,IN.LM)*2);
float3 NormalMap=tex2D(Normal,NewUv)*2-1;
NormalMap=normalize(NormalMap);
float3 LightV=normalize(IN.LightVec);
float Normal=saturate(dot(reflect(-View,NormalMap),LightV));
Normal=pow(Normal,SpecularPow)+saturate(dot(NormalMap,LightV));
float PixelLight=1-saturate(dot(IN.Attenuation,IN.Attenuation));
float3 Light=PixelLight*LightColor;
return float4(Texture*((Normal*Light)+(Ambient*LightMap)),Texture.w*Alpha);
}
//--------------
// techniques
//--------------
technique Relief
{
pass p1
{
vertexShader = compile vs_2_0 VS();
pixelShader = compile ps_2_a PS();
FOGCOLOR=(FogColor);
FOGENABLE=TRUE;
}
}
And the model is posted above in post #5.
http://mattsmith.carbonmade.com/