Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Discussions / General Discussions / Re: Designing a game - hard work? on: 2014-12-11 14:40:42
It's not all bad though. Having limitations forces you to be creative instead. You'll have to come up with interesting game play ideas to compensate for poor graphics. Just take a game like Dwarf fortress for example, they completely focused on game play instead of graphics and the result is a game with an incredible amount of depth. Because of that the game is quite popular, despite looking awful. Oh, and the community is actually helping to create graphics for the game, for free, how awesome isn't that?. Another example is of course Minecraft. Simple graphics, yet the game play is appealing to a lot of people so the game became incredibly popular. So what I am trying to say here is: focus on game play, not graphics.

With that said, if you're looking for pixel art graphics, you could take a look at http://oryxdesignlab.com
I think you may to use the sprites for non-commercial for free, but have to pay if you want to use them for commercial games (though the price is really low in my opinion). I bought some sprites from there and I am satisfied with what I got.
2  Discussions / General Discussions / Re: Good pixel art font on: 2014-12-11 14:20:27
You could always make your own font! That's what I did.



Okay, maybe I'm not too good at making fonts, but hey, it's fun!  Grin
3  Java Game APIs & Engines / Engines, Libraries and Tools / [Kryonet] Is there a limit on UDP packet size? on: 2014-12-11 13:22:26
I found out that my client doesn't receive any UDP packets if they're bigger than about 1460 bytes. If they're smaller than that, it works just fine. I've tried using Log.set(Log.LEVEL_DEBUG) but it doesn't help at all. The server simply says "00:10 DEBUG: [kryonet] Connection 1 sent UDP: Packet (1486)". The client doesn't even say anything. It doesn't matter if I send one packet every second or 30 every second, the result is the same, it only depends on the size of the packet. Also, I can send TCP packets much bigger than 1460 bytes without any problems. So could there be a limit on how big UDP packets can be? I admit I don't know much about networking.
4  Discussions / General Discussions / Re: Simple 3D modeling software suitable for games? on: 2014-12-10 17:10:08
Yeah I suppose I'll give Blender a try. Thanks for the answers everyone!
5  Discussions / General Discussions / Simple 3D modeling software suitable for games? on: 2014-12-10 14:38:20
To be honest I don't know if this is the right place to ask such a question, but hey, let's give it a try.

The game I'm currently developing is a 3D game but with a very "retro" style. For example the creatures in the game are just animated sprites instead of actual 3D models. However I want to be able to make simple 3D models as well for things like a building that you can enter etc. So I realized I had a license for Maya and I decided to try it. The first impression wasn't very nice, the program took minutes to start. Once the program is running I am completely overwhelmed. There are just so many buttons and menus and other things that I will never have any use for. The next thing I did was to uninstall it.

I just want a 3D modelling program that isn't too hard to learn and doesn't have 100000 features that are completely useless to me. I want to be able to create models consisting of simple shapes, texture them and export them as .obj. I'm thankful for any suggestion that's better than Maya.  Tongue
6  Java Game APIs & Engines / OpenGL Development / Re: VBO causes stuttering on: 2014-11-05 14:47:42
Quote
I don't know the details, but direct byte buffers are extra hard for the garbage collector to manage for some reason. You're also allocating 4x as big buffers as you need. It already takes into account the primitive size, so what you need is createFloatBuffer(16) = createByteBuffer(16*4).asFloatBuffer(). No need to multiply by 4 manually in your case.

Fixed, thank you. Feels like everything else is in amount of bytes, so I guess I just assumed this was in bytes too.
7  Java Game APIs & Engines / OpenGL Development / Re: VBO causes stuttering on: 2014-11-04 12:11:43
You're absolutely right. I fixed it now and it runs smoothly! I had no idea garbage collection could cause something like this. Thanks a lot!  Pointing
8  Java Game APIs & Engines / OpenGL Development / Re: VBO causes stuttering on: 2014-11-04 05:57:54
Don't create new buffers every frame.

Pretty sure I'm not doing that.

...

If I understood what you said correctly, then that's exactly what I am doing (or intending to do, in case I made a mistake somewhere).

My real problem remains though.
9  Java Game APIs & Engines / OpenGL Development / VBO causes stuttering on: 2014-11-04 00:02:43
I decided to start playing around with openGL (LWJGL) again after a few years break. This time im actually going to learn how to use VBOs properly, and not use immediate mode like last time. First of all I'd just like to ask for some general advice. Say I have a program with a bunch of objects (or mesh/model whatever you would call it). These objects are kind of static, meaning no animations that would change vertex data. However they may be translated, rotated or scaled. My question is, what is generally the best way to deal with this using VBOs? I can picture two way:

1. Setting up the VBO with all the object vertex data and not modifying it further. I would have to loop through every object and send a uniform to the shader depending on its position, rotation, and scale, and then render. This way I don't have to touch the VBO which is nice, but instead i have to perform a glUniform and a glDrawArrays for every object. This is what I use currently.

2. Modify the data in the VBO directly. If I do it this way I don't have to do any glUniform calls and I could probably just use one glDrawArrays call, but instead I have to modify the data in the VBO, perhaps many times per frame.

3. Something else.

I haven't figured out how to use VBOs properly, so any advice is more than welcome.

------------------------------------------------------------------------------------

Now to the actual problem. Rendering using VBOs causes stuttering. By stuttering I don't mean lag or fps drop. I can have 5000+ FPS and still stutter. What happens is that occasionally the program freezes for a short time. I'd say around 0.25s on average, but it can vary from maybe 0.1s to 0.5s. These freezes occur maybe once every second or so. It doesn't seem to matter how many objects I am rendering, the stuttering is still noticeable, even when I'm only rendering 300 vertices. The duration of the freezes seems to increase as I increase the amount of objects I draw, but only a little.

Here's some code. I removed every thing that is not relevant to this problem.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
import java.nio.FloatBuffer;
import java.util.ArrayList;

import org.lwjgl.BufferUtils;
import org.lwjgl.LWJGLException;
import org.lwjgl.Sys;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;

public class CopyOfMain {

   int shaderProgram;

   int bufferObject;

   PerspectiveCamera camera;
   
   int fps;
   
   float lastFps;
   
   FloatBuffer vertexBuffer;
   
   ArrayList<Cube> cubes = new ArrayList<Cube>();
   

   public void start() {
      try {
         Display.setDisplayMode(new DisplayMode(800,800));
         Display.create();
      } catch (LWJGLException e) {
         e.printStackTrace();
         System.exit(0);
      }

      GL11.glEnable(GL11.GL_DEPTH_TEST);
      GL11.glDepthMask(true);
      GL11.glDepthFunc(GL11.GL_LEQUAL);
      GL11.glDepthRange(0.0f, 1.0f);

      shaderProgram = ShaderLoader.loadShader("res/shader/default.vert", "res/shader/default.frag");
   
      bufferObject = GL15.glGenBuffers();
     
      camera = new PerspectiveCamera(70,Display.getWidth()/(float)Display.getHeight(), 1000, 0.05f);


      vertexBuffer = BufferUtils.createFloatBuffer(100 * 6 * 6 * 12 * 4);
      for (int i = 0; i<100; i++) {
         Cube cube = new Cube();
         
         cube.setScale((float) (Math.random()*2));
         cube.setX((float) (Math.random()*40 -20));
         cube.setY((float) (Math.random()*40 -20));
         cube.setZ((float) (Math.random()*1000 - 998));
         cubes.add(cube);
         
         addToVBO(cube);
      }
         
      vertexBuffer.flip();
     
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferObject);
      GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer, GL15.GL_STATIC_DRAW);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
     
      GL20.glUseProgram(shaderProgram);
      GL20.glUniformMatrix4(GL20.glGetUniformLocation(shaderProgram, "projectionMatrix"), true, (FloatBuffer)BufferUtils.createFloatBuffer(4*16).put(camera.getProjectionMatrix().getData()).flip());
      GL20.glUniformMatrix4(GL20.glGetUniformLocation(shaderProgram, "modelMatrix"), true, (FloatBuffer)BufferUtils.createFloatBuffer(4*16).put(new Matrix4x4().toIdentity().getData()).flip());
      GL20.glUseProgram(0);

      lastFps = (Sys.getTime() * 1000) / Sys.getTimerResolution();
     
      while (!Display.isCloseRequested()) {

         if (Keyboard.isKeyDown(Keyboard.KEY_W)) {
            camera.setY(camera.getY() + 0.01014f);  
         }

         if (Keyboard.isKeyDown(Keyboard.KEY_S)) {
            camera.setY(camera.getY() - 0.01014f);  
         }

         if (Keyboard.isKeyDown(Keyboard.KEY_A)) {
            camera.setX(camera.getX() - 0.01014f);
         }

         if (Keyboard.isKeyDown(Keyboard.KEY_D)) {
            camera.setX(camera.getX() + 0.01014f);
         }

         render();

         updateFPS();

         Display.update();
         //Display.sync(60);
         
      }

      Display.destroy();
   }

   public void addToVBO(Cube cube) {
     
      for (int i = 0; i<cube.getVertices().length; i++) {
     
      vertexBuffer.put(cube.vertices[i].getX());
      vertexBuffer.put(cube.vertices[i].getY());
      vertexBuffer.put(cube.vertices[i].getZ());
      vertexBuffer.put(cube.vertices[i].getU());
      vertexBuffer.put(cube.vertices[i].getV());
      vertexBuffer.put(cube.vertices[i].getNX());
      vertexBuffer.put(cube.vertices[i].getNY());
      vertexBuffer.put(cube.vertices[i].getNZ());
      vertexBuffer.put(cube.vertices[i].getR());
      vertexBuffer.put(cube.vertices[i].getG());
      vertexBuffer.put(cube.vertices[i].getB());
      vertexBuffer.put(cube.vertices[i].getA());
     
      }
     
   }

   public void updateFPS() {
      if ((Sys.getTime() * 1000) / Sys.getTimerResolution() - lastFps > 1000) {
         Display.setTitle("FPS: " + fps);
         fps = 0;
         lastFps += 1000;
      }
      fps++;
   }

   public void render() {
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

      GL20.glUseProgram(shaderProgram);
      GL20.glUniformMatrix4(GL20.glGetUniformLocation(shaderProgram, "viewMatrix"), true, (FloatBuffer)BufferUtils.createFloatBuffer(4*16).put(camera.getViewMatrix().getData()).flip());
     
     
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, bufferObject);

      GL20.glEnableVertexAttribArray(0);
      GL20.glVertexAttribPointer(0, 3, GL11.GL_FLOAT, false, 48, 0);
      GL20.glEnableVertexAttribArray(1);
      GL20.glVertexAttribPointer(1, 2, GL11.GL_FLOAT, false, 48, 3*4);
      GL20.glEnableVertexAttribArray(2);
      GL20.glVertexAttribPointer(2, 3, GL11.GL_FLOAT, false, 48, 5*4);
      GL20.glEnableVertexAttribArray(3);
      GL20.glVertexAttribPointer(3, 4, GL11.GL_FLOAT, false, 48, 8*4);
     
     
      for (int i = 0; i<cubes.size(); i++) {
         
         Cube m = cubes.get(i);
         
         GL20.glUniformMatrix4(GL20.glGetUniformLocation(shaderProgram, "modelMatrix"), true, (FloatBuffer)BufferUtils.createFloatBuffer(4*16).put(new Matrix4x4().toIdentity().translate(m.x, m.y, m.z).rotateX(m.pitch).rotateY(m.yaw).rotateZ(m.roll).scale(m.scale).getData()).flip());
         GL11.glDrawArrays(GL11.GL_TRIANGLES, i*36, 36);
         
      }
     
      GL20.glDisableVertexAttribArray(0);
      GL20.glDisableVertexAttribArray(1);
      GL20.glDisableVertexAttribArray(2);
      GL20.glDisableVertexAttribArray(3);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
      GL20.glUseProgram(0);
   }

   public static void main(String[] argv) {
      CopyOfMain display = new CopyOfMain();
      display.start();
   }
}
10  Java Game APIs & Engines / OpenGL Development / Re: FBO depth texture not working properly on: 2012-05-07 14:38:32
It's a shame that a lot of computers doesn't support OpenGL 3+ yet. That's why im limiting myself to OpenGL 2 for now.

Anyway, here's a off-topic question. Are loops supported in GLSL 1.20? The shader doesn't work on my old computer (which supports glsl 1.2 and opengl 2.1). It compiles without any errors but everything is just black. If I remove the loop and just copy everything inside it a few times, it will work. 
11  Java Game APIs & Engines / OpenGL Development / Re: FBO depth texture not working properly on: 2012-05-07 14:00:36
I agree. Starting to use VBOs and writing my own shaders was the best decision ever. Not only is it easier to achieve what you want to, it also gives you a much better understanding of basicly everything related to graphics programming.
12  Java Game APIs & Engines / OpenGL Development / Re: FBO depth texture not working properly on: 2012-05-07 13:32:06
I finally managed to solve it! All I had to do was to disable textures when rendering the depth map.

Still not sure why. It worked when I did this:

1  
2  
3  
4  
5  
// Works
glBindTexture(GL_TEXTURE_2D, tex1)
object1.render();
object2.render();
...


But if I bound another texture it stopped working:

1  
2  
3  
4  
5  
6  
// Doesn't work
glBindTexture(GL_TEXTURE_2D, tex1)
object1.render();
glBindTexture(GL_TEXTURE_2D, tex2)
object2.render();
...


Really weird. Anyway, I'm really happy I finally got it working.

Also,

You might still need to at least update the projection matrix since you have a new aspect ratio. Frankly I´m at quite a loss here...

Thanks for this. I actually forgot to make a new projection matrix. Perhaps not a huge deal, but it probably would've given me some bugs to fix later on.

Now I gotta post some smileys to express my happiness:

 Grin Grin Smiley Cheesy Grin Cool Tongue Smiley Grin
13  Java Game APIs & Engines / OpenGL Development / Re: FBO depth texture not working properly on: 2012-05-06 09:46:32
Could definitly be a shader problem. Ill try to remove all unrelated code in my shaders and post them here later today.

The reason why im not changing to the lights matrix is because right now I'm rendering the depth texture from the cameras POV.
14  Java Game APIs & Engines / OpenGL Development / Re: FBO depth texture not working properly on: 2012-05-06 08:50:48
The depth texture is not bound while rendering to it. This is my depth map rendering method (simplified)

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
public void createDepthMap(Light light) {
     
   glBindFramebuffer(GL_FRAMEBUFFER, light.getShadowMapFBO());
     
   glClear(GL_DEPTH_BUFFER_BIT);
     
   glPushAttrib(GL_VIEWPORT_BIT);
   glViewport(0,0,Constants.SHADOW_MAP_WIDTH, Constants.SHADOW_MAP_HEIGHT);
   glColorMask(false, false, false, false);
   
   for (Renderable r : renderableEntities)
         r.render();
     
   glColorMask(true, true, true, true);
   glPopAttrib();
   glBindFramebuffer(GL_FRAMEBUFFER, 0);
     
   glActiveTexture(GL_TEXTURE7);
   glBindTexture(GL_TEXTURE_2D,light.getShadowMapTexture());
   glActiveTexture(GL_TEXTURE0);
   
}


Here's my FBO generation method if it makes any difference

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
public void initFBO() {

      depthTexture = glGenTextures();
      glBindTexture(GL_TEXTURE_2D, depthTexture);
     
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
     
     
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
      glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
      glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
     
      glTexImage2D( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, Constants.SHADOW_MAP_WIDTH, Constants.SHADOW_MAP_HEIGHT, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, (ByteBuffer)null);
     
      glBindTexture(GL_TEXTURE_2D, 0);
     
      fbo = glGenFramebuffers();
      glBindFramebuffer(GL_FRAMEBUFFER,fbo);
      glDrawBuffer(GL_NONE);
      glReadBuffer(GL_NONE);
     
      glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D, depthTexture, 0);
     
      int FBOstatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
        if(FBOstatus != GL_FRAMEBUFFER_COMPLETE)
           System.out.println("GL_FRAMEBUFFER_COMPLETE failed, CANNOT use FBO\n");

        glBindFramebuffer(GL_FRAMEBUFFER, 0);

   }
15  Java Game APIs & Engines / OpenGL Development / FBO depth texture not working properly on: 2012-05-05 21:32:22
So, im trying to implement shadow mapping into my game and I can't seem to render to the depth texture properly (which is attached to a FBO). I don't know what part of the code that causes this problem so I wont post code for now. Anyway, here's a screenshot from my game. It has nothing to do with the problem, I posted it so you could see how it looks like.



Anyway, so instead of rendering the actual textures, I rendered the depth map instead. This is the result:



Yeah, that's not how it should look like. There appears to be a lot of tiny point everywhere and if you look closley, you can see that theres a line where every edge of the triangle is. However, look at the quad to the right. The depthmap seems to be correct for that quad.

I increased the depth texture dimensions and it now looks like this:



More and smaller points, not very surprising. I'm completly lost now. It's probably something really simple, but I can't just figure out what it is. Oh, and by the way, the depth texture is not rendered from the lights POV, but the cameras. I did this to make it more simple.

Any ideas on why this could be happening?

Edit: It appears to work the way it should if the size of the depth texture is less than or equal to 32x32. This doesn't make me less confused though.

16  Game Development / Newbie & Debugging Questions / Re: Trying to make a TweenMovement component on: 2012-04-30 22:43:29
lol hi! Cheesy You're the nehifish I know, right!?

I can help you over skype or something, lol.
17  Java Game APIs & Engines / OpenGL Development / Re: Can't get GLSL per-pixel lighting to work. on: 2012-04-22 16:59:46
Quote
Your shader code works perfectly fine. Try to put a light very very close to the skeleton and you´ll see that the color really varies per pixel.

You're right, it does work the way it should! Oh wow, now I feel really stupid. I guess the light was just too far away to make the lighting vary pixel by pixel.

Quote
Are you using an index buffer to draw the skeleton or not? I think you´re creating unique vertices for each triangle, am I correct?

You are correct, but I smoothed the normals the way you suggested earlier, by adding the normal of all the vertices that has the same position and then normalizing them. However, there must be something wrong with the code that does that. Anyway, thanks for you help. You've been really helpful  Smiley
18  Java Game APIs & Engines / OpenGL Development / Re: Can't get GLSL per-pixel lighting to work. on: 2012-04-22 16:02:31
Point light.
19  Java Game APIs & Engines / OpenGL Development / Re: Can't get GLSL per-pixel lighting to work. on: 2012-04-22 14:23:02
I get what you're saying but I don't believe that's the problem. I think I managed to smooth the normals, but the problem is still there. Please verify that I've understood everything about the lighting calculations correctly.

Currently I take the dot product of the normal (which remains constant for every face) and the normalized distance vector from the pixel to the light source. Take a look at this image:



Every black block represents a pixel, the yellow circle the light source, every red line a normal, and every green line the vector from the light source to the pixel.

The distance vector from the light source to the pixel will be different for every pixel since it's calculated in the fragment shader. The normal will of course remain the same for every pixel. As seen in the image, the angle between the two vectors varies so taking the dot product of the two should give different values for different pixels, right? Why isnt this the case?  Huh
20  Java Game APIs & Engines / OpenGL Development / Can't get GLSL per-pixel lighting to work. on: 2012-04-22 01:14:16
I'm trying to implement per-pixel lighting with GLSL in my program and I just can't get it to work. Also, sorry for the long post.

Every face has the same color. This image of an ugly skull that I rendered with my shaders should explain the problem:



Here's my shaders. I removed everything unrelated.

Vertex shader

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
#version 130

in vec3 inPosition;
in vec4 inColor;
in vec3 inNormal;

smooth out vec4 color;
smooth out vec3 normal;
smooth out vec3 position;

uniform mat4 perspectiveMatrix;
uniform mat4 cameraTransformationMatrix;
uniform mat4 modelTransformationMatrix;

uniform vec3 lightPos;

void main()
{

   normal = inNormal;
   
   position = inPosition;
   
   color = inColor;
   
   vec4 pos  = cameraTransformationMatrix * vec4(inPosition, 1);
   
    gl_Position = perspectiveMatrix * pos;
 
}


Fragment shader:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
#version 130

smooth in vec4 color;
smooth in vec3 normal;
smooth in vec3 position;

uniform vec3 lightPos;

void main()
{

   vec3 lightDir = normalize(lightPos - position);

   float diffuseLightIntensity = max(0,dot(normalize(normal),lightDir));

   vec4 fragcolor = vec4(diffuseLightIntensity * color.rgb,color.a);
   
   fragcolor.rgb += vec3(0.2,0.2,0.2);

    gl_FragColor = fragcolor;
}


I've been trying to figure out what could cause this to happen. I've tried to change gl_FragColor to different things. For example, gl_FragColor = vec4(lightDir,1) draws the skull with interpolated colors (check image below).



This shows that lightDir varies with every fragment. So that can't be the problem. Now, if i put gl_FragColor = vec4(normalize(normal),1) I get this:



Which is expected, since every face has the same normal. Now, this part is what confuses me.

float diffuseLightIntensity = max(0,dot(normalize(normal),lightDir));

I take the dot product of the normal and the direction of the light. The normal remains the same for every part of the face, while the lightDir is different for every fragment of the face. Taking the dot product should give me a different value for each fragment, since lightDir is different for each fragment. Am I correct? Either way, diffuseLightIntensity remains the same for every fragment of the face, which can be seen on the first image.

I'm probably just misunderstanding something. If I'm doing something really stupid that I should be able to fix myself, then sorry for wasting your time. But hopefully I shouldn't make myself look like a fool.  Tongue

Any help is appreciated.  Smiley
21  Game Development / Networking & Multiplayer / Re: Prediction? on: 2012-02-04 20:56:58
If by shooters you mean first person shooters, then Im pretty sure alot of them only use client/server. For example all games made with the Source Engine. Sorry if it seems like Im trying to disprove you or something. I've always thought most action games used client/server so when someone tells me the complete opposite I have the right to sceptical. Tongue

Edit:

Heres a link that I found interesting, it describes the networking that the source engine use:

https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking
22  Game Development / Networking & Multiplayer / Re: Prediction? on: 2012-02-04 17:42:50
... at the cost of throughput. For the lowest delay use UDP, a peer-to-peer model and send as little as possible. There's a reason all (yes, all) major shooters out there today use this.

I know I shouldn't really argue with you about this since my knowledge is low, but I'm pretty sure lots of major shooter games use the client/server model. I could be wrong though.

Either way, if you say I should use p2p, then I probably should. It going to be a pain to re-write all my network code though. :/
23  Game Development / Networking & Multiplayer / Re: Prediction? on: 2012-02-04 15:17:38
I did a little test application that does this a couple of weeks ago:
http://www.java-gaming.org/topics/client-side-prediction-and-delayed-interpolation/25446/view.html

Thanks, ill check that out.

- Are you using a server-client model or a peer-to-peer model?
 - Are you using TCP or UDP?

Server/Client model. Currently using UDP, which I believe is the best choise for this project since I want to reduce latency as much as possible. But like I said, my experience is limited. If some thinks using TCP instead would be better, then I can change.

24  Game Development / Networking & Multiplayer / Prediction? on: 2012-02-04 12:11:01
Hi everyone, first post here.

Im working on a top-down multiplayer shooter game. Right now im working on the network code (using kryonet). This is my first multiplayer project so my networking knowledge is limited.

The first version of the networking code consisted of the server sending a packet containing information about the world every frame. I quickly realised that sending 60 big packets every second to every player is too much, so i set a limit on how often the server would send packets. Now, since the clients were no longer getting an update every frame, the game started to lag and stutter. I solved this by adding interpolation and now the problem is gone. Well, except that now I have input delay to deal with.

If I get it right, I understand that I must implement client side prediction. I don't know how to do it thought, and thats why I made this thread. It would be much appriceated if you could explain how I should implement prediction.  Smiley
Pages: [1]
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (32 views)
2014-12-15 09:26:44

Mr.CodeIt (23 views)
2014-12-14 19:50:38

BurntPizza (50 views)
2014-12-09 22:41:13

BurntPizza (84 views)
2014-12-08 04:46:31

JscottyBieshaar (45 views)
2014-12-05 12:39:02

SHC (59 views)
2014-12-03 16:27:13

CopyableCougar4 (58 views)
2014-11-29 21:32:03

toopeicgaming1999 (123 views)
2014-11-26 15:22:04

toopeicgaming1999 (114 views)
2014-11-26 15:20:36

toopeicgaming1999 (32 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!