Fake flat surface reflections
I've been wanting to add this for a while, but I can't seem to get the math together to do what I want. Basically, I just want to use a low quality blurry texture to represent the ceiling (or the ceiling and all four walls), and render this as a secondary texture on the floor.
If anyone reading this played Half Life 2, this was happening in the first building area you enter, where you have to enter the metal-fence-looking queue. You could see the ceiling lights on the floor. Just a texture that moved about when you look at it from different perspectives.
I'm guessing I need to do some type of bounce from the camera, off of the normal of the surface, to the object surface being reflected. But nothing I try seems to work the way I want it to. I drew this up quickly to explain what I expect I need to do, or at least simulate:
I have my texture loaded and my vertex shader technique is ready for me to start typing, but I'm not sure what to try. Can anyone recommend a tutorial or some type of online reading material?
I would really appreciate any information. Thanks.
Just render the ceiling (and walls if you have to) to a texture with inverted up axis. Then project this texture on to the floor (you may even perturb the texcoords on the floor judiciously in a fragment program or in a vertex program with a tesselated mesh to simulate a bumpy surface). You can find implementation details in this article.
Well, this is a top-down third person view, so I don't actually have a ceiling to reflect. Just literally a texture that I've manually created. From what I understood, it doesn't look like that operation will work quite the same way. It looks like it relies on the reflection texture to be from the perspective of the camera.
But it was still educational, so thanks. I still need a little help figuring out how to render using, as he puts it, "projective texturing", with a pre-generated texture. I believe it could be similarly accomplished with the camera matrices.
Thanks again :)
But it was still educational, so thanks. I still need a little help figuring out how to render using, as he puts it, "projective texturing", with a pre-generated texture. I believe it could be similarly accomplished with the camera matrices.
Thanks again :)
Well.... if I understand correctly, you have a 3rd person view, so you don't have geometry for the ceiling, but you want to pretend there is so it may be reflected.
That's why you called the "fake" flat surface reflections.
You plan to make use of a "flat" ceiling texture (or collection of textures)
You can do that - the equation becomes nothing more than a position raytrace of each corner of the viewing frustrum (as you've shown) brush up on the maths and you'll be fine.
You may want to (if you're already using a 3d renderer) make use of its capabilities and just "mirror" (no really, mathematically) the coordinates of flat 3d geometry of the ceiling below the floor plane.
At his point you can blend the result over a stenciled section of the scene, or can render to texture and use it slightly differently if you're wanting to do blurry, noisy, or distorted floor reflections (probably advisable for quality)
Hopefully this pushes you in the right direction.
-Michael g.
That's why you called the "fake" flat surface reflections.
You plan to make use of a "flat" ceiling texture (or collection of textures)
You can do that - the equation becomes nothing more than a position raytrace of each corner of the viewing frustrum (as you've shown) brush up on the maths and you'll be fine.
You may want to (if you're already using a 3d renderer) make use of its capabilities and just "mirror" (no really, mathematically) the coordinates of flat 3d geometry of the ceiling below the floor plane.
At his point you can blend the result over a stenciled section of the scene, or can render to texture and use it slightly differently if you're wanting to do blurry, noisy, or distorted floor reflections (probably advisable for quality)
Hopefully this pushes you in the right direction.
-Michael g.
Half Life 2 simply used pre-rendered cubemaps for environment reflections. The level builders placed points in the level where the environment was rendered into a low resolution cubemap. The game then used this cubemap as the specular component by choosing the closest cubemap to a surface (or material) and doing a cubemap lookup based on the reflection vector.
So you need to render the environment that you want reflected at various sample points (and the environment could be different then what you render in the game since this can be a preprocess) and do simple cubic environment mapping. If you decide to do this I'd highly recommend using glossmaps (where the reflection is modulated by the glossmap to allow varying reflectivity).
So you need to render the environment that you want reflected at various sample points (and the environment could be different then what you render in the game since this can be a preprocess) and do simple cubic environment mapping. If you decide to do this I'd highly recommend using glossmaps (where the reflection is modulated by the glossmap to allow varying reflectivity).
Quote:Original post by blue_knight
Half Life 2 simply used pre-rendered cubemaps for environment reflections. The level builders placed points in the level where the environment was rendered into a low resolution cubemap. The game then used this cubemap as the specular component by choosing the closest cubemap to a surface (or material) and doing a cubemap lookup based on the reflection vector.
So you need to render the environment that you want reflected at various sample points (and the environment could be different then what you render in the game since this can be a preprocess) and do simple cubic environment mapping. If you decide to do this I'd highly recommend using glossmaps (where the reflection is modulated by the glossmap to allow varying reflectivity).
:(
Environment mapped cubemapping for flat reflections is a bad idea...
(I've never seen it done well, anyway...)
-Michael g.
I could get the result I want by throwing a flat quad down under the floor, just as far down from the floor as the ceiling would be up, then making the floor mesh blend by modulating over that quad.
Imagine a glass floor, where another opaque floor is about five feet down under it. The glass floor would not be entirely transparent. If you were drunk, you might think that the glass floor is just a very shiny opaque floor, and that the secondary floor (which is under it) is the ceiling being reflected.
The only input to this calculation is the 5-feet, which represents how far the reflected object is from the surface. I just figured there was a way to accomplish this same effect by generating secondary texture coordinates for the floor in the vertex shader.
I still appreciate the information. Thanks.
Imagine a glass floor, where another opaque floor is about five feet down under it. The glass floor would not be entirely transparent. If you were drunk, you might think that the glass floor is just a very shiny opaque floor, and that the secondary floor (which is under it) is the ceiling being reflected.
The only input to this calculation is the 5-feet, which represents how far the reflected object is from the surface. I just figured there was a way to accomplish this same effect by generating secondary texture coordinates for the floor in the vertex shader.
I still appreciate the information. Thanks.
stupid question, but can't you just add a ceiling quad? and then reflect it normally?
It will be backface-culled so it wont be obstructing the camera, and reflections will be accurate - so unless you have a good reason for not adding an extra pair of triangles per room, I see no point not doing it the "right" way. :)
It will be backface-culled so it wont be obstructing the camera, and reflections will be accurate - so unless you have a good reason for not adding an extra pair of triangles per room, I see no point not doing it the "right" way. :)
Quote:Environment mapped cubemapping for flat reflections
can indeed be done easily.. its basically just dependent on calculating a reflection vector in the vertex shadoer and projecting your cubemap in the pixel shader.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement