How mirrors work...
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-02-2007 19:30
OK, I've been experimenting with mirrors, and I'm pretty sure I've figured the clever trick that's being pulled. Runitai isn't actually attempting to reproduce optically correct reflections, he's producing something that's enough like them to fool the eye if you don't pay attention.
The correct algorithm for creating a reflective surface is simple: you make each mirror contain the scene viewed as from the mirror-image of the camera. The problem is that it requires a rendering pass (albeit a clipped and low resolution one... since you can get away with only rendering a fraction of the pixels for all but the very closest mirrors). He's found a MUCH cheaper solution... what he's doing is a clever hack using spherical maps.
Instead of rendering the scene multiple times, he renders a 360 degree view of the world for each frame... which accounts for MOST of the lower frame rate when dynamic reflections are enabled. Then, this texture is applied... with some distortion to try and approximate a more correct view... to *every* reflective object for rendering the next frame.
The up-side is that there's very little additional overhead for each additional reflective object. It's very efficient.
The downside is that it's nowhere near optically correct. In particular, the reflection seen in a flat mirror is the projection of the reflection of the scene in the plane through the camera parallel to the surface onto the mirror. It only approximates reality when the plane of the mirror is close to the plane of the camera. This is why reflections on rippled water look "good enough": between the distortion of the ripples and the low angle of reflection the error is minimized. And curved mirrors look good because people don't have as good a mental model of how they "should" look. Flat mirrors, though, really need better handling.
[Edit: replace "plane surface" with "flat surface" to avoid reduce-reduce conflict in dracos18.y]
|
Draco18s Majestic
Registered User
Join date: 19 Sep 2005
Posts: 2,744
|
02-02-2007 19:56
From: Argent Stonecutter In particular, the reflection seen in a plane is the projection of the reflection of the scene in the plane through the camera parallel to the plane surface onto the mirror. My brain hurts. o..o I don't understand. Glad you figured out what's going on though. 
|
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
|
02-02-2007 21:24
Diagram.
_____________________
-
So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.
I can be found on the web by searching for "SuezanneC Baskerville", or go to
http://www.google.com/profiles/suezanne
-
http://lindenlab.tribe.net/ created on 11/19/03.
Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard, Robin, and Ryan
-
|
grumble Loudon
A Little bit a lion
Join date: 30 Nov 2005
Posts: 612
|
02-02-2007 21:32
I understand. Cool On the upside by rendering a 360 view you are providing a full view for object-object occlusion. Is there any way to turn off the LOD system so that small objects don't disappear when 25m away?
|
grumble Loudon
A Little bit a lion
Join date: 30 Nov 2005
Posts: 612
|
02-02-2007 21:42
From: SuezanneC Baskerville Diagram. Place a flat box on the ground and call it your mirrored watter. Now have a tree past it. Your camera position to the boxes center decides what part of your view is mapped on to the box. The angle of incidence = the angle of reflection... sort of... The problem is that the client does not know where the objects are that make up the reflection are located, so it makes a guess that the objects are about the same distance away. Since you are at the center of the view, you are always invisible. (unless you are in flying alt mouse look.) Other avatars should be visible if they are farther away from you than twice the distance to the mirror.
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
02-02-2007 22:10
I'm trying to work out where the reflection camera is... it seems to depend in some way on both the position of the main camera and the position of the focus.
Best not teach optics in SL...
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
02-02-2007 22:31
Now if we could only get Alpha and Mirror to work at the same time. Glass always look so dull in SL. Only method that does work is use that invisible and offset it so you can see it then apply your Shinny/Reflection to it. But in the First Look viewer it looses the color that is applied while the color is there in the main viewer.
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
02-02-2007 23:39
From: SuezanneC Baskerville Diagram. Ok, if I understand what Argent is saying correctly, think of it like this, no diagram but here is a visual aid: Look at this picNow, in the real world, each mirror would have its own reflection from a different angle: one would show her from a a slightly left angle, one at a slightly right angle, ect,ect. Instead of rendering a different texture for each reflective object, it renders one panoramic texture and then skews and scales that one texture onto each reflective object.
|
Draco18s Majestic
Registered User
Join date: 19 Sep 2005
Posts: 2,744
|
02-03-2007 00:06
I understood that much of it, I suppose. I could infer that from one rendering it used the same texture on all the mirrors, I just didn't understand the technobabble of how it did it.
|
Kyrah Abattoir
cruelty delight
Join date: 4 Jun 2004
Posts: 2,786
|
02-03-2007 01:07
hehe i guess we aren't at the per pixel reflection yet 
_____________________
 tired of XStreetSL? try those! apez http://tinyurl.com/yfm9d5b metalife http://tinyurl.com/yzm3yvw metaverse exchange http://tinyurl.com/yzh7j4a slapt http://tinyurl.com/yfqah9u
|
grumble Loudon
A Little bit a lion
Join date: 30 Nov 2005
Posts: 612
|
02-03-2007 04:24
The reflection camera is always at your camera's point of view.
Try this. 1. stand about 4m away from a mirror. 2. Use the alt key and place the camera 2m from the mirror.
At this point you will see yourself in the prim as if you were 2m from the camera since the prim is using the image generated from your camera, only it's using the backwards facing image.
This definitely has promise since it will look nice if you could somehow set the prims scaling of the image.
Perhaps the prim should have to have a specific (hard coded) texture key that is then scaled to control the zoom of the reflection camera. "1 repeat per face" would be normal and you could modify it based on where people would be able to see it from. This would allow you to distort the X or the Y based on the design of the scene.
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
02-03-2007 13:08
From: grumble Loudon The reflection camera is always at your camera's point of view. If that were true, then surely we would see the blue face of the cube in this picture: http://www.sluniverse.com/pics/pic.aspx?id=137883 Instead we're seeing the purple face, which is the face of the cube that faces the mirror wall.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-03-2007 13:31
From: Seifert Surface I'm trying to work out where the reflection camera is... it seems to depend in some way on both the position of the main camera and the position of the focus. As near as I can tell, the reflection camera is in the same position as the real camera... the reflected image is the image generated for the previous frame. A distortion seems to be performed on the texture when it's applied to a surface to try and correct for the camera position being incorrect.
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-03-2007 13:35
From: Seifert Surface If that were true, then surely we would see the blue face of the cube in this picture: http://www.sluniverse.com/pics/pic.aspx?id=137883 Instead we're seeing the purple face, which is the face of the cube that faces the mirror wall. I'm not sure I understand what you're showing in this picture. I'll look you up when I'm inworld on my Mac (the latest FL viewer doesn't do reflections at all on my Wintendo) and we can go over it. If Runitai is taking a separate 360 degree shot from some other location, that would be really weird.
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
02-03-2007 14:04
The same thing as in the photo is up at The Future (92,197,505). Position your camera facing the mirror but behind the coloured cube, with the focus on the mirror. You can get a reflection of the cube in the mirror, and you can see the back side of the cube there, but you see the front side of the cube from your usual camera position.
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Logan Bauer
Inept Adept
Join date: 13 Jun 2004
Posts: 2,237
|
02-03-2007 16:17
That's interesting... Seifert, I can't seem to duplicate that, This is what I got on my client.
|
Seifert Surface
Mathematician
Join date: 14 Jun 2005
Posts: 912
|
02-03-2007 17:04
It looks like the reflection 360 camera is placed somewhere between the main camera position and the focus position. Logan: I think you needed to zoom in some, the reflection camera was still behind the cube? Edit: it seems that viewer 57520 (the one I took the photo in) and 57575 (Logan's video) have the reflection camera in different places... no wonder it was confusing 
_____________________
-Seifert Surface 2G!tGLf 2nLt9cG
|
Draco18s Majestic
Registered User
Join date: 19 Sep 2005
Posts: 2,744
|
02-03-2007 17:17
It wouldn't play for me on the linked page, so I went to download it.
Download File: To download the file "Mirror-Test" you must click the NEXT PAGE link located below until the download link shows. Status: Your are on page 1 of 20 before the download page. NEXT PAGE
Wha? Whatever. I got the file, but that has got to be the dumbest thing I have ever seen (and you can't skip numbers either, I tried).
Bah, still won't play. What codec do I need?
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-04-2007 12:14
Logan sent me a camera follower that is a really useful tool for exploring the mirrors. It's basically a hollow sphere with different colored grids that tracks your camera position, and voice commands for turning on and off.
In 57520, when the camera is not focussed on any object, all mirrors show the interior of the sphere. Which means that the main camera is the reflection camera. When the camera is focussed on a prim, you can see the sphere from the outside... and it's scaled so it's clear that it's being seen from a position between the camera and the camera focus.
When I get a chance to try it on my Mac, I'll try it in 57575. Mirrors in 57575 don't work on my Wintendo, but Logan reported that it was showing the inside of the sphere in all mirrors for him.
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
02-04-2007 18:28
What ever the case may be it looks nice enough to fool your eyes at a very low cost. http://www.joe-brown.net/SecondLife/Reflection2.jpghttp://www.joe-brown.net/SecondLife/Reflection3.jpgNow if it only worked on my ATI. So when do we get refractions?
|
Kensuke Leviathan
Wandering fox
Join date: 11 Dec 2002
Posts: 127
|
02-04-2007 23:22
From: Gearsawe Stonecutter So when do we get refractions?
My guess..four years  thats about how long it took to get updating cube maps
_____________________
_________________
":> wark wark"
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-05-2007 07:34
I'm not sure that it's much cheaper than doing it right for plane mirrors. Doing it right would require more passes, but each would be at MUCH lower resolution: for a mirror N meters away, it would only have to render as many pixels as if you were looking at the same part of the scene 2N meters away. Since it's already doing two rendering passes at full resolution rendering only part of the scene at a much lower resolution doesn't seem like it would be out of the question.
|
Gearsawe Stonecutter
Over there
Join date: 14 Sep 2005
Posts: 614
|
02-05-2007 14:10
I was sort of kidding about the refractions but then I forgot about the water and how it refracts. So it is there we just can't use it.
|
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
|
02-05-2007 15:06
In 57575 on the Mac the mirror camera is always the real camera - even when focussed on a mirror the camera remains inside Logan's follow sphere.
|
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
|
02-05-2007 16:03
Might as well ask for lenses. With properly done lenses and mirrors we could make microscopes and telescopes, and burn ants. 
_____________________
-
So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.
I can be found on the web by searching for "SuezanneC Baskerville", or go to
http://www.google.com/profiles/suezanne
-
http://lindenlab.tribe.net/ created on 11/19/03.
Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard, Robin, and Ryan
-
|