I'm coding a little terrain engine in Java3D and was wondering if anyone could give me a few pointers with some questions I have. I'm aware of course that this is a forum for jME, but my questions are fairly general and (hopefully) not too API specific. Besides that, this community seems to be extremely active, welcoming and helpful!
How is the effect of water reflection acheived? I'm vaguely aware of the following approach…
- Render the relevant aspects of the current scene to a texture (terrain and sky)
- Pass that texture down to your shader
- Perform the necessary operations with your noise texture and the rendered scene texture to create the appearance of a reflection.
The last part isn't much of a problem, because I've got quite a number of good examples of water shaders and they are simple enough to understand.
Where I am running into difficulty is the initial step of rendering to texture. I don't really understand how I can produce a texture from my current scene which is appropriate as a reflection. Off the top of my head, I suppose that it should be something along the lines of…
- Invert the appropriate aspects along the vertical axis
- When in the shader, have the reflection texture be projected onto the surface from the camera's point of view.
The most immediate problem, and perhaps one which is of least relevance to the jME forum, is that, as far as I can tell, Java3D does not actually have a render-to-texture function! Does anyone know if this is the case, and if so, are water reflections in Java3D a total dead-end? Are there any possible work-arounds to acheive this effect myself?
I suppose I'll leave it at that for now. If anyone has any useful information at all regarding this problem, I would be greatly appreciative. I have seen the work of Mr.Coder with the projected grid implementation and was extremely impressed. I'm only hoping to have a simple reflective quad stretched across my scene, so I hope someone can give a bit of insight!