LibGDX Coordinate System in Shaders?

Hi.

I am writing a 2D lighting system using LibGDX, but I have run into difficulties with shaders.

Previously I had written a lighting system in Slick2D, which worked very well, however the way coordinates worked in shaders in that library seems to be very different to LibGDX.

I had to write this Java function to change coordinates from ‘world coordinates’ to whatever works in shaders. I did this by analysing the output for different coordinates.

public static Vector2 screenToNDC(Vector2 screenCoords, Vector2 textureSize, Vector2 texturePosition)
{
return screenCoords.scl(new Vector2(1f / textureSize.x, 1f / textureSize.y)).sub(texturePosition.scl(new Vector2(1f / textureSize.x, 1f / textureSize.y)));
}

This function works fine translating the light position. This is my shader code:

#ifdef GL_ES
precision mediump float;
#endif

varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform mat4 u_projTrans;

uniform vec2 lightPos;
uniform vec3 lightCol;

//uniform float lightIntensity;

float dist(vec2 a, vec2 b) {
    return sqrt((b.x - a.x) * (b.x - a.x) + (b.y - a.y) * (b.y - a.y));
}

void main() {
    gl_FragColor = vec4(lightCol, 1.0 / dist(v_texCoords, lightPos));
}

Currently, this will draw only the light colour, with full alpha. Upon investigation, I found this must be because the dist function is returning very small values such that 1.0 / dist is positive. If I multiply dist(v_texCoords, lightPos) by a value like 10, the light falloff works as intended.

Is there any way to simply make coordinates work in LibGDX shaders in the same way that they do in Java or Slick2D shaders?

Thanks, Jack3311