Author Topic: Interresting false 3D effect [update : Sources added]  (Read 6488 times)

0 Members and 1 Guest are viewing this topic.

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Hey :) I was playing with my [magnification] entry and I came with this. It's funny how it really looks like (imho) a real 3D bumpmap or something like this .. (Of course, the light is moving  :) ) Here's a screen. I can't post the source since I use the code from the magnification entry, but once the contest is over, I'll post it here  ;) If someone wants the linux binary, please ask.

For information, there's absolutely no 3D calcs, the program just calculates new positions with an exponential rule and uses the moving blobs as a texture.
« Last Edit: July 26, 2009 by Hezad »

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Interresting false 3D effect
« Reply #1 on: July 23, 2009 »
At the very least you have created a beautiful glass like texture that would look wonderful in some 3D app :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline mind

  • Texture-San
  • DBF Aficionado
  • ******
  • Posts: 2324
  • Karma: 85
    • View Profile
    • boredom is a beatiful thing.
Re: Interresting false 3D effect
« Reply #2 on: July 23, 2009 »
looks like a very interesting lighting technique.. looking forward to hearing an explanation/seeing the source for it :)
Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
Re: Interresting false 3D effect
« Reply #3 on: July 23, 2009 »
Quote
At the very least you have created a beautiful glass like texture that would look wonderful in some 3D app Smiley

thanks, yeah I guess that could look nice as a dynamic texture ;D


Quote
looks like a very interesting lighting technique.. looking forward to hearing an explanation/seeing the source for it Smiley
Well to be honnest there's no light calc, the program just looks for a pixel in the basic background ("light" blobs) with an exponential calc (this explains the sides look rounded), anyway, the source will be posted :)


Little update, still in the same kind of wanderings : moving mercury liquid :P


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Very nice, I wish I could see it moving :D It might help explain the technique
Shockwave ^ Codigos
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
thats cool, hats off to you Hezad

Challenge Trophies Won:

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
This reminds me of photoshop filters alot of people use to make "interfaces" and buttons and so on.

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
thanks a lot mates :) I'll post all sources once the magnifying contest will be over  :cheers:

Offline va!n

  • Pentium
  • *****
  • Posts: 1435
  • Karma: 109
    • View Profile
    • http://www.secretly.de
@Hezad:
Wow... the screenshots are really cool... as shockwave said, i would i like to the the stuff in action (animated) and explaining how does it works too ;)
Still looking forward to your entry and this routine ;)
- 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
Awesome stuff, mate. Really looking forward to see this in motion.
[ mycroBLOG - POUET :: whatever keeps us longing - for another breath of air - is getting rare ]

Challenge Trophies Won:

Offline Hezad

  • Sponsor
  • Pentium
  • *******
  • Posts: 613
  • Karma: 44
  • I believe .. in Patrick.
    • View Profile
    • Hezad.com Web hosting
The voting is open :) So as promised here is the source code of those snippets. Each stuff is already in the same code (particules entry, square stuff and mercury stuff. You just have to uncomment the desired one (and to comment the previous uncommented one of course ^^)

Code: [Select]
Randomize Timer

Const NB_BLOBS = 20
Const SPEED = 5

Type BlobT
as single x,y,r
as single vx,vy,vr
as integer cr,cg,cb
end type

Screenres 320,240,32,2

Dim shared as BlobT Blob(NB_BLOBS-1)
Dim shared as uinteger ptr scrptr,realscrptr
dim shared as single t

scrptr = Callocate(320*240,sizeof(Uinteger))
realscrptr = screenptr

Sub MoveBlobs()

static as single r1

for k as integer = 0 to NB_BLOBS-1

r1 = rnd

if rnd<.07 then blob(k).vx = SPEED*cos(r1*6.283)
if rnd<.07 then blob(k).vy = SPEED*sin(r1*6.283)

blob(k).x += blob(k).vx
blob(k).y += blob(k).vy

if blob(k).x>320 or blob(k).x<0 then blob(k).x-=blob(k).vx : blob(k).vx = -blob(k).vx
if blob(k).y>240 or blob(k).y<0 then blob(k).y-=blob(k).vy : blob(k).vy = -blob(k).vy
next

End sub



Sub DrawBlobs()

'' idée : interpolation de couleurs entre chaque blob
static as single sum, xp,yp, xp2,yp2


for i as integer = 0 to 319
for j as integer = 0 to 239

sum = 0

for k as integer = 0 to NB_BLOBS-1
xp = (i-blob(k).x)*(i-blob(k).x)
yp = (j-blob(k).y)*(j-blob(k).y)

sum += blob(k).r/(.03*(xp + yp + 5*(blob(k).vx*blob(k).vx + blob(k).vy*blob(k).vy)))

if sum > 1 then sum = 1
next

sum = sum*255

ScrPtr[i+j*320] = rgb(sum*.9,sum*.85,sum)

next
next
end sub

Sub Magnify_Blobs()

static as integer newx,newy,intensity
static as single calc

For i as integer = -160 to 159
For j as integer = -120 to 119

'' === Mercury stuff ===
'realscrptr[(i+160)+(j+120)*320] = scrptr[(i+160)+(j+120)*320]
'intensity = scrptr[(i+160)+(j+120)*320] and 255
'newx = i*(sqr(i*i+j*j)*.001)*.0001 * intensity *i*i
'newy = j*(sqr(i*i+j*j)*.001)*.0001 * intensity *j*j
'' =====================

'' === squared stuff ===
'realscrptr[(i+160)+(j+120)*320] = scrptr[(i+160)+(j+120)*320]
'intensity = scrptr[(i+160)+(j+120)*320] and 255
'newx = i*(exp(((i*i-160)*.001)))*.05
'newy = j*(exp(((j*j-120)*.001)))*.05
'' =====================

'' === magnification ===
calc = .000017*(i*i+j*j+17000)
newx = i*calc
newy = j*calc
'' =====================

if newx+160>=0 and newx+160<320 then
if newy+120>=0 and newy+120<240 then
realscrptr[(i+160)+(j+120)*320] = scrptr[(newx+160)+(newy+120)*320]
end if
end if
next
next

End sub

Sub InitBlobs()
For k as integer = 0 to NB_BLOBS-1
blob(k).r = .05+5*rnd*exp(rnd*.5)
blob(k).x = 320*rnd
blob(k).y = 240*rnd
blob(k).vx = SPEED*(1-2*rnd)
blob(k).vy = SPEED*(1-2*rnd)
next

End sub

initBlobs

Do

MoveBlobs

DrawBlobs

screenlock : cls

magnify_Blobs

Screenunlock : sleep 1,1
Loop until multikey(&h01)

deallocate scrptr

I'll post some youtube vids in some minutes

edit : Vids added on the top post
« Last Edit: July 26, 2009 by Hezad »

Offline spitfire

  • Amiga 1200
  • ****
  • Posts: 275
  • Karma: 9
    • View Profile
Great! I was looking forward to this code. thanks for sharing

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
K+ for making the source code available.

Thanks!
Shockwave ^ Codigos
Challenge Trophies Won: