Gah - a solution with more questions. – EntropicLqd

Legacy:Nightvision

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search

Creating NighVision goggles' effect is done in 2 parts:

1 - exec function

where you turn on unlit texture rendering mode like with "rmode 6".

2 - overlays

alpha overlay to simulate limited oval goggle view and

a similar greenish overlay texture to simulate greenish part of a NighVision goggles.

class HudWithNighVision extends HudBTeamDeathMatch;
 
var bool bNighVision;
var Material mtScopeAlpha;
var Material mtScopeOverlay;
 
exec function ToggleNightVision()
{
 
	bNighVision=!bNighVision;
 
	if (!bNighVision)
	{
		playerowner.RendMap=5; //normal mode
		playerowner.ClientMessage("--bNighVision OFF!");
	}
	else
	{
		playerowner.RendMap=6; //textured mode unlit
		playerowner.ClientMessage("--bNighVision ON!");
	}
 
}
 
simulated function DrawHud (Canvas C)
{
	if( PlayerOwner.pawn == None)
	{
		bNighVision=false;
		playerowner.RendMap=5; 
	}
 
	DrawNightVision(C);
	Super.DrawHud(C);
}
 
//DRAW OVERLAYS
//like scope and greenish color multiply
simulated function DrawNightVision(Canvas C)
{
	if (bNighVision)
	{
		//set green color only
		C.DrawColor.R = 0; 
		C.DrawColor.G = 127; 
		C.DrawColor.B = 0;
		C.DrawColor.A = 255; 	
 
		//scope alpha
		C.Style = ERenderStyle.STY_Alpha; 
		C.SetPos(0,0); 
		C.DrawTile(mtScopeAlpha, C.SizeX, C.SizeY,0.0,0.0,512,512);
 
		//greenish modulation
		C.Style = ERenderStyle.STY_Modulated;   
		C.SetPos(0,0); 
		C.DrawTile(mtScopeOverlay, C.SizeX, C.SizeY,0.0,0.0,512,512);
 
		//greenish overlay
		C.Style = ERenderStyle.STY_Additive; 
		C.SetPos(0,0); 
		C.DrawTile(mtScopeOverlay, C.SizeX, C.SizeY,0.0,0.0,512,512);
 
	}
}

This should be simple.

Note that there may be lighting issues with the terrain, since it wont always loose the lighting (Epic bug).

–HeatVision–

I found a way to see actors (pawns) through walls. It's a little limited on-line tho.

If you set the OverlayMaterial of a pawn to a texture with bZTest= false then you can see it trough walls.

I tried it with Material'XGameShaders.ModuNoise'. This material is not suitable for real heat vision but just an example how this works.

simulated function DrawHeatVision(Canvas C)
{
	local Actor p;
 
	ForEach DynamicActors(class'Actor', p)
	{//NOTE: On server side you could go trough the ControllerList.
		if (p.IsA('Pawn') && pawn(p) != playerowner.pawn)
		{
			p.SetOverlayMaterial(Material'XGameShaders.ModuNoise',1, true);
		}
	}
}

–DocEDo–

Foxpaw: Wouldn't it be better to leave the lights on and simply amplify existing light? That's how real night vision systems work, so I'd think that would be cooler. Maybe that's just me though..

DocEDo: It is? You can always leave the lights on. I tried, it was cool untill I tried it in dark rooms, where it sucked. I have a camera with NV and it amplifys light but not only the one we see, actually mostly the one we can't.

Foxpaw: Yes, it's mostly the infrared light (I think) that is picked up on it, but it does work on amplifying the existing light. If you take it into a completely dark room (IE a room with no windows at night) you won't be able to see anything, unless the night vision unit also has an IR "flashlight" on it, which some units do. You could also get "heat vision" which is similar, but has the cool thing with all the different colors representing different levels of heat. Mmm, that'd be a neat feature for a sniper rifle in UT.

DocEDo: Added "heat vision".

Pingz: Shouldn't 'heat vision' be on some other page?

Daid303: Well, it's also a vision enhancer. Maybe call this page vision enhancement?

Jarronis, The Vampiric Unicorn: I'll have interesting thread on 3dbuzz about heat vision: http://sv1.3dbuzz.com/vbforum/showthread.php?s=&threadid=66761&pagenumber=4