Here is the terrain cfg I am using (or trying to use)
Code: Select all
# WorldTexture=libnoise_color.png
# Heightmap source
PageSource=Heightmap
# Heightmap-source specific settings
Heightmap.image=terrain3.png
# How large is a page of tiles (in vertices)? Must be (2^n)+1
PageSize=513
# How large is each tile? Must be (2^n)+1 and be smaller than PageSize
TileSize=65
# The maximum error allowed when determining which LOD to use
MaxPixelError=1
# The size of a terrain page, in world units
PageWorldX=1500
PageWorldZ=1500
# Maximum height of the terrain
MaxHeight=150
# Upper LOD limit
MaxMipMapLevel=5
# The proportional distance range at which the LOD morph starts to take effect
# This is as a proportion of the distance between the current LODs effective range,
# and the effective range of the next lower LOD
LODMorphStart=0.2
# Use vertex program to morph LODs, if available
VertexProgramMorph=no
# Custom material. Does use vertex normals.
CustomMaterialName=terrain/SplattingShaderParallax_1_4
VertexNormals=yes
the material
Code: Select all
//
// SplattingShaderParallax_1_4.material for PLSM2
// Xavier Verguín González
// October 2007
//
// - 2 Coverage maps
// - 1 Parallax splatting texture / 4 diffuse splatting textures
// - 1 pass
//
vertex_program SplattingShaderParallax_1_4/VP cg
{
source SplattingShaderParallax_1_4.cg
entry_point main_vp
//target vs_2_0
profiles vs_1_1 arbvp1
}
fragment_program SplattingShaderParallax_1_4/FP cg
{
source SplattingShaderParallax_1_4.cg
entry_point main_fp
//target vs_2_0
profiles ps_2_0 arbfp1 fp20
}
material terrain/SplattingShaderParallax_1_4
{
technique
{
pass
{
vertex_program_ref SplattingShaderParallax_1_4/VP
{
param_named_auto uLightPosition light_position_object_space 0
param_named_auto uEyePosition camera_position_object_space
param_named_auto uWorldViewProj worldviewproj_matrix
}
fragment_program_ref SplattingShaderParallax_1_4/FP
{
param_named_auto uAmbient ambient_light_colour
//param_named_auto uLightDiffuse light_diffuse_colour 0
//param_named_auto uLightSpecular light_specular_colour 0
param_named uLightDiffuse float3 0.95 1 1
param_named uLightSpecular float3 0.6 0.6 0.6
// Parallax Height scale and bias
param_named uScaleBias float4 0.05 -0.02 1 0
}
texture_unit
{
texture alpha_1test.png
}
texture_unit
{
texture alpha_2.png
}
texture_unit
{
texture 512_sand.png
}
texture_unit
{
texture 512_sandGrass.png
}
texture_unit
{
texture 512_shortGrass.png
}
texture_unit
{
texture 512_sand.png
}
// Normal + height(alpha) map
texture_unit
{
texture 512_crackedDirtSandNormal.png
}
// Base diffuse texture map
texture_unit
{
texture 512_crackedDirtSand.png
}
// Base colour map
texture_unit
{
texture mymap_c.png
}
}
}
}
and the shader
Code: Select all
void main_vp(// IN
float4 iPosition : POSITION,
float3 iNormal : NORMAL,
float2 iUv : TEXCOORD0,
// OUT
out float4 oPosition : POSITION,
out float2 oUv : TEXCOORD0,
out float3 oLightDir : TEXCOORD1,
out float3 oEyeDir : TEXCOORD2,
out float3 oHalfAngle : TEXCOORD3,
// UNIFORM
uniform float4 uLightPosition,
uniform float3 uEyePosition,
uniform float4x4 uWorldViewProj)
{
oPosition = mul(uWorldViewProj, iPosition);
oUv = iUv;
float3 lightDir = normalize(uLightPosition.xyz - (iPosition * uLightPosition.w));
float3 eyeDir = uEyePosition - iPosition.xyz;
float3 binormal = cross(float3(1,0,0), iNormal);
float3 tangent = cross(iNormal, binormal);
float3x3 rotation = float3x3(tangent, binormal, iNormal);
lightDir = normalize(mul(rotation, lightDir));
eyeDir = normalize(mul(rotation, eyeDir));
oLightDir = lightDir;
oEyeDir = eyeDir;
oHalfAngle = normalize(eyeDir + lightDir);
}
// Expand a range-compressed vector
float3 expand(float3 v)
{
return (v - 0.5) * 2;
}
void main_fp(// IN
float2 iUv : TEXCOORD0,
float3 iLightDir : TEXCOORD1,
float3 iEyeDir : TEXCOORD2,
float3 iHalfAngle : TEXCOORD3,
// OUT
out float4 oColor : COLOR,
// UNIFORM
uniform float3 uLightDiffuse,
uniform float3 uLightSpecular,
uniform float4 uScaleBias,
uniform float3 uAmbient,
uniform sampler2D uCoverage1 : register(s0),
uniform sampler2D uCoverage2 : register(s1),
uniform sampler2D uSplatting0 : register(s2),
uniform sampler2D uSplatting1 : register(s3),
uniform sampler2D uSplatting2 : register(s4),
uniform sampler2D uSplatting3 : register(s5),
uniform sampler2D uNormalHeightMap : register(s6),
uniform sampler2D uDiffuseMap : register(s7),
uniform sampler2D uColourMap : register(s8))
{
// Get coverage values
float4 Coverage1 = tex2D(uCoverage1, iUv);
float Coverage2 = tex2D(uCoverage2, iUv).y;
float2 coverColourMap = iUv;
// Scale UV coord
float2 texscale = float2(300,300);
iUv *= texscale;
float4 col = float4(0,0,0,0);
if(Coverage1.x>0)
{
// Get the height from the alpha channel of normal-height tex.
float height = tex2D(uNormalHeightMap, iUv).a;
// Scale and bias factors
float scale = uScaleBias.x;
float bias = uScaleBias.y;
// Calculate displacement
float displacement = (height * scale) + bias;
float3 uv2 = float3(iUv, 1);
// Calculate the new tex coord to use for normal and diffuse
float2 newTexCoord = ((iEyeDir * displacement) + uv2).xy;
// Get the new normal and diffuse values
float3 normal = expand(tex2D(uNormalHeightMap, newTexCoord).xyz);
float3 diffuse = tex2D(uDiffuseMap, newTexCoord).xyz;
// Calculate specular and final pixel colour
float3 specular = pow(saturate(dot(normal, iHalfAngle)), 32) * uLightSpecular;
col = float4(diffuse * saturate(dot(normal, iLightDir)) * uLightDiffuse + specular, 1);
// Adjust the ambient value
float3 diffuse2 = diffuse*uAmbient;
if(col.x < diffuse2.x)
col.x += (diffuse2.x-col.x);
if(col.y < diffuse2.y)
col.y += (diffuse2.y-col.y);
if(col.z < diffuse2.z)
col.z += (diffuse2.z-col.z);
}
// Final pixel colour
oColor = col*Coverage1.x
+ ((tex2D(uSplatting0, iUv) * Coverage1.y
+ tex2D(uSplatting1, iUv) * Coverage1.z
+ tex2D(uSplatting2, iUv) * Coverage1.w
+ tex2D(uSplatting3, iUv) * Coverage2)
+ tex2D(uColourMap, coverColourMap.xy)-0.5) * float4(uAmbient, 1);
}
Well after a days work we now have a patcher, Registeration state (still a work in progress), User accounts (passwords are set from with in the player.cfg), When a client connects the server connects to a mysql database. Wish there was some way I could test how many people could be connected with the server being hosted on my computer. Maybe I will upload the client and post the link here so any one can download it. If any one is interested in helping to test it let me know!