Garry's Mod

Garry's Mod

Not enough ratings
How to make an Infinite Map
By Alexandrovich
Introduction

In this guide you wll learn how to make an Infinite map from scratch step by step.

Requirements

-Infinite Map Base
-Basic Valve Hammer editor skills.
-Blender skills (If model needs editing)
-A model in .obj format and its matching textures.



STEP 1 - Making the folders

1.1- Go to "Garry's Mod/garrysmod/addons"
1.2- Make a folder structure like this: (You may change "mapname" to your desired map name.)

GM_INFMAP_MAPNAME
MAPS...MATERIALS........LUA
....................|...........................|
............INFMAP............INFMAP
................................................|
......................GM_INFMAP_MAPNAME



STEP 2

2.1-Go to "Garry's Mod/garrysmod/addons/gm_infmap_mapname/lua/infmap/gm_infmap_mapname"
2.2-Create a text file and name it "LOADOBJECT.LUA"

Here we will establish the settings for our object to be loaded, we will do this in step 5



STEP 3 - Making the map

We need an empty .bsp map. Launch Hammer editor (you can find it in "Garry's Mod/bin"

3.1-Make an empty map by simply closing the player spawn with a cage with skybox texture. Don't go beyond map limits.
3.2-Set your prefered light_environment/env_fog settings that match your .obj model. You can edit the r_farz with env_fog if it's too big.
3.3-(Optional) Add cubemaps starting from the player spawn to the top of the skybox cage.
3.4-(Optional) To prevent the map being "mat_fullbright 1" (Shiny and no shadows) add a very small solid box, with a glass texture on one face and INVISIBLE texture on the other faces. This will trigger VRAD.EXE and force it to bake lights into the map.



STEP 4 - Making the .obj model

We need an .OBJ model and its .MTL file with its matching textures that won't hit the triangle limit.
If your model does not need editing you may skip to 4.2

4.1-In Blender, make sure the model is below 21845 triangles or at least is segmented into pieces below this tri count. If it exceeds there can be strange results when loading it in Garry's Mod like missing pieces, strange shapes, or not load at all. (Or even crash your computer)
4.2-Place the .OBJ and .MTL files in "Garry's Mod/garrysmod/addons/gm_infmap_mapname/maps"
4.3-(Optional)Rename them from "modelname.obj" >>to>> "modelname.obj.AIN" This is necessary only if you are going to upload your addon to the Workshop since .obj and .mtl files are not accepted.
4.4-Open the .MTL file with notepad. -> Remove unnecessary texture paths.
EXAMPLE:
Change: "c:/users/user/downloads/folder/TEXTURE01.jpg" to: "TEXTURE01.jpg"

If there are many textures you can use CTRL+R in Notepad. Copy "c:/users/user/downloads/folder/" and replace with nothing, this will delete the confusing path and allow the Infinite Map to load materials properly.
4.5-Place all the model's textures in: "Garry's Mod/garrysmod/addons/gm_infmap_mapname/materials/infmap"



STEP 5 - Making the LUA file

5.1-Go to "Garry's Mod/garrysmod/addons/gm_infmap_mapname/lua/infmap/gm_infmap_mapname" and open the LOADOBJECT.LUA file you created in STEP 2.
5.2-Copy and paste the following text in it:



// Clear pervious data if it exists
InfMap.clear_parsed_objects()

// Create a matrix to scale the model
local mat = Matrix()
mat:SetTranslation(Vector (0, 0, 0))
mat:SetAngles(Angle(0, 0, 0))
mat:SetScale(Vector(1, 1, 1) * 39.3701)

// visuals = 1
// collision = 2
// both = 3

// nocull Shader = No backface culling
// alphatest Shader = Enable transparency on the model (if supported)

// Create our visual model, note the "1" which means it is ONLY visual
InfMap.parse_obj("MODEL_NAME", mat, 3, "alphatest")

// Create our physical model, note the "2" which means it is ONLY collision
// Because it is collision, we do not need the shader option
// If you wish to have collision AND visuals combined, you can do so by using "0" or "3"
// Example: InfMap.parse_obj("cloud", mat, 3, "nocull alphatest")
// Use either nocull or alphatest not both



5.3-In this text we are spawning a single .obj model named "MODEL_NAME" at scale 1, origin 0,0,0 (XYZ) and rotation 0,0,0. You may change this with your model's name. Do not include file extension.

If you wish to spawn multiple models you can do so like this:


// Clear pervious data if it exists
InfMap.clear_parsed_objects()

// Create a matrix to scale the model
local mat = Matrix()
mat:SetTranslation(Vector (0, 0, 0))
mat:SetAngles(Angle(0, 0, 0))
mat:SetScale(Vector(1, 1, 1) * 39.3701)

// visuals = 1
// collision = 2
// both = 3

// nocull Shader = No backface culling
// alphatest Shader = Enable transparency on the model (if supported)

// Create our visual model, note the "1" which means it is ONLY visual
InfMap.parse_obj("MODEL_NAME", mat, 3, "alphatest")
InfMap.parse_obj("MODEL_NAME2", mat, 3, "alphatest")
InfMap.parse_obj("MODEL_NAME3", mat, 3, "alphatest")

// Create our physical model, note the "2" which means it is ONLY collision
// Because it is collision, we do not need the shader option
// If you wish to have collision AND visuals combined, you can do so by using "0" or "3"
// Example: InfMap.parse_obj("cloud", mat, 3, "nocull alphatest")
// Use either nocull or alphatest not both



In the example above we spawn 3 different models at the same position/angles/scale, all with collisions and visuals combined. Enabling alpha for transparent/alpha textures.


You can also spawn multiple models at different sizes/angles/positions:
EXAMPLE



// Clear pervious data if it exists
InfMap.clear_parsed_objects()

// Create a matrix to scale the model
local mat = Matrix()
mat:SetTranslation(Vector (0, 0, 0))
mat:SetAngles(Angle(0, 0, 0))
mat:SetScale(Vector(1, 1, 1) * 39.3701)

// visuals = 1
// collision = 2
// both = 3

// nocull Shader = No backface culling
// alphatest Shader = Enable transparency on the model (if supported)

// Create our visual model, note the "1" which means it is ONLY visual
InfMap.parse_obj("MODEL_NAME", mat, 3, "alphatest")

local mat = Matrix()
mat:SetTranslation(Vector (2000, 0, -1500))
mat:SetAngles(Angle(0, 180, 0))
mat:SetScale(Vector(12, 12, 12) * 39.3701)

InfMap.parse_obj("MODEL_NAME2", mat, 3, "alphatest")


// Create our physical model, note the "2" which means it is ONLY collision
// Because it is collision, we do not need the shader option
// If you wish to have collision AND visuals combined, you can do so by using "0" or "3"
// Example: InfMap.parse_obj("cloud", mat, 3, "nocull alphatest")
// Use either nocull or alphatest not both



In the example above we are spawning two different models, at different scale/rotation/position.



STEP 6 - Testing

6.1. Test your map's position, angles and scale. You can edit the LOADOBJECT.LUA file while in-game and see results instantly. This will help you callibrate the proper position/angles/scale of your model from the spawn location of your map.
6.2-Because the map is empty, you will be falling into the void. You can always go back to spawn by typing KILL in console and enabling noclip instantly. You can also make a map in Hammer
6.3-If you change your mind about your model, you can also change it while in-game. To load the new object, simply save the LOADOBJECT.LUA file again.



(Optional) STEP 7 - Map Thumbnail

Make a folder in MAPS named THUMB
7.1-Add a custom thumbnail for your map in "Garry's Mod/garrysmod/addons/gm_infmap_mapname/maps/thumb"
7.2-Resolution must be 128x128. This will let you distinguish your map from the others in the map selector.

Although this is completely optional, it will show an image for your map instead of black box and setting an image with Paint at 128x128 is not that hard.


Special thanks

Mee for creating this amazing Garry's Mod LUA based modification.
   
Award
Favorite
Favorited
Unfavorite
Main
Introduction

In this guide you wll learn how to make an Infinite map from scratch step by step.

Requirements

-Infinite Map Base
-Basic Valve Hammer editor skills.
-Blender skills (If model needs editing)
-A model in .obj format and its matching textures.



STEP 1 - Making the folders

1.1- Go to "Garry's Mod/garrysmod/addons"
1.2- Make a folder structure like this: (You may change "mapname" to your desired map name.)

GM_INFMAP_MAPNAME
MAPS...MATERIALS........LUA
....................|...........................|
............INFMAP............INFMAP
................................................|
......................GM_INFMAP_MAPNAME



STEP 2

2.1-Go to "Garry's Mod/garrysmod/addons/gm_infmap_mapname/lua/infmap/gm_infmap_mapname"
2.2-Create a text file and name it "LOADOBJECT.LUA"

Here we will establish the settings for our object to be loaded, we will do this in step 5



STEP 3 - Making the map

We need an empty .bsp map. Launch Hammer editor (you can find it in "Garry's Mod/bin"

3.1-Make an empty map by simply closing the player spawn with a cage with skybox texture. I recommend making it as big as the grid. Don't go beyond map limits.
3.2-Set your prefered light_environment/env_fog settings that match your .obj model. You can edit the r_farz with env_fog if it's too big.
3.3-(Optional) Add cubemaps starting from the player spawn to the top of the skybox cage. (Use buildcubemaps once you spawn at the final version of your map to generate proper cubemaps)
3.4-(Optional) To prevent the map being "mat_fullbright 1" (Shiny and no shadows) add a very small solid box, with a glass texture on one face and INVISIBLE texture on the other faces. This will trigger VRAD.EXE and force it to bake lights into the map.



STEP 4 - Making the .obj model

We need an .OBJ model and its .MTL file with its matching textures that won't hit the triangle limit.
If your model does not need editing you may skip to 4.2

4.1-In Blender, make sure the model is below 21845 triangles or at least is segmented into pieces below this tri count. If it exceeds there can be strange results when loading it in Garry's Mod like missing pieces, strange shapes, or not load at all. (Or even crash your computer)
4.2-Place the .OBJ and .MTL files in "Garry's Mod/garrysmod/addons/gm_infmap_mapname/maps"
4.3-(Optional)Rename them from "modelname.obj" >>to>> "modelname.obj.AIN" This is necessary only if you are going to upload your addon to the Workshop since .obj and .mtl files are not accepted.
4.4-Open the .MTL file with notepad. -> Remove unnecessary texture paths.
EXAMPLE:
Change: "c:/users/user/downloads/folder/TEXTURE01.jpg" to: "TEXTURE01.jpg"

If there are many textures you can use CTRL+R in Notepad. Copy "c:/users/user/downloads/folder/" and replace with nothing, this will delete the confusing path and allow the Infinite Map to load materials properly.
4.5-Place all the model's textures in: "Garry's Mod/garrysmod/addons/gm_infmap_mapname/materials/infmap"



STEP 5 - Making the LUA file

5.1-Go to "Garry's Mod/garrysmod/addons/gm_infmap_mapname/lua/infmap/gm_infmap_mapname" and open the LOADOBJECT.LUA file you created in STEP 2.
5.2-Copy and paste the following text in it:



// Clear pervious data if it exists
InfMap.clear_parsed_objects()

// Create a matrix to scale the model
local mat = Matrix()
mat:SetTranslation(Vector (0, 0, 0))
mat:SetAngles(Angle(0, 0, 0))
mat:SetScale(Vector(1, 1, 1) * 39.3701)

// visuals = 1
// collision = 2
// both = 3

// nocull Shader = No backface culling
// alphatest Shader = Enable transparency on the model (if supported)

// Create our visual model, note the "1" which means it is ONLY visual
InfMap.parse_obj("MODEL_NAME", mat, 3, "alphatest")

// Create our physical model, note the "2" which means it is ONLY collision
// Because it is collision, we do not need the shader option
// If you wish to have collision AND visuals combined, you can do so by using "0" or "3"
// Example: InfMap.parse_obj("cloud", mat, 3, "nocull alphatest")
// Use either nocull or alphatest not both



5.3-In this text we are spawning a single .obj model named "MODEL_NAME" at scale 1, origin 0,0,0 (XYZ) and rotation 0,0,0. You may change this with your model's name. Do not include file extension.

If you wish to spawn multiple models you can do so like this:


// Clear pervious data if it exists
InfMap.clear_parsed_objects()

// Create a matrix to scale the model
local mat = Matrix()
mat:SetTranslation(Vector (0, 0, 0))
mat:SetAngles(Angle(0, 0, 0))
mat:SetScale(Vector(1, 1, 1) * 39.3701)

// visuals = 1
// collision = 2
// both = 3

// nocull Shader = No backface culling
// alphatest Shader = Enable transparency on the model (if supported)

// Create our visual model, note the "1" which means it is ONLY visual
InfMap.parse_obj("MODEL_NAME", mat, 3, "alphatest")
InfMap.parse_obj("MODEL_NAME2", mat, 3, "alphatest")
InfMap.parse_obj("MODEL_NAME3", mat, 3, "alphatest")

// Create our physical model, note the "2" which means it is ONLY collision
// Because it is collision, we do not need the shader option
// If you wish to have collision AND visuals combined, you can do so by using "0" or "3"
// Example: InfMap.parse_obj("cloud", mat, 3, "nocull alphatest")
// Use either nocull or alphatest not both



In the example above we spawn 3 different models at the same position/angles/scale, all with collisions and visuals combined. Enabling alpha for transparent/alpha textures.


You can also spawn multiple models at different sizes/angles/positions:
EXAMPLE



// Clear pervious data if it exists
InfMap.clear_parsed_objects()

// Create a matrix to scale the model
local mat = Matrix()
mat:SetTranslation(Vector (0, 0, 0))
mat:SetAngles(Angle(0, 0, 0))
mat:SetScale(Vector(1, 1, 1) * 39.3701)

// visuals = 1
// collision = 2
// both = 3

// nocull Shader = No backface culling
// alphatest Shader = Enable transparency on the model (if supported)

// Create our visual model, note the "1" which means it is ONLY visual
InfMap.parse_obj("MODEL_NAME", mat, 3, "alphatest")

local mat = Matrix()
mat:SetTranslation(Vector (2000, 0, -1500))
mat:SetAngles(Angle(0, 180, 0))
mat:SetScale(Vector(12, 12, 12) * 39.3701)

InfMap.parse_obj("MODEL_NAME2", mat, 3, "alphatest")


// Create our physical model, note the "2" which means it is ONLY collision
// Because it is collision, we do not need the shader option
// If you wish to have collision AND visuals combined, you can do so by using "0" or "3"
// Example: InfMap.parse_obj("cloud", mat, 3, "nocull alphatest")
// Use either nocull or alphatest not both



In the example above we are spawning two different models, at different scale/rotation/position.



STEP 6 - Testing

6.1. Test your map's position, angles and scale. You can edit the LOADOBJECT.LUA file while in-game and see results instantly. This will help you callibrate the proper position/angles/scale of your model from the spawn location of your map.
6.2-Because the map is empty, you will be falling into the void. You can always go back to spawn by typing KILL in console and enabling noclip instantly. You can also make your map in Hammer have a platform under the player's spawn to prevent the player from falling.
6.3-If you change your mind about your model, you can also change it while in-game. To load the new object, simply save the LOADOBJECT.LUA file again.



(Optional) STEP 7 - Map Thumbnail

Make a folder in MAPS named THUMB
7.1-Add a custom thumbnail for your map in "Garry's Mod/garrysmod/addons/gm_infmap_mapname/maps/thumb"
7.2-Resolution must be 128x128. This will let you distinguish your map from the others in the map selector.

Although this is completely optional, it will show an image for your map instead of black box and setting an image with Paint at 128x128 is not that hard.


Special thanks

Mee for creating this amazing Garry's Mod LUA based modification.
9 Comments
nks 12 May @ 11:18am 
daddy :gman:
vyquad 11 Mar @ 3:07pm 
it is
Alexandrovich  [author] 11 Mar @ 5:24am 
Make sure the folder path is correct and matches the map name
vyquad 10 Mar @ 12:18pm 
Something also worth mentioning is that i put the map bsp into the addon maps folder
vyquad 10 Mar @ 12:17pm 
i am. i can load the base infmap maps fine
Alexandrovich  [author] 10 Mar @ 12:15pm 
@vyquad Make sure to be running on the 64 bit branch gmod version
vyquad 10 Mar @ 12:14pm 
Followed everything yet it makes no attempt to load the obj?
Arkymarble 6 Sep, 2023 @ 3:16pm 
Also thank you for this guide, I always wanted to make my own infinite map
Arkymarble 6 Sep, 2023 @ 3:16pm 
@You're in a modded l4d2 server
Bro stop advertising your shitty YT channel lol