Author Topic: Floor Casting with Xor Texture  (Read 5444 times)

0 Members and 1 Guest are viewing this topic.

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Floor Casting with Xor Texture
« on: January 19, 2008 »
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*

Code: [Select]
; --------------------------------------------------------------
;
; 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
« Last Edit: January 19, 2008 by va!n »
- 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:

Offline benny!

  • Senior Member
  • DBF Aficionado
  • ********
  • Posts: 4384
  • Karma: 228
  • in this place forever!
    • View Profile
    • bennyschuetz.com - mycroBlog
Re: Floor Casting with Xor Texture
« Reply #1 on: January 20, 2008 »
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:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Floor Casting with Xor Texture
« Reply #2 on: January 20, 2008 »
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:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
Re: Floor Casting with Xor Texture
« Reply #3 on: January 20, 2008 »
Small modified version with added depth effect...

Code: [Select]
; --------------------------------------------------------------
;
; 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:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Floor Casting with Xor Texture
« Reply #4 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
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Floor Casting with Xor Texture
« Reply #5 on: January 21, 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:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Floor Casting with Xor Texture
« Reply #6 on: January 23, 2008 »
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: