project-navigation
Personal tools

Author Topic: Discuss 'night vision' effect using GL Shading Language  (Read 5021 times)

Offline Andrew.Smart

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Discuss 'night vision' effect using GL Shading Language
« on: August 25, 2010, 08:06:10 am »
On activating the IR goggles I could apply a 'night vision' shader for that turn.  I want to get some feedback.  I don't see any other proposals like this:
http://ufoai.ninex.info/wiki/index.php/Proposals

My motivation is I can't see much in the night maps, even after tweaking lots of settings.  I know I'm not alone.  I like that the darkness is for realism but it is too strenuous on the eyes.

I'm interpreting the IR goggles as a device that magnifies the amount of received photons:
    http://upload.wikimedia.org/wikipedia/commons/5/52/Nightvision.jpg
    http://upload.wikimedia.org/wikipedia/commons/thumb/8/83/PEO_ANAVS-6_NVG.jpg/800px-PEO_ANAVS-6_NVG.jpg
Not thermal imaging:
    http://en.wikipedia.org/wiki/Infrared
Are the IR goggles intended as a thermal imaging devices?  If so, I could make a different piece of headgear for my night vision purpose.

I noticed that clicking the IR goggles takes up 12 TU. When exactly does the improved visibility for that unit end?  (I apologize I could look in the code and see what really happens, but I'd rather ask)

I have not submitted a patch as things aren't perfect yet.  I'll do this all myself but I'd appreciate any tips & directions from those more intimate with this project.  For example I see I may need to write some code in ./src/client/renderer/r_program.c, and all my GLSL will be in ./base/shaders/world_fs.glsl

This is a screenshot without the UI with my night vision (dated Aug 23rd) applied:
    http://i558.photobucket.com/albums/ss30/andrewusu/ufoai/Screenshot-UFOAI.jpg

I plan to:
  • Use a darker shade of green in the shader to make the green selection box more distinct.
  • Apply the 'night vision' algorithm after the glow effect (so that the yellow/red/blue glows will glow green).
  • I could make things slightly fuzzy looking like in the wikipedia pictures for realism (uses a little more GPU resources).
  • Sharply fade into the 'night vision' when the IR goggles are applied and sharply fade out when the IR goggles' effect ends.
  • Apply the normal battlescape shader when a different unit is selected, and reapply the 'night vision'  if an IR wearing soldier is selected.
  • I've heard looking at a bright light source while wearing night vision (that amplifies light from the moon and stars) temporarily blinds the wearer; even looking up into the night sky is blinding.  I can white everything out if it is a day map; In the night maps I can also bias brighter colors to be more white (lights will be much brighter and will appear to have a bigger radius).

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Discuss 'night vision' effect using GL Shading Language
« Reply #1 on: August 25, 2010, 08:31:46 am »
i like that effect. the ideas are good and the positions in the code you found are the correct ones, too. you are working on trunk? because we have a renderer_branch going on with a lot of changes regarding lighting and shadows already (heavy use of glsl, too) - it might be a good idea to base your work on this branch.

btw. if you are familiar with glsl shaders a trillion people would kiss your feets if you could have a look at the ati related shader bugs in trunk.

https://sourceforge.net/tracker/?func=detail&aid=2994183&group_id=157793&atid=805242
https://sourceforge.net/tracker/?func=detail&aid=2997073&group_id=157793&atid=805242
https://sourceforge.net/tracker/?func=detail&aid=3029867&group_id=157793&atid=805242
https://sourceforge.net/tracker/?func=detail&aid=3015331&group_id=157793&atid=805242
https://sourceforge.net/tracker/?func=detail&aid=3031936&group_id=157793&atid=805242

as you can see - there are a lot of rendering bugs - and we currently have nobody that is able to fix them (arisian is on holidays)
« Last Edit: August 25, 2010, 08:44:56 am by Mattn »

Offline Andrew.Smart

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Discuss 'night vision' effect using GL Shading Language
« Reply #2 on: August 25, 2010, 09:21:56 am »
i like that effect. the ideas are good and the positions in the code you found are the correct ones, too. you are working on trunk? because we have a renderer_branch going on with a lot of changes regarding lighting and shadows already (heavy use of glsl, too) - it might be a good idea to base your work on this branch.
Thanks.  I'll base my work on that branch then.

Oh, and after looking in the UFOpedia, it looks like the IR goggles really are thermal imaging devices (that can see heat through thin walls I assume).  I assume it would be best to make a different piece of headgear for the device that magnifies the amount of received photons.  It is possible to write some GLSL code for the thermal imaging as well; but it would take more work.

btw. if you are familiar with glsl shaders a trillion people would kiss your feets if you could have a look at the ati related shader bugs in trunk.

as you can see - there are a lot of rendering bugs - and we currently have nobody that is able to fix them (arisian is on holidays)
I'm not that familiar with GLSL, but it seems quite intuitive.  I'll work on those bugs.

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Discuss 'night vision' effect using GL Shading Language
« Reply #3 on: August 25, 2010, 09:53:56 am »
Quote
I'm not that familiar with GLSL, but it seems quite intuitive.  I'll work on those bugs.

great!! fixing those damn ati bugs would be really nice.