Night Vision

share shaders here
Post Reply
  • Author
  • Message
Offline
Posts: 19
Joined: 26 Sep 2013, 15:01

Night Vision

I know that defining "APPLYGAMECOLORCORRECTION" in enbeffect.fx allows Khajiit Night Vision to work, and I see in the code that it seems to be based on the value of "_c3.w".

But does anyone know what the actual range of this value is, in-game? I assumed it began at 0.0 and went to 1.0 when Night Vision was active, but that doesn't seem to be quite right. Is there some way to display the current value of this field in ENB's menus so I can test it myself? I tried setting something like "tempF1.x = _c3.w;" so that it would appear in the menu, but then the shader didn't work at all, I guess because tempF1 is supposed to be read-only by the shader.

Can any shader code gurus give me a snippet that will evaluate to 0.0 while Night Eye is inactive, 1.0 while fully enabled, and in between while it's transitioning? Or is it not that simple?

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17552
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Night Vision

You going wrong way, shader have post processing code and control variables, nothing else. There are too much factors which modify every shader constant, not just night vision.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 19
Joined: 26 Sep 2013, 15:01

Re: Night Vision

Then, what is the meaning of this code comment?

Code: Select all

r1=_c3.w * r1 - r0.y; //khajiit night vision _c3.w
Is there no way to even approximately detect when night vision is active? Because my hope was to tie it into the procedural color correction (cut gamma in half, set saturation to 0 seems to look alright).

Offline
Posts: 19
Joined: 26 Sep 2013, 15:01

Re: Night Vision

Okay, I did some testing of my own. I see that _c3.wxz contains the effective Cinematic Brightness, Saturation and Contrast (y is always 0 it seems), _c4.wxyz contains the effective Tint ARGB, and _c5.wxyz contains the effective Fade ARGB. All of these values are from the base imagespace of the current cell, plus any active imagespace modifiers (such as Night Eye). Since Night Eye sets Cinematic Brightness = 1x+1.1, _c3.w will always be 1.1 higher while Night Eye is on than when it's off; but since the base brightness could be anything depending on the cell's imagespace, it can't be used to reliably detect just the Night Eye effect.

So my next question is, can we access the HDR imagespace parameters somehow in the shader code, in addition to these Cinematic parameters? In particular, Night Eye (and a few similar effects) set Target Lum Min = 0x+0.25 and Target Lum Max = 0x+0.75. If there's some way to read the effective Target Lum Min/Max in shader code, then I think it would be pretty reliable to use that to detect Night Eye and any other imagespace modifier which is supposed to make it easier to see in the dark, so that we can apply a comparable effect in ENB.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17552
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Night Vision

All imagespace parameters are input constants of enbeffect.fx, how they are converted to these constants, i don't know and don't think it's possible to do something. Also haven't found any scripts for detecting night vision activation in the engine, so can't do this as helper plugin too. If you can edit all imagespaces, then it's the only solution i believe.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 19
Joined: 26 Sep 2013, 15:01

Re: Night Vision

Yes, I see all of the "Cinematic" imagespace parameters available in enbeffect.fx (under _c3, _c4 and _c5), but _c1 and _c2 didn't seem to correspond to the values I expected for various "HDR" parameters, including the Target Lum Min/Max. But if there are more registers we could import that would contain those, that would be great.

What I did in the mean time was to make a tiny plugin which modifies the NightEyeImod imagespace modifier so that all it does is set Cinematic Contrast to -1. I looked through all the other imagespaces and modifiers to make sure that nothing else sets negative values, which they shouldn't because it doesn't make any sense to do that normally. But with this -1 as a "flag" on the Night Eye effect, my enbeffect.fx can check for it and apply an appropriate night eye effect instead.

The plugin and enbeffect.fx changes are in my preset here if anyone's interested: http://skyrim.nexusmods.com/mods/48220

Offline
User avatar
*master*
Posts: 229
Joined: 21 Feb 2013, 03:21
Location: Los Angeles, CA

Re: Night Vision

Hi,
I have a noob question on this topic.

Here is some night vision code that works in enbeffect.fx that I would like to move to effect.txt. Here's my snippet from enbeffect.txt:

Code: Select all

...
float4 enbBloom = tex2D(_s3, _v0);
float t = clamp(_c3.w - 1.0, 0.0, 1.0);
...
I tried adding the following to effect.txt

Code: Select all

texture2D texs3;
sampler2D _s3 = sampler_state
{
	Texture   = <texs3>;
	MinFilter = LINEAR;//
	MagFilter = LINEAR;//
	MipFilter = NONE;//LINEAR;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};

float4	_c3 : register(c3);
However, the values for _s3 and _c3 seem to be zero or invalid since I do not get the results like I do in enbeffect.fx.

Are the _c3 registers and <texs3> texture accessible in effect.txt or only in enbeffect.fx?

Thanks
_________________
i7-4970K 4.8ghz, 16gb ram, Geforce Titan X 12gb vram, win7

Offline
User avatar
*blah-blah-blah maniac*
Posts: 17552
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: Night Vision

They are not.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
Posts: 5
Joined: 12 Jun 2013, 01:00

Re: Night Vision

Post Reply