How can I find point position in fragment shader?

Viewed 16

I need to add a new element to Carto map engine to draw a circle with a bit gradient inside it.

  • First I draw a square; I'm doing that with drawing two triangles beside in the map using glDrawElements method and GL_TRIANGLES.

  • Second thing I need is to find the point position in that square inside the fragment shader but I can not do that because every coordinate position of the square is multiplying to Mode-View-Projection matrix like this:

/////////////////////////////////Vertex Shader///////////////////////////////////
#version 100
attribute vec4 a_coord;
uniform mat4 u_mvpMat;

varying vec4 v_coord;


void main() {
    v_coord = a_coord;
    gl_Position = u_mvpMat * a_coord;
}

How can find the point position in the square after multiplying to MVP Matrix?

///////////////////////////////Fragment Shader////////////////////////////////

#version 100
precision mediump float;
varying lowp vec4 v_coord;

void main() {
    vec2 position = ??????
//    position = position - 0.5;
//    float pixelColor = circleShape(position, 0.25);
//    position = position + 0.5;
    gl_FragColor = vec4(vec3(pixelColor), 1.0);
}

0 Answers
Related