For an editor project, I created a terrain multitexturing shader, which I tweaked so that it looks like the GS terrain. It is sort of a hack but was the easiest way for me to achieve the same look.

First, I calculated the per vertex lighting in the Vertex Shader. I wrote a small Color Correction function, for which I found nice values by trial-and-error:

Code:
// ambient
Out.Color = fAmbient;

// add sunlight and up to 8 dynamic lights
for (int i = 0; i < 8; i++)
{
    float f = 0.0f;
    float d = dot(N, normalize(vecLightPos[i].xyz - P));
    if (d >= 0.f) 
        f = 2 * d * lightAttenuation(vecLightPos[i], P);
    
    Out.Color += vecLightColor[i] * f;
}

// color correction (contrast, saturation, brightness)
Out.Color.rgb = ColorCorrection(Out.Color.rgb, 0.5f, 1.0f, 2.5f);



The light attenuation function is this:

Code:
float lightAttenuation (float4 lightPos, float3 surfacePos)
{
    float fac = 0.f;
    
    if (lightPos.w > 0.f)
    {    
        float l = length(lightPos.xyz - surfacePos) / lightPos.w;
        if (l < 1.f)
            fac = saturate(1.f - l);
    }
    
    return fac;
}



and the Color Correction function is this (if I remember right, I posted this here some time ago):

Code:
// Simple color correction; adjusts contrast, saturation and brightness of a RGB color
float3 ColorCorrection (float3 color, float contrast, float saturation, float brightness)
{
    // color for 0% contrast (mean color intensity)
    float3 meanLuminosity = float3(0.5, 0.5, 0.5);
    
    // coeefficients to convert to greyscale; coeeficients taken from OpenCV, which
    // were derived from 'Adrian Ford, Alan Roberts. Colour Space Conversions.', which
    // can be found here: http://www.poynton.com/PDFs/coloureq.pdf
    //
    float3 rgb2greyCoeff = float3(0.299, 0.587, 0.114);
    
    // enbrighten color
    float3 brightened = color * brightness;
    
    // approximate color intensity by transforming rgb to grey
    float intensity = dot(brightened, rgb2greyCoeff);		
    
    // saturate (brightended) color
    float3 saturated = lerp(float3(intensity, intensity, intensity), brightened, saturation);
    
    // apply contrast to saturated color
    float3 contrasted = lerp(meanLuminosity, saturated, contrast);
    
    return(contrasted);
}



In the Pixel Shader, I calculated my blended multitexture color and then, I just do:

Code:
color *= In.Color;



If you do this for a terrain, you should get a similar lighting like the GS terrain. I don't know exactly, but I guess this works for models, too. Just make sure you use the appropriate material properties from mtl_terrain, mtl_model or whatever you wanna re-create.

Good luck!

Last edited by HeelX; 08/20/12 19:39.