Quake3World.com Forums
     Level Editing & Modeling
        Direct modification of BSP files


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Direct modification of BSP files

Grunt
Grunt
Joined: 22 Dec 2014
Posts: 58
PostPosted: 05-29-2015 04:06 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Trainee
Trainee
Joined: 20 May 2015
Posts: 32
PostPosted: 05-29-2015 04:37 AM           Profile Send private message  E-mail  Edit post Reply with quote


V1979 wrote:
[...] 1. Open a chosen map in a hex editor (for example Hex Editor Neo). [...]

...or you can just use GSAR for huge amounts of patching (search/replace) or batch processing.

DOWNLOAD LINK: http://gnuwin32.sourceforge.net/packages/gsar.htm

Command:
Code:
gsar <filename.bsp> -stextures/example/shader-or-texture:000 -rcustomtx/example/shader-or-texture:000 -o

...works on text files too (e.g.: *.shader)

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 05-29-2015 07:00 AM, edited 1 time in total.

Top
                 

Grunt
Grunt
Joined: 22 Dec 2014
Posts: 58
PostPosted: 05-29-2015 04:48 AM           Profile Send private message  E-mail  Edit post Reply with quote


m4xpower wrote:
***

There is no need in batching, because each texture is named in a *.bsp file for just the only time.




Top
                 

Trainee
Trainee
Joined: 20 May 2015
Posts: 32
PostPosted: 05-29-2015 05:49 AM           Profile Send private message  E-mail  Edit post Reply with quote


V1979 wrote:
There is no need in batching, because each texture is named in a *.bsp file for just the only time.

There usually is - unless you enjoy tedious, mind-numbing work.
Just a quick example:
Code:
#!/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

Even if you are just modifying one map, it's by far easier and faster to use a command-line tool.




Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1922
PostPosted: 05-29-2015 06:18 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Only for Linux users! How will use command line ordinary Windows users when Windows CMD is based off completely different scheme?



_________________
[ Websites | Facebook | Twitter | YouTube | Instagram ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon


Top
                 

Grunt
Grunt
Joined: 22 Dec 2014
Posts: 58
PostPosted: 05-29-2015 06:21 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 

Trainee
Trainee
Joined: 20 May 2015
Posts: 32
PostPosted: 05-29-2015 06:28 AM           Profile Send private message  E-mail  Edit post Reply with quote


CZghost wrote:
Only for Linux users! How will use command line ordinary Windows users when Windows CMD is based off completely different scheme?


Code:
@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
)


...that should do the trick.




Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1922
PostPosted: 05-29-2015 06:42 AM           Profile   Send private message  E-mail  Edit post Reply with quote


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...



_________________
[ Websites | Facebook | Twitter | YouTube | Instagram ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon


Top
                 

Trainee
Trainee
Joined: 20 May 2015
Posts: 32
PostPosted: 05-29-2015 06:48 AM           Profile Send private message  E-mail  Edit post Reply with quote


V1979 wrote:
As for me, I don't understand [...]

Maybe you should read up on GSAR. And on batch processing in general.

V1979 wrote:
[...]whilst with Hex Editor and its GUI, I successfully modify not only *.bsp files, but *.md3 and any others too.

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:
Let practice will be our judge.

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.
You won't get far, if you lower your bar.




Top
                 

Trainee
Trainee
Joined: 20 May 2015
Posts: 32
PostPosted: 05-29-2015 06:50 AM           Profile Send private message  E-mail  Edit post Reply with quote


CZghost 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...


Download link was in the 2nd post of this thread. But apparently nobody really reads anymore :rolleyes:.

http://gnuwin32.sourceforge.net/packages/gsar.htm




Top
                 

The hell good boy
The hell good boy
Joined: 22 Jun 2011
Posts: 1922
PostPosted: 05-29-2015 08:39 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Okay, you got me :olo: :up:



_________________
[ Websites | Facebook | Twitter | YouTube | Instagram ]
When you feel the worst, turn to the sun and all the shadows will fall behind you.” - John Lennon


Top
                 

Grunt
Grunt
Joined: 22 Dec 2014
Posts: 58
PostPosted: 05-30-2015 01:38 AM           Profile Send private message  E-mail  Edit post Reply with quote


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.




Top
                 
Quake3World.com | Forum Index | Level Editing & Modeling


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.