Old School Fractal Mountains?

BlitzMax Forums/BlitzMax Programming/Old School Fractal Mountains?

DrDeath(Posted 2010) [#1]
Does anyone here remember such retro game classics like Rescue on Fractalus, Koronis Rift, The Eidolon or Captain Blood? They all have in common to feature (pseudo?-)3D fractal mountains (or caves in the case of The Eidolon).

I'm looking for a way to create similar graphics, but I can't seem to find suitable algorithms for that. All that I come up with are true 3D fractal landscaping engines, and that's not quite what I need.

Has anyone stumbled upon such algorithms or a general idea how to these would work?


TomToad(Posted 2010) [#2]
This site describes how to do both 2d and 3d mountains. http://www.gameprogrammer.com/fractal.html

Here's another one. http://www.bugfree.dk/blog/2009/02/23/generating-2d-random-fractal-terrains-with-c/


DrDeath(Posted 2010) [#3]
Okay, thanks, but unfortunately, these methods don't really hit the nail on the head. I don't know in how far you are familiar with the games I mentioned (especially the ones from Lucasfilm Games), but (even if might not be that apparent by looking at the screenshots) the fractals there go a bit further than the randomised jiggly lines the examples you found provide.

Might still be a suitable starting point, though, since the midpoint displacement method appears to play a role in the Lucasfilm engine, but there's obviously more behind it – otherwise there wouldn't have been movement through consistent (pseudo-)3-dimensional space.


Bremer(Posted 2010) [#4]
There seems to be a lot of algorithms on the web for making colorful fractals. Could you not use on of those, and then instead of using the values for colors, then use them for heights to generate a hightmap?


DrDeath(Posted 2010) [#5]
Sure I could. But that's really not what I'm looking for. ;)


plash(Posted 2010) [#6]
There seems to be a lot of algorithms on the web for making colorful fractals

Sure I could. But that's really not what I'm looking for. ;)


I'm looking for a way to create similar graphics, but I can't seem to find suitable algorithms for that.


Sounds like it to me.


DrDeath(Posted 2010) [#7]
Sounds like it to me.

Okay, I should rephrase my original request: I'm not looking for a way to create just any fractal mountains. I know how to do that. I'm looking for a way to create the very specific kind of fractal mountains (or caves) like in RoF, KR, TE or CB. These aren't just random landscapes, you know?


Shortwind(Posted 2010) [#8]
http://www.electriceggplant.com/media/RG44_RescueOnFractalus.pdf


DrDeath(Posted 2010) [#9]
@ Shortwind: I don't know if you have actually read that article, but apart from what boils down to "we had an awesome fractal engine running on a 6502", there's not that much information about the game engine.


theHand(Posted 2010) [#10]
Maybe if you make a ingame video and put it on YouTube (or I could host it for you), people would understand what you're looking for and be able to give more relevant advice.
Or at least look on YouTube for videos that are already there. You don't seem too enthusiastic about this.

Captain Blood at around 0:06


Rescue on Fractalus
Koronis Rift
The Eidolon


andy_mc(Posted 2010) [#11]
Captain Blood was awesome, I used to play it on the Amstrad CPC


ima747(Posted 2010) [#12]
Off Topic: every time I cruise through the forum and notice this thread's title I start humming the tune to "Big Rock Candy Mountain" and my productivity plummets... apologies for infecting anyone else with this comment.


DrDeath(Posted 2010) [#13]
@ theHand: Thanks. You're right, in videos it's more obvious what differentiates the fractal sceneries I talk about from the usually purely random mountains most algorithms produce.

When you look at these videos, note how there is a persistent landscape given by a predetermined map with the rocky bits (mountains or cave walls) at very specific positions. I can't seem to find any maps for TE or KR online with the usual search engines (I have them in some old magazines, though), but you would see that the levels had a non-random structure.

Coming to think of it, Captain Blood is probably not the best example of what I'd like to achieve, since the landscape there is only very rudimentary (basically only that valley with craggy mountains left and right).


TomToad(Posted 2010) [#14]
One way I'd might try is creating the landscape using an editor and a few rudimentary lines. Then use the fractal algorithms already posted to make those lines more jaggy. Might be the way it was done in the games.


BlitzSupport(Posted 2010) [#15]
Captain Blood and Koronis Rift had unbelievable landscapes considering they ran on the Spectrum -- and in real time in KR's case.

Other than commenting that I once typed in a brilliant fractal landscape routine from Amstrad Action magazine, I'm afraid I really can't help.

However, there was a book called 'Computers and Chaos' by Conrad Bessant (as found here, aimed at the Amiga, that I still have, which has a really convincing landscape modelling routine (which invokes deliberate land 'faults') that would fit in nicely with Koronis Rift's landscapes, but I never really got around to trying to port it to Blitz.

If you can find it, or a digital copy, you would probably find it very relevant.

Quick Amazon search later... well, jeez, the Amiga version is "from £29.90" (mine was perhaps £3, car boot sale), while the Atari (boo) version, which must contain pretty much the same code, is "from £2.99"!

http://www.amazon.co.uk/Books/s?ie=UTF8&rh=n:266239,p_27:Conrad%20Bessant&field-author=Conrad%20Bessant&page=1


SoggyP(Posted 2010) [#16]
Hello.

Here's a crap way of doing it, knocked up quickly and not particularly good but should give you a way to start.

Goodbye.


Graphics 1024,768
Local pm:TPixmap = LoadPixmap("heightmap.jpg")

Local maxx = 64

Local tri#[maxx*2]

tri[0] = 0
tri[1] = 768
tri[maxx-2] = 1024
tri[maxx-1] = 768
Local y

Graphics 512,480
While Not KeyHit(KEY_ESCAPE)
		Cls
		
		sy = 0
		
		For iy = -15 To 0
			If y+iy > 0  Then
				For i = 0 To maxx-1
					
					If (15+i+xp)>0 And (15+i+xp)<255 Then
						x = i*2
						tri[x] = Float(i*8)
						tri[x+1] = (ReadPixel(pm,8+i+xp,y+iy) & $ff)*2
					End If
				Next				

				tri[0] = 0
				tri[1] = 768
				tri[maxx-2] = 1024
				tri[maxx-1] = 768

				sy = sy + 16
				
				SetOrigin 0,sy-64				
				SetColor 255,255,255
				DrawPoly tri

				SetOrigin 0,sy-64	+1			
				SetColor 64,255-sy,64
				DrawPoly tri
				
			EndIf
	
		Next
		
		SetOrigin 0,0
		SetColor 255,0,0
		DrawText "xp="+ xp,0,0
		DrawText "y="+ y,0,16
	
		If KeyDown(KEY_DOWN) Then y=y+1
		If KeyDown(Key_UP) Then y=y-1
		If KeyDown(Key_Right) Then xp=xp+1
		If KeyDown(Key_Left) Then xp=xp-1
		
		If y>255 Then y = 255
		If y<0 Then y = 0
		If xp>255 Then xp = 255
		If xp<0 Then xp = 0		

	Flip
Wend



DrDeath(Posted 2010) [#17]
Thanks! Now we are getting somewhere. Heightmaps definitely seem to be involved in some way.


SoggyP(Posted 2010) [#18]
Hello.

Another 1/2 hour, a bit of an improvement.


Graphics 1024,768,32
Local pm:TPixmap = LoadPixmap("heightmap.jpg")

isx = PixmapWidth(pm)
isy = PixmapHeight(pm)

xp = isx/2
y = isy/2
Local maxx = 64

Local tri#[maxx*2]

tri[0] = 0
tri[1] = 768
tri[maxx-2] = 1024
tri[maxx-1] = 768

viewdistance = 8 ' number of mountains to draw
linestep = 64 'distance between mountain draw

xsize = maxx ' how many vertices to draw
startx = (xsize / 2) * -1
endx = (xsize / 2) -1

stepwidth = 1024/xsize
stepheight = 32

colstep = 256/viewdistance

Graphics 512,480
		sy = 0
While Not KeyHit(KEY_ESCAPE)
		Cls
		
		y_count = 0
		screen_x = 0
				
		sy = 0
		While y_count < viewdistance
		
			' get y position of line
			inner_y = y - (y_count * viewdistance)
			If inner_y > (isy-1) Then inner_y = inner_y - isy
			If inner_y < 0 Then inner_y = inner_y + isy
			
			screen_x = 0		
			For xl = 0 To maxx-1
				
				inner_x = xp + xl
				
				If inner_x < 0 Then inner_x =inner_x + isx
				If inner_x > (isx-1) Then inner_x = inner_x - isx
				
				tripos = xl * 2
				
				tri[tripos] = Float(screen_x)
				my = (ReadPixel(pm,inner_x, inner_y) & $ff)*2

				tri[tripos+1] = my
				screen_x = screen_x + stepwidth			
			Next

			tri[0] = 0
			tri[1] = 768
			tri[2] = 0
			tri[maxx-4]=1024	
			tri[maxx-2] = 1024
			tri[maxx-1] = 768

			
			SetOrigin 0,sy
			SetColor 255,255,255
			DrawPoly tri
			
			SetOrigin 0,sy+4
			SetColor 0,y_count * colstep,0
			DrawPoly tri

			y_count = y_count + 1
			
			sy = sy + 32
		Wend
				
		Flip

		
		If KeyDown(KEY_DOWN) Then y=y-1
		If KeyDown(Key_UP) Then y=y+1
		If KeyDown(Key_Right) Then xp=xp+1
		If KeyDown(Key_Left) Then xp=xp-1
	
		If y>isy-1 Then y = isy-1
		If y<0 Then y = 0
		If xp>isx-1 Then xp = isx
		If xp<0 Then xp = 0		

Wend


Goodbye.