Author Topic: How oldskool effects are done  (Read 5236 times)

0 Members and 1 Guest are viewing this topic.

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
How oldskool effects are done
« on: September 28, 2006 »
I'm interested to know how some oldskool effects are done and maybe some software engine coders can enlighten me. Maybe even with code :-)

1. How is the image for the rotating rubber thing created? You know the one that runs from the top of the screen to the bottom and twists like it is made of rubber. It seems to be done by indexing into an image of one twist but whats the maths for the first image?

2. Lens effect. Is that done the obvious way by sort of raycasting or is there a much cleverer, simpler way?

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: How oldskool effects are done
« Reply #1 on: September 28, 2006 »
Two questions, I don't know what you mean exactly by a lens effect as there are so many types...

The rotating rubber thing is really simple,  if you are making a bar for example, you go down the screen creating 4 X co-ordinates for each line. These are really simple, just some sine with 90 degree offsets for each.

Then you test 4 lines between co-ordinate pairs and if the line runs from L to R it is visible so draw it.

It's as simple as that!

You can make some improvements to the routine quite easilly by calculating the length of the line, it can be coloured accordingly, to give fake light sourcing.

Alternatively you can do a crude linear texture map, just divide line width by texture width and that's your interpolation value. It can look quite effective.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: How oldskool effects are done
« Reply #2 on: September 29, 2006 »
I'm interested to know how some oldskool effects are done and maybe some software engine coders can enlighten me. Maybe even with code :-)

1. How is the image for the rotating rubber thing created? You know the one that runs from the top of the screen to the bottom and twists like it is made of rubber. It seems to be done by indexing into an image of one twist but whats the maths for the first image?

2. Lens effect. Is that done the obvious way by sort of raycasting or is there a much cleverer, simpler way?



1. Depends actually, if you want to do it in 3d, you could do radial displacement of the cylinder.  For 2d, some do it with texture offsets + sine displacement

Here's an example with source:
One is in OpenGL the other use tinyPTC

http://rel.betterwebber.com/junk.php?id=54
2. Lens effect could be done in OpenGL with vertex manipulation and wth sofware I used a texture displacement both uses this fomula: height = 1/distance^2.

Here's an example:
http://rel.betterwebber.com/junk.php?id=58

Screens:

Rubber:



Lens:


Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: How oldskool effects are done
« Reply #3 on: September 29, 2006 »
Have some Karma dude - great answer for me. Thanks also shockwave. For the lens I meant this simple effect, you know the one where you have an image in the background and a sphere like object bouncing back and forth infront of it. I can think of complex maths ways to do it but was wondering if there are massive cheats :-)

Thats flower lens effect is great BTW. I think if you rendered to a texture each time you draw a lens then use that as input , the refractions would accumulate and end up looking just awesome.
« Last Edit: September 29, 2006 by taj »
Challenge Trophies Won:

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: How oldskool effects are done
« Reply #4 on: September 30, 2006 »
That's a great idea, sadly, my comp is not that fast.
 :cheers:
Challenge Trophies Won:

Offline Optimus

  • DBF Aficionado
  • ******
  • Posts: 2456
  • Karma: 128
    • View Profile
    • Optimouse Demo Site
Re: How oldskool effects are done
« Reply #5 on: September 30, 2006 »
For the sphere map, the math I used is the equation of a sphere: X^2 + Y^2 + Z^2 = R^2
solving this to Z: Z = SQRT(R^2 - X^2 - Y^2)

You can write it this way: Z = SQRT(R^2 - (X - ScreenWidth/2)^2 - (Y - ScreenHeight^2)) to translate the sphere calcs to the center of the screen.
R can be variable, depending in that the sphere is bigger or smaller, play with the values to find a good size.

Now, that equation gives a Z value for each (X,Y) pixel in the screen. That Z value by using a displacement functions gave the Xb, Yb of a bitmap according to real X, Y on screen. You read from the texture in Xb, Yb position to write in X, Y pixel position according to the following:

Xb = (X - ScreenWidth/2) / Z
Yb = (Y - ScreenHeight/2) / Z
iirc

Now, that's the math in few words. The trick for speed is to just calculate these displacements for each pixel in some buffer arrays, e.g. DIM SphereDispX[320*200] AS INTEGER and DIM SphereDispY[320*200] AS INTEGER for example and you can use the precalculated values now without calculating any slow math!

In a nutshell. If you have anything else maybe I'll be here to reply oneday..

p.s. The twirl is another effect I'd like to make. Aren't some of them done with voxels? Maybe I'll read the comments and think again about it. Maybe it's much easier than I thought..
Challenge Trophies Won:

Offline taj

  • Bytes hurt
  • DBF Aficionado
  • ******
  • Posts: 4810
  • Karma: 189
  • Scene there, done that.
    • View Profile
Re: How oldskool effects are done
« Reply #6 on: September 30, 2006 »
Great answer too optimus - thanks and karma!
Challenge Trophies Won:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: How oldskool effects are done
« Reply #7 on: October 02, 2006 »
The twirl effect is often known as a Peristalsis effect. Meaning "A Whipping Motion"
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: How oldskool effects are done
« Reply #8 on: October 02, 2006 »
Fnaaarrrr! ;)
Shockwave ^ Codigos
Challenge Trophies Won: