Page 3 of 7

Re: [HLSL CODE] 3D LUT

Posted: 01 Nov 2016, 17:25
by ZeroKing
Sweet, thank you.

Re: [HLSL CODE] 3D LUT

Posted: 07 Dec 2016, 01:28
by Visitant
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

Re: [HLSL CODE] 3D LUT

Posted: 07 Dec 2016, 07:54
by kingeric1992

Code: Select all

Color --> color
I presume.

op updated for DNI example.

Re: [HLSL CODE] 3D LUT

Posted: 03 Jul 2017, 03:23
by Simjedi
nvm

Re: [HLSL CODE] 3D LUT

Posted: 03 Jul 2017, 22:53
by Simjedi
I would like to say I figured out. It's not pretty since I'm not a coder but it works....lol

Re: [HLSL CODE] 3D LUT

Posted: 15 Jan 2018, 20:24
by evok99
Where can I download a neutral LUT?

Re: [HLSL CODE] 3D LUT

Posted: 15 Jan 2018, 22:03
by Guzio
In my preset for SSE (in yours too), it's a "LUT_Preset5.png"

Re: [HLSL CODE] 3D LUT

Posted: 15 Jan 2018, 23:19
by evok99
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.

Re: [HLSL CODE] 3D LUT

Posted: 16 Jan 2018, 07:09
by mindflux
It's very easy in Photoshop or Gimp.

Re: [HLSL CODE] 3D LUT

Posted: 20 Apr 2018, 15:31
by phoenixfabricio
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 ???