I need an 'Infra-red' camera mode

Blitz3D Forums/Blitz3D Programming/I need an 'Infra-red' camera mode

Flexman(Posted 2003) [#1]
I'm need to render a 'greyscale' view from an infra-red camera but can't think for the life of me how to do it except to have black-white textures for ALL objects and swap the textures when required.

Basically I need to seemlessly switch from normal 3D mode to a grey-scale mode. Is there a quick solution to this?


mearrin69(Posted 2003) [#2]
I believe the way it's done in the 'real world' -- i.e. military sensor simulation -- is similar to what you've described.

They hang some sort of thermal data onto the material descriptions and then turn that into a texture at run-time.

You could probably take some sort of short cuts if you don't really need to simulate all of the thermal characteristics in such detail...i.e. you could pre-render the thermal maps and just swap them in for the real textures when you need them.

Make any sense?
M


Dock(Posted 2003) [#3]
The easiest way is to use alternative black and white versions of the graphics. If you have played Aliens Vs Predator 2 on PC, you'll see they use something similar to swap through the different visual styles. They use one with different colours for thermal, which is a bit cheap but does the job!

I'm not sure whether Blitz is capable of altering the colours on textures and resaving them. You may care to check out the code archives and see what is available in terms of batch image conversion. Failing that, you should be able to run all your images through a graphics package like PSP or Photoshop. That's a bit of a pain though, and means you have to update all your images (it will also increase the size of your distributable). I would try to find a way to get Blitz to make greyscale copies of all the images you need and save them to the HD.


darklordz(Posted 2003) [#4]
why not use the new setgamma cmd's
to set the colors of teh scene to greyish..


Dock(Posted 2003) [#5]
Ah, I wasn't aware of the SetGamma command. ^^;
However, this effects the entire screen, so it would make it impossible for a colour HUD whilst using infra-red via Set Gamma. Still, the sheer convenience of this compared to some long winded graphic copying would probably make it worthwhile :)


Flexman(Posted 2003) [#6]
I experimented with the gamma commands, while it's possible to achieve a "green screen" effect I couldn't get them to "desaturate" the screen. And as mentioned above any hud is also altered.

Is it possible (clutching at straws here to see what you think) to have some kind of texture in front of the camera that tinted or even better desaturated everything?

I wonder how you would do it in OpenGL.


Marcelo(Posted 2003) [#7]
I found no way to make a grayscale render using the hardware (except by using programmable shaders), but for my "infrared" image I've used two planes in the front of the camera, one is set to Multiply with the color 0,255,0 and the other is a Additive animated green noise, the first one leaves only the green channel and the second add some brightness and noise to the screen.

Off


On



Mustang(Posted 2003) [#8]
Using two fullscreen planes that cover the whole screen is prpbably going to affect (drop) your Framerate - it's a lot of fill?


jhocking(Posted 2003) [#9]
Those screens look pretty good. How many polygons is that character? And was the level created in Maplet?

I'ld also be concerned about fillrate. At low resolutions (eg. 640x480) that technique would probably work fine but at higher resolution that would kill your framerate.

Still, that's a pretty clever trick.


Tom(Posted 2003) [#10]
Hi,

this is the reason I was investigating the idea of using Blits via userlibs, I can get some things to work, but Blitz3D doesn't like you messing with it's buffers.

Tom


Marcelo(Posted 2003) [#11]
jhocking,
The character is 1400 polys (excluding the infrared glasses) and the level is created in a internal editor.


At 800x600 there's a about 15 fps drop when the infrared googles are turned on, but one strage thing happens:

Less the FPS less it will decay when it's on, as a example in my machine (p3-700, gforce1) this level runs at 80fps, and drops to 65fps when the googles are on.

But in my test machine (p2-400, tnt2)it runs at 30fps and go down to 25fps when on.

I have no idea why this happens. :)

If you want to reduce the fill rate you can work with one plane only (the additive green), but you will be able to see some saturated colors at the infrared, such as the red of the t-shirt.


Andy(Posted 2003) [#12]
Nice pictures... But that's just a colourfilter... It doesn't really have anything to do with infrared imaging...

http://www.indigosystems.com/gallery_fire.html
http://sirtf.caltech.edu/EPO/IRapp/fire.html

Andy


Flexman(Posted 2003) [#13]
Still, it's a neat solution for a Blitz game, it conveys the sense of night-vision and makes things a little harder to see. Which is what you want for a game.

I don't think there's any other solution in Blitz, which is a shame. I'd like a color processor of some sort. It would have been easier in the bad old days of 256 color pals.


Andy(Posted 2003) [#14]
>Still, it's a neat solution for a Blitz game, it conveys
>the sense of night-vision and makes things a little harder
>to see. Which is what you want for a game.

Isn't that missing the point of nightvision and infrared... If there is plenty of light(as in the scene above), then you don't need 'nightvision'(which is usually a light enhancing/intensifying device), and infrared imaging is to see varying degrees of 'heat'... Not just a coloured filter that you apply to the screen. In real life, both makes things 'easier' to see.

If you put something into a game, surely you would want it to be atleast somewhat realistic.

lovely pics though.


Marcelo(Posted 2003) [#15]
That's why I wrote "infrared" (quoted). :)

The shots are in a lighted room, but there are some map sectors that is completely dark and the use of the googles is required.


Anthony Flack(Posted 2003) [#16]

Less the FPS less it will decay when it's on, as a example in my machine (p3-700, gforce1) this level runs at 80fps, and drops to 65fps when the googles are on.

But in my test machine (p2-400, tnt2)it runs at 30fps and go down to 25fps when on.



65/80 = 81% of full speed
25/30 = 83% of full speed

Seems pretty consistent to me.

Anyway it sounds like your framerates are well within acceptable levels in both cases (considering the hardware you're running it on)


RetroBooster(Posted 2003) [#17]
The aproximate same effect of the green filter can be accomplished more efficiently by changing the ambient light and other light values, should save you some of that 20% speed drop.


Flexman(Posted 2003) [#18]
Changing the ambient light is a good idea, that was one of the things I tried but not good for me as I use a second "non-IR" camera.


jhocking(Posted 2003) [#19]
"infrared imaging is to see varying degrees of 'heat'"

Actually you are getting terms confused. Infrared imaging can only see intense infrared light cast from an infrared light source. Such light sources include many motion detector alarm systems (thus infrared goggles are very useful for avoiding security systems.) Meanwhile, if you want to be able to see in the dark, you need an infrared "flashlight" to cast infrared light on your surroundings. Infrared imaging systems commonly include a light attached to the goggles.

What you are describing is thermo-imaging. Thermo-imaging sees heat, hence the name.


Mustang(Posted 2003) [#20]
Here's few "thermal" and "ir" reference screenshots (REALLY messy page...):

http://www.x20.org/thermal/


Andy(Posted 2003) [#21]
<jhocking> You are absolutely right... Apologies for being confused... I have been checking up on the subject and find it very interesting...

>That's why I wrote "infrared" (quoted). :)

cool... I was a little too fast... It just bothers me when a game uses interesting gadgets but in a completely unrealistic way...

Lovely pics by the way!

Andy


Tom(Posted 2003) [#22]
Have you played Splinter Cell?

The heatvision goggles mode is amazing, and runs so smooth.

Tom


Ziltch(Posted 2003) [#23]
This is some code I wrote a while back to do nightvision/heat vision.

It does slow the FPS but as it looks at every 2nd pixel, it is workable.

Also Changing the lights,fog,ambientlight adds to the effect.

This code in main loop (replace your updateworld/renderworld)

[code]
If Keyhit(211) then ;del key toggles nightvision
; you may want to increase ambient light here
NightView = Not NightView
End If


UpdateWorld
RenderWorld
If NightView then NightVision()
[\code]

The Function
[code]
Function NightVision()
SetBuffer BackBuffer()
LockBuffer

For x = 0 To gw Step 3
For y = 0 To gh Step 3
c=ReadPixelFast(x,y)
WritePixelFast(x,y,16768-c) ; play here
WritePixelFast(x+1,y+1,16768-(c+cc)) ; for color changes
cc = c
Next
Next
UnlockBuffer
End Function

[\code]

I like your method Marcelo, looks good.