[Solved] How to change the color for selected vertex using shader?

I want to wright a simple example with cube where I will pick one of face(4 points) of cube using ray cast than I’ll pass these points to shader.
Now I don’t know how to set different color for picked face…!

I tried but might be my entire code is wrongly written.
Here is initial code.
Vertex Shader

attribute vec3 inPosition;
attribute vec4 inTexCoord;
uniform mat4 g_WorldViewProjectionMatrix;
uniform mat4 g_WorldViewMatrix;
uniform vec3 m_PointsToHColor[4];
varying vec4 vertextPosition;
varying float changeColor;
void main() {
vec4 position = vec4(inPosition, 1.0);
for (int i = 0; i < 4; i++) {
if(inPosition.xyz == m_PointsToHColor[i].xyz) {
changeColor = 1.0;
} else {
changeColor = 0.0;
gl_Position = g_WorldViewProjectionMatrix * position;

Fragment Shader

#ifdef COLOR
uniform vec4 m_Color;
#ifdef HCOLOR
uniform vec4 m_HColor;
varying float changeColor;
void main() {
vec4 color = vec4(1.0);
#ifdef COLOR
color = color;
#ifdef HCOLOR
if(texCoord.z == 1.0) {
color *= m_Color;
gl_FragColor = color;

Java Code

    Box b = new Box(1, 1, 1);
    Geometry geom = new Geometry("Box", b);
    mat = new Material(assetManager, "MatDefs/TestColor/ColorTest.j3md");
    mat.setColor("Color", ColorRGBA.Blue);
    mat.setColor("HColor", ColorRGBA.White);

     inputManager.addListener((ActionListener) (String name, boolean isPressed, float tpf) -> {
     } else if (name.equals("LEFT_CLICK")) {
            Ray ray = new Ray(cam.getLocation(), cam.getDirection());
            CollisionResults results = new CollisionResults();
            int resCount = geom.collideWith(ray, results);
            if (!isPressed) {

                if (resCount > 0) {

                    Vector3f point = results.getClosestCollision().getContactPoint();
                    Vector3f[] data = getFace(point); // Returns 4 points as one side face of cube
                    mat.setParam("PointsToHColor", VarType.Vector3Array, data);

inPosition is in model space, are m_PointsToHColor in model space too?
In the fragment, what is changeColor used for ? In the code you posted it seems you are not using it at all.

the texCoord.z is mistake it supposed to be changeColor. 'changeColor ’ is used as flag like boolean.

Then yes…you should use changeColor in that line…
And by the way, inTexCoord should be a vec2, not a vec4

Thanks, I was passing wrong vertex. I corrected it and its working good.