Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 06 Mar 2013
Offline Last Active Jun 27 2014 07:11 AM

Topics I've Started

Some times a little oversight can make a hilarious bug

22 June 2014 - 09:16 PM



I've already fixed the problem but that made my night. happy.png

AMD GLSL "subtle" or "quiet" error.

19 June 2014 - 11:43 PM

My GLSL shader in my game engine has a very odd bug that my roomate found today. On his AMD graphics card any model that is skinned/animated is invisible. The models show up fine on my Nvidia card so this is ATI specific. The shaders compile fine on his card and there are no errors in the AMD GPU shader analyzer which is very odd.


We messed with this for a few hours and I found the block of code that causes the invisible models glitch. It's the part of the GLSL vertex shader that does the rotation for skinned meshes. Something here IS causing the problem. If I comment this out everything renders fine but nothing rotates obviously.


Here are all my uniforms, attributes, and varyings in the vertex shader:

uniform bool bRotation;
uniform vec4 modelPosition;
uniform vec4 modelRotation;
uniform float modelScale;
uniform bool bSkin;
uniform vec3 bonesOffset[64];
uniform vec3 bonesPos[64];
uniform vec4 bonesRot[64];
uniform vec4 sunLocation;
uniform vec3 sunDir;

varying vec3 halfVec;
varying vec3 eyeVec;
varying vec3 lightVec;

varying vec4 position;
varying vec3 normal;

attribute vec3 indices;
attribute vec3 weights;
attribute vec3 tangent;

varying vec4 nearShadowCoord;
varying vec4 farShadowCoord;

Here is the part of the vertex shader that is causing the problem:

		//do rotation
		i = 0;
		vec4 v = pos;
		vec4 rot[3];
		vec4 nor[3];
		while(i < 3) {
			vec4 r = bonesRot[int(indices[i])];
			rot[i] = vec4(quatRotation(vec3(v.x, v.y, v.z), r), 0.0f);
			nor[i] = vec4(quatRotation(normal, r), 0.0f);
		//Average the rotations by weight and apply them
		i = 0;
		vec4 final;
		normal = vec3(0.0f,0.0f,0.0f);
		while(i < 3) {
			final.x += (rot[i].x * weights[i]);
			final.y += (rot[i].y * weights[i]);
			final.z += (rot[i].z * weights[i]);
			normal.x += (nor[i].x * weights[i]);
			normal.y += (nor[i].y * weights[i]);
			normal.z += (nor[i].z * weights[i]);
		pos = final;

And here is the quatRotation() function that is used in the above code on lines 8 and 9:

vec3 quatRotation(vec3 v, vec4 r) {
			float q00 = 2.0f * r.x * r.x;
			float q11 = 2.0f * r.y * r.y;
			float q22 = 2.0f * r.z * r.z;
			float q01 = 2.0f * r.x * r.y;
			float q02 = 2.0f * r.x * r.z;
			float q03 = 2.0f * r.x * r.w;
			float q12 = 2.0f * r.y * r.z;
			float q13 = 2.0f * r.y * r.w;
			float q23 = 2.0f * r.z * r.w;
			vec3 f = vec3(0.0f,0.0f,0.0f);
			f.x = (1.0f - q11 - q22) * v.x + (q01 - q23) * v.y + (q02 + q13) * v.z;
			f.y = (q01 + q23) * v.x + (1.0f - q22 - q00) * v.y + (q12 - q03) * v.z;
			f.z = (q02 - q13) * v.x + (q12 + q03) * v.y + (1.0f - q11 - q00) * v.z;
			return f;

I have no idea what's actually wrong with my code. I develop on Nvidia and everything works great. I'm stumped D:

Is Java Socket the best option for a real time game server?

22 November 2013 - 06:00 PM

Alright, so to start off I am currently using the native Java Socket implementation and everything works fine. I'm planning on rewriting the networking portion of the game engine to improve and clean it up and I'm not sure if I should move to another API or not.


From what I've read, my options are:
Native Java Socket

Java Fast Socket



The game engine in question is 3d, with an aim of 2 - 24 players on a server at a time. I use floats for location/velocity/rotation updates.


What would be the best option? Latency and stability are extremely important. No one likes lag and random disconnects. tongue.png


Also, there is an API I saw a while back that was an optimized network packet API for Java. I can't remember the name unfortunately... Anyone know what it was called?





And of course, I immediately find some good anwsers after I post this thread.


Looks like I should use Kryonet which is designed for this kind of thing, or I should build my own thing off of Java NIO.

Is this Gimbal Lock at work or do I have a real problem?

07 July 2013 - 07:04 PM

Here's a quick video I recorded:



Currently I am using bullet physics to calculate my RigidBody physics actors. After each bullet step I basically run this code on my RigidBody game actors to get their position and rotation from bullet.


      //the variable "physics" is the bullet RigidBody object

        Vector3f c = physics.getCenterOfMassPosition(new Vector3f());
        setLocation(new Vertex(c.x, c.y, c.z + 10));

        Quat4f q = physics.getOrientation(new Quat4f());
        setRotation(MathUtil.convertQuat2Euler3(new Quat(q.x, q.y, q.z, q.w)));


Problem A:

I'm currently converting the Quaternion that is returned by the RigidBody to an Euler angle then applying that to the object and rendering.

I'm like 99% sure thats causing gimbal lock. I can rewrite my renderer to use Quat's instead of Euler angles and solve the problem if that is it. It's a lot of work though so I want to confirm that this is the problem.


Problem B:

I have to add 10 to the location.z value of the RigidBody for some odd reason. I have no idea why.


Thanks :)

I don't even know where to begin - Licenses

25 June 2013 - 04:57 PM

I've been developing a game engine for the past few years and I'm finally at a point where I want to allow people to make contributions and play with it and stuff. I want to put it up on GitHub, I'm just afraid of the rather unlikely event where my work gets stolen or copyrighted or patented or basically any kind of horrid legal thing that could happen.


I basically want some kind of license agreement that states:
- The engine source belongs to me, any contributions made to the engine by users are *non-exclusively* a part of that.

- Code added to the engine by a contributor is just a part of the engine and the contributor can still use that code outside of the engine freely still.

(EX: someone writes an awesome shadow calculation and puts it in the engine, they can still use that same shadow calculation elsewhere and it's fine)

- The engine is free to use non-profit

- The engine requires a lincse to use commerically which can be negotiated with me.


How should I go about that? I'm broke and I can't really hire a lawyer to write some crazy legal stuff for me.


I've read up on GPL and BSD but neither of those are quite what I want to do.