Realtime cubemap reflections (GTA IV)

Started by
15 comments, last by spek 15 years, 11 months ago
Dear graphics friends, I was enjoying GTA IV, and wondered how they did the reflections. The cars, but also the environment (buildings, pavement, etc.) reflect. I guess they do it with cubeMaps, where the player carries one cubeMap with him which is updated every frame. This way the car will always have a proper realtime reflection. Now I was thinking, would they use the very same "player cubeMap" as well for the (nearby) environment? In the past I did reflections like Halflife2 did, by placing (pre-rendered) cubeMaps all over the scene. Each surface would pick the most nearby/efficient probe. Works ok, but its not a realtime solution of course. And I also had problems sometimes where 2 neighbour polygons would use a different probe; a seam became noticable. GTA IV doesn't seem to have that "seam" problems, and the reflection are dynamic (the lighting changes all the time). I doubt if they use a lot of probes that are updated each frame. So maybe the (nearby) environment simply uses the same cubeMap as the player? Of course this won't give super accurate results, but with the help of low-res and blurring, you won't see it that much anyway. If this is the case, there is one thing I still wonder though. How are the reflections working for more distant/larger objects? For example, a cubeMap for the player that stands in a narrow dark alley won't be working very well for the skyscraper in the background... Maybe the objects further away simply don't reflect in GTA IV, I haven't really checked that out yet. Greetings, Rick
Advertisement
Msy be they update objects close to the camere more ofthen than the one's further away. Just guessing..
Maybe... But I still doubt if they use multiple cubeMaps. I mean, updating those damn things could cost quite some time. The XBox and PS3 are equiped with some graphical power which allows to do this, but I wonder how much probes they use then (nearby). Maybe the player not carries 1, but a whole grid of probes surrounding him.

Could be, but I still doubt it. For a start, the environment in GTA IV doesn't show seams between 2 different cubeMaps (imagine 2 walls next to each other, where 1 wall uses probe A, and the other probe B). This makes me think either 1 probe is used, or they are blending between probes instead of assigning only 1 probe per face/polygon/chunk. Since you can drive pretty fast in this game, it would become quite noticable if the underground would be switching between a lot of probes.

On the other hand, using only 1 probe isn't really accurate of course. They mask this by only using very blurred and vague reflections (and even then you can see errors). But maybe they use some other tricks as well?

I was just wondering how they did it. One of the things I need to implement in my new hobby engine, are reflections. Normally I would have created pre-rendered probes and assign them to polygons, but maybe this works as well. At least its easy to maintain, its realtime, and it doesn't require the designer to place these stupid probes everywhere :)

Greetings,
Rick
I haven't played GTA IV yet, but I am pretty sure it is a direct3d based game. This means that you can fire up PIX from the DX SDK and take a single frame capture at an appropriate time. Then go back and you can see every API call that was made and what resources were used. You can even view the contents of the various textures and/or cubemaps at various points in the frame rendering.

It takes some time to dig through everything, but I actually ran a few frames from Crysis through the same process and it proves to be very educational. Check it out - you won't be disappointed!
Jason - that won't work unless you happen to work at Rockstar, with GTA 4 currently only being a console title I think it might prove difficult to run it through PIX.
Whoops! I didn't realize that there isn't a PC version yet! I wonder why they didn't launch on multiple platforms at the same time...
GTA IV is not the first game to do this. What other games have done, was render a low poly/detail version of the environment(including other cars etc.) into a low resolution cube map every frame. Since GTA IV is running on next generation hardware, I am assuming its able to do this with more detail and higher resolution.
@Jason Z
Thanks for that tip anyway! Never heard of it, but it sounds usefull. I saw GTA IV indeed on the Playstation 3. BTW, I thought the PS3=OpenGL, and XBox=DirectX?


I've seen these dynamic reflections in a lot of (race)games as well, but GTA IV was the first game where I noticed these (realtime) reflections on the surrounding geometry as well. I have no doubt that current hardware can easily render a couple of cubeMaps and even blur them every frame. But still, the question is where/how many probes do games like GTA IV use? Only 1 probe (the one inside the player/car), a grid of probes surrounding the player, or probes at fixed positions like Halflife 2 did?

I'm hoping to hear they indeed only use 1 probe inside the player. Because it doesn't require you to place these probes when designing the world, and updating only 1 cubeMap every frame won't be much of a problem. But of course, it has some accuresy issues though...

Greetings,
Rick
Quote:Original post by spek
I thought the PS3=OpenGL, and XBox=DirectX?

The Xbox 360 uses a somewhat customized version of DirectX 9, it's very similar but not identical to the PC version. The PS3 does have an OpenGL implementation as part of the SDK but very few games use it - most use an alternative API called libGCM that gives much more direct access to the hardware.

Game Programming Blog: www.mattnewport.com/blog

Quote:I'm hoping to hear they indeed only use 1 probe inside the player. Because it doesn't require you to place these probes when designing the world, and updating only 1 cubeMap every frame won't be much of a problem. But of course, it has some accuresy issues though...


If you want the definite word on it, Wolf would be the one to ask. FWIW I did notice the accuracy is indeed somewhat off with the water reflections for example and it seems increasingly worse the further reflected objects are away from the player.
Rim van Wersch [ MDXInfo ] [ XNAInfo ] [ YouTube ] - Do yourself a favor and bookmark this excellent free online D3D/shader book!

This topic is closed to new replies.

Advertisement