[HLSL CODE] 3D LUT

share shaders here
  • Author
  • Message
Offline
User avatar
*sensei*
Posts: 391
Joined: 03 Oct 2012, 06:12
Location: Ottawa, Canada

Re: [HLSL CODE] 3D LUT

Sweet, thank you.
_________________
Intel Core i9 10900K @4.9GHz | ASUS ROG Strix Z490-G | NVIDIA - EVGA RTX 2080 XC Ultra | 32GB DDR4 Corsair Vengeance RGB PRO | 2x ADATA XPG SX8200 Pro 1TB

Flickr
Twitter

Offline
User avatar
Posts: 27
Joined: 05 Jan 2016, 08:14

Re: [HLSL CODE] 3D LUT

I realize this is an old post, but I thought it nice to update it.

But before going on, thank you kingeric1992 for reading my original blurb, and then updating your original post with new code. Also, thank you TKTK for your original code, which I lightly modified for use in my own ENBs.

Now, here's a simple LUT code for day/night/interior that is light on modifications, and doesn't require helper functions. I'll see about adding a dense-packed, neutral LUT at a later date. Meanwhile, if you're interested in seeing what you can do with a DNI set of 256x256 palettes, check out my tutorial.

///======================////======================//

When customizing a LUT I noticed it would probably be better with a LUT for Day, Night, and Interior. Here's a simple way to do it (thanks, TKTK!):

In your textures section, add the following lines above texture2D texs7; -

Code: Select all

texture2D texs5 < string ResourceName="enbpalette__.tga"; >;	//	ENB interior palette (Added.)
texture2D texs6 < string ResourceName="enbpalette_.tga"; >;	 //	ENB night palette (Added.)
Note that texture2D texs7; defaults to enbpalette.*, where * can be a BMP, TGA, or PNG file. The added files can also be set to BMP and PNG by changing the suffix to designate the appropriate file type.

Next, add the following lines to the sampler section -

Code: Select all

sampler2D _s5 = sampler_state
	{
		Texture = <texs5>;
		MinFilter = LINEAR;
		MagFilter = LINEAR;
		MipFilter = NONE;
		AddressU = Clamp;
		AddressV = Clamp;
		SRGBTexture = FALSE;
		MaxMipLevel = 0;
		MipMapLodBias = 0;
	};

sampler2D _s6 = sampler_state
	{
		Texture = <texs6>;
		MinFilter = LINEAR;
		MagFilter = LINEAR;
		MipFilter = NONE;
		AddressU = Clamp;
		AddressV = Clamp;
		SRGBTexture = FALSE;
		MaxMipLevel = 0;
		MipMapLodBias = 0;
	};
Finally, buzz down to the ENB palette section, and replace the original code with this:

Code: Select all

#ifdef E_CC_PALETTE
	
	float3 CLuTD1;		// CLuT for Days
	float3 CLuTD2;
	
	float3 CLuTN1;		// CLuT for Nights
	float3 CLuTN2;
	
	float3 CLuTI1;		// CLuT for Interiors
	float3 CLuTI2;
	
	float3 CLuTA1;		// CLuT Averages
	float3 CLuTA2;
	
	
	float2 CLut_pSize	=	float2(0.00390625, 0.0625);		// 1 / float2(256, 16);
	color.rgb			=	saturate(color.rgb);
	color.b		        *=	15;
	float4 CLut_UV		=	0;
	
        CLut_UV.w			=	floor(color.b);
	CLut_UV.xy			=	color.rg * 15 * CLut_pSize + 0.5 * CLut_pSize ;
	CLut_UV.x			+=	CLut_UV.w * CLut_pSize.y;
		
	CLuTD1.rgb			=	tex2Dlod(_s7, CLut_UV.xyzz).rgb;
	CLuTD2.rgb			=	tex2Dlod(_s7, CLut_UV.xyzz + float4(CLut_pSize.y, 0, 0, 0)).rgb;
	
	CLuTN1.rgb			=	tex2Dlod(_s6, CLut_UV.xyzz).rgb;
	CLuTN2.rgb			=	tex2Dlod(_s6, CLut_UV.xyzz + float4(CLut_pSize.y, 0, 0, 0)).rgb;
	
	CLuTI1.rgb			=	tex2Dlod(_s5, CLut_UV.xyzz).rgb;
	CLuTI2.rgb			=	tex2Dlod(_s5, CLut_UV.xyzz + float4(CLut_pSize.y, 0, 0, 0)).rgb;
	
	CLuTA1.rgb			=	lerp( lerp(CLuTN1.rgb, CLuTD1.rgb, ENightDayFactor), CLuTI1.rgb, EInteriorFactor);
	CLuTA2.rgb			=	lerp( lerp(CLuTN2.rgb, CLuTD2.rgb, ENightDayFactor), CLuTI2.rgb, EInteriorFactor);
	
	color.rgb			=	lerp(CLuTA1.rgb, CLuTA2.rgb, color.b - CLut_UV.w);

#endif //E_CC_PALETTE
Last edited by Visitant on 09 Jun 2017, 21:23, edited 4 times in total.

Offline
*blah-blah-blah maniac*
Posts: 565
Joined: 05 Apr 2014, 10:29
Location: Taiwan

Re: [HLSL CODE] 3D LUT

Code: Select all

Color --> color
I presume.

op updated for DNI example.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
Posts: 6
Joined: 06 Jun 2017, 00:11

Re: [HLSL CODE] 3D LUT

nvm
Last edited by Simjedi on 05 Jul 2017, 12:27, edited 1 time in total.

Offline
Posts: 6
Joined: 06 Jun 2017, 00:11

Re: [HLSL CODE] 3D LUT

I would like to say I figured out. It's not pretty since I'm not a coder but it works....lol

Offline
*blah-blah-blah maniac*
Posts: 552
Joined: 11 Apr 2012, 03:24

Re: [HLSL CODE] 3D LUT

Where can I download a neutral LUT?
_________________
i5-6600k -- Nvidia GTX 970 -- 16Gb ram @3200mhz

Offline
User avatar
*blah-blah-blah maniac*
Posts: 983
Joined: 09 Dec 2012, 00:29

Re: [HLSL CODE] 3D LUT

In my preset for SSE (in yours too), it's a "LUT_Preset5.png"
_________________
Rudy ENB for Skyrim, Skyrim SE, for Fallout New Vegas, for Dragon's Dogma

English is not my native language.

AMD Ryzen 9 5900X, Gigabyte B550 AORUS PRO AC, Arctic Liquid Freezer II 280, Nvidia Geforce RTX 2070 Super, 64GB ram

Offline
*blah-blah-blah maniac*
Posts: 552
Joined: 11 Apr 2012, 03:24

Re: [HLSL CODE] 3D LUT

Thank you Rudy! I've actually decided to try figure out how to make my own LUT in Unity so I don't have to use yours and rip you off! I have no idea how to do it yet and it seems complicated.
_________________
i5-6600k -- Nvidia GTX 970 -- 16Gb ram @3200mhz

Offline
User avatar
*blah-blah-blah maniac*
Posts: 3136
Joined: 27 Jan 2012, 13:42

Re: [HLSL CODE] 3D LUT

It's very easy in Photoshop or Gimp.

Offline
User avatar
*master*
Posts: 177
Joined: 08 Nov 2016, 15:18
Location: Brazil

Re: [HLSL CODE] 3D LUT

Its possible to change the color tone ingame by LUT edition ? For exemple, if I want to change the green from the grass to another kind of green. If its possible, which tool in Photoshop I need to use ???
_________________
Intel i5 9400f ; NVIDIA RTX 3060 12gb VRAM; 16gb RAM; Windows 10

PhoenixVivid ENB for SSE / Phoenix Cinematic ENB for Fallout 4
Imaginarium ENB for SSE / Insanity ENB for Skyrim LE
NCW ENB for Fallout 4 / Somber Phantasy ENB for SSE


My Nexus Page
Post Reply