Environment map on a sphere


I am in need of a method to create an environment map on a sphere using the rest of my scene. So what I basicly want is something similar to this:

I am using a TextureRenderer as for now to get the pictures, but is this the right approach? If so, what position and angle of the camera should I use, center of the sphere pointing at the world camera? And what spread angle should that camera use?

Or is there another approach to this that you would recommend?

Please help me out.


Let's bump this up a bit.

Ok, I really need this. I'm trying to extend the WaterRenderPass class to work on a sphere instead of a plane. Acctually I would like it to work with any shape.

Please help, this is something I really need.

Thank you


Try to create a huge sphere autoilluminated.

How will this work in real-time? It's absolutely necessary that it works in real-time.

And if that solution works in real-time please explain a little more in depth.
I'm new when it comes to 3d.

Thank you


I'm out of ideas.  :cry:

But "WaterRenderPass" extends the "Pass" Class…

So possibly you can create something like this:









    initialize()     /* you can use Refraction and ProjectedShader */



usual way is rendering in all six directions from the object center, then using those render textures as a cubemap.

Thank you, I'm not able to test this right now as I'm not at home.

I believe that this was all the information I needed, if not I'll gladly post here again.

Once again, thank you MrCoder.

MrCoder said:

usual way is rendering in all six directions from the object center, then using those render textures as a cubemap.

Ok, I've run into a problem. The TestCubeMap example of Cube Mapping uses Images and and The TextureRenderer creates Textures and somehow I can't obtain those Images with:


Well I can, but the returning image is null  :(

I might have done something terribly wrong. At the moment I'm trying to set up a test for this by modifying the TestCubeMap example code.

/* Some variables */
   TextureRenderer tRenderer;
   Texture2D fakeTex;
    private Quaternion rotQuat = new Quaternion();
    private float angle = 0;
    private Vector3f axis = new Vector3f(1, 1, 0);
    private Sphere t;
    private Node sky;
   Sphere sphere;
   Node n;
   private Skybox skybox;
   private float farPlane = 10000.0f;
   private float textureScale = 0.02f;
   TextureState screen;
   Texture2D tex;
   Box q;
   Texture2D tex1;
   Texture2D tex2;
   Texture2D tex3;
   Texture2D tex4;
   Texture2D tex5;
   Texture2D tex6;
   boolean isFirstRender = true;

/*End of variables */

   protected void simpleInitGame() {

      q = new Box("Box", new Vector3f(), 5, 5, 5);

      sphere = new Sphere("Sphere", 25, 25, 5);
      tRenderer = display.createTextureRenderer(512, 512, TextureRenderer.Target.Texture2D);
      tRenderer.setBackgroundColor(new ColorRGBA(1f, 0f, 0f, 1f));
      fakeTex = new Texture2D();
      tex1 = new Texture2D();
      screen = display.getRenderer().createTextureState();
      rootNode.attachChild( skybox );
      n = rootNode;
      Sphere testS = new Sphere("Sphere", new Vector3f(0,10*4,0), 50, 50, 5);
      Sphere testS2 = new Sphere("Sphere", new Vector3f(0,-10*4,0), 50, 50, 5);
      Sphere testS3 = new Sphere("Sphere", new Vector3f(5*4,0,0), 50, 50, 5);
      Sphere testS4 = new Sphere("Sphere", new Vector3f(-6*4,0,0), 50, 50, 5);
      Sphere testS5 = new Sphere("Sphere", new Vector3f(0,0,7*4), 50, 50, 5);


   protected void simpleRender()

      tRenderer.getCamera().setLocation(new Vector3f(0,0,5));
      tRenderer.getCamera().lookAt(new Vector3f(0,0,10),new Vector3f(0,1,0));

               Image img1 = tex1.getImage();
               if(img1 == null)
                      System.out.println("The image is null, arrgh!!")
         isFirstRender = false;

I can't see why the image returns null when the box "q" gets the Texture rendered to it.
Please help.