I want to draw a point, to simulate the position of which the light originates, however the issue I am facing now is that it is always the same size, regardless of the distance:
I push literally one vertex to the GPU, my code:
point.vs.glsl
#version 440 core
layout(location = 0) in vec4 position;
layout(location = 0) uniform mat4 model_matrix;
layout(location = 1) uniform mat4 view_matrix;
layout(location = 2) uniform mat4 proj_matrix;
void main(void) {
gl_PointSize = 100.0;
gl_Position = proj_matrix * view_matrix * model_matrix * position;
}
point.fs.glsl
#version 440 core
out vec4 color;
void main(void) {
//create round point
vec2 p = gl_PointCoord * 2.0 - vec2(1.0);
if (dot(p, p) > 1.0) {
discard;
}
color = vec4(0.5, 0.0, 0.0, 1.0);
}
Also does the code for creating a round point actually work in 3D? I believe it came from a 2D tutorial if I'm not mistaken.
About the point size again, I know what I am doing wrong, however how would I correctly calcualte the size? I have the information available I think, with view_matrix
and somehow I need to get the distance to the point, and scale depending on that.