Skip to main content
gamedev.net
🔒 Locked

Terrain: Section Lines

Started by mr_hell Apr 1, 2009 at 8:14 AM 0 replies 800+ views
Original Post
mr_hell
mr_hell
DX 9.0. I have to draw x, y, z level lines on my relief surface. 2 soluttions: 1. Using of additional geometry (lines). Major disadvantage - i need time to calculate this lines. 2. Using pixel shader. Its better, because i neednt time for calculations.

float4 TestP1(PS_INPUT Input): COLOR0
{
        float4 Color;
	int z = ceil(Input.Position.y);
	int y = ceil(Input.Position.z);
	int x = ceil(Input.Position.x);
	Color = Input.Color;

	if(abs(fmod(z, 100))<1.0)
	{
		Color.b = 1.0f;
		Color.r = Color.g = 0.0f;
	}
	if(abs(fmod(x, 100))<1.0)
	{
		Color.b = 1.0f;
		Color.r = Color.g = 0.0f;
	}
	if(abs(fmod(y, 100))<1.0)
	{
		Color.r = 1.0f;
		Color.b = Color.g = 0.0f;
	}

	return Color;
}

But on this way i have troubles: first far and second near Any ideas, how to get "good" level lines in shader? P.S. I know about textures, but i dont want, since i have very large terrains.
NecroDOME
NecroDOME
What you can do is have a 1D texture and do texture lookups as function of the height of your terrain. The 1D texture would be a texture that is black, with white lines (dots as it is 1D) at every 32 pixels or something.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.