Issue with unwanted shadow on a transparent box

I know its something simple, but i cant seem to come up with a way to remove shadowing on a transparent box. 



I’m not using shadow pass, but on one side of the box there is a shadowing effect.  I have tryed putting a light state on the box itself and still same effect.  Any ideas?



Good View:





Bad View:







Thanks


Could it be the depth sorting? It looks kinda like when the transparent object is rendered on the black background, before the terrain is rendered.



With that problem, things I check are:



Does everything have a bounding box?

Did I set up a z-buffer?

Are all transparent objects in the transparent render queue?

Do all transparent objects have z-buffer write disabled? (zs.setWritable(false):wink:

Does everything have a bounding box?


Yep

Did I set up a z-buffer?


Z-buffer is set on the root node.  Adding one directly to the object had no effect.

Are all transparent objects in the transparent render queue?


Yep

Do all transparent objects have z-buffer write disabled? (zs.setWritable(false)


Tryed this with no effect.


sample code:


  Box targetBox;
  MaterialState materialState;
 
  ColorRGBA hostileTarget = new ColorRGBA(.6f, 0, 0, .5f);
  ColorRGBA nonhostileTarget = new ColorRGBA(0, .6f, 0, .5f);


    targetBox = new Box("TBox", new Vector3f(), 1f, 1f, 1f);
    targetBox.setModelBound(new BoundingBox());
    targetBox.updateModelBound();
    targetBox.setLocalTranslation(new Vector3f(0, 0, 15));
    targetBox.setIsCollidable(false);
    targetBox.setSolidColor(neutralTarget);
    targetBox.setDefaultColor(nonhostileTarget);

    ZBufferState buf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
//    buf.setQuickCompares(true);
//    buf.setFunction(ZBufferState.CF_LEQUAL);
    buf.setEnabled(true);
    buf.setWritable(false);
    targetBox.setRenderState(buf);

    LightState ls = DisplaySystem.getDisplaySystem().getRenderer().createLightState();

    PointLight pl = new PointLight();
    pl.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
    pl.setAmbient(neutralTarget);
    pl.setLocation(targetBox.getLocalTranslation());

    ls.attach(pl);
    ls.setTwoSidedLighting(false);
    targetBox.setRenderState(ls);

    materialState = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();
    materialState.setEnabled(true);
    materialState.setDiffuse(neutralTarget);
    materialState.setShininess(128);
    materialState.setAmbient(neutralTarget);
    targetBox.setRenderState(materialState);

    AlphaState as = DisplaySystem.getDisplaySystem().getRenderer().createAlphaState();
    as.setEnabled(true);
    as.setBlendEnabled(true);
    as.setSrcFunction(AlphaState.SB_SRC_ALPHA);
    as.setDstFunction(AlphaState.DB_ONE_MINUS_SRC_ALPHA);
    targetBox.setRenderState(as);

    targetBox.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
    targetBox.updateRenderState();


Do you have two pass transparency enabled?

Tryed with it enabled and disabled.  Got the same shadowing. 




It seems that the objects lightstate does not override the scenes light state.  I can add another scene light opposite of my current one and the shadow disappears, but shouldn't the object lightstate override this?  If not,  how do i achieve this (if possible)?


Lightstates can be controlled by setting the lightCombineMode on the Node…



try this:

Node.setLightCombineMode( LightState.COMBINE_FIRST );


or

node.setLightCombineMode( LightState.REPLACE );


or even

node.setLightCombineMode( LightState.OFF );



On the node you are having problems with.

Only the LightState.OFF changes the look.  And it make an undefined box.  I guess i could make something that will add lines around the box to give it definition.


I think the confusion is that you think light is actually passing through the box.  On "transparent" objects, lighting is still affecting the colors on the faces of the box as it would if it was completely opaque…  it's just that the results are then being alpha blended with the scene.  Having the two lights in there just lights up both sides of the box equally, which is why it looks ok.  You might consider turning off the lights, but using a texture or vertex coloring to give the box more definition.