Does TextureRenderer create the Image of a Texture?

I'm new to JME and trying to create a TextureCubeMap from 6 textures I've rendered with the TextureRenderer. However, when I try to combine the images of each texture to create the cubemap I get a nullpointer exception, since all the Textures' Images are null, at least whenever I check them. Does the TextureRenderer create the Image for each Texture at some point or am I missing how it works? (The Textures do appear correctly when I apply them to spatials, I just can't seem to get to their Image)



Thanks in advance for any help.

If anyone has any idea I would really appreciate the information (even a simple yes or no). I'm utterly stuck and have tried everything I can think of to make sure that the texture is rendered, but I still can't seem to access the produced image.

It's not possible to do what you're trying to do with jME.

With pure OpenGL… it might be a different story but you will need video card with good (OpenGL3+) support.

It also depends, do you need this for real time or no?

I was worried I'd have to start messing with OpenGL directly :(. As for whether it needs to be real-time, I'd definitely prefer it, but since this project is due next week I'd settle for static images. Would I just need to take screenshots or export the textures for importing during the actual game's run?



PS - If this is impossible to do with JME, someone should probably remove the suggestion from the User's Guide here:

http://www.jmonkeyengine.com/wiki/doku.php?id=texturerenderer - at the point where it states that the TextureRenderer is very useful for creating CubeMaps for mirrors. Unless there is a way that doesn't involve directly programming in OpenGL?

It is possible to create mirrors with TextureRenderer, but it has nothing to do with cubemaps. Assuming the mirror is a plane that is.

If you are okay with non real-time, you can create 6 screenshots with Renderer.takeScreenShot() for each angle and then compose them into a cubemap.

Thanks a lot for your help so far Momoko_Fan, otherwise I'd still be wondering if I was just trying to access the image in the wrong way. I might be able to use non-real time reflections. I also think a lot of the surfaces that would require real-time rendering are going to be flat planes. If you could direct me to somewhere that describes how to create mirrors I'd really appreciate it, it seems like a lot is missing from the User's Guide. Does it involve Stencil States?

SwitchShift said:

Thanks a lot for your help so far Momoko_Fan, otherwise I'd still be wondering if I was just trying to access the image in the wrong way. I might be able to use non-real time reflections. I also think a lot of the surfaces that would require real-time rendering are going to be flat planes. If you could direct me to somewhere that describes how to create mirrors I'd really appreciate it, it seems like a lot is missing from the User's Guide. Does it involve Stencil States?


The simple way of creating a mirror is by setting up another camera, and rendering the scene to a texture with that camera (e.g. a mirror plane would have the camera facing outward, and then the scene from that perspective gets rendered and the texture is applied to the mirror plane).

I've never done this with jmonkey (I have with other engines), but the texture renderer pretty much would do all of this for you, I'd assume, just would have to grab the texture from it.

However, usually this is slow, generally the stencil buffer is used to create the reflection. This is more complicated (and something I can't really give much input in how to do in jmonkey).

Rendering using the stencil buffer requires rendering the mirror while writing stencil, then rendering the scene inverted along the mirror plane normal with stencil test on. It's faster and uses less memory than the texture renderer method but is a bit more difficult to implement.

Do you know of any resources on how to use the Stencil Buffer with JME? And with the TextureRenderer method, won't you run into a problem where you'd render more of the scene than should be in the Texture?

Hey guys and sorry for raping that old thread :wink:

I wonder what TextureRenderer to use?


The simple way of creating a mirror is by setting up another camera, and rendering the scene to a texture with that camera (e.g. a mirror plane would have the camera facing outward, and then the scene from that perspective gets rendered and the texture is applied to the mirror plane).


Is there a good tut out there for achieving a mirror? Is the proposed method still recommended? I ask since I guess they weren't talking about jME3 :p

I would be interested too. I have a car racing game with two wing mirrors implemented using view ports and a rear facing camera, but the image is not reversed as it would be with a mirror.