• entries
375
1136
• views
298553

# The subject appears... uncomfortable...

93 views

So I was thinking about glass on the bus this morning (while looking out the window, would you believe?). When rendering glass what we'd really like is to correctly mix reflection and refraction. This is more or less sorted for glass objects, but to my knowledge nobody has done it for sheet glass - things like windows. The current model seems to be to just render an alpha-blended poly with a 'glassy' texture on it, simulating a very slight reflection. That works ok right up to the point that you've got a glass window between a light room and a dark one; what we see, from the light side, is a dark poly. What we should see is our own reflection.

So, rendering is probably simple enough. If we keep our current glass*refraction (so we can get coloured translucency), would simply adding the reflection (*some constant) work? Might do. Standing in the dark room means the reflection contribution will be small. Standing in the light room means the reflection contribution will be high. Yeah, I think that works from an intensity point of view - not sure about colour. Multiply the reflection by the colour of the glass, probably, just like the refraction.

Now, the other side of the coin I always like to toss - AI. Can we get the AI to take that reflection/refraction property into account?

Say you're in the dark room and the AI is in the light room. The AI shouldn't be able to see you. I'm wondering if we can use a sort of lightmapping to work that out. Create a lightmap for each side of the pane of glass, something that allows you to take a position on the glass and an angle and work out how much light is hitting that side of the glass at that angle (per-texel SH?). When you do your line-of-sight test through the glass, you perform two lookups, one for each side of the glass, and basically subtract the value of the near side from the value of the far side. The higher the result, the more you can see through the glass.

I'd imagine it's not gonna be that difficult to implement provided you have that light/dark information. If it's readily available, then fine, but it'd probably be quite costly to try and compute it on each render.

EDIT: probably wouldn't be hard with a downsampled render-to-texture operation, as per the HDRI luminance impl.

Quote:
 Now, the other side of the coin I always like to toss - AI. Can we get the AI to take that reflection/refraction property into account?

Just out of curiosity, have you ever read through the somewhat simplistic discussions by game players on this sort of thing. I usually can't be bothered, but this reminds of a few actual features that us games developers put in games that the players see and assume as stupidity.

In your context, player in dark room see's window, see's no reflection (as per your rendering idea). Then said bad-guy wanders in to the light room. Looks around, doesn't see the player standing on the other side of the glass.... player just assumes its crap AI and bitches about it being too stupid to spot the player through the glass.

The player is wrong, but correct - as they say, the customer is always right [wink]

hth
Jack

Heh. Yeah, I guess that's a potential problem, but if the rendering were handled correctly then I think it would counteract it. Players might go, "huh, he didn't see me?" then walk outside and realise that they can't see into the room either. If players get used to the idea that "reflections in glass may prevent people seeing through it" as encountered by themselves, they accept that other agents have the same issue.

Computing an SH on a per-frame basis is definitely not viable, but you wouldn't need to - it'd more be a question of recomputing it when the light level changes significantly (e.g. someone turns on the lightswitch) and even then it could be amortized over multiple frames. Still, there are probably much cheaper approaches than SH knocking around - simple radiosity with averaged light direction ought to be enough, and that's something you can do more or less entirely on the GPU.

Looking out a bus window and wonders about glass rendering. Are you sure you do not suffer from adult (loose term) ADD or are you really into games? NM don't answer with either one. j/k

## Create an account

Register a new account