Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualbelfegor

Posted 18 July 2013 - 11:56 AM

Since i am bored i get you started a bit:

float4x4 WorldViewProj;
float4x4 World;
 
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;
    float3 Normal : NORMAL;
    float2 TexCoord : TEXCOORD0;
};
 
struct VS_OUTPUT
{
    float4 Pos : POSITION;
    float3 PosWorld : TEXCOORD0;
    float3 NormalWorld : TEXCOORD1;
    float2 TexCoord : TEXCOORD2;
};
 
struct PS_OUTPUT
{
    float4 Color : COLOR0;
};
 
void VertexProgram( in VERTEX IN, out VS_OUTPUT OUT )
{
     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;
}
 
void PixelProgram( in VS_OUTPUT IN, out PS_OUTPUT OUT )
{
    float r0TexCoordScale = 1.0f;
    float r1TexCoordScale = 2.0f;
    float r2TexCoordScale = 2.0f;
    float r3TexCoordScale = 2.0f;
    float r4TexCoordScale = 2.0f;
    float r5TexCoordScale = 16.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( r2, r1, r0.y );
    r3 = lerp( r3, r2, r0.z );
    r0 = lerp( r4, r3, r0.w );
    r5 = r5 * r0;
 
    OUT.Color = float4(r5.xyz, 1.0f);
}
 
technique TerrainTech
{
    pass p0
    {
        VertexShader = compile vs_3_0 VertexProgram();
        PixelShader  = compile ps_3_0 PixelProgram();
    }
}

1. Note that i have done this by hand, so it might contain typos.

2. You must add your lightning calculations.

3. Might not work as i did not test it.


#1belfegor

Posted 18 July 2013 - 11:54 AM

Since i am bored i get you started a bit:

float4x4 WorldViewProj;
float4x4 World;
 
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;
    float3 Normal : NORMAL;
    float2 TexCoord : TEXCOORD0;
};
 
struct VS_OUTPUT
{
    float4 Pos : POSITION;
    float3 PosWorld : TEXCOORD0;
    float3 NormalWorld : TEXCOORD1;
    float2 TexCoord : TEXCOORD2;
};
 
struct PS_OUTPUT
{
    float4 Color : COLOR0;
};
 
void VertexProgram( in VERTEX IN, out, VS_OUTPUT OUT )
{
     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;
}
 
void PixelProgram( in VS_OUTPUT IN, out PS_OUTPUT OUT )
{
    float r0TexCoordScale = 1.0f;
    float r1TexCoordScale = 2.0f;
    float r2TexCoordScale = 2.0f;
    float r3TexCoordScale = 2.0f;
    float r4TexCoordScale = 2.0f;
    float r5TexCoordScale = 16.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( r2, r1, r0.y );
    r3 = lerp( r3, r2, r0.z );
    r0 = lerp( r4, r3, r0.w );
    r5 = r5 * r0;
 
    OUT.Color = float4(r5.xyz, 1.0f);
}
 
technique TerrainTech
{
    pass p0
    {
        VertexShader = compile vs_3_0 VertexProgram();
        PixelShader  = compile ps_3_0 PixelProgram();
    }
}

 

1. Note that i have done this by hand, so it might contain typos.

2. You must add your lightning calculations.

3. Might not work as i did not test it.


PARTNERS