[HLSL CODE] 3D LUT

share shaders here
  • Author
  • Message
Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: [HLSL CODE] 3D LUT

It won't work the way it's set.
At the end of your LUT function, you set " color.rgb = lerp( lerp( CLutFunc(color.rgb, SamplerLUT_Night), CLutFunc(color.rgb, SamplerLUT_Day), ENightDayFactor), CLutFunc(color.rgb, SamplerLUT_Int), EInteriorFactor); " but "color" is not declared yet. This line comes at the end of the post process you're using if you want it exclusive to this specific post-process, f.e. for POST PROCESS 3, put that line just before the " #endif ", this way:

#if (POSTPROCESS==3)

grayadaptation=max(grayadaptation, 0.0);
grayadaptation=min(grayadaptation, 50.0);
color.xyz=color.xyz/(grayadaptation*EAdaptationMaxV3+EAdaptationMinV3);//*tempF1.x

float lumamax=EToneMappingOversaturationV3;
color.xyz=(color.xyz * (1.0 + color.xyz/lumamax))/(color.xyz + EToneMappingCurveV3);

color.rgb = lerp( lerp( CLutFunc(color.rgb, SamplerLUT_Night), CLutFunc(color.rgb, SamplerLUT_Day), ENightDayFactor), CLutFunc(color.rgb, SamplerLUT_Int), EInteriorFactor); // <- PUT THIS LINE HERE

#endif

If you want it whatever the post-process being used, just set it before (or after) the palette code, this way:

....... previous code here

color.rgb = lerp( lerp( CLutFunc(color.rgb, SamplerLUT_Night), CLutFunc(color.rgb, SamplerLUT_Day), ENightDayFactor), CLutFunc(color.rgb, SamplerLUT_Int), EInteriorFactor); // <- PUT THIS LINE HERE

//pallete texture (0.082+ version feature)
#ifdef E_CC_PALETTE
color.rgb=saturate(color.rgb);
float3 brightness=Adaptation.xyz;//tex2D(_s4, 0.5);//adaptation luminance

etc, etc.... In this case, LUT is applied before palette, if you use both at the same time (not adviced much).

Now if you want to activate / deactivate on the fly via GUI, you have to create a boolean before this line :

if (USE_LUT) color.rgb = lerp( lerp( CLutFunc(color.rgb, SamplerLUT_Night), CLutFunc(color.rgb, SamplerLUT_Day), ENightDayFactor), CLutFunc(color.rgb, SamplerLUT_Int), EInteriorFactor);

Then replicate this boolean into your UI, at the beginning of your file :

bool USE_LUT <string UIName="LUTS - Enable"; > = {true};
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

Offline
Posts: 9
Joined: 25 Mar 2021, 17:38

Re: [HLSL CODE] 3D LUT

Thanks for your answer Oyama! Just saw it)
I tryed to do what you wrote here, but it dosent work for me(

First I deleted the line:
color.rgb = lerp( lerp( CLutFunc(color.rgb, SamplerLUT_Night), CLutFunc(color.rgb, SamplerLUT_Day), ENightDayFactor), CLutFunc(color.rgb, SamplerLUT_Int), EInteriorFactor);
at the end of LUT Function section.

Then I add it at the end of POSTPROCESS 2 that I use, with:
if (USE_LUT) color.rgb = lerp( lerp( CLutFunc(color.rgb, SamplerLUT_Night), CLutFunc(color.rgb, SamplerLUT_Day), ENightDayFactor), CLutFunc(color.rgb, SamplerLUT_Int), EInteriorFactor);

An after that added:
bool "USE_LUT <string UIName="LUTS - Enable"; > = {true};
for UI at the internal parametrs section.

What Iam doing wrong? Can you help me again please)
Actually I dont need palette, it just there from original enb. Can be replaced with 3dlut, its far more powerfull.

Offline
User avatar
*blah-blah-blah maniac*
Posts: 1498
Joined: 31 Mar 2012, 15:06
Location: France

Re: [HLSL CODE] 3D LUT

has to be

bool USE_LUT <string UIName="LUTS - Enable"; > = {true};

Not

bool "USE_LUT <string UIName="LUTS - Enable"; > = {true};

You added an unnecessary " before USE_LUT
_________________
Lian Li PC011 Dynamic, Corsair AX 1500i PSU, i9 10850K @5.0 Ghz, Aorus Z490 Ultra, RTX3090 MSI Gaming X Trio, 32GB Corsair Vengeance Pro RGB RAM@3600, Corsair MP600 1TB NVME System Drive, 10 TB Storage, W10 Pro 64, Custom Hard Tubing Watercooling Loop

Offline
Posts: 9
Joined: 25 Mar 2021, 17:38

Re: [HLSL CODE] 3D LUT

Sorry its my mistake in the message here, but in file its correct. In game it doesnt work and after edits I lose controls of the POSTPROCESS section(
What might be wrong here?

Offline
Posts: 21
Joined: 04 Oct 2018, 09:06

Re: [HLSL CODE] 3D LUT

Dato_N wrote: 31 Mar 2021, 22:09 Sorry its my mistake in the message here, but in file its correct. In game it doesnt work and after edits I lose controls of the POSTPROCESS section(
What might be wrong here?
upload your file to pastebin.

Offline
Posts: 9
Joined: 25 Mar 2021, 17:38

Re: [HLSL CODE] 3D LUT

markimoo0714 wrote: 16 Apr 2021, 11:58
Dato_N wrote: 31 Mar 2021, 22:09 Sorry its my mistake in the message here, but in file its correct. In game it doesnt work and after edits I lose controls of the POSTPROCESS section(
What might be wrong here?
upload your file to pastebin.
Hi, thank you)
But can you give a link to file?
Pastebin search dont work right now(
Or you can upload the file on my google drive folder, the link from before. It would be great)

Offline
Posts: 21
Joined: 04 Oct 2018, 09:06

Re: [HLSL CODE] 3D LUT

@Dato_N Sorry if I didn't make my self clear, what I mean is, you upload the file that you're editing and we'll try to edit it for you.
You can try to use pastebin for that.

Offline
Posts: 9
Joined: 25 Mar 2021, 17:38

Re: [HLSL CODE] 3D LUT

markimoo0714 wrote: 25 Apr 2021, 15:35 @Dato_N Sorry if I didn't make my self clear, what I mean is, you upload the file that you're editing and we'll try to edit it for you.
You can try to use pastebin for that.
Ok, here is a link:
https://pastebin.com/CpqY9Tyz
I only created LUT texture helper and LUT function sections. Need a UI section but dont know how to add this.
I want a switch in UI to activate/deactivate a lut, and then use 3 separate 3dluts images for DNI in 1024^32 size: LUT_Day, LUT_Night, LUT_Int. (png format)
Dont need palette texture, this code can be replaced by 3dlut.

Offline
Posts: 21
Joined: 04 Oct 2018, 09:06

Re: [HLSL CODE] 3D LUT

Here, didn't test it because I don't have dx9 games.
https://pastebin.com/19MtxRMZ

edit: fixed typo

Offline
Posts: 9
Joined: 25 Mar 2021, 17:38

Re: [HLSL CODE] 3D LUT

markimoo0714 wrote: 27 Apr 2021, 08:33 Here, didn't test it because I don't have dx9 games.
https://pastebin.com/19MtxRMZ

edit: fixed typo
Thank you
I test your file and it didnt work as it should be(
Changes dont take effect and Iost control of brightness, saturation and other settings in enbeffect file
Post Reply