• Welcome to Dark Bit Factory & Gravity.
 

Floor Casting with Xor Texture

Started by va!n, January 19, 2008

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

va!n

Our board member rain_storm has released his great  source for an so called "floor casting oldskool demo effect with Xor texture" using freebasic. (http://dbfinteractive.com/index.php?topic=2816.0) I really like this old skoolish floor effect since end of the 80th/beginning 90th from amiga scene! So i have tried to convert rain_storm source to pure... Here we go... (there is a lot of optimizing potential). Have fun and again a big thanks to rain_storm for sharing his original source! *thumbs up*


; --------------------------------------------------------------
;
; OldSkool DemoEffect:  Floor Casting
;
; Converted by: Thorsten Will aka Mr.Vain/Secretly!
; Thanks a lot to "rain_storm" for his original source! *thumbs up*
;
; --------------------------------------------------------------

resX = 640
resY = 480
xres = 320
yres = 240

InitSprite()
InitKeyboard()
OpenScreen( resX, resY, 32, "Floor Casting DemoEffect" )

Repeat
    ExamineKeyboard()
    StartDrawing(ScreenOutput())
 
    camY.f = camY  + 2                           ; change for speed
    camX.f = xres * Sin( camY * 3.14159 / 180 )
    b.f = 0
    For y = 0 To resY -1
        w.f = -yres / y
        v.f = (  resX * w - camY )
        u.f = ( -xres * w + camX )
        For x = 0 To resX -1
            c = ( Int(u) ! Int(v) ) & 255
            Plot( x, y, RGB( c, c, c ))
            u = u + w
        Next
        b = b + resX
    Next

    StopDrawing()
    FlipBuffers()
Until KeyboardPushed( #PB_Key_Escape )
End

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

benny!

Cool that you converted it.

Guess you could speed this up using the direct DrawingBuffer access
functions !?

Anyway, nice conversion  :clap:
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

va!n

Thx benny and yes, there are a lot of optimisations possible... like replacing plot with direct screen drawing and some other things (parts with inline asm, where PB generate slow asm output :P)
- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

va!n

Small modified version with added depth effect...


; --------------------------------------------------------------
;
; OldSkool DemoEffect:  Floor Casting
;
; Converted by: Thorsten Will aka Mr.Vain/Secretly!
; Thanks a lot to "rain storm" for his original source! *thumbs up*
;
; --------------------------------------------------------------

resX = 640
resY = 480
xres = 320
yres = 240

InitSprite()
InitKeyboard()
OpenScreen( resX, resY, 32, "Floor Casting DemoEffect" )

Repeat
    ExamineKeyboard()
    StartDrawing(ScreenOutput())

    camY.f = camY  + 2                           ; change for speed
    camX.f = xres * Sin( camY * 3.14159 / 180 )
    b.f = 0
    For y = 0 To resY -1
        w.f = -yres / y
        v.f = (  resX * w - camY )
        u.f = ( -xres * w + camX )
        For x = 0 To resX -1
            t =  ((Int(u) ! Int(v) ) & 255 )
            c = Int((t / resY) * y)
            Plot( x, y, RGB( c, c, c ))
            u = u + w
        Next
        b = b + resX
    Next

    StopDrawing()
    FlipBuffers()
Until KeyboardPushed( #PB_Key_Escape )
End

- hp EliteBook 8540p, 4 GB RAM, Windows 8.1 x64
- Asus P5Q, Intel Q8200, 6 GB DDR2, Radeon 4870, Windows 8.1 x64
http://www.secretly.de
Challenge Trophies Won:

Jim

Someone already pointed out you have a problem when y=0
       w.f = -yres / y
If y=0 what does w.f come out to?

Jim
Challenge Trophies Won:

mind

Quote from: Jim on January 20, 2008
Someone already pointed out you have a problem when y=0
       w.f = -yres / y
If y=0 what does w.f come out to?

Jim


if y=0 the world ends! divide by zero wins :)

and by all means, dont credit me for the depth effect i suggested! bastard :P
Challenge Trophies Won:

rain_storm

Good job with the tranlation Va!n. I really like this effect and you're right it has a lot of potential.

Challenge Trophies Won: