[LibGDX] Shader "camera"

I’m fairly unexperienced in shader programming and I can’t really grasp how could I transform my OrthographicCamera pixel coors
to shader coords. I know there are some matrices, modelview, eye coord and a few more but I don’t know how to make them work.
Made a picture quickly to help me xeplain my problem better.

  • Black rectangle is the whole 2d scene (map, since it is a platformer game) with 10000 x 4000 size.
  • Red rectangle is the Orthograpic camera centered at the Gray moving box which is the player.
  • Orange circles are static light sources.

http://s29.postimg.org/xa1czmq47/help.jpg

Basicly the only thing done with shaders here is the light sources wich lights normal mapped textures using the Lambertian Illumination Model.
The light sources’ positions are uniform values and they are all static, so they stay at the position they were created until they are destroyed.

My reals question is how could I pass the light’s position to the shader and the transform it inside the shader so they won’t follow the camera but they stay where they should.
(no matter what I tried the lights were following the camera as I moved or they were appearing at wrong positions)

I edited the post so you may understand my problem better.

Could we have some shader code? It would help a bit.

The problem you have here is that the model/view matrix (assuming you’re using the build-in ones, and not passed to the shader) is not translating the light’s position, but it is translating the model’s(s).

So, the easy fix is to translate your light’s position by the model/view matrix before you give it to the fragment shader.

Vertex Shader


...
//Ignore the sloppy naming, it makes more sense to me...
uniform vec3 uniform_LightPosition; //Light (position)
uniform vec3 uniform_LightColor; //Light (color)
...
varying vec3 LightPosition; // Final light position
varying vec3 LightColor; // Final light color
...

void main(void)
{
      // This translate's the light's position by whatever matrix your 
      // translating.
      LightPosition = uniform_LightPosition * gl_ModelViewMatrix; // Final light position = uniform light position * model/view matrix
      LightColor = uniform_LightColor;                                         // Leave the light's color as it is
      ...
}

Pretty easy fix really.