Beginning on terrain rendering

Terrains are awesome, so therefore I’m trying to mess around with them.

I didnt really need to change anything in my engine because I really dont see any reason to seperate a mesh from a terrain like many engines do. So using World machine to generate a small section of a terrain, I imported the mesh file and heightmap to generate and displace the terrain. In the process I saw some disgusting SSAO errors which I still dont get why:

Posted Image

The voxelization for GI:
Posted Image

The diffuse output which is just a really simple shader that lerps between height and normals:
Posted Image

But in the process I saw this nightmare when voxelizing, not good.
Posted Image

The shader if anyone is interested. Really simple.

A simple shader file that the engine parses

shader "Simple Terrain"
                info = "A simple terrain shader that lerps between 4 textures";
    // Considered to be global
		Texture2D tgrass;
		Texture2D trock;
		Texture2D tsnow;
		Texture2D tdarkdirt;
	pass(cull = true😉
			float2 tex =  input.positionWS.xz * 2.5f;
			float3 rock = trock.Sample(ss, tex);
			float3 grass = tgrass.Sample(ss, tex);
			float3 snow = tsnow.Sample(ss, tex);
			float3 dirt = tdarkdirt.Sample(ss, tex);

			float NormalLerp = 
			saturate( lerp( 0.0f, 1.0f, 1 - dot( input.normalWS, float3( 0.0, 1.3, 0.0 ) ) ) );
			float3 fvColor =  lerp(
			lerp(grass, dirt, NormalLerp), lerp(snow, rock, NormalLerp), 
			saturate(input.positionWS.y / 20.0f - 0.5)); = fvColor;
                        // Yeah yeah its hackyish...
                        // Sets the specular level to 0.2f

Thats it, just a bit of progress! Posted Image

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s