Direct modification of BSP files
Direct modification of BSP files
I want to share my experience of direct modification of *.bsp files. If there is no need in such articles, let admins delete this topic.
This method has some limitations, but anyway it works.
Once, I was asked to modify a custom map. The purpose of modification is to substitute custom textures with original Q3 textures from \baseq3\pak0.pk3. This allows to reduce volume of a map pack on a server and time of downloading a map from a server.
Also, this method can be applied when there is a map with a good construct, but with ugly textures or simply with textures of low quality (resolution), and you want a new modified map to look correctly everywhere (to avoid collision of textures).
1. Open a chosen map in a hex editor (for example Hex Editor Neo).
2. Substitute an old texture by yours. Attention! Both (old and new) textures must have the same lenght of names and resolution (or such a new texture should be properly scaled in a shader). For example:
FIND
textures/base_wall/alpha01
REPLACE BY
textures/base_wall/beta002
3. Repeat the step 2 for all the textures that you want to replace and save the map.
4. Write shaders for your new textures, if you have complex textures or if you want to redirect (link) these new textures to the textures which already exist in your pak0.pk3.
Or make your *.jpg and (or) *.tga files or rename and use (if you're authorized) other custom textures, if you just want to re-colorize the map.
This method has some limitations, but anyway it works.
Once, I was asked to modify a custom map. The purpose of modification is to substitute custom textures with original Q3 textures from \baseq3\pak0.pk3. This allows to reduce volume of a map pack on a server and time of downloading a map from a server.
Also, this method can be applied when there is a map with a good construct, but with ugly textures or simply with textures of low quality (resolution), and you want a new modified map to look correctly everywhere (to avoid collision of textures).
1. Open a chosen map in a hex editor (for example Hex Editor Neo).
2. Substitute an old texture by yours. Attention! Both (old and new) textures must have the same lenght of names and resolution (or such a new texture should be properly scaled in a shader). For example:
FIND
textures/base_wall/alpha01
REPLACE BY
textures/base_wall/beta002
3. Repeat the step 2 for all the textures that you want to replace and save the map.
4. Write shaders for your new textures, if you have complex textures or if you want to redirect (link) these new textures to the textures which already exist in your pak0.pk3.
Or make your *.jpg and (or) *.tga files or rename and use (if you're authorized) other custom textures, if you just want to re-colorize the map.
Re: Direct modification of BSP files
...or you can just use GSAR for huge amounts of patching (search/replace) or batch processing.V1979 wrote: [...] 1. Open a chosen map in a hex editor (for example Hex Editor Neo). [...]
DOWNLOAD LINK: http://gnuwin32.sourceforge.net/packages/gsar.htm
Command:
Code: Select all
gsar <filename.bsp> -stextures/example/shader-or-texture:000 -rcustomtx/example/shader-or-texture:000 -o
You might be able to use a shorter new texture name/path, if you just append the corrent amount of 0x00 to the new name.
p.s.: there's probably a unix/linux binary of gsar somewhere - or just compile it from the source.
Last edited by m4xpower on Fri May 29, 2015 3:00 pm, edited 1 time in total.
Re: Direct modification of BSP files
There is no need in batching, because each texture is named in a *.bsp file for just the only time.m4xpower wrote:***
Re: Direct modification of BSP files
There usually is - unless you enjoy tedious, mind-numbing work.V1979 wrote:There is no need in batching, because each texture is named in a *.bsp file for just the only time.
Just a quick example:
Code: Select all
#!/bin/bash
for BSP in *.bsp; do
gsar ${BSP} -stextures/example/shader-or-texture-01:000 -rcustomtx/example/shader-or-texture-01:000 -o
# texture 0..n
gsar ${BSP} -stextures/example/shader-or-texture-99:000 -rcustomtx/example/shader-or-texture-99:000 -o
done
Re: Direct modification of BSP files
Only for Linux users! How will use command line ordinary Windows users when Windows CMD is based off completely different scheme?
Re: Direct modification of BSP files
As for me, I don't understand what's to do with your code. And I won't be able to repeat it by myself, whilst with Hex Editor and its GUI, I successfully modify not only *.bsp files, but *.md3 and any others too.
Let practice will be our judge.
Let practice will be our judge.
Re: Direct modification of BSP files
CZghost wrote:Only for Linux users! How will use command line ordinary Windows users when Windows CMD is based off completely different scheme?
Code: Select all
@echo off
for /f %%a IN ('dir /b /On *.bsp') do (
gsar %%a -stextures/example/shader-or-texture-01:000 -rcustomtx/example/shader-or-texture-01:000 -o
REM # texture 0..n
gsar %%a -stextures/example/shader-or-texture-99:000 -rcustomtx/example/shader-or-texture-99:000 -o
)
Re: Direct modification of BSP files
Okay, but I do not remember Windows CMD ever had gsar command. I think it is in basic installation of Linux. I think Windows user has to download it somewhere if possible, if not, they are just over...
Re: Direct modification of BSP files
Maybe you should read up on GSAR. And on batch processing in general.V1979 wrote:As for me, I don't understand [...]
Manual Hex Editing is simply a waste of time. GSAR works on any file. Be it binary or text. This includes bsp, md3, jpg, tga, shader or any other file type.V1979 wrote: [...]whilst with Hex Editor and its GUI, I successfully modify not only *.bsp files, but *.md3 and any others too.
Tru dat! Been working with GSAR and various other tools for a very long time. Take it from a pro: GUI hex editors are merely a shiny toy.V1979 wrote: Let practice will be our judge.
You won't get far, if you lower your bar.
Re: Direct modification of BSP files
Download link was in the 2nd post of this thread. But apparently nobody really reads anymoreCZghost wrote:Okay, but I do not remember Windows CMD ever had gsar command. I think it is in basic installation of Linux. I think Windows user has to download it somewhere if possible, if not, they are just over...

http://gnuwin32.sourceforge.net/packages/gsar.htm
Re: Direct modification of BSP files
m4xpower,
Useless dispute. I just give some comparison. My instructions can be compared to a manual how to drive a car, and it doesn't matter if such a car is good or bad, it exists, it works and it's enough. While you say, that a better car could be made, and suggest learning how to create such a car.
Useless dispute. I just give some comparison. My instructions can be compared to a manual how to drive a car, and it doesn't matter if such a car is good or bad, it exists, it works and it's enough. While you say, that a better car could be made, and suggest learning how to create such a car.