I made this effect to look like the ninja suit in Metal Gear Solid.
It works pretty well, even if it doesn't look that much like the ninja suit, it looks just like the object is made of glass.
It doesn't need any special 3D or anything.
It's not a shader!
Screenies
The object is quite hard to see in some of them:
Demo
Here's a demo to see it in action (C + P link):
http://www.geocities.com/ntnod/Glass.zip
Code
Here are the functions you need to use to effect:
function SetStealthEffectOn( ObjectNumber )
GhostingCamera#(5) = ObjectNumber
set object light ObjectNumber, 0
endfunction
function SetupStealthEffect()
make camera 8
set camera range 8, 0.5, 1000
set camera to image 8, 2000, 128, 128
dim GhostingCamera#(5)
` 0 - 2 ................... Positions
` 3 - 4 ................... Rotations
` GhostingCamera#(5) ...... Ghosted Object
endfunction
function StealthEffect()
`Point the Ghosting Camera at the real camera and grap the angles
xCamera# = camera position x()
yCamera# = camera position y()
zCamera# = camera position z()
point camera 8, xCamera#, yCamera#, zCamera#
GhostingCamera#(3) = camera angle x(8)
GhostingCamera#(4) = camera angle y(8)
`Flip the angles so it's pointing away from the main camera
GhostingCamera#(3) = wrapvalue( 0 - GhostingCamera#(3) )
GhostingCamera#(4) = wrapvalue( GhostingCamera#(4) + 180 )
`Position and rotate the Ghosting Camera
Object = GhostingCamera#(5)
xObject# = object position x( Object )
yObject# = object position y( Object )
zObject# = object position z( Object )
position camera 8, xObject#, yObject#, zObject#
rotate camera 8, GhostingCamera#(3), GhostingCamera#(4), 0
xDifference# = ( xObject# - GhostingCamera#(0) )
yDifference# = ( yObject# - GhostingCamera#(1) )
zDifference# = ( zObject# - GhostingCamera#(2) )
Distance# = sqrt( xDifference#^2 + yDifference#^2 + zDifference#^2 )
FOV# = 20 + ( 25 - Distance# )
if FOV# > 40 then FOV# = 40
set camera fov 8, FOV#
`Stealth the object!
set sphere mapping on Object, 2000
endfunction
You can put them in a separate source file then include it in the IDE.
- You need to call
SetupStealthEffect() at the top of your program.
- You need to apply the effect to the object with
SetStealthEffectOn( ObjectNumber )
- You need to call
StealthEffect() every loop.
Here's an example program (crap but no media required):
make object cube 1, -10
color object 1, rgb(255,0,128)
Cube = 3
for xPos = - 4 to 4 step 2
for yPos = - 4 to 4 step 2
for zPos = - 4 to 4 step 8
make object sphere Cube, 1
position object Cube, xPos, yPos, zPos
color object Cube, 255
inc Cube
next zPos
next yPos
next xPos
SetupStealthEffect()
make object sphere 2, 1
SetStealthEffectOn( 2 )
xSpeed# = 0.025
zSpeed# = 0.01
ySpeed# = 0.03
sync on
do
StealthEffect()
position camera 0,0,0
point camera xPos#, yPos#, zPos#
position object 2, xPos#, yPos#, zPos#
rotate object 2, object angle x(2) + 1, object angle y(2) + 1, object angle z(2) + 1
xPos# = xPos# + xSpeed#
yPos# = yPos# + ySpeed#
zPos# = zPos# + zSpeed#
if xPos# > 4 and xSpeed# > 0 then xSpeed# = 0 - xSpeed#
if xPos# < -4 and xSpeed# < 0 then xSpeed# = 0 - xSpeed#
if yPos# > 4 and ySpeed# > 0 then ySpeed# = 0 - ySpeed#
if yPos# < -4 and ySpeed# < 0 then ySpeed# = 0 - ySpeed#
if zPos# > 4 and zSpeed# > 0 then zSpeed# = 0 - zSpeed#
if zPos# < -4 and zSpeed# < 0 then zSpeed# = 0 - zSpeed#
sync
loop
`>>>>>>>>>>>>>>>>>>>>> THESE ARE THE IMPORTANT FUNCTIONS <<<<<<<<<<<<<<<<<<<<<<<<<
function SetStealthEffectOn( ObjectNumber )
GhostingCamera#(5) = ObjectNumber
set object light ObjectNumber, 0
endfunction
function SetupStealthEffect()
make camera 8
set camera range 8, 0.5, 1000
set camera to image 8, 2000, 128, 128
dim GhostingCamera#(5)
` 0 - 2 ................... Positions
` 3 - 4 ................... Rotations
` GhostingCamera#(5) ...... Ghosted Object
endfunction
function StealthEffect()
`Point the Ghosting Camera at the real camera and grap the angles
xCamera# = camera position x()
yCamera# = camera position y()
zCamera# = camera position z()
point camera 8, xCamera#, yCamera#, zCamera#
GhostingCamera#(3) = camera angle x(8)
GhostingCamera#(4) = camera angle y(8)
`Flip the angles so it's pointing away from the main camera
GhostingCamera#(3) = wrapvalue( 0 - GhostingCamera#(3) )
GhostingCamera#(4) = wrapvalue( GhostingCamera#(4) + 180 )
`Position and rotate the Ghosting Camera
Object = GhostingCamera#(5)
xObject# = object position x( Object )
yObject# = object position y( Object )
zObject# = object position z( Object )
position camera 8, xObject#, yObject#, zObject#
rotate camera 8, GhostingCamera#(3), GhostingCamera#(4), 0
xDifference# = ( xObject# - GhostingCamera#(0) )
yDifference# = ( yObject# - GhostingCamera#(1) )
zDifference# = ( zObject# - GhostingCamera#(2) )
Distance# = sqrt( xDifference#^2 + yDifference#^2 + zDifference#^2 )
FOV# = 20 + ( 25 - Distance# )
if FOV# > 40 then FOV# = 40
set camera fov 8, FOV#
`Stealth the object!
set sphere mapping on Object, 2000
endfunction
It uses camera 8 and image 2000 so you can't use those in your game.
Have fun.