[HLSL CODE] 3D LUT

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 983
Joined: 09 Dec 2012, 00:29

Re: [HLSL CODE] 3D LUT

Just use a Hue/Saturation :)
_________________
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
User avatar
*master*
Posts: 177
Joined: 08 Nov 2016, 15:18
Location: Brazil

Re: [HLSL CODE] 3D LUT

Thanks, Rudy! ;)
_________________
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

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

Re: [HLSL CODE] 3D LUT

Other Question: Its possible to get a Neutral LUT that does not affect the color and contrast of my Base settings ??? The Neutral LUT in the 1st page and others I find on web when I put in game make the scene very dark and without colors. I have to do a lot of editions in Photoshop and don't get close to my original colors ......
_________________
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

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

Re: [HLSL CODE] 3D LUT

there's probably something wrong with your implementation.
_________________
Intel Xeon L5639 6C12T @3.96GHz | Gigabyte ga-x58a-ud3r | MSI GTX680 4G | 48G RAM | Intel 760p Nvme w clover bootloader
Flickr
YouTube

Offline
*master*
Posts: 117
Joined: 22 Feb 2013, 03:33

Re: [HLSL CODE] 3D LUT

Thank you kingeric1992 for the useful shader! I exported some film stock simulation .cube LUTs from Adobe Premiere and converted them to .png and .bmp for my own use with this shader, but I figured maybe someone else could use them. Here they are!

To use them you need to rename them, example LUT.png for DX11 or LUT.bmp for DX9 (unless you're using DNI separation, in which case refer to the code in the original post for names).

Another tip: use something like

Code: Select all

float lutIntensity = 1.0; 
color.rgb = lerp(color.rgb, CLutFunc(color.rgb, LUTtex), lutIntensity);
to control the strength of the effect by changing the value of lutIntensity. Replacing float lutIntensity = 1.0; with the code for a GUI variable would be handy but I forget that code at the moment as I'm not at my usual computer right now.

Hopefully someone finds this useful :)
Attachments
FilmStockLUTs.zip
Fujifilm and Kodak film stock simulation LUTs exported from Adobe Premiere and converted to PNG/BMP
(164.21 KiB) Downloaded 720 times

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

Re: [HLSL CODE] 3D LUT

Kermles -- Thank you :)
_________________
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
User avatar
*blah-blah-blah maniac*
Posts: 17447
Joined: 27 Dec 2011, 08:53
Location: Rather not to say

Re: [HLSL CODE] 3D LUT

Maybe better to put this file in separate topic, so it will not be lost here?
_________________
i9-9900k, 64Gb RAM, RTX 3060 12Gb, Win7

Offline
*master*
Posts: 117
Joined: 22 Feb 2013, 03:33

Re: [HLSL CODE] 3D LUT

@ENBSeries Okay, wasn't sure if that was appropriate; I'll get right on it.

@Guzio: You're very welcome!

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

Re: [HLSL CODE] 3D LUT

Well, I already have an enbeffect.fx with one LUT for all situations. If I want to make a DNI separation and include 2 more LUT files for Nights and Interiors, what are the specific lines I need to replace (or add) in the fx file ? I read the posts in previous page, but I'm afraid I didn't understand ...... Thanks in advance.
_________________
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

Offline
User avatar
Posts: 56
Joined: 02 Aug 2017, 13:30

Re: [HLSL CODE] 3D LUT

So i have a little trick for multiple luts ;) first the add the function anywere:

Code: Select all

static const float2 Lut_Size256 = float2(256.0, 16.0);

float3 Lut256( float3 colorIN, Texture2D lutTexIn ) {
    float2 CLut_pSize = 1.0 / Lut_Size256;
    float4 CLut_UV;
    colorIN    = saturate(colorIN) * ( Lut_Size256.y - 1.0);
    CLut_UV.w  = floor(colorIN.b);
    CLut_UV.xy = (colorIN.rg + 0.5) * CLut_pSize;
    CLut_UV.x += CLut_UV.w * CLut_pSize.y;
    CLut_UV.z  = CLut_UV.x + CLut_pSize.y;
    return       lerp (lutTexIn.SampleLevel(Sampler1, CLut_UV.xy, 0).rgb, 
                       lutTexIn.SampleLevel(Sampler1, CLut_UV.zy, 0).rgb, colorIN.b - CLut_UV.w);
}


static const float2 Lut_Size1024 = float2(1024.0, 32.0);

float3 Lut1024( float3 colorIN, Texture2D lutTexIn ) {
    float2 CLut_pSize = 1.0 / Lut_Size1024;
    float4 CLut_UV;
    colorIN    = saturate(colorIN) * ( Lut_Size1024.y - 1.0);
    CLut_UV.w  = floor(colorIN.b);
    CLut_UV.xy = (colorIN.rg + 0.5) * CLut_pSize;
    CLut_UV.x += CLut_UV.w * CLut_pSize.y;
    CLut_UV.z  = CLut_UV.x + CLut_pSize.y;
    return       lerp (lutTexIn.SampleLevel(Sampler1, CLut_UV.xy, 0).rgb, 
                       lutTexIn.SampleLevel(Sampler1, CLut_UV.zy, 0).rgb, colorIN.b - CLut_UV.w);
}


static const float2 Lut_Size4096 = float2(4096.0, 64.0);

float3 Lut4096( float3 colorIN, Texture2D lutTexIn ) {
    float2 CLut_pSize = 1.0 / Lut_Size4096;
    float4 CLut_UV;
    colorIN    = saturate(colorIN) * ( Lut_Size4096.y - 1.0);
    CLut_UV.w  = floor(colorIN.b);
    CLut_UV.xy = (colorIN.rg + 0.5) * CLut_pSize;
    CLut_UV.x += CLut_UV.w * CLut_pSize.y;
    CLut_UV.z  = CLut_UV.x + CLut_pSize.y;
    return       lerp (lutTexIn.SampleLevel(Sampler1, CLut_UV.xy, 0).rgb, 
                       lutTexIn.SampleLevel(Sampler1, CLut_UV.zy, 0).rgb, colorIN.b - CLut_UV.w);
}
This basically make 3 functions that you have to choose from depending on what size your lut has
in your pixel shader you want to do something like:

Code: Select all

	//example:
	color.rgb = Lut4096(color.rgb, LOGtoREC);
	
	//In case you want seperate luts for each daytime you will need to load 3 luts. Apply them by doing:
    color.rgb = lerp(lerp(Lut256(color.rgb, LUTxy_Night), 
                          Lut256(color.rgb, LUTxy_Day),      ENightDayFactor),
                          Lut256(color.rgb, LUTxy_Interior), EInteriorFactor);
Depending on the size of the lut you loaded you will need a diffrent function to apply it
available lut sizes are: 256x16 1024x32 4096x64
functions for these are: Lut256 Lut1024 Lut4096
also youll need to load the lut textures of cause (look main post)

now to the switch part. Make a UI item like that:

Code: Select all

float	LUTSwitch
<
	string UIName="Choose LUT";
	string UIWidget="spinner";
	float UIMin=0.0;
	float UIMax=3.0;
	float UIStep=1.0;
> = {0.0};
and then bring the part of the pixel shader into { } with an if. Like that:

Code: Select all

	if (LUTSwitch==1) {
    color.rgb = Lut4096(color.rgb, LOGtoREC);
	}
	
	if (LUTSwitch==2) {
	color.rgb = Lut1024(color.rgb, sLOG_LUT);
	}
	
	if (LUTSwitch==3) {
    color.rgb = lerp(lerp(Lut256(color.rgb, LUTxy_Night), 
                          Lut256(color.rgb, LUTxy_Day),      ENightDayFactor),
                          Lut256(color.rgb, LUTxy_Interior), EInteriorFactor);
	}
if you have questions to it you can read up on my LUTSetup.fxh file of my Shader Libary ;) i wrote something more detailed there. Or ask me on discord :D
Post Reply