Here's a night vision function, complete with static. You can adjust it to fit your needs. It basically does what VanB said only it adds static. This is probably possible with a fullscreen shader too if you don't want to use sprites. But sprites are easier to make an example of
. You can make your own static texture if you want. This example generates its own at the start. If you don't want night vision on the screen then just don't call the function
. It's fully commented, so if you want to adjust anything (like the color) just read the comments in the function.
rem ***************************
rem
rem NIGHT VISION
rem
rem By Sixty Squares
rem ***************************
rem Setup
Sync On
Sync Rate 0
Autocam Off
`Generate a noise texture for the static
Noise=1
Size=512 `Change this to change the resolution of the noise (low resolutions make the method I'm using to control the noise easier to notice, which is bad...
Create bitmap 1,Size,Size
for x = 0 to Size-1
for y = 0 to Size-1
c=rnd(255)
ink rgb(c,c,c),0
box x,y,x+1,y+1
next y
next x
Get Image Noise,0,0,Size,Size,1
Delete bitmap 1
rem Make a scene of random cubes to look at.
for o = 1 to 100
make object cube o,10
position object o,-250+rnd(500),0,-250+rnd(500)
set object emissive o,rgb( rnd(255), rnd(255), rnd(255) )
next o
rem Make a night vision camera and set it to an image. You can change the resolution by changing the size of the image.
nvcam=1 `Night vision camera #
nvIMG=2 `Night vision image #
Make Camera nvcam
Set Camera To Image nvcam,nvIMG,screen width(),screen height()
rem Set the noise size to the length of the diagonal of the screen. This way you never see the edge of the texture.
Size=SQRT( Screen Width()^2 + Screen Height()^2 )
rem Setup the timer based movement.
OldTime=Timer()
Do
rem Simple timer based movement
factor#=(Timer()-OldTime)*0.060
OldTime=Timer()
rem Control Camera
Control Camera Using Arrowkeys 0,2*factor#,1.25*factor#
Position Camera nvcam,camera position x(0),camera position y(0),camera position z(0)
Rotate Camera nvcam,camera angle x(0),camera angle y(0),camera angle z(0)
rem Hold space to see the night vision
if Spacekey() then NightVision(nvIMG,Noise,1,Size)
rem Print stuff
set cursor 0,0
ink rgb(255,255,255),0
print "FPS: ",screen fps()
print " "
print "Hold SPACE to see everything in night vision."
Sync
Loop
Function NightVision(CamTex,NoiseTex,SpriteToUse,Size)
remstart
CamTex= Image # of the camera to use
NoiseTex= Image # of the texture to use for noise
SpriteToUse= The Sprite # to use. It gets deleted after each call.
Size= The size of the noise sprite (make sure it's bigger than the screen). If you specify 0 then it will auto-calculate the size.
remend
rem If you do not specify a size then it is auto-calculated.
if Size=0 then Size=SQRT( Screen Width()^2 + Screen Height()^2 )
s=SpriteToUse
rem Stretch the camera texture across the whole screen and make it green.
sprite s,0,0,CamTex
size sprite s,screen width(),screen height()
set sprite diffuse s,0,255,0 `Change this to change the basic color (I chose green for night vision)
set sprite alpha s,255
paste sprite s,0,0
rem Apply the noise texture and stretch it to a size larger than the screen (Specified in size variable)
offset=10 `Increase this for more randomness in the noise. You'll need a bigger "Size" though so the noise texture doesn't go off screen.
sprite s,screen width()/2.0,screen height()/2.0,NoiseTex
size sprite s,Size,Size
set sprite alpha s,25 `Change this to change the noise density.
offset sprite s,Size/2.0-offset/2+rnd(offset),Size/2.0-offset/2+rnd(offset)
set sprite diffuse s,255,255,255 `Change this to change the noise color.
rem Randomly rotate/flip/mirror/offset the nosie so it looks like static
rotate sprite s,rnd(359)
if rnd(1)=0 then flip sprite s
if rnd(1)=0 then mirror sprite s
paste sprite s,screen width()/2.0,screen height()/2.0
delete sprite s
Endfunction
Guns, cinematics, stealth, items and more!