Per-surface env_cubemap selection for envmap reflections #21

Closed
opened 2026-03-18 02:35:18 +00:00 by kit · 0 comments
Owner

Currently we use a single skybox-derived cubemap as a global fallback for all $envmap reflections. Source maps contain env_cubemap entities at specific positions, each with a baked cubemap texture stored in the BSP's cubemap lump. The engine selects the nearest env_cubemap to each surface for its reflections.

Requirements

  • Parse env_cubemap entities from the BSP entity lump (position + cubemap size)
  • Extract baked cubemap textures from the BSP pakfile or cubemap lump
  • For each surface with $envmap "env_cubemap", select the nearest env_cubemap and assign its cubemap texture
  • Fall back to the skybox cubemap when no baked cubemap is available

Context

  • env_cubemap entities are placed by mappers at key reflection points
  • Materials reference them via $envmap "env_cubemap" (which means "use nearest")
  • The baked cubemaps are stored as VTF files inside the BSP pakfile, named like c{x}_{y}_{z}.vtf
  • Current envmap implementation: client/src/bsp/loader.js (loadSkyboxCubemap, _applyPendingEnvmaps)
  • This would significantly improve reflection quality since different areas of the map would have context-appropriate reflections
Currently we use a single skybox-derived cubemap as a global fallback for all `$envmap` reflections. Source maps contain `env_cubemap` entities at specific positions, each with a baked cubemap texture stored in the BSP's cubemap lump. The engine selects the nearest `env_cubemap` to each surface for its reflections. ## Requirements - Parse `env_cubemap` entities from the BSP entity lump (position + cubemap size) - Extract baked cubemap textures from the BSP pakfile or cubemap lump - For each surface with `$envmap "env_cubemap"`, select the nearest `env_cubemap` and assign its cubemap texture - Fall back to the skybox cubemap when no baked cubemap is available ## Context - `env_cubemap` entities are placed by mappers at key reflection points - Materials reference them via `$envmap "env_cubemap"` (which means "use nearest") - The baked cubemaps are stored as VTF files inside the BSP pakfile, named like `c{x}_{y}_{z}.vtf` - Current envmap implementation: `client/src/bsp/loader.js` (`loadSkyboxCubemap`, `_applyPendingEnvmaps`) - This would significantly improve reflection quality since different areas of the map would have context-appropriate reflections
kit closed this issue 2026-03-19 17:47:09 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kit/gmod-web-stream#21
No description provided.