Jump to content
  • Advertisement
Sign in to follow this  
  • entries
  • comments
  • views

The subject appears... uncomfortable...

Sign in to follow this  


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.
Sign in to follow this  


Recommended Comments

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.

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]


Share this comment

Link to comment
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.

Share this comment

Link to comment
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

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!