A more "noob friendly" explenation about env_cubemap?

N0VA

L1: Registered
Oct 16, 2016
23
4
When looking around in decompiled Valve maps, i noticed entitys called env_cubemaps.
I have seen this quite some time but i dont really know what it does and what it mostly is for, i tried looking it up on the Valve dev wiki but it was not really clear,

Could someone tell me in a "noob friendly" way what it is for etc?
Much obliged
~Leon
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Instead of real time reflections, source uses these entities that pre-render their whereabouts and any reflective surface gets its reflection image from the nearest env_cubemaps.
 

N0VA

L1: Registered
Oct 16, 2016
23
4
So it works like this?

Walls work like "Mirrors" and the env_cubemap kind off "Executes" those reflections? its still not 100% clear though
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
A cubemap renders its surroundings and saves the image. When a nearby reflective surface needs a reflection, it uses the texture a cubemap rendered before. The rendering kind of happens at compile. Actually, it's done after compile, but before release, so the images for every cubemap are saved in the BSP.
 

killohurtz

Distinction in Applied Carving
aa
Feb 22, 2014
1,016
1,277
This image from the Wikipedia article for cube mapping illustrates the concept perfectly:

427px-Panorama_cube_map.png


The black dot (env_cubemap) basically takes 6 pictures of its surroundings and stitches them together into a fully 3D map. You might recognize this as the same concept skybox textures use to appear spherical; they are, in essence, one giant cubemap. Like Crowbar said, reflective surfaces will use the nearest cubemap entity to decide what its reflection looks like.
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
That's a good way to think of it, yeah. Notice how that cube in the picture looks like it's a reflective surface, even though it actually just has mirror images of those first six pictures printed on it. Cubemaps also shift around when you move the camera to sell the illusion better, but it's the same basic principle.
 

Moth

L2: Junior Member
Jul 3, 2016
82
247
So in practise you should put multiple cubemaps in the map, in most rooms? or a couple is enough?
 

Crowbar

Spiritual preprocessor
aa
Dec 19, 2015
1,455
1,297
Wherever you need a unique cubemap in a place. aka pretty many of them, usually.
 

Tumby

aa
May 12, 2013
1,084
1,192
Cubemaps also shift around when you move the camera to sell the illusion better, but it's the same basic principle.
Cubemaps are as static as it can get. Just make a giant wall using the chrome texture, buildcubemaps, stand in front of it and move left/right. You won't be able to tell that you are actually moving because nothing in your view is.

So in practise you should put multiple cubemaps in the map, in most rooms? or a couple is enough?
One cubemap per area is good. Keep in mind that the only things that require cubemaps are 1. reflective surfaces 2. view- and playermodels. People don't pay too much attention to their sniperrifles' scope, so don't be too agressive with these. Reflective surfaces should get about one cubemap per surface. Try to keep it simple for the sake of file size.
 

Vel0city

func_fish
aa
Dec 6, 2014
1,947
1,589
Also, cubemaps store their pictures taken inside the BSP (your map's file that the game can read). If you go overboard on them your map can become quite the size.
 

henke37

aa
Sep 23, 2011
2,075
515
Of course, you can override the texture size for individual cubemaps. Probably don't need much resolution in areas isn't spending time. No one is going to notice if the sniper rifle reflection is a tad blurred while they are falling to their doom.
 

Moth

L2: Junior Member
Jul 3, 2016
82
247
I guess valve does it pretty well, i'll cheak out how many cubemaps stock maps have
 

Pocket

Half a Lambert is better than one.
aa
Nov 14, 2009
4,694
2,579
Cubemaps are as static as it can get. Just make a giant wall using the chrome texture, buildcubemaps, stand in front of it and move left/right. You won't be able to tell that you are actually moving because nothing in your view is.
That was my point. They move with the camera instead of just being locked to the surface like they were painted on, something that picture didn't make clear.
 

Tumby

aa
May 12, 2013
1,084
1,192
That was my point. They move with the camera instead of just being locked to the surface like they were painted on, something that picture didn't make clear.
Well that picture doesn't even show a cubemap in effect, it just shows a cube with a texture on it.
 

N0VA

L1: Registered
Oct 16, 2016
23
4
I think i kinda know what they are now, i have noticed this while playing 2fort and observing my sniper rifle scope (when unzoomed)
Since i have restarted ill do this at a later point, im now busy doing the general layouts and height scaling, i also wanna mess around with sound first.

Thanks for all the help!