Facepunch / garrysmod-requests

Feature requests for Garry's Mod
84 stars 24 forks source link

render.GetCubemaps()/engine.GetCubeMaps() #1532

Open Kinyom opened 4 years ago

Kinyom commented 4 years ago

I'm not entirely sure if this would be how they'd be named or if there's some nuance I'm forgetting, but long story short what I'm looking for is a way to get access to the cubemap textures built into a map; a list of all the ones that exist in the map would be great, and if we wanted to find the cubemap used for a given position we could just check where the nearest env_cubemap is in Lua and go from there. Would be very useful for making use of matproxies to edit specular reflections/apply effects to cubemaps if what's currently available on either front isn't enough.

Kinyom commented 4 years ago

After some quick checking through vbsp.exe's source code (and looking into cs_assault's .bsp data, seeing the following:)

PK
         ëMÿ;„   „   @   materials/maps/cs_assault/metal/metaldoor042a_6748_5700_-823.vmt"patch"
{
    "include"       "materials/METAL/METALDOOR042A.vmt"
    "replace"
    {
        "$envmap"       "maps/cs_assault/c6748_5700_-823"
    }
}

It looks like the cubemaps are actually loaded into the materials directory and accessible to any texture that wants to use them when you load a map. I changed the $envmap parameter of one of my materials to the listed cubemap (this only works when cs_assault in particular is loaded, as expected), and it worked fine. So this would probably be even easier than it looks to implement via C++.