Jump to content

  • Log In with Google      Sign In   
  • Create Account

Calling all IT Pros from Canada and Australia.. we need your help! Support our site by taking a quick sponsored surveyand win a chance at a $50 Amazon gift card. Click here to get started!


Member Since 15 Sep 2012
Offline Last Active Aug 21 2014 02:05 PM

Topics I've Started

Shading individual areas of triangles without aliasing artifacts

15 July 2014 - 06:38 PM

I recently simplified my map geometry merging identical faces with each other. The problem is I have a 3d texture that defines a damage value for each cell of the map. I sample the center of these texels to shade cells with the damage value. This works perfectly when there's 4 vertices per face cell but now that 2 triangles can make up many face cells, the damage shading has to change.


This is how it looks when each face cell has 4 vertices each.



This is the simplified mesh with my shader changes.



I first pass the vertex position as a varying. In the frag shader I floor it and add 0.5, I think this is what Nearest neighbour filtering does. This is very aliased and unacceptable so I tried smoothing it out, which is what you see in the second picture. http://csantosbh.wordpress.com/2014/01/25/manual-texture-filtering-for-pixelated-games-in-webgl/


This works well for removing the aliasing but it means edges that are adjacent to an air cell get interpolated back to a light colour.


I want to be able to have the exact results of the first image without having 4 vertices per cell face.


It's almost like I need to be able to emulate what CLAMP_TO_EDGE does because the error does not happen for edges touching the map bounds, which is when clamp to edge takes effect. I'm not sure if that's possible to do though.

Safely Simulating Player Movement Server-Side

17 April 2014 - 05:14 PM

I have a fast paced multiplayer FPS game with the client running the player movement code and sending its position to the server. Obviously this is open to cheating so I want to have the player movement run on the server with the client sending only input to the server.


I have read all about client side prediction but there's still a few problems I'm not able to solve.


When I sample input and send that packet to the server, by the time the server receives it, the player simulation will have potentially moved the player to a different position than where the clients player was during that input.


One way to solve this is to send the frame time in the input packet to progress the simulation by that amount using that input. The problem with this is that it's also open to cheating, someone could speed up their client so the server simulates the player faster. I'm sure there's ways to detect that but there's still the problem of the player on the server freezing in mid-air when input isn't being received.


So to me it doesn't look like there's a perfect solution to this problem, I want the server to always simulate the player but due to packet latency, it's going to receive input at a different time than the client predicted it, resulting in constant error correction for the player.


An example of this is, imagine the client is predicting the player moving forward and then jumps, the server will be moving the player forward but the input with the jump keypress hasn't been received yet so the player on the server keeps running forward. When the input with the jump key press finally comes in, the player on the server has already ran into a hole but the client predicted that the player jumped over the hole.

Rollercoaster Track Orientation

15 June 2013 - 03:06 AM

I'm making a rollercoaster and I'm having trouble figuring out the tracks up and side vectors from the track tangent. I have a series nodes with roll values and points that make up the track. Now, I want to keep the track upright as much as possible so it doesn't start to roll around corners but at the same time allow for the node roll values to make loops. No matter what I do, I get twists and bends when the loop goes up and starts to bend back around.


This is the code I have now that works okay apart from loops. I'm at a dead end with this, I just can't figure out a way to keep the track upright but still allow for loops. I know it's possible - I just don't know the maths to do it. My requirement is that there can't be any other data the user needs to give - just the node positions and roll values at each node. I'm using bezier curves if that helps.

	m_trackLength = 0.0f;
	const Vector3f up(0.0f, 1.0f, 0.0f);

	size_t segmentIndex = 0;
	size_t segmentPointIndex = 0;

	for (unsigned int i = 0; i < m_points.size(); ++i)
		Point& point = m_points[i];

		Vector3f trackDelta;
		size_t rollIndex;
		size_t nextRollIndex;
		float rollPercentage;

		if (i < m_points.size() - 1)
			trackDelta = m_points[i + 1].position - point.position;

			size_t segmentPointCount = m_segments[segmentIndex].pointCount;

			rollIndex = segmentIndex;
			nextRollIndex = rollIndex + 1;
			rollPercentage = (float)segmentPointIndex / ((float)segmentPointCount - 1);


			if (segmentPointIndex >= (segmentPointCount - 1))
				segmentPointIndex = 0;
			trackDelta = m_points[1].position - point.position;
			rollIndex = m_nodes.size() - 1;
			nextRollIndex = 0;
			rollPercentage = 1.0f;

		m_trackLength += trackDelta.Length();

		point.tangent = trackDelta.Normalise();

		float firstNodeRoll = m_nodes[rollIndex].GetRoll();
		float nextNodeRoll = m_nodes[((rollIndex < (m_nodes.size() - 1)) ? nextRollIndex : 0)].GetRoll();

		float pointRoll = Math::RadiansToDegrees(nextNodeRoll - firstNodeRoll);

		pointRoll -= floor(pointRoll / 360.0f) * 360.0f;

		if (pointRoll >= 270.0f)
			pointRoll -= 360.0f;
		else if (pointRoll <= -270.0f)
			pointRoll += 360.0f;

		pointRoll = Math::DegreesToRadians(pointRoll);

		pointRoll = firstNodeRoll + Util::Interpolate(0.0f, pointRoll, rollPercentage);

		point.normal = up;
		point.normal.Rotate(-pointRoll, point.tangent);
		point.binormal = point.tangent.Cross(point.normal).Normalise();
		point.normal = point.binormal.Cross(point.tangent).Normalise();

And here's a picture of the problem:




I've heard about "Parallel Transport Frames" and have tried implementing them but all it seems to do is make the track roll around corners - something I don't want to happen. Maybe I'm just doing it wrong?

VOIP - How often should I be sending packets when streaming music?

23 May 2013 - 09:31 PM

I have added voip to my game which works perfectly for broadcasting speech over network using the audio data from an input device. I want to add support for streaming audio from files but the problem I'm having is deciding how often I should be reading parts from the file to send over network. When streaming and playing audio locally this problem is easy to solve because I can just queue a buffer when there's a slot available, this isn't an option here because I'm not playing back the audio I'm sending.


The only solution I see is to send packets in timed intervals but I see that being unreliable. What do you guys think?


A ghetto way would be to actually play the stream locally but with zero volume, that doesn't seem too bad.

Sound (Voice) over Network

31 December 2012 - 09:59 AM

This is mostly to do with sound programming for the most part but I just want some reasurance before going deep into this.

I want to add in-game voice chat to my game. My libraries of choice are OpenAL for sound capture and playing. For encoding/decoding I'll be using Opus.

I'm just wondering what challenges I'll face. It seems easy enough to me but maybe I'm forgetting something. Is it just a case of encoding the captured data, sending that over network as fast as possible and having clients decode it and play?

As internet speeds get faster, wont there become a point where encoding sound data would be uneeded and the raw sound data could be sent across without a problem?

Has anyone done this before? Could you give a quick rundown on what is required to get this done?

I'm also wondering if I'll need to be threading any part of this. I don't like using threads so if it can be avoided for now then that's good.