SlideShare a Scribd company logo


.WAD files
Anton Gerdelan
making our own doom WADs
(maps/levels etc) in 1994-5
a port of DEU from http://interreality.org/~tetron/technology/lde/
Here is all the data!
- binary file, custom layout
- Id released specs to help modders build tools
~1994 (I went in raw though)
- IWAD and PWAD
- combines all game data
- parts of levels; { walls, floors, monsters… }
- sound effects data (proprietary format)
- music (proprietary format)
- colour palettes, images for maps, enemies,
panels…
- images with transparent bits have custom format
tools
- hexedit
- C
- fread()
- fwrite()
- fseek()
- valgrind
- Audacity
- OpenGL
- DosBox
binary sleuthing
- figure out file structure
- search for strings
- determine directory
structure
- match hex-format
address with values
- h/w arch of 1993
machines
- trial and error
e.g. directory started at

~ 00 BC C5 00



this 4-byte group says

“C4 C5 BC 00”
printf() the directory
- Directory entries in block at
end of file:
- entry string (good hint)
- entry size in bytes
- entry offset from file start -
use fseek()
- I was after the music but
couldn’t resist
- “VERTEX” “LINEDEF”
“SECTOR” …
LINEDEF ~walls
references 2 VERTEXES
references 1-2 SIDEDEFS

find height in SECTORS
VERTEX

has 2 (x,y) integer values
SECTOR

~floor/ceiling
bounded by SIDEDEFS

not tessellated

not always convex

have holes
Walls and Floors
- Create a struct for each type of map part and

put them in arrays to do quick line->height etc.
- Walls - just extrude them up?
- lower lip
- mid (sometimes a gap)
- upper lip
- Floors - tessellation algorithm
- I used “Ear Clipping”

extended for holes
Ear-Clipping Tessellation
- David Eberly’s white paper is great

https://www.geometrictools.com/
Documentation/
TriangulationByEarClipping.pdf

- breaks a simple polygon into triangles
- single region bounded by loop of edges
and verts

- a group of 3 consecutive verts is reflex
(angle > pi) or convex (angle < pi)

- convex triplet = a polygon ear

- but not if another vert is inside that triangle

- and final line is fully inside poly

- can recurse clipping until 3 vertices remain

O(n^3) … but can improve on this
The Two Ears Theorem
A polygon of >3 sides always has at
least 2 valid ears.



is_convex(

vert a, vert b, vert c );
is_in_triangle(

vert a, vert b, vert c, 

vert x );
Ear-Clipping Tessellation
- Loop around all n verts in polygon
- use curr-1, curr, curr+1 (modulo n)

- test all other verts - is_in_triangle()



(pre-calc current reflex/convex status per triangle
to reduce time complexity). ~O(n^2)

- if (is_ear) {
- remove curr vertex from polygon
- add triangle to a list
- decrement n.
- if n == 3 found last triangle. HALT
- https://youtu.be/9wrhIvpOKlg

shows algorithm on Doom E1M1 in steps

- src (experiment 039)

https://github.com/capnramses/opengl_expmts
- extend Ear Clipping for O-shapes (hole in middle):
- outer vertices clockwise order - make inner loop CCW
- add to end of loop’s vertex list
- add a valid “cut” line between outer and inner (tricky)
- proceed as normal - now treated as a C-shape
Pool of toxic sludge inside

another sector - gets obscured
modified ear clipping

worked!

(sludge pool no longer

paved over)
shader for ceilings with “sky” image
texture is one half of a 180

that wraps ~ proto-skybox
mapped to 320x200 screen

pixels so hard to map to

arbitrary size/resolution

Secrets of Romero’s Head
- found tiny ledges on wall
that had big daemon head
- clever way of splitting
enormous image into many

sub-images
Hacking the unpublished
sound format
- Custom 8-byte header - I just ditched it
- Body is a blob of waveform data
- Guess format based on original

SoundBlaster
- Trial and error in Audacity raw data import
- unsigned 8-bit mono 11025Hz samples
- 16 bytes additional padding at front and end that can all be
trimmed, leaving raw sound data.
- Seems to work. https://youtu.be/AZxU9fNsWoU
Music format
- Wasn’t MIDI! It was MIDI encoded into a proprietary format
- 9 instruments
- custom playback software (never released)
- MIDI2MUS and MUS2MIDI (MS-DOS)
- I don’t know enough about MIDI etc to work it out.
- I used DosBox and an ancient MUS2MIDI
- Sub-par results - need original playback software!
“Dude, you need to stop
working on your vanity projects!”
- How do other Doom renderers deal with the sector tessellation
problem?
- They didn’t! Specially prepared .WAD [cheating!].
- Better potential solution
- try Delaunay triangulation instead
- Source code
- DeWad - https://github.com/capnramses/doom_projects
- OpenGL renderer - Blog post about it - antongerdelan.net/blog/
Finding a good cut
- find rightmost inner loop vertex
- project vector right from it
- intersect all outer edges
- find closest vertex to projected
line (except if vertex is not visible
to first vertex).
- if closest point is an outer point
use this. HALT.
- otherwise search the outer edge
for valid visible vertex to first

(many tests and conditions here)
multiple holes or complex?
create hierarchies of simple

shapes, solve small, combine

More Related Content

PDF
Computer Graphics - Lecture 02 transformation
PDF
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
PDF
Computer Graphics - Lecture 01 - 3D Programming I
PPTX
DirectX 11 Rendering in Battlefield 3
PPTX
FrameGraph: Extensible Rendering Architecture in Frostbite
PDF
HBase Consistency and Performance Improvements
PDF
Apache spark - Spark's distributed programming model
PPTX
Intensity Transformation Functions of image with Matlab
Computer Graphics - Lecture 02 transformation
Computer Graphics - Lecture 03 - Virtual Cameras and the Transformation Pipeline
Computer Graphics - Lecture 01 - 3D Programming I
DirectX 11 Rendering in Battlefield 3
FrameGraph: Extensible Rendering Architecture in Frostbite
HBase Consistency and Performance Improvements
Apache spark - Spark's distributed programming model
Intensity Transformation Functions of image with Matlab

What's hot (20)

PDF
Filtre adaptatif LMS avec Système On Chi (SOC) sur FPGA
PPSX
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
PPTX
Triangle Visibility buffer
PDF
Computer Vision: Feature matching with RANSAC Algorithm
PPTX
Optimizing the Graphics Pipeline with Compute, GDC 2016
PPT
PPT
Line drawing algorithm and antialiasing techniques
PDF
Deferred Rendering in Killzone 2
PDF
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
PPTX
Rendering Technologies from Crysis 3 (GDC 2013)
PPTX
Parallel Futures of a Game Engine
PPTX
Computer graphics basic transformation
PPTX
Truenorth - Ibm’s brain like chip
PDF
Recursive Neural Networks
PDF
Lecture 1 Introduction to image processing
PDF
[Basic 7] OS の基本 / 割り込み / システム コール / メモリ管理
PPTX
Approaching zero driver overhead
PDF
cgrchapter2version-1-200729063505 (1).pdf
PPT
bresenham circle algorithm .ppt
PPT
OpenGL for 2015
Filtre adaptatif LMS avec Système On Chi (SOC) sur FPGA
Vertex Shader Tricks by Bill Bilodeau - AMD at GDC14
Triangle Visibility buffer
Computer Vision: Feature matching with RANSAC Algorithm
Optimizing the Graphics Pipeline with Compute, GDC 2016
Line drawing algorithm and antialiasing techniques
Deferred Rendering in Killzone 2
An introduction to Realistic Ocean Rendering through FFT - Fabio Suriano - Co...
Rendering Technologies from Crysis 3 (GDC 2013)
Parallel Futures of a Game Engine
Computer graphics basic transformation
Truenorth - Ibm’s brain like chip
Recursive Neural Networks
Lecture 1 Introduction to image processing
[Basic 7] OS の基本 / 割り込み / システム コール / メモリ管理
Approaching zero driver overhead
cgrchapter2version-1-200729063505 (1).pdf
bresenham circle algorithm .ppt
OpenGL for 2015
Ad

Similar to Cracking into Doom (1993) WAD Files (20)

PPTX
Decima Engine: Visibility in Horizon Zero Dawn
PDF
[04][dx11 테셀레이션] ni tessellation
PDF
IAP09 CUDA@MIT 6.963 - Lecture 04: CUDA Advanced #1 (Nicolas Pinto, MIT)
PPT
GDC 2012: Advanced Procedural Rendering in DX11
PPT
CS 354 Transformation, Clipping, and Culling
PDF
3. CUDA_Thread.pdf info on cuda threads .
PPTX
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
PPT
CS 354 Object Viewing and Representation
PPT
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
PDF
Masked Software Occlusion Culling
PDF
Markus Tessmann, InnoGames
PPT
SIGGRAPH 2012: NVIDIA OpenGL for 2012
PPTX
The Technology behind Shadow Warrior, ZTG 2014
PPS
Crocotta R&D - Virtual Universe
PPT
OpenGL 4 for 2010
PDF
Virtual Reality in Pharo: Challenges and Demo
PDF
Rainbow Over the Windows: More Colors Than You Could Expect
PPT
GTC 2012: NVIDIA OpenGL in 2012
PPT
Implementation
PDF
Doom Technical Review
Decima Engine: Visibility in Horizon Zero Dawn
[04][dx11 테셀레이션] ni tessellation
IAP09 CUDA@MIT 6.963 - Lecture 04: CUDA Advanced #1 (Nicolas Pinto, MIT)
GDC 2012: Advanced Procedural Rendering in DX11
CS 354 Transformation, Clipping, and Culling
3. CUDA_Thread.pdf info on cuda threads .
4K Checkerboard in Battlefield 1 and Mass Effect Andromeda
CS 354 Object Viewing and Representation
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
Masked Software Occlusion Culling
Markus Tessmann, InnoGames
SIGGRAPH 2012: NVIDIA OpenGL for 2012
The Technology behind Shadow Warrior, ZTG 2014
Crocotta R&D - Virtual Universe
OpenGL 4 for 2010
Virtual Reality in Pharo: Challenges and Demo
Rainbow Over the Windows: More Colors Than You Could Expect
GTC 2012: NVIDIA OpenGL in 2012
Implementation
Doom Technical Review
Ad

Recently uploaded (20)

PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Cost to Outsource Software Development in 2025
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PPTX
Introduction to Windows Operating System
PPTX
GSA Content Generator Crack (2025 Latest)
DOCX
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
PPTX
assetexplorer- product-overview - presentation
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
PPTX
Custom Software Development Services.pptx.pptx
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Cost to Outsource Software Development in 2025
Autodesk AutoCAD Crack Free Download 2025
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Time Tracking Features That Teams and Organizations Actually Need
How Tridens DevSecOps Ensures Compliance, Security, and Agility
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Designing Intelligence for the Shop Floor.pdf
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Advanced SystemCare Ultimate Crack + Portable (2025)
Introduction to Windows Operating System
GSA Content Generator Crack (2025 Latest)
Greta — No-Code AI for Building Full-Stack Web & Mobile Apps
assetexplorer- product-overview - presentation
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
Custom Software Development Services.pptx.pptx
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...

Cracking into Doom (1993) WAD Files

  • 2. making our own doom WADs (maps/levels etc) in 1994-5 a port of DEU from http://interreality.org/~tetron/technology/lde/
  • 3. Here is all the data! - binary file, custom layout - Id released specs to help modders build tools ~1994 (I went in raw though) - IWAD and PWAD - combines all game data - parts of levels; { walls, floors, monsters… } - sound effects data (proprietary format) - music (proprietary format) - colour palettes, images for maps, enemies, panels… - images with transparent bits have custom format
  • 4. tools - hexedit - C - fread() - fwrite() - fseek() - valgrind - Audacity - OpenGL - DosBox
  • 5. binary sleuthing - figure out file structure - search for strings - determine directory structure - match hex-format address with values - h/w arch of 1993 machines - trial and error e.g. directory started at
 ~ 00 BC C5 00
 
 this 4-byte group says
 “C4 C5 BC 00”
  • 6. printf() the directory - Directory entries in block at end of file: - entry string (good hint) - entry size in bytes - entry offset from file start - use fseek() - I was after the music but couldn’t resist - “VERTEX” “LINEDEF” “SECTOR” …
  • 7. LINEDEF ~walls references 2 VERTEXES references 1-2 SIDEDEFS
 find height in SECTORS VERTEX
 has 2 (x,y) integer values SECTOR
 ~floor/ceiling bounded by SIDEDEFS
 not tessellated
 not always convex
 have holes
  • 8. Walls and Floors - Create a struct for each type of map part and
 put them in arrays to do quick line->height etc. - Walls - just extrude them up? - lower lip - mid (sometimes a gap) - upper lip - Floors - tessellation algorithm - I used “Ear Clipping”
 extended for holes
  • 9. Ear-Clipping Tessellation - David Eberly’s white paper is great
 https://www.geometrictools.com/ Documentation/ TriangulationByEarClipping.pdf
 - breaks a simple polygon into triangles - single region bounded by loop of edges and verts
 - a group of 3 consecutive verts is reflex (angle > pi) or convex (angle < pi)
 - convex triplet = a polygon ear
 - but not if another vert is inside that triangle
 - and final line is fully inside poly
 - can recurse clipping until 3 vertices remain
 O(n^3) … but can improve on this The Two Ears Theorem A polygon of >3 sides always has at least 2 valid ears.
 
 is_convex(
 vert a, vert b, vert c ); is_in_triangle(
 vert a, vert b, vert c, 
 vert x );
  • 10. Ear-Clipping Tessellation - Loop around all n verts in polygon - use curr-1, curr, curr+1 (modulo n)
 - test all other verts - is_in_triangle()
 
 (pre-calc current reflex/convex status per triangle to reduce time complexity). ~O(n^2)
 - if (is_ear) { - remove curr vertex from polygon - add triangle to a list - decrement n. - if n == 3 found last triangle. HALT - https://youtu.be/9wrhIvpOKlg
 shows algorithm on Doom E1M1 in steps
 - src (experiment 039)
 https://github.com/capnramses/opengl_expmts
  • 11. - extend Ear Clipping for O-shapes (hole in middle): - outer vertices clockwise order - make inner loop CCW - add to end of loop’s vertex list - add a valid “cut” line between outer and inner (tricky) - proceed as normal - now treated as a C-shape Pool of toxic sludge inside
 another sector - gets obscured
  • 12. modified ear clipping
 worked!
 (sludge pool no longer
 paved over)
  • 13. shader for ceilings with “sky” image texture is one half of a 180
 that wraps ~ proto-skybox mapped to 320x200 screen
 pixels so hard to map to
 arbitrary size/resolution

  • 14. Secrets of Romero’s Head - found tiny ledges on wall that had big daemon head - clever way of splitting enormous image into many
 sub-images
  • 15. Hacking the unpublished sound format - Custom 8-byte header - I just ditched it - Body is a blob of waveform data - Guess format based on original
 SoundBlaster - Trial and error in Audacity raw data import - unsigned 8-bit mono 11025Hz samples - 16 bytes additional padding at front and end that can all be trimmed, leaving raw sound data. - Seems to work. https://youtu.be/AZxU9fNsWoU
  • 16. Music format - Wasn’t MIDI! It was MIDI encoded into a proprietary format - 9 instruments - custom playback software (never released) - MIDI2MUS and MUS2MIDI (MS-DOS) - I don’t know enough about MIDI etc to work it out. - I used DosBox and an ancient MUS2MIDI - Sub-par results - need original playback software!
  • 17. “Dude, you need to stop working on your vanity projects!” - How do other Doom renderers deal with the sector tessellation problem? - They didn’t! Specially prepared .WAD [cheating!]. - Better potential solution - try Delaunay triangulation instead - Source code - DeWad - https://github.com/capnramses/doom_projects - OpenGL renderer - Blog post about it - antongerdelan.net/blog/
  • 18. Finding a good cut - find rightmost inner loop vertex - project vector right from it - intersect all outer edges - find closest vertex to projected line (except if vertex is not visible to first vertex). - if closest point is an outer point use this. HALT. - otherwise search the outer edge for valid visible vertex to first
 (many tests and conditions here) multiple holes or complex? create hierarchies of simple
 shapes, solve small, combine