Jump to content
  • Advertisement
Sign in to follow this  
spek

Realtime cubemap reflections (GTA IV)

This topic is 3712 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
Msy be they update objects close to the camere more ofthen than the one's further away. Just guessing..

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
@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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!