Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualMedo3337

Posted 24 July 2013 - 12:41 AM

@belfegor: I have made modifications to correct the code, it works, but I notice that the terrain quality is not same, it's too bright.

 

Before, it was much better.

 

Why it got too bright? I want to get the same as the old results...

 

[attachment=16962:before_after.png]

 

Here is the shader code (Modified):

float4x4 World;
float4x4 WorldViewProj;

texture r0_tex;
sampler r0_samp  = sampler_state
{
    Texture     = <r0_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r1_tex;
sampler r1_samp  = sampler_state
{
    Texture     = <r1_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r2_tex;
sampler r2_samp  = sampler_state
{
    Texture     = <r2_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r3_tex;
sampler r3_samp  = sampler_state
{
    Texture     = <r3_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r4_tex;
sampler r4_samp  = sampler_state
{
    Texture     = <r4_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r5_tex;
sampler r5_samp  = sampler_state
{
    Texture     = <r5_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

struct VERTEX
{
    float3 Pos : POSITION;
    float2 TexCoord : TEXCOORD0;
    float3 Normal : NORMAL;
};

struct VS_OUTPUT
{
    float4 Pos : POSITION;
    float3 PosWorld : TEXCOORD0;
    float3 NormalWorld : TEXCOORD1;
    float2 TexCoord : TEXCOORD2;
};

VS_OUTPUT VertexProgram( VERTEX IN )
{
     VS_OUTPUT OUT;
     OUT = (VS_OUTPUT)0;
     OUT.Pos = mul( float4(IN.Pos, 1.0f), WorldViewProj );
     OUT.PosWorld = mul( float4(IN.Pos, 1.0f), World );
     OUT.NormalWorld = mul( float4(IN.Normal, 0.0f), World );
     OUT.TexCoord = IN.TexCoord;
     return OUT;
}

float4 PixelProgram( VS_OUTPUT IN ) : COLOR
{
     float r0TexCoordScale = 1.0f;
     float r1TexCoordScale = 70.0f;
     float r2TexCoordScale = 70.0f;
     float r3TexCoordScale = 70.0f;
     float r4TexCoordScale = 70.0f;
     float r5TexCoordScale = 4000.0f;

     float4 r0 = tex2D( r0_samp, IN.TexCoord * r0TexCoordScale );
     float4 r1 = tex2D( r1_samp, IN.TexCoord * r1TexCoordScale );
     float4 r2 = tex2D( r2_samp, IN.TexCoord * r2TexCoordScale );
     float4 r3 = tex2D( r3_samp, IN.TexCoord * r3TexCoordScale );
     float4 r4 = tex2D( r4_samp, IN.TexCoord * r4TexCoordScale );
     float4 r5 = tex2D( r5_samp, IN.TexCoord * r5TexCoordScale );

     r1 = r1 * r0.x;
     r2 = lerp ( r0.y, r2, r1 );
     r3 = lerp ( r0.z, r3, r2 );
     r0 = lerp ( r0.w, r4, r3 );
     r5 = r5 * r0;

     return float4(r5.xyz, 1.0f);
}

technique TerrainTech
{
    pass p0
    {
        VertexShader = compile vs_3_0 VertexProgram();
        PixelShader  = compile ps_3_0 PixelProgram();
    }
}

#1Medo3337

Posted 24 July 2013 - 12:40 AM

I have made modifications to correct the code, it works, but I notice that the terrain quality is the not same, it's more bright.

 

Before, it was much better.

 

Why it got too bright? I want to get the same as the old results...

 

[attachment=16962:before_after.png]

 

Here is the shader code (Modified):

float4x4 World;
float4x4 WorldViewProj;

texture r0_tex;
sampler r0_samp  = sampler_state
{
    Texture     = <r0_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r1_tex;
sampler r1_samp  = sampler_state
{
    Texture     = <r1_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r2_tex;
sampler r2_samp  = sampler_state
{
    Texture     = <r2_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r3_tex;
sampler r3_samp  = sampler_state
{
    Texture     = <r3_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r4_tex;
sampler r4_samp  = sampler_state
{
    Texture     = <r4_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

texture r5_tex;
sampler r5_samp  = sampler_state
{
    Texture     = <r5_tex>;
    MIPFILTER   = LINEAR;
    MAGFILTER   = LINEAR;
    MINFILTER   = LINEAR;
};

struct VERTEX
{
    float3 Pos : POSITION;
    float2 TexCoord : TEXCOORD0;
    float3 Normal : NORMAL;
};

struct VS_OUTPUT
{
    float4 Pos : POSITION;
    float3 PosWorld : TEXCOORD0;
    float3 NormalWorld : TEXCOORD1;
    float2 TexCoord : TEXCOORD2;
};

VS_OUTPUT VertexProgram( VERTEX IN )
{
     VS_OUTPUT OUT;
     OUT = (VS_OUTPUT)0;
     OUT.Pos = mul( float4(IN.Pos, 1.0f), WorldViewProj );
     OUT.PosWorld = mul( float4(IN.Pos, 1.0f), World );
     OUT.NormalWorld = mul( float4(IN.Normal, 0.0f), World );
     OUT.TexCoord = IN.TexCoord;
     return OUT;
}

float4 PixelProgram( VS_OUTPUT IN ) : COLOR
{
     float r0TexCoordScale = 1.0f;
     float r1TexCoordScale = 70.0f;
     float r2TexCoordScale = 70.0f;
     float r3TexCoordScale = 70.0f;
     float r4TexCoordScale = 70.0f;
     float r5TexCoordScale = 4000.0f;

     float4 r0 = tex2D( r0_samp, IN.TexCoord * r0TexCoordScale );
     float4 r1 = tex2D( r1_samp, IN.TexCoord * r1TexCoordScale );
     float4 r2 = tex2D( r2_samp, IN.TexCoord * r2TexCoordScale );
     float4 r3 = tex2D( r3_samp, IN.TexCoord * r3TexCoordScale );
     float4 r4 = tex2D( r4_samp, IN.TexCoord * r4TexCoordScale );
     float4 r5 = tex2D( r5_samp, IN.TexCoord * r5TexCoordScale );

     r1 = r1 * r0.x;
     r2 = lerp ( r0.y, r2, r1 );
     r3 = lerp ( r0.z, r3, r2 );
     r0 = lerp ( r0.w, r4, r3 );
     r5 = r5 * r0;

     return float4(r5.xyz, 1.0f);
}

technique TerrainTech
{
    pass p0
    {
        VertexShader = compile vs_3_0 VertexProgram();
        PixelShader  = compile ps_3_0 PixelProgram();
    }
}

 


PARTNERS