Glow/Bloom Effect

How do you create a glow/bloom effect in StandardGame? I am trying to create a translucent cube/sphere with light coming out of it from its center – is this even possible? If so, I would like to apply this effect to just one object while keeping the rest in my scene normally shaded. Can anyone point me in the right direction? Do I absolutely need to extend SimplePassGame? I am trying to create an app which is multithreaded and would like to use StandardGame…



Thanks!



PS Sorry, just realized that this should probably go under the "Effects" section of the Forum.

This is a solution to you problem.



import com.jme.math.Vector3f;
import com.jme.renderer.pass.BasicPassManager;
import com.jme.renderer.pass.RenderPass;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.state.CullState;
import com.jme.scene.state.LightState;
import com.jmex.game.StandardGame;
import com.jmex.game.state.GameStateManager;

public class PassStandardGame  {
   private PassManagerGameState pManagerState;
   private BasicPassManager pManager;
   private Node rootNode = new Node("root");
   private StandardGame game = null;
   
   public static void main(String[] args) {
      PassStandardGame mainGame = new PassStandardGame("Pass GameState Test");
   }

   public PassStandardGame(String gameName)
   {
      game = new StandardGame(gameName);         
      initGame();
   }
   
   public void start()
   {
      game.start();
   }

   protected void initGame()
   {
      //Startup the game
      game.start();
      pManager = new BasicPassManager();
      setupEnvironment();

      //tm returns a Spatial
      /*
      TerrainManager tm = new TerrainManager();
      Spatial terrain = tm.createTerrain();
      rootNode.attachChild(terrain);
      rootNode.updateRenderState();
      */

      RenderPass rootPass = new RenderPass();
      rootPass.add(rootNode);
      pManager.add(rootPass);
      pManagerState = new PassManagerGameState();
      pManagerState.setPassManager(pManager);
      //Attach game state
      GameStateManager.getInstance().attachChild( pManagerState ); // attach it to the GameStateManager

      //Activate game state
      pManagerState.setActive(true);
   }

   private void setupEnvironment()
   {
      game.getCamera().setFrustumPerspective(50.0f,
            (float) game.getDisplay().getWidth() / (float) game.getDisplay().getHeight(), 1f,
            1000f);
      game.getCamera().setLocation(new Vector3f(-270, 180, -270));
      game.getCamera().lookAt(new Vector3f(0, 0, 0), Vector3f.UNIT_Y);
      game.getCamera().update();

      CullState cs = game.getDisplay().getRenderer().createCullState();
      cs.setCullMode(CullState.CS_BACK);

      rootNode.setRenderState(cs);
      rootNode.setLightCombineMode(LightState.OFF);
   }
}




import com.jme.image.Texture;
import com.jme.renderer.pass.BasicPassManager;
import com.jme.system.DisplaySystem;
import com.jme.util.geom.Debugger;
import com.jmex.game.state.DebugGameState;

public class PassManagerGameState extends DebugGameState
{
   private BasicPassManager pManager;
   
   public PassManagerGameState() { super(); }

   public void setPassManager( BasicPassManager pManager )
   {
      this.pManager = pManager;
   }
   @Override
   public void render( float tpf )
   {
      DisplaySystem.getDisplaySystem().getRenderer().clearBuffers();
      pManager.renderPasses( DisplaySystem.getDisplaySystem().getRenderer() );

      //Instead of calling super.render() which would cause everything to be double
      //rendered, I do everything here myself.
      if (showBounds) {
            Debugger.drawBounds(rootNode, DisplaySystem.getDisplaySystem()
                    .getRenderer(), true);
        }

        if (showNormals) {
            Debugger.drawNormals(rootNode, DisplaySystem.getDisplaySystem()
                    .getRenderer());
        }

        if (showDepth) {
            DisplaySystem.getDisplaySystem().getRenderer().renderQueue();
            Debugger.drawBuffer(Texture.RTT_SOURCE_DEPTH, Debugger.NORTHEAST,
                    DisplaySystem.getDisplaySystem().getRenderer());
        }
   }
}

What a community… someone asks a question and get a reply with full code example in 1 hour, lol.



Anyways this looks good, I will try that out myself also… Now only to get this working with FengGUI and StrategicHandler.

Mindgamer said:

What a community.. someone asks a question and get a reply with full code example in 1 hour, lol.

Anyways this looks good, I will try that out myself also... Now only to get this working with FengGUI and StrategicHandler.


thats one of the best part of jme. we have the best community!  :D

anyways, going to bed....ill post the md5importer tomorrow haha

Thanks for the code – will try this out soon!

neakor said:

thats one of the best part of jme. we have the best community!  :D


I quote.

We have to thanks for this the authors (mojomonk and renanse), they started it the right way.

Sorry to bring up an old thread especially after I got help like an hour after my first post, but I am just now getting into bloom and don't know how to make everything work. Do I need to create a BloomRenderPass and add my pManagerState rootNode to it? When I add a simple box to my pManagerState rootNode, I don't see anything. Do you have any example code that I can look at?



Thanks!