Main
Tutorials











 

Reflection Proof Of Concept

This article is less of a tutorial than it is a Proof Of Concept, and is recommended for advanced mappers or people experimenting with the engine's capabilities. Anyone with thoughts or ideas about this feel free to email me and I will take a look, updating this page as necessary and giving credit where it is due. I will assume you have already read my Security Camera Tutorial, if not go ahead and do that first. Using this idea we can give an effect of reflections on water, but it is not without bugs and problems.

First, I subtracted a room with a hole in the ground for our water, and made a generic blue textured sky. I put a rocket launcher in to test our reflection, and a Gorge for scaling purposes.



With that in place, I set up the camera per my tutorial. The FOV is very important, and takes some experimenting to find the right value. For my 512 by 512 pool, I found that a value of 160 worked perfectly. I placed the camera just above where the water's center will be, to avoid having the waves show up in the rendering, then applied the camera's output texture to the FluidSurfaceInfo.



You might think it would be as easy as that, but if you test it out you'll notice that the reflection is backwards, and the water looks more like a mirror. We need to adjust the texture applied to the water's surface to make it look better. To do this, first I apply a TexScaler to the camera texture and give it a V Scale of -1 to flip it the right way. Now comes the difficult part to explain. To make it look like water, first I needed to get rid of the sky on the camera texture. This is especially important if there is any distinctive features in it such as a moon, but for simple star filled nights or clear blue skies it might not be necessary to take the step to get rid of it. To do this, I temporarily replaced the water with a cube fitting the pool, then took a screenshot of it in game, hitting the NumPad 5 key to get it lined up right. It is necessary to do this in game since the camera view texture does not show up in the editor. Once I had that, I applied a Combiner and subtracted it from the camera texture. The resulting texture should be nearly completely black in game, and will only display things that are different from what the camera would normally see, such as a bot or weapon fire crossing over it. To get it to look like water, I simply used Photoshop to combine a water texture I liked with the screenshot I took, and subtracted that in the Combiner instead. Depending on what your skybox looks like and what objects are near your pool, you will need to experiment to find the best way to combine the textures. The results of my experiment are shown here in the editor and in game:





Another use of this effect would be applying it to a simple wall surface to give a realistic reflection of weapon fire and player opponents. Once again, a lot of experimenting would be necessary to get the right FOV settings for the camera and the right combination of textures for it to look realistic.

Now for the bad news. The major one being that this will probably give a substantial performance hit in most situations. Also, since the camera texture is rendered from the center and depends on the FOV, the effect gets worse as the pool grows larger, so it would only be useful for small areas. As with the normal use of the camera, since the engine does not display your character model in first person mode, you will not be able to see yourself in it. Finally, if a player runs directly over the camera, well...



The engine will not let you apply the camera texture to a cubemap, so this effect would have to be combined with one in another way, such as making the reflection a separate sheet, with the cubemap applied to the FluidSurface normally.

As with Warp Zones, if you can live with the limitations then it makes a great effect that can end up being very useful. I hope someone gets some use out of this. Good luck!

Example Map from this Tutorial (44kb zip)