Drawing Custom lines: material is rendered black sometimes

Hello, to all

I’ve been working for a while in a project, and this is the only thing is driving me crazy…

Sorry if this is obvious for JME Gurus, but i’ve tried to figure out what is wrong in here but i’ve failed miserably.

Here is my problem.

I’m working on a “Logic Circuit Simulator” using JME, all models are imported from Blender, Circuit Components have a Symbol which have a “Lighting.j3md” material applied when component receive a signal it glows (Using post filter) all is working as I expect for the components but I’m having problems with the wires.

Wire material is the same:Lighting.j3md

The wires are created using custom method, which is using “A*” algorithm to create path from initial component to final component, this line is made by vertices that this algorithm returns, when line is finished is drawn using the color from parent component , my problem is this color is not applied correctly on whole line, sometimes line is totally black, and sometimes it has some of the color it should have, and sometimes is rendered with the real color…

I really do not know where is the problem here is how it looks graphically:

You can see what I mean with material not being applied to all line…

If I move the components to other positions then some of the lines are rendered correctly but also some of them have this black patch:

Here is the code for custom line creation:


  • This method will create wire from initial node until final node

  • if reWire is true, it will “re-make” the actual wire to a new

  • geometry keeping the same wire node.

    public synchronized void createWire(boolean reWire)
    // This previous calculation will compensate the component position and also will
    // compensate Cirucuit board position
    Vector3f realLocation=initialPin.getWorldTranslation().add((Vector3f)initialPin.getUserData(“Location”));
    Vector3f realLocation1=finalPin.getWorldTranslation().add((Vector3f)finalPin.getUserData(“Location”));

    Vector3f wirePath[]=calculateWirePath();
    if (wirePath==null)
    Vector3f initialSegment=new Vector3f(wirePath[0].x-0.1f,wirePath[0].y,wirePath[0].z);
    Vector3f finalSegment=new Vector3f(wirePath[wirePath.length-1].x+0.1f,wirePath[wirePath.length-1].y,wirePath[wirePath.length-1].z);
    int numIndexes = 2 * wirePath.length;
    int numLines = numIndexes / 2;
    int padding = 0;
    int[] indexes = new int[numIndexes];
    for (int i = 0; i < numLines - padding; i++)
        indexes[2 * i] = i;
        indexes[2 * i + 1] = (i + 1) % numLines;
     Mesh wireMesh = new Mesh();
     wireMesh.setBuffer(VertexBuffer.Type.Position, 3,BufferUtils.createFloatBuffer(wirePath));
     wireMesh.setBuffer(VertexBuffer.Type.Index, 3, indexes);        
     // if it's a re-draw of wire I need to delete the old one.
     Node existingWireNode=(Node)baseCircuitBoard.getChild(getWireName());
     if (reWire && existingWireNode!=null)
     Geometry lineGeometry = new Geometry("GEOM:"+getWireName(), wireMesh);
     Material lineMaterial = new Material(assetManager,"Common/MatDefs/Light/Lighting.j3md");
     lineMaterial.setBoolean("UseMaterialColors", true);
     if (getWireSignal()!=0)
        lineMaterial.setColor("GlowColor", getWireColor());  
        lineMaterial.setColor("GlowColor", ColorRGBA.Black);         
     lineMaterial.setColor("Ambient", getWireColor());
     lineMaterial.setColor("Diffuse", getWireColor());        

// lineMaterial.setReceivesShadows(false);


    if (reWire && existingWireNode!=null)
        // if is an existing wire, just attach new Geometry

// addNewWire(getWireName(),this);
Node nwire=new Node();
CircuitComponent iNode=getInitialComponent();
CircuitComponent fNode=getFinalComponent();


    fNode.setInputPinSignal(this.getFinalPinName(), getWireSignal());



And here is code for the scene setup, I’m using a single light source:


  • Setup Scene
    private void setupScene()
    // Setting up scene
    // Disable flying camera
    float frustumSize = 15;

    float aspect = (float) cam.getWidth() / cam.getHeight();
    cam.setFrustum(-1000, 1000, -aspect * frustumSize, aspect * frustumSize, frustumSize, -frustumSize);
    cam.lookAt(new Vector3f(0f,0f,-35f), Vector3f.UNIT_Z);
    //cam.lookAt(new Vector3f(0f,-35f,0f), Vector3f.UNIT_Y);

    // Setup Lighting
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-.5f,-.5f,-.5f).normalizeLocal());
    // AmbientLight al=new AmbientLight();
    // al.setColor(ColorRGBA.White.mult(0.5f));

    // Setup default camera position
    cam.setLocation(new Vector3f(0f,0f,0f));
    // rootNode.addLight(al);


So any help is welcomed…


Sorry here is first missing image:

Lighting requires normals. That’s how lighting works. Light direction against the normal.

I don’t even know what normal vector a line would have in this case so maybe you really want to be using unshaded.

1 Like

Hello pspeed, thank you for your answer.

Actually I was using unshaded material at the beginning but glow effect does not work on that material…

I’ve choose lighting material on lines to make it glows when line is carriying a signal how I can achieve a similar effect with unshaded?

Actually doesn’t matter if it glows I just want the color to lit(be brigther) when it is carrying a signal.

Just to correct my self is the other way around unshaded material is too bright how I can turn it a little bit darker?

@xquake said: Actually I was using unshaded material at the beginning but glow effect does not work on that material...

yeh it does

@xquake said: Just to correct my self is the other way around unshaded material is too bright how I can turn it a little bit darker?

Yeah, just set the color to gray or whatever. I don’t know if you are using a texture for the coloring or not… but I figured if you were using color then the solution is obvious.

@pspeed said: Yeah, just set the color to gray or whatever. I don't know if you are using a texture for the coloring or not... but I figured if you were using color then the solution is obvious.

Ok thanks, no the lines does not have any texture applied. Line creation is like you see on the posted code…

Ok anyway I will try to setup a texture to see how it goes…

@wezrule said: yeh it does</blockquot>

Ok I need to double check this again last time I’ve tried I got no effect at all.

And actually unshaded color is already bright I would like to turn it darker instead.

Thanks for your suggestions.


@xquake said:

You don’t have to setup a texture. But if you are already setting a color and it’s “too bright” then set a less bright color. I’m not sure what the issue is there.

@pspeed said: You don't have to setup a texture. But if you are already setting a color and it's "too bright" then set a less bright color. I'm not sure what the issue is there.

Hello pspeed, sorry for my innorance on this, my issue was because I was using “absolute” color values for RGBA for example:

ColorRGBA.Green, ColorRGBA.Blue; etc so I was looking for a way to set this “absolute” color Darken, and not storing two different colors for this. (A bright color and A dark color)

After all your comments, and some digging on Internet I’ve found a way to convert a color to a Darken color, so I’ve applied this into my program and it’s working as I was expecting it.

So I followed your advice and changed material to “unshaded” and then applied this easy formula to get a darken color with a supplied “Absolute” color:

public ColorRGBA darker(ColorRGBA rgb,float percent)
if(percent>100) {
if(percent<0) {

        float factor=1-(percent/100);
        float r=rgb.r,g=rgb.g,b=rgb.b;
        return rgb;


@wezrule said: yeh it does

Thanks to you too, I’ve also did this and it’s working as well, I really not sure why it wasn’t before.

This case is solved now Please close this thread as Resolved.


FYI: the javadoc is available online and right in the SDK.


darker = someColor.mult(0.5f)