Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 18 Sep 2010
Offline Last Active Nov 21 2012 03:03 PM

Topics I've Started

Shadowmapping in Camera-Space

20 November 2012 - 02:58 PM

while continuing my work on my deferred shader engine I descided to implement a shadowmapping feature.

Here is the process i do for each light that casts shadows:
1. render the scene from light point of view to create depth-shadowmap
2. store modelview and projection matrix
3. draw light to lightmap using g-buffer and shadowmap
3.1 build transformation matrix that goes from cameraspace to light-view-clipping space by using this matrix:
transformation-matrix = light_projection_matrix * light_modelview_matrix * camera_modelview_matrix_inverse
3.2 In the shader: read fragment position from gbuffer, calculate shadowmap_texture_coordinate with:
shadowmap_texture_coordinate = transformation-matrix * gbuffer_pos
3.3 do the is-in-shadow check stuff

I have several problems:
1. The shadowmap_texture_coordinate does not seem to have an orthographic projection. I fixed this by applying this to the shadowmap_texture_coordinate (sc):
sc.xy = sc.xy / sc.z
This is not correct in any way I think but I have no idea what else could cause the projection-bug.

2. When I read from the shadowmap I get values in [0,1]. How do I transform these to compare them with the distance of a fragment from the light-position since those are given in engine-units.

I hope someone will understand what I am doing Posted Image sometimes I'm not sure my self Posted Image

Deferred shading - problems with normal map

30 October 2012 - 12:51 PM

I'm implementing a deferred shading renderer based on OpenGL. I got everything setup and lighting seems to work but I can't figure out why the light is appearing on the faces that should be completely dark.
For non-normal-mapped objects everything works fine. So I guess there is something wrong with my tangent-space normalmaps.

Here's the code for generating g-buffer-normal-map (in view-space):
[source lang="cpp"]Vertex Shader: normal = normalize(gl_NormalMatrix * gl_Normal); vec3 t = normalize(gl_NormalMatrix * gl_MultiTexCoord1.xyz); vec3 b = cross(normal,t); TBN = mat3(t,b,normal);Fragment Shader: vec3 n = (texture2D(normalMap,gl_TexCoord[0].st).rgb-0.5)*2; n = normalize(TBN * n); gl_FragData[2] = vec4((n+1)*0.5,1); [/source]

Even if I only display dot(normal,lightdir) I get light artifacts on the faces the light shouldn't reach ...
Here are images of the "final" lightmap render and the normalmap from the g-buffer.

Thanks for your help

Object synchronization (for physics based games)

19 December 2011 - 03:52 PM

We're trying to write a network synchronization for a physics based 2D shooter (in Java)(website). Its our second attempt but we feel it won't work again.

Our first attempt was:
1) Server builds sync packages which contain position + rotation updates all as byte arrays
This usually ended in a mess with Java's ByteBuffers but we got it working for some basic parts
2) Client receives sync packages and decodes the byte array and applies updates
Like for 1) it was a mess with bytes

3) Important events like "add physics body" or "shoot gun" had to be sent to server and acknowledged/accepted before client could add a bullet
Bullets are physic bodies too. Adding physic bodies (same fore loading the level) also was a command witch was nearly 100% synced over network.

But all together never worked well over network and after a while every thing starts to slow down on the client side or events were applied seconds after they were physically sent.

The protocol was written using a UDP socket. I implemented functions that could guarantee package transfer and functions that did not guarantee but gave a good speed. The unsecure functions were used for 1) and 2) and the secure functions were used for 3)

Our main question is: Is there a much easier way to implement a working synchronization over the network? Are there any libraries that do exactly what I need here?
Is Java's serialization API something that could help?

Thanks for any comment!