Infinite Procedural Terrain Engine

Ah. I had wondered about their name. Anyways I’m following your suggestions but my fshader is getting correct brightness values, but not the height of the terrain. Oddly it used to get the correct terrain height before I started messing with the semantics. I’ll just post the whole shader here.
EDIT: updated code

struct vfconn
{
    float2 l_texcoord0 : TEXCOORD0;
    float2 l_texcoord3 : TEXCOORD3;
    float4 l_position  : POSITION;
    float2 l_slope_brightness: TEXCOORD2;
    float3 l_mpos;//      : FOG;
    //float3 l_normal;
};

vfconn vshader( in float4 vtx_position : POSITION,
	      in float3 vtx_normal : NORMAL,
              in float2 vtx_texcoord0 : TEXCOORD0,
              in float2 vtx_texcoord3 : TEXCOORD3,
              in uniform float4x4 mat_modelproj,
	      in uniform float4x4 trans_model_to_world,
	      in uniform float4 k_lightvec,
	      in uniform float4 k_lightcolor,
	      in uniform float4 k_ambientlight,
	      in uniform float4 k_tscale
          //out vfconn OUT
            )
{
    vfconn OUT;

    OUT.l_position=mul(mat_modelproj,vtx_position);
    OUT.l_texcoord0=vtx_texcoord0*k_tscale;
    OUT.l_texcoord3=vtx_texcoord3;

    // worldspace position, for clipping in the fragment shader
    OUT.l_mpos = mul(trans_model_to_world, vtx_position);

    // lighting
    //WTF IS THIS NECESSARY
    vtx_normal.x *= -400;
    vtx_normal.y *= -400;
    //k_lightvec.z /= 400;
    float3 N = normalize( vtx_normal );
    float3 L = normalize( k_lightvec.xyz );

    float3 UP = float3(0,0,1);
    OUT.l_slope_brightness.x = 1.0 - dot( N, UP );

    OUT.l_slope_brightness.y = (max( dot( -N, L ), 0.0f )*k_lightcolor)+k_ambientlight;
    //OUT.l_normal = N;
    return OUT;
}

float calculateWeight( float value, float max, float min )
{
    if (value > max)
        return 0.0;
    if (value < min)
        return 0.0;

    //return 1.0;

    float weight = 0.0;

    weight = value - min < max - value ?
             value - min : max - value;

    //weight /= max - min;
    //weight *= weight;
    //weight = log2( weight );
    //weight = sqrt( weight );

    weight+= 0.001;
    //weight = clamp(weight, 0.001, 1.0);
    return weight;
}

float calculateFinalWeight( float height, float slope, float4 limits )
{
    return calculateWeight(height, limits.x, limits.y)
           //* calculateWeight(0.4, limits.z, limits.a);
           * calculateWeight(slope, limits.z, limits.a);
}

void fshader( in  vfconn IN,
              in uniform float4 region1Limits : REGION1LIMITS,
              in uniform float4 region2Limits : REGION2LIMITS,
              in uniform float4 region3Limits : REGION3LIMITS,
              in uniform float4 region4Limits : REGION4LIMITS,
              in uniform float4 k_waterlevel  : WATERLEVEL,
              in uniform sampler2D region1ColorMap : TEXUNIT0,
              in uniform sampler2D region2ColorMap : TEXUNIT1,
              in uniform sampler2D region3ColorMap : TEXUNIT2,
              in uniform sampler2D region4ColorMap : TEXUNIT3,
              in uniform sampler2D detailTexture   : TEXUNIT4,
              out float4 o_color : COLOR )
{
    // clipping
    //if ( IN.l_mpos.z < k_waterlevel.z) discard;

    //unpack some input
    // 0 = horizontal 1 = vertical 
    float slope = IN.l_slope_brightness.x; //0.45;
    float brightness = IN.l_slope_brightness.y;
    //float slope = abs( l_slope );
    //float3 vertical = normalize(float3(0.0, 0.0, 1.0));
    //float slope =  1 - abs( dot( normalize(IN.normal), vertical) );
    float height = IN.l_mpos.z;

    vec4 weights = float4(0.0, 0.0, 0.0, 0.0);
    vec4 terrainColor = float4(0.0, 0.0, 0.0, 1.0);

    weights.x = calculateFinalWeight(height, slope, region1Limits);
    weights.y = calculateFinalWeight(height, slope, region2Limits);
    weights.z = calculateFinalWeight(height, slope, region3Limits);
    weights.a = calculateFinalWeight(height, slope, region4Limits);

    //--- Color terrain proportionately to weights
    float normalizer = (weights.x + weights.y + weights.z + weights.a + 0.000001);

    if (weights.x)
        terrainColor += weights.x / normalizer * tex2D(region1ColorMap, IN.l_texcoord0);
    if (weights.y)
        terrainColor += weights.y / normalizer * tex2D(region2ColorMap, IN.l_texcoord0);
    if (weights.z)
        terrainColor += weights.z / normalizer * tex2D(region3ColorMap, IN.l_texcoord0);
    if (weights.a)
        terrainColor += weights.a / normalizer * tex2D(region4ColorMap, IN.l_texcoord0);

    // detail texture
    float2 detailTexCoord= IN.l_texcoord0*8.0;
    terrainColor*= tex2D(detailTexture, detailTexCoord);
    // alpha splatting and lighting
    o_color=terrainColor*(brightness);
    //HDRL
    o_color = (o_color*o_color + o_color) / (o_color*o_color + o_color + float4(1.0, 1.0, 1.0, 1.0));
    o_color.a=1.0;
}

Once this is working I’m certain my terrain will look great. I guess I’ve gotten ahead of myself in the shader learning process though.