Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
gggmork

techwall and doorish texture generator

Recommended Posts

I was messing around in python/pygame and unintentionally ended up with something that auto generates pictures that look kinda like doom techwall type textures (or doom doors since those are kind of techwallish), so thought I'd share it.

They're all black/white right now.

gif showing 10 randomly generated techwalls (actually 9... whatever I can't count):


gif showing 10 randomly generated doors:
(same as above but 1/4 the size and mirror flipped 4 ways so it can tile)


The algorithm is start with a big square (like 256x256)
Now divide it into 2 rectangles at a random spot (randomly either horizontally or vertically). Repeat for each of those resulting rectangles... repeat repeat (but don't divide if the division is smaller than 3 pixels or something and stop if you reach like 9-15 iterations or so).

Share this post


Link to post

Cool looking doors. Some give me an Inca feel, shapes look like bricks and ornamental motifs.

Share this post


Link to post

I've worked on a ton of texture generators, it's really really difficult to get something useful.

As for your textures one immediate problem I can see is that those gradients do not make any sense in a lighting context. If you can look up an embossing algorithm, you can use that on your b/w images and get a good 3dish looking textures, from there you can apply a colour, some noise, other little bits and bobs and come out with something possibly usable.

This is making me want to get back into it haha, mirroring the texture like you do is a cool idea.

EDIT: for ref, here's a couple of my generated textures (failed attempts imo, and not doom palette)
https://www.dropbox.com/s/42m1rm1shi9xq94/ss%20%282014-10-13%20at%2009.10.43%29.jpg?dl=0
https://www.dropbox.com/s/nrjjqwcwuhz6kqx/ss%20%282014-10-11%20at%2002.31.55%29.jpg?dl=0

Share this post


Link to post

Those are interesting jmickle66666666 for attempting to make randomish shading so its not all solid color. Did you make it divide the width into a random but equal number of brick divisions (like sometimes 7 bricks across, sometimes 3 etc)? I think some cellular automata rule could make each brick randomly but mostly shaded toward its sides or something.

One more, with multiple colors, random number of divisions so some are more complex than others:

My guess is its hosted on another site so it doesn't matter much to post large file size gifs bandwith wise (actually that was only 96 kb so I guess they're not even big)?

The code is short so here it is if anyone wants (python/pygame):

import pygame,random,copy,math,time

doompalette=[[0, 0, 0], [31, 23, 11], [23, 15, 7], [75, 75, 75], [255, 255, 255], [27, 27, 27], [19, 19, 19], [11, 11, 11], [7, 7, 7], [47, 55, 31], 
[35, 43, 15], [23, 31, 7], [15, 23, 0], [79, 59, 43], [71, 51, 35], [63, 43, 27], [255, 183, 183], [247, 171, 171], [243, 163, 163], [235, 151, 151], 
[231, 143, 143], [223, 135, 135], [219, 123, 123], [211, 115, 115], [203, 107, 107], [199, 99, 99], [191, 91, 91], [187, 87, 87], [179, 79, 79], [175, 71, 71], 
[167, 63, 63], [163, 59, 59], [155, 51, 51], [151, 47, 47], [143, 43, 43], [139, 35, 35], [131, 31, 31], [127, 27, 27], [119, 23, 23], [115, 19, 19], 
[107, 15, 15], [103, 11, 11], [95, 7, 7], [91, 7, 7], [83, 7, 7], [79, 0, 0], [71, 0, 0], [67, 0, 0], [255, 235, 223], [255, 227, 211], [255, 219, 199], 
[255, 211, 187], [255, 207, 179], [255, 199, 167], [255, 191, 155], [255, 187, 147], [255, 179, 131], [247, 171, 123], [239, 163, 115], [231, 155, 107], 
[223, 147, 99], [215, 139, 91], [207, 131, 83], [203, 127, 79], [191, 123, 75], [179, 115, 71], [171, 111, 67], [163, 107, 63], [155, 99, 59], [143, 95, 55], 
[135, 87, 51], [127, 83, 47], [119, 79, 43], [107, 71, 39], [95, 67, 35], [83, 63, 31], [75, 55, 27], [63, 47, 23], [51, 43, 19], [43, 35, 15], [239, 239, 239], 
[231, 231, 231], [223, 223, 223], [219, 219, 219], [211, 211, 211], [203, 203, 203], [199, 199, 199], [191, 191, 191], [183, 183, 183], [179, 179, 179], 
[171, 171, 171], [167, 167, 167], [159, 159, 159], [151, 151, 151], [147, 147, 147], [139, 139, 139], [131, 131, 131], [127, 127, 127], [119, 119, 119], 
[111, 111, 111], [107, 107, 107], [99, 99, 99], [91, 91, 91], [87, 87, 87], [79, 79, 79], [71, 71, 71], [67, 67, 67], [59, 59, 59], [55, 55, 55], [47, 47, 47], 
[39, 39, 39], [35, 35, 35], [119, 255, 111], [111, 239, 103], [103, 223, 95], [95, 207, 87], [91, 191, 79], [83, 175, 71], [75, 159, 63], [67, 147, 55], 
[63, 131, 47], [55, 115, 43], [47, 99, 35], [39, 83, 27], [31, 67, 23], [23, 51, 15], [19, 35, 11], [11, 23, 7], [191, 167, 143], [183, 159, 135], 
[175, 151, 127], [167, 143, 119], [159, 135, 111], [155, 127, 107], [147, 123, 99], [139, 115, 91], [131, 107, 87], [123, 99, 79], [119, 95, 75], [111, 87, 67], 
[103, 83, 63], [95, 75, 55], [87, 67, 51], [83, 63, 47], [159, 131, 99], [143, 119, 83], [131, 107, 75], [119, 95, 63], [103, 83, 51], [91, 71, 43], 
[79, 59, 35], [67, 51, 27], [123, 127, 99], [111, 115, 87], [103, 107, 79], [91, 99, 71], [83, 87, 59], [71, 79, 51], [63, 71, 43], [55, 63, 39], 
[255, 255, 115], [235, 219, 87], [215, 187, 67], [195, 155, 47], [175, 123, 31], [155, 91, 19], [135, 67, 7], [115, 43, 0], [255, 255, 255], [255, 219, 219], 
[255, 187, 187], [255, 155, 155], [255, 123, 123], [255, 95, 95], [255, 63, 63], [255, 31, 31], [255, 0, 0], [239, 0, 0], [227, 0, 0], [215, 0, 0], 
[203, 0, 0], [191, 0, 0], [179, 0, 0], [167, 0, 0], [155, 0, 0], [139, 0, 0], [127, 0, 0], [115, 0, 0], [103, 0, 0], [91, 0, 0], [79, 0, 0], [67, 0, 0], 
[231, 231, 255], [199, 199, 255], [171, 171, 255], [143, 143, 255], [115, 115, 255], [83, 83, 255], [55, 55, 255], [27, 27, 255], [0, 0, 255], [0, 0, 227], 
[0, 0, 203], [0, 0, 179], [0, 0, 155], [0, 0, 131], [0, 0, 107], [0, 0, 83], [255, 255, 255], [255, 235, 219], [255, 215, 187], [255, 199, 155], [255, 179, 123], 
[255, 163, 91], [255, 143, 59], [255, 127, 27], [243, 115, 23], [235, 111, 15], [223, 103, 15], [215, 95, 11], [203, 87, 7], [195, 79, 0], [183, 71, 0], 
[175, 67, 0], [255, 255, 255], [255, 255, 215], [255, 255, 179], [255, 255, 143], [255, 255, 107], [255, 255, 71], [255, 255, 35], [255, 255, 0], 
[167, 63, 0], [159, 55, 0], [147, 47, 0], [135, 35, 0], [79, 59, 39], [67, 47, 27], [55, 35, 19], [47, 27, 11], [0, 0, 83], [0, 0, 71], [0, 0, 59], [0, 0, 47], 
[0, 0, 35], [0, 0, 23], [0, 0, 11], [0, 0, 0], [255, 159, 67], [255, 231, 75], [255, 123, 255], [255, 0, 255], [207, 0, 207], [159, 0, 155], [111, 0, 107], [167, 107, 107]]

##all tested correct, and go light to dark
pinks=[]
for i in range(16,48,1):
	pinks.append(doompalette[i])
tans=[]
for i in range(48,80,1):
	tans.append(doompalette[i])
greys=[]
for i in range(80,112,1):
	greys.append(doompalette[i])
greens=[]
for i in range(112,128,1):
	greens.append(doompalette[i])
browns=[]
for i in range(128,144,1):
	browns.append(doompalette[i])
rellows=[]
for i in range(160,168,1):
	rellows.append(doompalette[i])
reds=[]
for i in range(169,192,1):
	reds.append(doompalette[i])
blues=[]
for i in range(192,208,1):
	blues.append(doompalette[i])
broranges=[]
for i in range(209,224,1):
	broranges.append(doompalette[i])
yellows=[]
for i in range(225,232,1):
	yellows.append(doompalette[i])
purples=[]
for i in range(250,255,1):
	purples.append(doompalette[i])
#chains=[pinks,tans,greys,greens,browns,rellows,reds,blues,broranges,yellows,purples]
chains=[pinks,tans,greys,greens,browns,reds,blues,broranges]
for chain in chains:
	chain.reverse()

def divboxes(boxes):
	newboxes=[]
	for box in boxes:
		b1=None
		b2=None
		r=random.randint(0,1)
		if r==0 and box.height>=7:
			#div horz
			y=random.randint(box.top+3, box.bottom-3)
			b1=pygame.Rect(box.left,box.top,box.width,y-box.top)
			b2=pygame.Rect(box.left,y,box.width,box.bottom-y)
		elif r==1 and box.width>=7:
			#div vert
			x=random.randint(box.left+3, box.right-3)
			b1=pygame.Rect(box.left,box.top,x-box.left,box.height)
			b2=pygame.Rect(x,box.top,box.right-x,box.height)
		if b1!=None and b2!=None:
			newboxes.append(b1)
			newboxes.append(b2)
		else:
			newboxes.append(copy.deepcopy(box))
	return newboxes

def draw(boxes,surf):
	global chains
	##put here instead to make all same color
	#chain=copy.deepcopy(chains[random.randint(0,len(chains)-1)])
	for box in boxes:
		chain=copy.deepcopy(chains[random.randint(0,len(chains)-1)])
		#chain.reverse()
		coli=0
		boxc=copy.deepcopy(box)
		while boxc.width>0 and boxc.height>0 and coli<=len(chain)-1:
			if coli<len(chain)-1 and boxc.width>3 and boxc.height>3:
				pygame.draw.rect(surf,chain[coli],boxc,1)
			elif coli==len(chain)-1 or boxc.width<=3 or boxc.height<=3:
				pygame.draw.rect(surf,chain[coli],boxc,0)
				break
			coli+=1
			boxc[0]+=1
			boxc[1]+=1
			boxc[2]-=2
			boxc[3]-=2


##1/4 size then mirror flipped 4 times (uncomment for this)

screen = pygame.display.set_mode((256,256))
presurf=pygame.Surface((128,128))
cc=0
while(1):
	for e in pygame.event.get():
		if e.type==pygame.QUIT or (e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE):
			running=False
	boxes=[pygame.Rect(0,0,128,128)]
	#how many divisions/how complex
	for i in range(random.randint(2,8)):
		boxes=divboxes(boxes)
	screen.fill((255,255,255))
	presurf.fill((255,255,255))
	draw(boxes,presurf)
	screen.blit(presurf,(0,0))
	presurf=pygame.transform.flip(presurf,1,0)
	screen.blit(presurf,(128,0))
	presurf=pygame.transform.flip(presurf,0,1)
	screen.blit(presurf,(128,128))
	presurf=pygame.transform.flip(presurf,1,0)
	screen.blit(presurf,(0,128))
	pygame.display.flip()
	if cc<10:
		pygame.image.save(screen,'door'+str(cc)+'.png')
		cc+=1
	time.sleep(0.8)




##full size no mirror flips (uncomment for this)
'''
screen = pygame.display.set_mode((256,256))
while(1):
	for e in pygame.event.get():
		if e.type==pygame.QUIT or (e.type == pygame.KEYDOWN and e.key == pygame.K_ESCAPE):
			running=False
	boxes=[pygame.Rect(0,0,256,256)]#this and screen were 512
	for i in range(7):
		boxes=divboxes(boxes)
	screen.fill((0,255,255))
	draw(boxes,screen)
	pygame.display.flip()
	time.sleep(0.8)
'''

Share this post


Link to post

I tried brick textures now (128x128) with a different program that uses cellular automata, similar to the zdoom caves I made, it sprinkles random colors (from a chain of colors like dark blue to light blue etc), then (for 3-6ish iterations) finds each pixels 8 neighbors, sets it to their average, then multiplies away from the middle color, so it smoothly blends (becomes less random-pixely) but doesn't all move to the middle color of the chain. Takes like 3 seconds just to generate 1/not computer efficient.

21 frame gif of randomly generated brick textures (chose better ones of a wider sample), should all be in the doom palette:


If someone wants the python code I can post it... but its just for fun and a better way is probably to like... print screen at google images of brick pictures... lol (or anyone can use the pics above if they want)

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×