(Skyrim LE) ENBEffect Multiple LUT In-Game Selector

not under any category
Post Reply
  • Author
  • Message
Offline
Posts: 8
Joined: 23 Jul 2018, 05:20

(Skyrim LE) ENBEffect Multiple LUT In-Game Selector

Firstly I need to say I'm not a software programmer... :?

As of now I am aware of 2 method of doing in-game LUT changing,
one is selecting through "technique", the way how Snapdragon ENB did, which seems to be able to support a lot of LUTs
the other one is recently I discovered used in QIRE ENB, while not configured by default,
I try to code it myself to add more LUTs, and find that it only can reach 13 LUT files max, otherwise it just crash.

File as in this link: https://drive.google.com/open?id=1dRdB7 ... 5bSmokiQX_

I just "declare" the LUT files like this, for multiple sets:

Code: Select all

///LUT1
texture2D texLUTD1 < string ResourceName="enblutd1.png"; >;
texture2D texLUTN1 < string ResourceName="enblutn1.png"; >;
texture2D texLUTI1 < string ResourceName="enbluti1.png"; >;
sampler2D samplerLUTD1 = sampler_state
{
	Texture   = <texLUTD1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};
sampler2D samplerLUTN1 = sampler_state
{
	Texture   = <texLUTN1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};
sampler2D samplerLUTI1 = sampler_state
{
	Texture   = <texLUTI1>;
	MinFilter = LINEAR;
	MagFilter = LINEAR;
	MipFilter = NONE;
	AddressU  = Clamp;
	AddressV  = Clamp;
	SRGBTexture=FALSE;
	MaxMipLevel=0;
	MipMapLodBias=0;
};
///
And then select it via the if..else statement:

Code: Select all

///LUT-MOD SELECTOR START
	if ( LUTType == 1 )
	{
	    color.rgb = lerp(lerp(ClutFunc(color.rgb, samplerLUTN1), ClutFunc(color.rgb, samplerLUTD1), ENightDayFactor), ClutFunc(color.rgb, samplerLUTI1), EInteriorFactor);
	}else if ( LUTType == 2 )
	{
	    color.rgb = lerp(lerp(ClutFunc(color.rgb, samplerLUTN2), ClutFunc(color.rgb, samplerLUTD2), ENightDayFactor), ClutFunc(color.rgb, samplerLUTI2), EInteriorFactor);
	}else if ( LUTType == 3 )
	{
	    color.rgb = lerp(lerp(ClutFunc(color.rgb, samplerLUTN3), ClutFunc(color.rgb, samplerLUTD3), ENightDayFactor), ClutFunc(color.rgb, samplerLUTI3), EInteriorFactor);
	}else if ( LUTType == 4 )
	{...................................................
13 seems to be the max amount of LUT files the if...else statement can handle. Adding any more than that and the shader file just become invalid, won't show up in ENB panel, and crash the game if try to load any game.
Is the above method is actually "valid" or safe at all? :?:

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

Re: (Skyrim LE) ENBEffect Multiple LUT In-Game Selector

Dx9 support max 16 textures, so other are already in use, you cant create more. But you can mix multiple textures of lut to single in image editor and apply specific code to change uv for them. And if you want if/else work fast, then make sure you are using tex2Dlod function instead of tex2D to read each, otherwise they all will be read, but in arithmetic proper one selected, as result performance degradation. Also it's better to place inside if/else just code to read texture, while after it color.rgb = lerp(lerp... math. This will decrease amount of code generated by compiler.
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7
Post Reply