Crap

Published October 12, 2006
Advertisement
Well I whipped up a new polygon splitter using ye old span method. It works for the most part except for hairline cracks EVERYWHERE.

The clear color is set to bright blue and it shows:


It also misses a few triangles on some levels. Now it might only be a few, but it's definitely noticeable:


Anyway I figure the cracks are caused by rounding errors. Anyone have any idea how to fix them? Here's the function to find a point on a line from the Z axis:

	public static Vertex HorizontalPlaneIntersection( Line LineReference, int Z )	{		Vertex A = LineReference.StartVertex; 		Vertex B = LineReference.EndVertex; 		int DX = B.X - A.X;		int DZ = B.Z - A.Z;		if( Math.Abs( DZ ) == 0 )		{    			return null;		    		}				if( A.Z == Z )		{			return A;		}		if( B.Z == Z )		{			return B;		}		if( A.Z < B.Z )		{			if( ( Z < A.Z ) || ( Z > B.Z ) )			{				return null;			}		}		else if( ( Z < B.Z ) || ( Z > A.Z ) )		{			return null;		}		if( Math.Abs( DX ) == 0 )		{			return new Vertex( A.X, Z );		}		float Slope = (float)DZ / (float)DX;    		float Beta = (float)A.Z - ( Slope * (float)A.X );    		float NewX = ( (float)Z - Beta ) / Slope;    		return new Vertex( (int)NewX, Z );	}


The function returns the new point or null if the plane doesn't pass through the line. I tried using doubles, but that was even worse. Points(or vertices) are just 2D points, X and Z.

Edit: The reward is of course, a giant rate++.
0 likes 6 comments

Comments

Ravuya
I had tons of cracks in my OpenGL stuff but it turns out it was because my view frustum was fucked up.
October 12, 2006 07:56 PM
HopeDagger
If a solution doesn't find its way to you, I suggest setting the clear colour to something virtually unnoticable in any DooM game: black. [grin]
October 12, 2006 10:48 PM
Scet
Quote:Original post by Ravuya
I had tons of cracks in my OpenGL stuff but it turns out it was because my view frustum was fucked up.


Unfortunatly Doom coordinates are in pixels, so setting the clipping plane to anything other than some insane value cuts off most of the level and looks wrong. I'll probably have to scale everything down.

Quote:Original post by HopeDagger
If a solution doesn't find its way to you, I suggest setting the clear colour to something virtually unnoticable in any DooM game: black. [grin]


That would work, except for the bright red or orange sky.
October 13, 2006 08:42 AM
Ravuya
Set the clear colour to the average colour of the skybox.
October 13, 2006 10:18 AM
OrangyTang
A lot of older games (back when the best we had going was 3Dfx cards or software rendering, both of which tended to be somewhat inaccurate) just wouldn't clear the colour buffer. As long as you're drawing *something* to all the pixels this works quite nicely, as the cracks pick up the colour that was previously there.
October 15, 2006 11:43 AM
Scet
Quote:Original post by OrangyTang
A lot of older games (back when the best we had going was 3Dfx cards or software rendering, both of which tended to be somewhat inaccurate) just wouldn't clear the colour buffer. As long as you're drawing *something* to all the pixels this works quite nicely, as the cracks pick up the colour that was previously there.


That would work as well, except for outdoor areas. Anyway it's not a problem now since I implemented glBSP.
October 15, 2006 12:33 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement