Is outline pass without light possible?

So I want to get a nice bright red and green with an outline pass, however using yields a forest green color.  (Light combine I think, however removing all light states, and setting default colors doesn't seem to help)

here is a test to show what I am talking about; press 'space bar' to toggle between outline pass (dark green) and pseudo outline pass (bright green done with a wireframe renderstate).

import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.math.Vector3f;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.pass.OutlinePass;
import com.jme.renderer.pass.RenderPass;
import com.jme.scene.Spatial;
import com.jme.scene.shape.Box;
import com.jme.scene.state.LightState;
import com.jme.scene.state.WireframeState;

public class OutlineTest extends SimplePassGame {

    Box greenBox = null;
    RenderPass renderPass = null;
    OutlinePass outlinePass = null;
    WireframeState wireframeState = null;

    public static void main( String[] args ) {
        new OutlineTest();

    public OutlineTest() {
        this.setDialogBehaviour( AbstractGame.FIRSTRUN_OR_NOCONFIGFILE_SHOW_PROPS_DIALOG );

    protected void simpleUpdate() {

        if( KeyBindingManager.getKeyBindingManager().isValidCommand( "toggle_mode", false ) ){

            if( renderPass.isEnabled() ){
                renderPass.setEnabled( false );
                wireframeState.setEnabled( false );
                greenBox.setCullMode( Spatial.CULL_ALWAYS );

                outlinePass.setEnabled( true );

            } else{

                renderPass.setEnabled( true );
                wireframeState.setEnabled( true );
                greenBox.setCullMode( Spatial.CULL_NEVER );

                outlinePass.setEnabled( false );


    protected void simpleInitGame() {

        display.getRenderer().setBackgroundColor( ColorRGBA.gray.clone() );
        wireframeState = display.getRenderer().createWireframeState();
        wireframeState.setLineWidth( 4 );
        wireframeState.setEnabled( false );

        KeyBindingManager.getKeyBindingManager().set( "toggle_mode", KeyInput.KEY_SPACE );

        Box whiteBox = new Box( "box", new Vector3f( -1, -1, -1 ), Vector3f.UNIT_XYZ.clone() );
        whiteBox.setLightCombineMode( LightState.OFF );
        whiteBox.setDefaultColor( ColorRGBA.white.clone() );
        greenBox = new Box( "box", new Vector3f( -1, -1, -1 ), Vector3f.UNIT_XYZ.clone() );
        greenBox.setLightCombineMode( LightState.OFF );
        greenBox.setDefaultColor( );
        greenBox.setRenderState( wireframeState );
        greenBox.setCullMode( Spatial.CULL_ALWAYS );

        outlinePass = new OutlinePass();
        outlinePass.setOutlineWidth( 4 );
        outlinePass.setOutlineColor( );
        outlinePass.setEnabled( true );
        outlinePass.add( whiteBox );
        pManager.add( outlinePass );

        renderPass = new RenderPass();
        renderPass.setEnabled( false );
        renderPass.add( whiteBox );
        renderPass.add( greenBox );
        pManager.add( renderPass );

        rootNode.attachChild( whiteBox );
        rootNode.attachChild( greenBox );
        rootNode.updateGeometricState( 0, true );


Also, here is an example pic:

  Outline            Desired
  Pass                Results


(Is this a dumb question??)

Of course its not a dumb question or it would have been answered already :slight_smile:

I played a bit with the OutlinePass and after i added a MaterialState, the nice green color appeared.

As i understand it, MaterialState.setColorMaterial, needs to be set if you want to use vertex Colors (set[Default/|Solid]Color() Methods) together with Lighting.

        ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();

But there is some, what seems z fighting, which i couldn't fix.

ahh settig the MaterialFace to Front and Back fixes the 'fighting issue' in your test case.

So if this MaterialState is added as a enforced state in OutlinePass, you get the expected result.

        ms = DisplaySystem.getDisplaySystem().getRenderer().createMaterialState();

But setting ms.setMaterialFace(MaterialState.MF_FRONT_AND_BACK); seems to be a bad idea, because it removes the diffuse grey color of the model in TestoutlinePass  :)


There is hope yet, I wonder if the z-fighting you are talking about is due to an improper cull state set on the outline pass box.  (I left it that way so they would look identical for the test)

Thanx for testing that out and coming up with a possible solution core-dump, you da man! :slight_smile:

but i don't understand why setColorMaterial would be needed, because the outline pass renders without lights.