Posted: 1st Nov 2014 4:14
(HAPPY HALLOWEEN!)

Actually you could make it bigger than 256, but there's plenty of detail on each one.

You can play will all the variables and get drastic results...
You can also sharpen or lessen the blur by changing both 'get image' texture flags.

The code is my usual slop-style, but runs like a thief =)

+ Code Snippet
`//////  CUSTOMIZE  /////
MaxCracks=20  `Max number of lines to start
WhitePass=500  `How much white to daub
GreyPass=1000   `How much grey to daub
BlackPass=2000   `How much black to daub
Stroke=4            `How far the pixel can travel per pass
Pos=1:Neg=-Pos  `Offset for transparent clones
Alph=40               `Transparency for clones (too much will negate blur effect)
`///////

randomize timer():hide mouse:backdrop on
dim crackX(MaxCracks)
dim crackY(MaxCracks)
Stone=5000
Stone2=5001
Final=5003

Restart:
color backdrop rgb(rnd(40),rnd(40),rnd(40))
while spacekey():ENDWHILE
if image exist(Stone) then delete image Stone
if image exist(Final) then delete image Final
if sprite exist(Stone) then delete sprite Stone
if sprite exist(Stone2) then delete sprite Stone2


`MakeStone
for y=0 to 265
for x=0 to 265
c=rnd(99)+1
dot x,y,rgb(c,c,c)
NEXT
NEXT

for c=1 to MaxCracks
CrackX(c)=rnd(255)
CrackY(c)=rnd(255)
NEXT

for pass=1 to WhitePass
for c=1 to MaxCracks
col=200+rnd(45)
dot CrackX(c),CrackY(c),rgb(col,col,col)
inc CrackX(c),rnd(Stroke)-rnd(Stroke)    
inc CrackY(c),rnd(Stroke)-rnd(Stroke)
NEXT
NEXT

for c=1 to MaxCracks
CrackX(c)=rnd(255)
CrackY(c)=rnd(255)
NEXT

for pass=1 to GreyPass
for c=1 to MaxCracks
col=100+rnd(45)
dot CrackX(c),CrackY(c),rgb(col,col,col)
inc CrackX(c),rnd(Stroke)-rnd(Stroke)    
inc CrackY(c),rnd(Stroke)-rnd(Stroke)
NEXT
NEXT


for c=1 to MaxCracks
CrackX(c)=rnd(255)
CrackY(c)=rnd(255)
NEXT

for pass=1 to BlackPass
for c=1 to MaxCracks
col=1+rnd(25)
dot CrackX(c),CrackY(c),rgb(col,col,col)
inc CrackX(c),rnd(Stroke)-rnd(Stroke)    
inc CrackY(c),rnd(Stroke)-rnd(Stroke)
NEXT
NEXT
get image Stone,0,0,265,265
sprite Stone, 0,0,Stone
`set sprite alpha Stone,50
hide sprite Stone
clone sprite Stone,Stone2
set sprite alpha Stone2,Alph
hide sprite Stone2
cls
paste sprite Stone,0,0
paste sprite Stone2,0,Neg
paste sprite Stone2,Pos,Neg
paste sprite Stone2,Pos,0
paste sprite Stone2,Pos,Pos
paste sprite Stone2,0,Pos
paste sprite Stone2,Neg,Pos
paste sprite Stone2,Neg,0
paste sprite Stone2,Neg,Neg
get image Final,4,4,260,260,1
cls
color backdrop rgb(rnd(40),rnd(40),rnd(40))
do
if spacekey() then goto ReStart
if lower$(inkey$())="s" then save image str$(rnd(10000))+".png",Final:backdrop off:print "...image saved!":wait 1000:backdrop on
paste image Final,(screen width()/2)-(image width(Final)/2),(screen height()/2)-(image height(Final)/2)
set cursor 0,0
print "SPACEKEY TO REDRAW"
print "S=SAVE .PNG"
LOOP


Posted: 2nd Nov 2014 15:50
Simple method yet with pleasant results. Nice work.

I modified your code slightly, structurally more than anything. It's a little shorter and in a function now.

+ Code Snippet
REM =========================
REM Author: Derek Darkly
REM Edited by: Phaelax
REM =========================


createHeightmap(5003, 20, 500, 1000, 2000, 4, 40)

repeat
    cls
    
    if spacekey() and flag=0 then createHeightmap(5003, 20, 500, 1000, 2000, 4, 40) : flag = 1
    if spacekey() = 0 then flag = 0
    
    if lower$(inkey$())="s" then save image "heightmap_"+str$(rnd(10000))+".png", 5003:backdrop off:print "...image saved!":wait 1000:backdrop on  
    
    paste image 5003,(screen width()/2)-(image width(5003)/2),(screen height()/2)-(image height(5003)/2)
    
    
    set cursor 0,0
    print "SPACEKEY TO REDRAW"
    print "S=SAVE .PNG"
until escapekey()
end



rem ////////////////////////////////////////////////////////////////////////////////////
rem img:                   image ID used to create heightmap image
rem maxCracks:             max number of lines to start
rem white/grey/black pass: how much of the color to daub
rem stroke:                how far the pixel can travel per pass
rem alpha:                 transparency for clones (too much will negate blur effect)
rem ////////////////////////////////////////////////////////////////////////////////////
function createHeightmap(img, maxCracks, whitePass, greyPass, blackPass, stroke, alpha)
    local img_stone1 = 5000
    local img_stone2 = 5001
    local pos = 1
    local neg = -1
        
    dim crackX(maxCracks)
    dim crackY(maxCracks)
    dim pass(3)
    
    pass(1) = whitePass : pass(2) = greyPass : pass(3) = blackPass
        
    rem Make stone
    for y = 0 to 265
        for x = 0 to 265
            c = rnd(99)+1
            dot x, y, rgb(c,c,c)
        next x
    next y
    
    rem Make the white, grey, black passes
    for p = 1 to 3
        for c = 1 to maxCracks
            crackX(c) = rnd(255)
            crackY(c) = rnd(255)
        next
    
        for pass = 1 to whitePass
            for c = 1 to maxCracks
                col = 200+rnd(45)
                dot crackX(c), crackY(c), rgb(col, col, col)
                inc crackX(c), rnd(stroke)-rnd(stroke)
                inc crackY(c), rnd(stroke)-rnd(stroke)
            next c
        next pass
    next p
    
    
    get image img_stone1, 0, 0, 265, 265
    sprite img_stone1, 0, 0, img_stone1
    hide sprite img_stone1
    clone sprite img_stone1, img_stone2
    set sprite alpha img_stone2, alpha
    hide sprite img_stone2
    
    cls
    paste sprite img_stone1, 0,   0
    paste sprite img_stone2, 0,   neg
    paste sprite img_stone2, pos, neg
    paste sprite img_stone2, pos, 0
    paste sprite img_stone2, pos, pos
    paste sprite img_stone2, 0,   pos
    paste sprite img_stone2, neg, pos
    paste sprite img_stone2, neg, 0
    paste sprite img_stone2, neg, neg
    
    rem get new image
    if image exist(img) then delete image img
    get image img, 4, 4, 260, 260, 1
    
    rem free resources  
    delete image  img_stone1
    delete sprite img_stone1
    delete sprite img_stone2
    undim crackX()
    undim crackY()
    undim pass()
endfunction

Posted: 2nd Nov 2014 18:31
I tried a very quick render of it!
Posted: 2nd Nov 2014 20:02
Thanks guys!!

Nice, Phaelax... the function format is better for dropping into a larger coder, yes? I need to do more work with functions myself.

Hey that's a cool pic, Le Verdier! I like the shadows!
Is that rendered with Blitz Terrain or something else?

I'm just now delving into texture splatting based on an old shader by DaveC9000. When I can figure out how the alpha maps affect one another I should be able to make some nice landscapes with multiple detail textures.
Posted: 2nd Nov 2014 21:31
It isn't realtime, I used Vue 2014
A raw 512*512 texture with no fractal details,
Atmosphere and texture provided...
As I said, a very quick render!
Posted: 10th Nov 2014 15:01
[Le Verdier's pic!]