Please or Register to create posts and topics.

Cubemaps, how do they work?

Been spending a lot of time the last week with the Portal 2 SDK. Built a map quickly and have been iterating on it repeatedly since in order to create something of release-level quality. Up to this point, I haven't bothered with cubemaps. The Value Source wiki entry on them wasn't terribly helpful with regard to figuring out what they do, and so I don't know what they're for or why I need them when I'm not making giant shiny silver couches. So, if so inclined, could someone explain the purpose of Cubemaps in the context of Portal 2 level development? Thanks in advance.

Also, if someone could clarify how those completed door instances are supposed to work, I'd be very appreciative. I can't for the life of me figure out how to cope with the Nodraw brush immediately behind the door.

Lots of textures, both on models and brush faces, have specular reflections. These reflections aren't rendered in real time (because that would be an unnecessary expense on processing power). Source uses prerendered static reflections of the world called cubemaps.

http://en.wikipedia.org/wiki/Cube_mapping

The above page explains the concept better than I, but essentially 6 shots are taken around a single point (the front, the back, the left, the right, above, and below). Those shots are then painted on the six inside faces of a hollow cube. If you can imagine standing inside the cube and looking around, you would see the same environment (source uses the same technique for its 2D skybox technology). We call this cube mapping, and the engine uses individually placed cubemaps for nearby reflections.

In terms of processing time, cubemaps are ridiculously cheap, and as long as they aren't too great in resolution or quantity, they're pretty cheap on memory as well.

When there are no cubemaps in a level, the engine will typically use the skybox for reflections. Here's a video I posted of another TWP member's map the other day:

http://www.youtube.com/watch?v=DY3425wr ... ideo_title

As you can see at the very end, the glass on the elevator is incredibly bright and jarring. This is because the engine is drawing the default reflection map because it cant find any cubemaps in the bsp. As you can see, a lack of cubemaps can make things look absolutely horrible at times.

I posted this in the thread for The Unknown, but it's useful here too.

msleeper wrote:
As a general rule, you should add a cubemap where there is any major change in lighting. For example in the sewer/tunnel areas in the first part of this map, you should add a cubemap where the lights are, as well as add one where the dark areas are.

Unfortunately it looks like Portal 2 doesn't have the cubemap testing "weapon", and I can't seem to get it to work by cheating and manually copying the model.

Ideally, cubemaps should be 64 units above the "ground", the ground being whatever surface the player is going to be walking around on. You can also tie a specific cubemap to a specific brush face - this is especially useful when placing glass or water.

You can easily overdo adding cubemaps into a map. The best way to see what a good layout for cubemaps is just to look in the Valve maps. Like I said, you want to definitely place them where there is a sharp contrast in lighting (such as in The Unknown), but if you have an area with similar lighting all around then you can generally get away with having fewer of them.

There's kind of an art to cubemapping, you'll get the hang of it once you look at some examples.

[Important Threads] Forum Rules | Welcome to the new Thinking With Portals
Please do not Private Message me for assistance. Post a thread if you have questions or concerns.
If you need to contact the staff privately, contact the Global Moderators via Discord.