diff --git a/src/games/rdr2vk/README.MD b/src/games/rdr2vk/README.MD new file mode 100644 index 000000000..081f40c70 --- /dev/null +++ b/src/games/rdr2vk/README.MD @@ -0,0 +1,105 @@ +# Red Dead Redemption 2 (Vulkan) + +## Requirements + +- Vulkan renderer +- Exclusive Fullscreen +- HDR enabled in Windows and in game +- 64-bit ReShade with addon support + +## Tone-mapper defaults + +The default **RenoDX (Enhanced)** tone mapper is anchored to RDR2's original tone-curve inflection while using perceptual highlight compression and slightly raised shadows. This is intentional: the more conservative **RenoDX (Vanilla+)** mode with 2.2 EOTF emulation more closely preserves the original look, but can appear excessively crushed. + +Use **Preset Off** for the native game path or **Purist** for the Vanilla+ presentation. + +## Compiling the shaders + +RDR2's Vulkan shaders use the custom SPIR-V entry point `VkMain` instead of `main`. The repository's normal shader build does not compile these GLSL sources, so the committed `.spv` files must be regenerated with the included script before building the addon. + +1. Install Vulkan SDK `1.4.313.0` to `C:\VulkanSDK\1.4.313.0\`. +2. Run `compileglsl.cmd` from `src\games\rdr2vk`. +3. Build the `rdr2vk` CMake target normally. + +The script finds each immediate subfolder containing `.glsl` files, compiles shader files whose names contain a shader hash, and writes each generated module to that source folder's `compiled` subfolder. Shared include files without a shader hash are reported as skipped. + +The script invokes `glslangValidator.exe` with: + +```text +-V --target-env vulkan1.3 --source-entrypoint main -e VkMain +``` + +`--source-entrypoint main` selects the GLSL source function, while `-e VkMain` writes Rockstar's required entry-point name into the generated SPIR-V module. + +Full script: + +```cmd +@echo off +setlocal EnableDelayedExpansion + +set "GLSLANG=C:\VulkanSDK\1.4.313.0\Bin\glslangValidator.exe" + +if not exist "%GLSLANG%" ( + echo ERROR: glslangValidator.exe was not found at: + echo %GLSLANG% + echo Install Vulkan SDK 1.4.313.0 or update GLSLANG in this script. + exit /b 1 +) + +pushd "%~dp0" + +set /A "FOLDER_COUNT=0, COMPILED_COUNT=0, SKIPPED_COUNT=0, FAILED_COUNT=0" + +echo Compiling RDR2 Vulkan shaders with SPIR-V entry point VkMain... +echo. + +REM Compile every immediate subfolder containing GLSL shaders. Generated SPIR-V +REM is written to a compiled subfolder beside the corresponding shader sources. +for /D %%D in (*) do ( + if exist "%%D\*.glsl" ( + set /A "FOLDER_COUNT+=1" + set /A "FOLDER_COMPILED=0, FOLDER_SKIPPED=0, FOLDER_FAILED=0" + + echo === %%D === + echo Output: %%D\compiled + + if not exist "%%D\compiled" mkdir "%%D\compiled" + + pushd "%%D" + for %%F in (*.glsl) do ( + echo %%~nF | %SystemRoot%\System32\findstr.exe /R /I "0x[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]" >nul + if errorlevel 1 ( + echo SKIP %%F ^(no shader hash in filename^) + set /A "SKIPPED_COUNT+=1, FOLDER_SKIPPED+=1" + ) else ( + set "BASE=%%~nF" + set "OUT_NAME=!BASE:*0x=0x!" + echo COMPILE %%F + "%GLSLANG%" -V --target-env vulkan1.3 --source-entrypoint main -e VkMain -o "compiled\!OUT_NAME!.spv" "%%F" + if errorlevel 1 ( + echo FAILED %%F + set /A "FAILED_COUNT+=1, FOLDER_FAILED+=1" + ) else ( + echo OK compiled\!OUT_NAME!.spv + set /A "COMPILED_COUNT+=1, FOLDER_COMPILED+=1" + ) + ) + ) + popd + + echo Folder summary: !FOLDER_COMPILED! compiled, !FOLDER_SKIPPED! skipped, !FOLDER_FAILED! failed + echo. + ) +) + +echo === Shader compilation summary === +echo Folders: !FOLDER_COUNT! +echo Compiled: !COMPILED_COUNT! +echo Skipped: !SKIPPED_COUNT! +echo Failed: !FAILED_COUNT! + +popd + +if !FAILED_COUNT! GTR 0 exit /b 1 +exit /b 0 +``` \ No newline at end of file diff --git a/src/games/rdr2vk/addon.cpp b/src/games/rdr2vk/addon.cpp new file mode 100644 index 000000000..e31fd3137 --- /dev/null +++ b/src/games/rdr2vk/addon.cpp @@ -0,0 +1,422 @@ +/* + * Copyright (C) 2024 Musa Haji + * SPDX-License-Identifier: MIT + */ + +#define ImTextureID ImU64 + +#define DEBUG_LEVEL_0 + +#include + +#include +#include + +#include "../../mods/shader.hpp" +#include "../../utils/date.hpp" +#include "../../utils/random.hpp" +#include "../../utils/settings.hpp" +#include "./shared.h" + +namespace { + +ShaderInjectData shader_injection; + +void OnTonemapShaderDrawn(reshade::api::command_list*) { + shader_injection.is_tonemapped = 1.f; +} + +renodx::mods::shader::CustomShaders custom_shaders = { + // tonemap + {0x0C1275BE, {.crc32 = 0x0C1275BE, .code = __0x0C1275BE, .on_drawn = &OnTonemapShaderDrawn}}, + // {0x2B012EDD, {.crc32 = 0x2B012EDD, .code = __0x2B012EDD, .on_drawn = &OnTonemapShaderDrawn}}, + {0x4205843B, {.crc32 = 0x4205843B, .code = __0x4205843B, .on_drawn = &OnTonemapShaderDrawn}}, + {0x54F0BD84, {.crc32 = 0x54F0BD84, .code = __0x54F0BD84, .on_drawn = &OnTonemapShaderDrawn}}, + // {0x6B9382CA, {.crc32 = 0x6B9382CA, .code = __0x6B9382CA, .on_drawn = &OnTonemapShaderDrawn}}, + {0x809F5852, {.crc32 = 0x809F5852, .code = __0x809F5852, .on_drawn = &OnTonemapShaderDrawn}}, + {0x9B304112, {.crc32 = 0x9B304112, .code = __0x9B304112, .on_drawn = &OnTonemapShaderDrawn}}, + {0x9F191B0B, {.crc32 = 0x9F191B0B, .code = __0x9F191B0B, .on_drawn = &OnTonemapShaderDrawn}}, + {0xA2ED1CB7, {.crc32 = 0xA2ED1CB7, .code = __0xA2ED1CB7, .on_drawn = &OnTonemapShaderDrawn}}, + {0xCD6F15F2, {.crc32 = 0xCD6F15F2, .code = __0xCD6F15F2, .on_drawn = &OnTonemapShaderDrawn}}, + {0xCF7FE0D7, {.crc32 = 0xCF7FE0D7, .code = __0xCF7FE0D7, .on_drawn = &OnTonemapShaderDrawn}}, + // {0xDA9A5AA0, {.crc32 = 0xDA9A5AA0, .code = __0xDA9A5AA0, .on_drawn = &OnTonemapShaderDrawn}}, + {0xDD04030E, {.crc32 = 0xDD04030E, .code = __0xDD04030E, .on_drawn = &OnTonemapShaderDrawn}}, + // {0xE3E0B5C4, {.crc32 = 0xE3E0B5C4, .code = __0xE3E0B5C4, .on_drawn = &OnTonemapShaderDrawn}}, + + // output + CustomShaderEntry(0x14BF23D4), + CustomShaderEntry(0x1B0D650C), + CustomShaderEntry(0x26B3FAA9), + CustomShaderEntry(0x6032A998), + CustomShaderEntry(0x76A78879), + CustomShaderEntry(0x7BE28339), + CustomShaderEntry(0x8B9C89F1), + CustomShaderEntry(0xA383C448), + CustomShaderEntry(0xBCF843ED), + CustomShaderEntry(0xFCD82342), + + // calibration + CustomShaderEntry(0xB17FDFCC), +}; + +void OnPresent( + reshade::api::command_queue*, + reshade::api::swapchain*, + const reshade::api::rect*, + const reshade::api::rect*, + uint32_t, + const reshade::api::rect*) { + shader_injection.is_tonemapped = 0.f; +} + +renodx::utils::settings::Settings settings = { + new renodx::utils::settings::Setting{ + .key = "ToneMapType", + .binding = &shader_injection.tone_map_type, + .value_type = renodx::utils::settings::SettingValueType::INTEGER, + .default_value = 1.f, + .label = "Tone Mapper", + .section = "Tone Mapping", + .tooltip = "Sets the tone mapper type", + .labels = {"Vanilla", "RenoDX (Enhanced)", "RenoDX (Vanilla+)", "SDR"}, + }, + new renodx::utils::settings::Setting{ + .key = "ToneMapPeakNits", + .binding = &shader_injection.peak_white_nits, + .default_value = 1000.f, + .can_reset = false, + .label = "Peak Brightness", + .section = "Tone Mapping", + .tooltip = "Sets the value of peak white in nits", + .min = 48.f, + .max = 10000.f, + .is_enabled = []() { return shader_injection.tone_map_type == 2.f || shader_injection.tone_map_type == 1.f; }, + .is_logarithmic = true, + }, + new renodx::utils::settings::Setting{ + .key = "ToneMapGameNits", + .binding = &shader_injection.diffuse_white_nits, + .default_value = 203.f, + .label = "Game Brightness", + .section = "Tone Mapping", + .tooltip = "Sets the value of 100% white in nits", + .min = 48.f, + .max = 500.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ToneMapUINits", + .binding = &shader_injection.graphics_white_nits, + .default_value = 203.f, + .label = "UI Brightness", + .section = "Tone Mapping", + .tooltip = "Sets the brightness of UI and HUD elements in nits", + .min = 48.f, + .max = 500.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f; }, + }, + new renodx::utils::settings::Setting{ + .key = "GammaCorrection", + .binding = &shader_injection.sdr_eotf_emulation, + .value_type = renodx::utils::settings::SettingValueType::INTEGER, + .default_value = 0.f, + .label = "SDR EOTF Emulation", + .section = "Tone Mapping", + .tooltip = "Emulates a 2.2 EOTF", + .labels = {"Off", "2.2"}, + .is_enabled = []() { return shader_injection.tone_map_type != 1.f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeGamma", + .binding = &shader_injection.tone_map_gamma, + .default_value = 1.f, + .label = "Gamma", + .section = "Color Grading", + .min = 0.75f, + .max = 1.25f, + .format = "%.2f", + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeHighlights", + .binding = &shader_injection.tone_map_highlights, + .default_value = 50.f, + .label = "Highlights", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeShadows", + .binding = &shader_injection.tone_map_shadows, + .default_value = 50.f, + .label = "Shadows", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeContrast", + .binding = &shader_injection.tone_map_contrast, + .default_value = 50.f, + .label = "Contrast", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeSaturation", + .binding = &shader_injection.tone_map_saturation, + .default_value = 50.f, + .label = "Saturation", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeHighlightSaturation", + .binding = &shader_injection.tone_map_highlight_saturation, + .default_value = 50.f, + .label = "Highlight Saturation", + .section = "Color Grading", + .tooltip = "Adds or removes highlight color.", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeDechroma", + .binding = &shader_injection.tone_map_dechroma, + .default_value = 0.f, + .label = "Dechroma", + .section = "Color Grading", + .tooltip = "Controls highlight desaturation due to overexposure.", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeFlare", + .binding = &shader_injection.tone_map_flare, + .default_value = 0.f, + .label = "Flare", + .section = "Color Grading", + .tooltip = "Flare/Glare Compensation", + .max = 100.f, + .is_enabled = []() { return shader_injection.tone_map_type != 0.f && shader_injection.tone_map_type != 3.f; }, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "ColorGradeLUTStrength", + .binding = &shader_injection.custom_lut_strength, + .default_value = 100.f, + .label = "LUT Strength", + .section = "Color Grading", + .max = 100.f, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "FxVignette", + .binding = &shader_injection.custom_vignette, + .default_value = 100.f, + .label = "Vignette", + .section = "Effects", + .max = 100.f, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "FxDithering", + .binding = &shader_injection.custom_dithering, + .default_value = 100.f, + .label = "Dithering", + .section = "Effects", + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "FxGrainStrength", + .binding = &shader_injection.custom_grain_strength, + .default_value = 0.f, + .label = "Film Grain", + .section = "Effects", + .max = 100.f, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "UnclampLighting", + .binding = &shader_injection.custom_unclamp_highlights, + .value_type = renodx::utils::settings::SettingValueType::BOOLEAN, + .default_value = 1.f, + .label = "Unclamp Lighting", + .section = "Advanced", + .tooltip = "Removes clamp on brightness", + }, + new renodx::utils::settings::Setting{ + .key = "CustomLUTEncoding", + .binding = &shader_injection.custom_lut_encoding, + .value_type = renodx::utils::settings::SettingValueType::INTEGER, + .default_value = 1.f, + .label = "LUT Encoding", + .section = "Advanced", + .tooltip = "Skip LUT encoding like Vanilla HDR or use SDR's sRGB-like encoding.", + .labels = {"Vanilla (Linear)", "Fixed (sRGB-like, Matches SDR)"}, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "Reset All", + .section = "Options", + .group = "button-line-1", + .on_change = []() { + for (auto* setting : settings) { + if (setting->key.empty()) continue; + if (!setting->can_reset) continue; + renodx::utils::settings::UpdateSetting(setting->key, setting->default_value); + } + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "Purist", + .section = "Options", + .group = "button-line-1", + .on_change = []() { + renodx::utils::settings::ResetSettings(); + renodx::utils::settings::UpdateSettings({ + {"ToneMapType", 2.f}, + {"GammaCorrection", 1.f}, + {"UnclampLighting", 0.f}, + }); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "RenoDX Discord", + .section = "Links", + .group = "button-line-2", + .tint = 0x5865F2, + .on_change = []() { + renodx::utils::platform::LaunchURL("https://discord.gg/", "Ce9bQHQrSV"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "HDR Den Discord", + .section = "Links", + .group = "button-line-2", + .tint = 0x5865F2, + .on_change = []() { + renodx::utils::platform::LaunchURL("https://discord.gg/", "5WZXDpmbpP"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "More Mods", + .section = "Links", + .group = "button-line-2", + .tint = 0x2B3137, + .on_change = []() { + renodx::utils::platform::LaunchURL("https://github.com/clshortfuse/renodx/wiki/Mods"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "Github", + .section = "Links", + .group = "button-line-2", + .tint = 0x2B3137, + .on_change = []() { + renodx::utils::platform::LaunchURL("https://github.com/clshortfuse/renodx"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "Musa's Ko-Fi", + .section = "Links", + .group = "button-line-3", + .tint = 0xFF5A16, + .on_change = []() { renodx::utils::platform::LaunchURL("https://ko-fi.com/musaqh"); }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "ShortFuse's Ko-Fi", + .section = "Links", + .group = "button-line-3", + .tint = 0xFF5A16, + .on_change = []() { renodx::utils::platform::LaunchURL("https://ko-fi.com/shortfuse"); }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::TEXT, + .label = std::string("Build: ") + renodx::utils::date::ISO_DATE_TIME, + .section = "About", + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::TEXT, + .label = std::string("- Requires Vulkan, Exclusive Fullscreen, and HDR on in game.\n" + "- Make sure to closely read installation instructions."), + .section = "About", + }, +}; + +void OnPresetOff() { + renodx::utils::settings::UpdateSettings({ + {"ToneMapType", 0.f}, + {"ToneMapPeakNits", 1000.f}, + {"ToneMapGameNits", 203.f}, + {"ToneMapUINits", 203.f}, + {"GammaCorrection", 0.f}, + {"ColorGradeHighlights", 50.f}, + {"ColorGradeShadows", 50.f}, + {"ColorGradeContrast", 50.f}, + {"ColorGradeSaturation", 50.f}, + {"ColorGradeHighlightSaturation", 50.f}, + {"ColorGradeDechroma", 0.f}, + {"ColorGradeFlare", 0.f}, + {"ColorGradeLUTStrength", 100.f}, + {"FxVignette", 100.f}, + {"FxDithering", 100.f}, + {"FxGrainStrength", 0.f}, + {"UnclampLighting", 0.f}, + {"CustomLUTEncoding", 0.f}, + }); +} + +bool initialized = false; + +} // namespace + +extern "C" __declspec(dllexport) constexpr const char* NAME = "RenoDX"; +extern "C" __declspec(dllexport) constexpr const char* DESCRIPTION = "RenoDX for Red Dead Redemption 2"; + +BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) { + switch (fdw_reason) { + case DLL_PROCESS_ATTACH: + if (!reshade::register_addon(h_module)) return FALSE; + + if (!initialized) { + renodx::mods::shader::allow_multiple_push_constants = true; + renodx::mods::shader::force_pipeline_cloning = true; + // renodx::utils::shader::use_replace_async = true; + + initialized = true; + } + + renodx::utils::random::binds.push_back(&shader_injection.custom_random); // film grain + reshade::register_event(OnPresent); + + break; + case DLL_PROCESS_DETACH: + reshade::unregister_event(OnPresent); + + reshade::unregister_addon(h_module); + break; + } + + renodx::utils::random::Use(fdw_reason); + renodx::utils::settings::Use(fdw_reason, &settings, &OnPresetOff); + renodx::mods::shader::Use(fdw_reason, custom_shaders, &shader_injection); + + return TRUE; +} diff --git a/src/games/rdr2vk/canvas.glsl b/src/games/rdr2vk/canvas.glsl new file mode 100644 index 000000000..3f205054b --- /dev/null +++ b/src/games/rdr2vk/canvas.glsl @@ -0,0 +1,1181 @@ +#ifndef SRC_GAMES_RDR2VK_CANVAS_GLSL_ +#define SRC_GAMES_RDR2VK_CANVAS_GLSL_ + +const int renodx_canvas_MODE_NORMAL = 0x00; +const int renodx_canvas_MODE_INVERT = 0x01; +const int renodx_canvas_MODE_UNDERLINE = 0x02; +const int renodx_canvas_MODE_BLINVERT = 0x04; +const int renodx_canvas_MODE_BLINK = 0x08; + +// Source bitmap size for the built-in 8x12 font. Keep these values integral. +const vec2 renodx_canvas_internal_GLYPH_SIZE = vec2(8.0, 12.0); +const float renodx_canvas_internal_BLINK_RATE = 2.0; + +#define RENODX_CANVAS_GLYPH(X, Y, Z, W) uvec4(uint(X), uint(Y), uint(Z), uint(W)) + +const uvec4 renodx_canvas_internal_GLYPH_MASK = + RENODX_CANVAS_GLYPH(0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF, 0x00FFFFFF); + +// Forked from Flyguy's 96-bit 8x12 font sheet. Entries cover ASCII 32-126. +const uvec4 renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[95] = uvec4[95]( + RENODX_CANVAS_GLYPH(0x000000, 0x000000, 0x000000, 0x000000), + RENODX_CANVAS_GLYPH(0x1E0C00, 0x0C1E1E, 0x0C000C, 0x00000C), + RENODX_CANVAS_GLYPH(0x666600, 0x002466, 0x000000, 0x000000), + RENODX_CANVAS_GLYPH(0x363600, 0x36367F, 0x367F36, 0x000036), + RENODX_CANVAS_GLYPH(0x3E0C0C, 0x1E0303, 0x1F3030, 0x000C0C), + RENODX_CANVAS_GLYPH(0x000000, 0x183323, 0x33060C, 0x000031), + RENODX_CANVAS_GLYPH(0x1B0E00, 0x5F0E1B, 0x3B337B, 0x00006E), + RENODX_CANVAS_GLYPH(0x0C0C00, 0x00060C, 0x000000, 0x000000), + RENODX_CANVAS_GLYPH(0x183000, 0x06060C, 0x180C06, 0x000030), + RENODX_CANVAS_GLYPH(0x0C0600, 0x303018, 0x0C1830, 0x000006), + RENODX_CANVAS_GLYPH(0x000000, 0xFF3C66, 0x00663C, 0x000000), + RENODX_CANVAS_GLYPH(0x000000, 0x7E1818, 0x001818, 0x000000), + RENODX_CANVAS_GLYPH(0x000000, 0x000000, 0x1C0000, 0x00061C), + RENODX_CANVAS_GLYPH(0x000000, 0x7F0000, 0x000000, 0x000000), + RENODX_CANVAS_GLYPH(0x000000, 0x000000, 0x1C0000, 0x00001C), + RENODX_CANVAS_GLYPH(0x400000, 0x183060, 0x03060C, 0x000001), + RENODX_CANVAS_GLYPH(0x633E00, 0x6F7B73, 0x636367, 0x00003E), + RENODX_CANVAS_GLYPH(0x0C0800, 0x0C0C0F, 0x0C0C0C, 0x00003F), + RENODX_CANVAS_GLYPH(0x331E00, 0x183033, 0x33060C, 0x00003F), + RENODX_CANVAS_GLYPH(0x331E00, 0x1C3030, 0x333030, 0x00001E), + RENODX_CANVAS_GLYPH(0x383000, 0x33363C, 0x30307F, 0x000078), + RENODX_CANVAS_GLYPH(0x033F00, 0x1F0303, 0x333030, 0x00001E), + RENODX_CANVAS_GLYPH(0x061C00, 0x1F0303, 0x333333, 0x00001E), + RENODX_CANVAS_GLYPH(0x637F00, 0x306063, 0x0C0C18, 0x00000C), + RENODX_CANVAS_GLYPH(0x331E00, 0x1E3733, 0x33333B, 0x00001E), + RENODX_CANVAS_GLYPH(0x331E00, 0x3E3333, 0x0C1818, 0x00000E), + RENODX_CANVAS_GLYPH(0x000000, 0x001C1C, 0x1C1C00, 0x000000), + RENODX_CANVAS_GLYPH(0x000000, 0x001C1C, 0x1C1C00, 0x000C18), + RENODX_CANVAS_GLYPH(0x183000, 0x03060C, 0x180C06, 0x000030), + RENODX_CANVAS_GLYPH(0x000000, 0x007E00, 0x00007E, 0x000000), + RENODX_CANVAS_GLYPH(0x0C0600, 0x603018, 0x0C1830, 0x000006), + RENODX_CANVAS_GLYPH(0x331E00, 0x0C1830, 0x0C000C, 0x00000C), + RENODX_CANVAS_GLYPH(0x633E00, 0x7B7B63, 0x03037B, 0x00003E), + RENODX_CANVAS_GLYPH(0x1E0C00, 0x333333, 0x33333F, 0x000033), + RENODX_CANVAS_GLYPH(0x663F00, 0x3E6666, 0x666666, 0x00003F), + RENODX_CANVAS_GLYPH(0x663C00, 0x030363, 0x666303, 0x00003C), + RENODX_CANVAS_GLYPH(0x361F00, 0x666666, 0x366666, 0x00001F), + RENODX_CANVAS_GLYPH(0x467F00, 0x3E2606, 0x460626, 0x00007F), + RENODX_CANVAS_GLYPH(0x667F00, 0x3E2646, 0x060626, 0x00000F), + RENODX_CANVAS_GLYPH(0x663C00, 0x030363, 0x666373, 0x00007C), + RENODX_CANVAS_GLYPH(0x333300, 0x3F3333, 0x333333, 0x000033), + RENODX_CANVAS_GLYPH(0x0C1E00, 0x0C0C0C, 0x0C0C0C, 0x00001E), + RENODX_CANVAS_GLYPH(0x307800, 0x303030, 0x333333, 0x00001E), + RENODX_CANVAS_GLYPH(0x666700, 0x1E3636, 0x663636, 0x000067), + RENODX_CANVAS_GLYPH(0x060F00, 0x060606, 0x666646, 0x00007F), + RENODX_CANVAS_GLYPH(0x776300, 0x6B7F7F, 0x636363, 0x000063), + RENODX_CANVAS_GLYPH(0x636300, 0x7F6F67, 0x63737B, 0x000063), + RENODX_CANVAS_GLYPH(0x361C00, 0x636363, 0x366363, 0x00001C), + RENODX_CANVAS_GLYPH(0x663F00, 0x3E6666, 0x060606, 0x00000F), + RENODX_CANVAS_GLYPH(0x361C00, 0x636363, 0x3E7B73, 0x007830), + RENODX_CANVAS_GLYPH(0x663F00, 0x3E6666, 0x666636, 0x000067), + RENODX_CANVAS_GLYPH(0x331E00, 0x0E0333, 0x333318, 0x00001E), + RENODX_CANVAS_GLYPH(0x2D3F00, 0x0C0C0C, 0x0C0C0C, 0x00001E), + RENODX_CANVAS_GLYPH(0x333300, 0x333333, 0x333333, 0x00001E), + RENODX_CANVAS_GLYPH(0x333300, 0x333333, 0x1E3333, 0x00000C), + RENODX_CANVAS_GLYPH(0x636300, 0x6B6363, 0x36366B, 0x000036), + RENODX_CANVAS_GLYPH(0x333300, 0x0C1E33, 0x33331E, 0x000033), + RENODX_CANVAS_GLYPH(0x333300, 0x1E3333, 0x0C0C0C, 0x00001E), + RENODX_CANVAS_GLYPH(0x737F00, 0x0C1819, 0x634606, 0x00007F), + RENODX_CANVAS_GLYPH(0x0C3C00, 0x0C0C0C, 0x0C0C0C, 0x00003C), + RENODX_CANVAS_GLYPH(0x010000, 0x0C0603, 0x603018, 0x000040), + RENODX_CANVAS_GLYPH(0x303C00, 0x303030, 0x303030, 0x00003C), + RENODX_CANVAS_GLYPH(0x361C08, 0x000063, 0x000000, 0x000000), + RENODX_CANVAS_GLYPH(0x000000, 0x000000, 0x000000, 0x00FF00), + RENODX_CANVAS_GLYPH(0x0C0600, 0x00180C, 0x000000, 0x000000), + RENODX_CANVAS_GLYPH(0x000000, 0x301E00, 0x33333E, 0x00006E), + RENODX_CANVAS_GLYPH(0x060700, 0x663E06, 0x666666, 0x00003B), + RENODX_CANVAS_GLYPH(0x000000, 0x331E00, 0x330303, 0x00001E), + RENODX_CANVAS_GLYPH(0x303800, 0x333E30, 0x333333, 0x00006E), + RENODX_CANVAS_GLYPH(0x000000, 0x331E00, 0x33033F, 0x00001E), + RENODX_CANVAS_GLYPH(0x361C00, 0x1F0606, 0x060606, 0x00000F), + RENODX_CANVAS_GLYPH(0x000000, 0x336E00, 0x3E3333, 0x1E3330), + RENODX_CANVAS_GLYPH(0x060700, 0x6E3606, 0x666666, 0x000067), + RENODX_CANVAS_GLYPH(0x181800, 0x181E00, 0x181818, 0x00007E), + RENODX_CANVAS_GLYPH(0x303000, 0x303C00, 0x303030, 0x1E3333), + RENODX_CANVAS_GLYPH(0x060700, 0x366606, 0x66361E, 0x000067), + RENODX_CANVAS_GLYPH(0x181E00, 0x181818, 0x181818, 0x00007E), + RENODX_CANVAS_GLYPH(0x000000, 0x6B3F00, 0x6B6B6B, 0x000063), + RENODX_CANVAS_GLYPH(0x000000, 0x331F00, 0x333333, 0x000033), + RENODX_CANVAS_GLYPH(0x000000, 0x331E00, 0x333333, 0x00001E), + RENODX_CANVAS_GLYPH(0x000000, 0x663B00, 0x666666, 0x0F063E), + RENODX_CANVAS_GLYPH(0x000000, 0x336E00, 0x333333, 0x78303E), + RENODX_CANVAS_GLYPH(0x000000, 0x763700, 0x06066E, 0x00000F), + RENODX_CANVAS_GLYPH(0x000000, 0x331E00, 0x331806, 0x00001E), + RENODX_CANVAS_GLYPH(0x040000, 0x063F06, 0x360606, 0x00001C), + RENODX_CANVAS_GLYPH(0x000000, 0x333300, 0x333333, 0x00006E), + RENODX_CANVAS_GLYPH(0x000000, 0x333300, 0x1E3333, 0x00000C), + RENODX_CANVAS_GLYPH(0x000000, 0x636300, 0x366B6B, 0x000036), + RENODX_CANVAS_GLYPH(0x000000, 0x366300, 0x361C1C, 0x000063), + RENODX_CANVAS_GLYPH(0x000000, 0x666600, 0x3C6666, 0x0F1830), + RENODX_CANVAS_GLYPH(0x000000, 0x313F00, 0x230618, 0x00003F), + RENODX_CANVAS_GLYPH(0x0C3800, 0x03060C, 0x0C0C06, 0x000038), + RENODX_CANVAS_GLYPH(0x181800, 0x001818, 0x181818, 0x000018), + RENODX_CANVAS_GLYPH(0x0C0700, 0x30180C, 0x0C0C18, 0x000007), + RENODX_CANVAS_GLYPH(0x5BCE00, 0x000073, 0x000000, 0x000000)); + +int renodx_canvas_internal_Pow10(float exponent) { + if (exponent < 1.0) return 1; + if (exponent < 2.0) return 10; + if (exponent < 3.0) return 100; + if (exponent < 4.0) return 1000; + if (exponent < 5.0) return 10000; + if (exponent < 6.0) return 100000; + if (exponent < 7.0) return 1000000; + if (exponent < 8.0) return 10000000; + if (exponent < 9.0) return 100000000; + return 1000000000; +} + +float renodx_canvas_internal_Pow10f(float exponent) { + if (exponent < 1.0) return 1.0; + if (exponent < 2.0) return 10.0; + if (exponent < 3.0) return 100.0; + if (exponent < 4.0) return 1000.0; + if (exponent < 5.0) return 10000.0; + if (exponent < 6.0) return 100000.0; + if (exponent < 7.0) return 1000000.0; + if (exponent < 8.0) return 10000000.0; + if (exponent < 9.0) return 100000000.0; + return 1000000000.0; +} + +bool renodx_canvas_internal_TestGlyphPixel(uvec4 glyph, vec2 glyph_uv) { + vec2 glyph_pixel = floor(glyph_uv); + if (glyph_pixel.x < 0.0 || glyph_pixel.y < 0.0 || glyph_pixel.x >= 8.0 || glyph_pixel.y >= 12.0) return false; + + float lane_index = floor(glyph_pixel.y / 3.0); + float row_in_lane = glyph_pixel.y - lane_index * 3.0; + uint bit_shift = uint(fma(row_in_lane, 8.0, glyph_pixel.x)); + uint glyph_lane = glyph[int(lane_index)]; + return ((glyph_lane >> bit_shift) & 1u) != 0u; +} + +bool renodx_canvas_internal_BlinkPhase(float time) { + return fract(time * (renodx_canvas_internal_BLINK_RATE * 0.5)) < 0.5; +} + +uvec4 renodx_canvas_internal_ApplyTextMode(uvec4 glyph, int mode, bool blink_phase) { + if ((mode & renodx_canvas_MODE_UNDERLINE) != 0) { + glyph.w = (glyph.w & 0x00FFFF00u) | 0x000000FFu; + } + + bool invert = (mode & renodx_canvas_MODE_INVERT) != 0; + if ((mode & renodx_canvas_MODE_BLINVERT) != 0 && blink_phase) { + invert = !invert; + } + + if (invert) { + glyph = glyph ^ renodx_canvas_internal_GLYPH_MASK; + } + return glyph; +} + +uvec4 renodx_canvas_internal_DigitGlyph(int digit) { + if (digit >= 0 && digit <= 9) { + return renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[digit + 16]; + } + return renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; +} + +uvec4 renodx_canvas_internal_GlyphFromAscii(int ascii) { + if (ascii >= 32 && ascii <= 126) { + return renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[ascii - 32]; + } + return renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; +} + +bool renodx_canvas_internal_TestGlyphCoverage( + vec2 position, + uvec4 glyph, + vec2 origin, + vec2 glyph_size, + int mode, + float time) { + vec2 local = position - origin; + if (local.x < 0.0 || local.y < 0.0 || local.x >= glyph_size.x || local.y >= glyph_size.y) return false; + + vec2 sprite_uv = local * (renodx_canvas_internal_GLYPH_SIZE / glyph_size); + if (mode == renodx_canvas_MODE_NORMAL) { + return renodx_canvas_internal_TestGlyphPixel(glyph, sprite_uv); + } + + bool uses_blink_phase = (mode & (renodx_canvas_MODE_BLINK | renodx_canvas_MODE_BLINVERT)) != 0; + bool blink_hidden = (mode & renodx_canvas_MODE_BLINK) != 0; + bool blink_phase = uses_blink_phase ? renodx_canvas_internal_BlinkPhase(time) : false; + if (blink_hidden && blink_phase) return false; + + glyph = renodx_canvas_internal_ApplyTextMode(glyph, mode, blink_phase); + return renodx_canvas_internal_TestGlyphPixel(glyph, sprite_uv); +} + +bool renodx_canvas_internal_TestGlyphCoverage( + vec2 position, + int ascii, + vec2 origin, + vec2 glyph_size, + int mode, + float time) { + return renodx_canvas_internal_TestGlyphCoverage( + position, + renodx_canvas_internal_GlyphFromAscii(ascii), + origin, + glyph_size, + mode, + time); +} + +bool renodx_canvas_internal_TestGlyphCoverage(vec2 position, uvec4 glyph, vec2 origin, vec2 glyph_size) { + return renodx_canvas_internal_TestGlyphCoverage( + position, glyph, origin, glyph_size, renodx_canvas_MODE_NORMAL, 0.0); +} + +bool renodx_canvas_internal_TestGlyphCoverage(vec2 position, int ascii, vec2 origin, vec2 glyph_size) { + return renodx_canvas_internal_TestGlyphCoverage( + position, ascii, origin, glyph_size, renodx_canvas_MODE_NORMAL, 0.0); +} + +float renodx_canvas_internal_IntegerDigitCount(int value) { + if (value <= -1000000000 || value >= 1000000000) return 10.0; + if (value <= -100000000 || value >= 100000000) return 9.0; + if (value <= -10000000 || value >= 10000000) return 8.0; + if (value <= -1000000 || value >= 1000000) return 7.0; + if (value <= -100000 || value >= 100000) return 6.0; + if (value <= -10000 || value >= 10000) return 5.0; + if (value <= -1000 || value >= 1000) return 4.0; + if (value <= -100 || value >= 100) return 3.0; + if (value <= -10 || value >= 10) return 2.0; + return 1.0; +} + +float renodx_canvas_internal_IntegerDigitCount(float value) { + if (value <= -1000000000.0 || value >= 1000000000.0) return 10.0; + if (value <= -100000000.0 || value >= 100000000.0) return 9.0; + if (value <= -10000000.0 || value >= 10000000.0) return 8.0; + if (value <= -1000000.0 || value >= 1000000.0) return 7.0; + if (value <= -100000.0 || value >= 100000.0) return 6.0; + if (value <= -10000.0 || value >= 10000.0) return 5.0; + if (value <= -1000.0 || value >= 1000.0) return 4.0; + if (value <= -100.0 || value >= 100.0) return 3.0; + if (value <= -10.0 || value >= 10.0) return 2.0; + return 1.0; +} + +float renodx_canvas_internal_IntegerFieldGlyphCount(int value, float max_digits, bool reserve_sign) { + return max_digits + ((reserve_sign || value < 0) ? 1.0 : 0.0); +} + +float renodx_canvas_internal_FloatFieldGlyphCount(float digits, float decimals, bool reserve_sign, bool negative) { + float count = digits + (decimals > 0.0 ? 1.0 + decimals : 0.0); + if (reserve_sign || negative) count += 1.0; + return count; +} + +uvec4 renodx_canvas_internal_IntegerGlyphAt( + float index, + int value, + float digits, + bool leading_zeros, + bool reserve_sign) { + bool negative = value < 0; + float sign_width = (negative || reserve_sign) ? 1.0 : 0.0; + if (index < sign_width) { + return negative + ? renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[13] + : renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; + } + + float digit_index = index - sign_width; + int divisor = renodx_canvas_internal_Pow10(digits - 1.0 - digit_index); + int quotient = value / divisor; + int digit = quotient % 10; + if (digit < 0) digit = -digit; + + bool show_digit = leading_zeros || quotient != 0 || digit_index == digits - 1.0; + return show_digit + ? renodx_canvas_internal_DigitGlyph(digit) + : renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; +} + +uvec4 renodx_canvas_internal_FloatGlyphAt( + float index, + float integer_part, + float fractional_part, + float digits, + float frac_digits, + bool negative, + bool leading_zeros, + bool reserve_sign) { + float sign_width = (negative || reserve_sign) ? 1.0 : 0.0; + float dot_index = sign_width + digits; + if (index < sign_width) { + return negative + ? renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[13] + : renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; + } + + if (index < sign_width + digits) { + float digit_index = index - sign_width; + int divisor = renodx_canvas_internal_Pow10(digits - 1.0 - digit_index); + int integer_value = int(integer_part); + int digit = (integer_value / divisor) % 10; + bool show_digit = leading_zeros || integer_value >= divisor || digit_index == digits - 1.0; + return show_digit + ? renodx_canvas_internal_DigitGlyph(digit) + : renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; + } + + if (frac_digits > 0.0 && index == dot_index) { + return renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[14]; + } + + if (frac_digits > 0.0) { + float frac_index = index - dot_index - 1.0; + int divisor = renodx_canvas_internal_Pow10(frac_digits - 1.0 - frac_index); + int fractional_value = int(fractional_part); + int digit = (fractional_value / divisor) % 10; + return renodx_canvas_internal_DigitGlyph(digit); + } + return renodx_canvas_internal_GLYPHS_PRINTABLE_ASCII[0]; +} + +float renodx_canvas_internal_TextLength( + int a, int b, int c, int d, + int e, int f, int g, int h, + int i, int j, int k, int l, + int m, int n, int o, int p) { + if (a == 0) return 0.0; + if (b == 0) return 1.0; + if (c == 0) return 2.0; + if (d == 0) return 3.0; + if (e == 0) return 4.0; + if (f == 0) return 5.0; + if (g == 0) return 6.0; + if (h == 0) return 7.0; + if (i == 0) return 8.0; + if (j == 0) return 9.0; + if (k == 0) return 10.0; + if (l == 0) return 11.0; + if (m == 0) return 12.0; + if (n == 0) return 13.0; + if (o == 0) return 14.0; + if (p == 0) return 15.0; + return 16.0; +} + +int renodx_canvas_internal_TextAsciiAt( + float index, + int a, int b, int c, int d, + int e, int f, int g, int h, + int i, int j, int k, int l, + int m, int n, int o, int p) { + if (index < 1.0) return a; + if (index < 2.0) return b; + if (index < 3.0) return c; + if (index < 4.0) return d; + if (index < 5.0) return e; + if (index < 6.0) return f; + if (index < 7.0) return g; + if (index < 8.0) return h; + if (index < 9.0) return i; + if (index < 10.0) return j; + if (index < 11.0) return k; + if (index < 12.0) return l; + if (index < 13.0) return m; + if (index < 14.0) return n; + if (index < 15.0) return o; + return p; +} + +float renodx_canvas_internal_DecodeSRGB(float value) { + return value <= 0.04045 + ? value / 12.92 + : pow(fma(value, 1.0 / 1.055, 0.055 / 1.055), 2.4); +} + +vec3 renodx_canvas_internal_ColorFromRGB8(int rgb) { + uint rgb8 = uint(rgb); + vec3 srgb = vec3( + float((rgb8 >> 16u) & 255u), + float((rgb8 >> 8u) & 255u), + float(rgb8 & 255u)) + * (1.0 / 255.0); + return vec3( + renodx_canvas_internal_DecodeSRGB(srgb.r), + renodx_canvas_internal_DecodeSRGB(srgb.g), + renodx_canvas_internal_DecodeSRGB(srgb.b)); +} + +bool renodx_canvas_TestRectCoverage(vec2 position, vec2 min_corner, vec2 max_corner) { + return position.x >= min_corner.x && position.y >= min_corner.y + && position.x <= max_corner.x && position.y <= max_corner.y; +} + +float renodx_canvas_ComputeRectMask(vec2 position, vec2 min_corner, vec2 max_corner) { + return renodx_canvas_TestRectCoverage(position, min_corner, max_corner) ? 1.0 : 0.0; +} + +struct renodx_canvas_Context { + vec2 position; + vec2 origin; + vec2 cursor; + vec2 glyph_size; + float line_height; + int mode; + float time; + vec3 color; + float alpha_scale; + float intensity_scale; + vec3 output_color; + float output_alpha; +}; + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, + vec2 origin, + vec2 glyph_size, + vec3 output_color, + float output_alpha, + vec3 color, + float alpha_scale, + float intensity_scale, + int mode, + float time, + float line_height) { + renodx_canvas_Context context; + context.position = position; + context.origin = origin; + context.cursor = origin; + context.glyph_size = glyph_size; + context.line_height = line_height; + context.mode = mode; + context.time = time; + context.color = color; + context.alpha_scale = alpha_scale; + context.intensity_scale = intensity_scale; + context.output_color = output_color; + context.output_alpha = output_alpha; + return context; +} + +renodx_canvas_Context renodx_canvas_CreateContext() { + return renodx_canvas_CreateContext( + vec2(0.0), vec2(0.0), vec2(8.0, 12.0), vec3(0.0), 0.0, + vec3(1.0), 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext(vec2 position) { + return renodx_canvas_CreateContext( + position, vec2(0.0), vec2(8.0, 12.0), vec3(0.0), 0.0, + vec3(1.0), 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext(vec2 position, vec2 origin) { + return renodx_canvas_CreateContext( + position, origin, vec2(8.0, 12.0), vec3(0.0), 0.0, + vec3(1.0), 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext(vec2 position, vec2 origin, vec2 glyph_size) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, vec3(0.0), 0.0, + vec3(1.0), 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, vec2 origin, vec2 glyph_size, vec3 output_color) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, 0.0, + vec3(1.0), 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, vec2 origin, vec2 glyph_size, vec3 output_color, float output_alpha) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, output_alpha, + vec3(1.0), 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, + vec2 origin, + vec2 glyph_size, + vec3 output_color, + float output_alpha, + vec3 color) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, output_alpha, + color, 1.0, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, + vec2 origin, + vec2 glyph_size, + vec3 output_color, + float output_alpha, + vec3 color, + float alpha_scale) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, output_alpha, + color, alpha_scale, 1.0, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, + vec2 origin, + vec2 glyph_size, + vec3 output_color, + float output_alpha, + vec3 color, + float alpha_scale, + float intensity_scale) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, output_alpha, + color, alpha_scale, intensity_scale, renodx_canvas_MODE_NORMAL, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, + vec2 origin, + vec2 glyph_size, + vec3 output_color, + float output_alpha, + vec3 color, + float alpha_scale, + float intensity_scale, + int mode) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, output_alpha, + color, alpha_scale, intensity_scale, mode, 0.0, 1.0); +} + +renodx_canvas_Context renodx_canvas_CreateContext( + vec2 position, + vec2 origin, + vec2 glyph_size, + vec3 output_color, + float output_alpha, + vec3 color, + float alpha_scale, + float intensity_scale, + int mode, + float time) { + return renodx_canvas_CreateContext( + position, origin, glyph_size, output_color, output_alpha, + color, alpha_scale, intensity_scale, mode, time, 1.0); +} + +vec4 renodx_canvas_GetOutput(renodx_canvas_Context context) { + return vec4(context.output_color, context.output_alpha); +} + +void renodx_canvas_SetPosition(inout renodx_canvas_Context context, vec2 position) { + context.position = position; +} + +void renodx_canvas_SetCursor(inout renodx_canvas_Context context, vec2 cursor) { + context.cursor = cursor; +} + +void renodx_canvas_ResetCursor(inout renodx_canvas_Context context) { + context.cursor = context.origin; +} + +void renodx_canvas_AdvanceCursor(inout renodx_canvas_Context context, float glyph_count) { + context.cursor.x = fma(glyph_count, context.glyph_size.x, context.cursor.x); +} + +void renodx_canvas_AdvanceCursor(inout renodx_canvas_Context context) { + renodx_canvas_AdvanceCursor(context, 1.0); +} + +void renodx_canvas_SetLineHeight(inout renodx_canvas_Context context, float line_height) { + context.line_height = line_height; +} + +void renodx_canvas_SetTime(inout renodx_canvas_Context context, float time) { + context.time = time; +} + +void renodx_canvas_InsertSpaces(inout renodx_canvas_Context context, float count) { + renodx_canvas_AdvanceCursor(context, count); +} + +void renodx_canvas_InsertSpaces(inout renodx_canvas_Context context) { + renodx_canvas_InsertSpaces(context, 1.0); +} + +void renodx_canvas_InsertSpace(inout renodx_canvas_Context context) { + renodx_canvas_InsertSpaces(context, 1.0); +} + +void renodx_canvas_NewLine(inout renodx_canvas_Context context, float line_count) { + context.cursor = vec2( + context.origin.x, + fma(line_count * context.line_height, context.glyph_size.y, context.cursor.y)); +} + +void renodx_canvas_NewLine(inout renodx_canvas_Context context) { + renodx_canvas_NewLine(context, 1.0); +} + +void renodx_canvas_SetMode(inout renodx_canvas_Context context, int mode) { + context.mode = mode; +} + +void renodx_canvas_SetColor( + inout renodx_canvas_Context context, + vec3 color, + float alpha_scale, + float intensity_scale) { + context.color = color; + context.alpha_scale = alpha_scale; + context.intensity_scale = intensity_scale; +} + +void renodx_canvas_SetColor(inout renodx_canvas_Context context, vec3 color, float alpha_scale) { + renodx_canvas_SetColor(context, color, alpha_scale, 1.0); +} + +void renodx_canvas_SetColor(inout renodx_canvas_Context context, vec3 color) { + renodx_canvas_SetColor(context, color, 1.0, 1.0); +} + +// Literal 0xRRGGBB inputs are decoded from sRGB. +void renodx_canvas_SetColor( + inout renodx_canvas_Context context, + int srgb, + float alpha_scale, + float intensity_scale) { + renodx_canvas_SetColor( + context, + renodx_canvas_internal_ColorFromRGB8(srgb), + alpha_scale, + intensity_scale); +} + +void renodx_canvas_SetColor(inout renodx_canvas_Context context, int srgb, float alpha_scale) { + renodx_canvas_SetColor(context, srgb, alpha_scale, 1.0); +} + +void renodx_canvas_SetColor(inout renodx_canvas_Context context, int srgb) { + renodx_canvas_SetColor(context, srgb, 1.0, 1.0); +} + +void renodx_canvas_SetAlphaScale(inout renodx_canvas_Context context, float alpha_scale) { + context.alpha_scale = alpha_scale; +} + +void renodx_canvas_SetIntensityScale(inout renodx_canvas_Context context, float intensity_scale) { + context.intensity_scale = intensity_scale; +} + +void renodx_canvas_EnableMode(inout renodx_canvas_Context context, int flag) { + context.mode |= flag; +} + +void renodx_canvas_DisableMode(inout renodx_canvas_Context context, int flag) { + context.mode &= ~flag; +} + +void renodx_canvas_SetUnderline(inout renodx_canvas_Context context, bool enabled) { + if (enabled) { + renodx_canvas_EnableMode(context, renodx_canvas_MODE_UNDERLINE); + } else { + renodx_canvas_DisableMode(context, renodx_canvas_MODE_UNDERLINE); + } +} + +void renodx_canvas_SetUnderline(inout renodx_canvas_Context context) { + renodx_canvas_SetUnderline(context, true); +} + +void renodx_canvas_RemoveUnderline(inout renodx_canvas_Context context) { + renodx_canvas_SetUnderline(context, false); +} + +void renodx_canvas_SetInvert(inout renodx_canvas_Context context, bool enabled) { + if (enabled) { + renodx_canvas_EnableMode(context, renodx_canvas_MODE_INVERT); + } else { + renodx_canvas_DisableMode(context, renodx_canvas_MODE_INVERT); + } +} + +void renodx_canvas_SetInvert(inout renodx_canvas_Context context) { + renodx_canvas_SetInvert(context, true); +} + +void renodx_canvas_RemoveInvert(inout renodx_canvas_Context context) { + renodx_canvas_SetInvert(context, false); +} + +void renodx_canvas_SetBlink(inout renodx_canvas_Context context, bool enabled) { + if (enabled) { + renodx_canvas_EnableMode(context, renodx_canvas_MODE_BLINK); + } else { + renodx_canvas_DisableMode(context, renodx_canvas_MODE_BLINK); + } +} + +void renodx_canvas_SetBlink(inout renodx_canvas_Context context) { + renodx_canvas_SetBlink(context, true); +} + +void renodx_canvas_RemoveBlink(inout renodx_canvas_Context context) { + renodx_canvas_SetBlink(context, false); +} + +void renodx_canvas_SetBlinkInvert(inout renodx_canvas_Context context, bool enabled) { + if (enabled) { + renodx_canvas_EnableMode(context, renodx_canvas_MODE_BLINVERT); + } else { + renodx_canvas_DisableMode(context, renodx_canvas_MODE_BLINVERT); + } +} + +void renodx_canvas_SetBlinkInvert(inout renodx_canvas_Context context) { + renodx_canvas_SetBlinkInvert(context, true); +} + +void renodx_canvas_RemoveBlinkInvert(inout renodx_canvas_Context context) { + renodx_canvas_SetBlinkInvert(context, false); +} + +void renodx_canvas_CompositeMask(inout renodx_canvas_Context context, float mask) { + float alpha = clamp(mask * context.intensity_scale, 0.0, 1.0) * context.alpha_scale; + context.output_color = mix(context.output_color, context.color, alpha); + context.output_alpha = max(context.output_alpha, alpha); +} + +void renodx_canvas_CompositeCoverage(inout renodx_canvas_Context context) { + float alpha = clamp(context.intensity_scale, 0.0, 1.0) * context.alpha_scale; + context.output_color = mix(context.output_color, context.color, alpha); + context.output_alpha = max(context.output_alpha, alpha); +} + +void renodx_canvas_DrawGlyph( + inout renodx_canvas_Context context, + uvec4 glyph, + vec2 origin) { + bool has_coverage = context.mode == renodx_canvas_MODE_NORMAL + ? renodx_canvas_internal_TestGlyphCoverage( + context.position, glyph, origin, context.glyph_size) + : renodx_canvas_internal_TestGlyphCoverage( + context.position, glyph, origin, context.glyph_size, + context.mode, context.time); + if (has_coverage) renodx_canvas_CompositeCoverage(context); +} + +void renodx_canvas_DrawGlyph( + inout renodx_canvas_Context context, + int ascii, + vec2 origin) { + bool has_coverage = context.mode == renodx_canvas_MODE_NORMAL + ? renodx_canvas_internal_TestGlyphCoverage( + context.position, ascii, origin, context.glyph_size) + : renodx_canvas_internal_TestGlyphCoverage( + context.position, ascii, origin, context.glyph_size, + context.mode, context.time); + if (has_coverage) renodx_canvas_CompositeCoverage(context); +} + +void renodx_canvas_FillRect( + inout renodx_canvas_Context context, + vec2 min_corner, + vec2 max_corner) { + if (renodx_canvas_TestRectCoverage(context.position, min_corner, max_corner)) { + renodx_canvas_CompositeMask(context, 1.0); + } +} + +void renodx_canvas_internal_DrawTextBody( + inout renodx_canvas_Context context, + int count, + int a, int b, int c, int d, + int e, int f, int g, int h, + int i, int j, int k, int l, + int m, int n, int o, int p) { + vec2 origin = context.cursor; + renodx_canvas_AdvanceCursor(context, float(count)); + + vec2 local = context.position - origin; + if (local.x < 0.0 || local.y < 0.0 || local.y >= context.glyph_size.y) return; + + float glyph_index = floor(local.x / context.glyph_size.x); + if (glyph_index >= float(count)) return; + + int ascii = renodx_canvas_internal_TextAsciiAt( + glyph_index, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p); + vec2 glyph_origin = origin + vec2(glyph_index * context.glyph_size.x, 0.0); + renodx_canvas_DrawGlyph(context, renodx_canvas_internal_GlyphFromAscii(ascii), glyph_origin); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a) { + renodx_canvas_internal_DrawTextBody(context, 1, a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b) { + renodx_canvas_internal_DrawTextBody(context, 2, a, b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b, int c) { + renodx_canvas_internal_DrawTextBody(context, 3, a, b, c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b, int c, int d) { + renodx_canvas_internal_DrawTextBody(context, 4, a, b, c, d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b, int c, int d, int e) { + renodx_canvas_internal_DrawTextBody(context, 5, a, b, c, d, e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b, int c, int d, int e, int f) { + renodx_canvas_internal_DrawTextBody(context, 6, a, b, c, d, e, f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b, int c, int d, int e, int f, int g) { + renodx_canvas_internal_DrawTextBody(context, 7, a, b, c, d, e, f, g, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText(inout renodx_canvas_Context context, int a, int b, int c, int d, int e, int f, int g, int h) { + renodx_canvas_internal_DrawTextBody(context, 8, a, b, c, d, e, f, g, h, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i) { + renodx_canvas_internal_DrawTextBody(context, 9, a, b, c, d, e, f, g, h, i, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { + renodx_canvas_internal_DrawTextBody(context, 10, a, b, c, d, e, f, g, h, i, j, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k) { + renodx_canvas_internal_DrawTextBody(context, 11, a, b, c, d, e, f, g, h, i, j, k, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k, int l) { + renodx_canvas_internal_DrawTextBody(context, 12, a, b, c, d, e, f, g, h, i, j, k, l, 0, 0, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m) { + renodx_canvas_internal_DrawTextBody(context, 13, a, b, c, d, e, f, g, h, i, j, k, l, m, 0, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, + int h, int i, int j, int k, int l, int m, int n) { + renodx_canvas_internal_DrawTextBody(context, 14, a, b, c, d, e, f, g, h, i, j, k, l, m, n, 0, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m, int n, int o) { + renodx_canvas_internal_DrawTextBody(context, 15, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, 0); +} + +void renodx_canvas_DrawText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m, int n, int o, int p) { + renodx_canvas_internal_DrawTextBody(context, 16, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, + int e, int f, int g, int h, + int i, int j, int k, int l, + int m, int n, int o, int p) { + float count = renodx_canvas_internal_TextLength( + a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p); + if (count <= 0.0) return; + + vec2 origin = context.cursor; + renodx_canvas_AdvanceCursor(context, count); + + vec2 local = context.position - origin; + if (local.x < 0.0 || local.y < 0.0 || local.y >= context.glyph_size.y) return; + + float glyph_index = floor(local.x / context.glyph_size.x); + if (glyph_index >= count) return; + + int ascii = renodx_canvas_internal_TextAsciiAt( + glyph_index, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p); + vec2 glyph_origin = origin + vec2(glyph_index * context.glyph_size.x, 0.0); + renodx_canvas_DrawGlyph(context, ascii, glyph_origin); +} + +void renodx_canvas_DrawDynamicText(inout renodx_canvas_Context context, int a) { + renodx_canvas_DrawDynamicText(context, a, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText(inout renodx_canvas_Context context, int a, int b) { + renodx_canvas_DrawDynamicText(context, a, b, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText(inout renodx_canvas_Context context, int a, int b, int c) { + renodx_canvas_DrawDynamicText(context, a, b, c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText(inout renodx_canvas_Context context, int a, int b, int c, int d) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, 0, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, 0, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, 0, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i, int j) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, j, 0, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, int i, int j, int k) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, j, k, 0, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, + int g, int h, int i, int j, int k, int l) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, j, k, l, 0, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, + int h, int i, int j, int k, int l, int m) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, j, k, l, m, 0, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, + int h, int i, int j, int k, int l, int m, int n) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, j, k, l, m, n, 0, 0); +} + +void renodx_canvas_DrawDynamicText( + inout renodx_canvas_Context context, + int a, int b, int c, int d, int e, int f, int g, int h, + int i, int j, int k, int l, int m, int n, int o) { + renodx_canvas_DrawDynamicText(context, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, 0); +} + +void renodx_canvas_DrawInteger( + inout renodx_canvas_Context context, + int value, + float max_digits, + bool leading_zeros, + bool reserve_sign) { + float digits = max_digits > 0.0 + ? max_digits + : renodx_canvas_internal_IntegerDigitCount(value); + vec2 origin = context.cursor; + float total_digits = renodx_canvas_internal_IntegerFieldGlyphCount( + value, digits, reserve_sign); + renodx_canvas_AdvanceCursor(context, total_digits); + + vec2 local = context.position - origin; + if (local.x >= 0.0 && local.y >= 0.0 && local.y < context.glyph_size.y) { + float glyph_index = floor(local.x / context.glyph_size.x); + if (glyph_index < total_digits) { + vec2 glyph_origin = origin + vec2(glyph_index * context.glyph_size.x, 0.0); + uvec4 glyph = renodx_canvas_internal_IntegerGlyphAt( + glyph_index, value, digits, leading_zeros, reserve_sign); + if (any(notEqual(glyph, uvec4(0u)))) { + renodx_canvas_DrawGlyph(context, glyph, glyph_origin); + } + } + } +} + +void renodx_canvas_DrawInteger(inout renodx_canvas_Context context, int value) { + renodx_canvas_DrawInteger(context, value, 0.0, false, false); +} + +void renodx_canvas_DrawInteger( + inout renodx_canvas_Context context, + int value, + float max_digits) { + renodx_canvas_DrawInteger(context, value, max_digits, false, false); +} + +void renodx_canvas_DrawInteger( + inout renodx_canvas_Context context, + int value, + float max_digits, + bool leading_zeros) { + renodx_canvas_DrawInteger(context, value, max_digits, leading_zeros, false); +} + +void renodx_canvas_DrawFloat( + inout renodx_canvas_Context context, + float value, + float max_digits, + float decimals, + bool leading_zeros, + bool reserve_sign) { + bool negative = value < 0.0; + float expected_digits = max_digits > 0.0 ? max_digits : 1.0; + + if (isnan(value)) { + float total_digits = renodx_canvas_internal_FloatFieldGlyphCount( + expected_digits, decimals, reserve_sign, false); + if (total_digits < 3.0) total_digits = 3.0; + float pad_digits = total_digits - 3.0; + if (pad_digits > 0.0) { + if (leading_zeros) { + renodx_canvas_DrawInteger(context, 0, pad_digits, true); + } else { + renodx_canvas_InsertSpaces(context, pad_digits); + } + } + renodx_canvas_DrawText(context, 78, 97, 78); // NaN + return; + } + + if (isinf(value)) { + float total_digits = renodx_canvas_internal_FloatFieldGlyphCount( + expected_digits, decimals, reserve_sign, negative); + float minimum_digits = negative ? 4.0 : 3.0; + if (total_digits < minimum_digits) total_digits = minimum_digits; + + if (negative) { + renodx_canvas_DrawText(context, 45); // '-' + float pad_digits = total_digits - 4.0; + if (pad_digits > 0.0) { + if (leading_zeros) { + renodx_canvas_DrawInteger(context, 0, pad_digits, true); + } else { + renodx_canvas_InsertSpaces(context, pad_digits); + } + } + } else { + float pad_digits = total_digits - 3.0; + if (pad_digits > 0.0) { + if (leading_zeros) { + renodx_canvas_DrawInteger(context, 0, pad_digits, true); + } else { + renodx_canvas_InsertSpaces(context, pad_digits); + } + } + } + renodx_canvas_DrawText(context, 73, 110, 102); // Inf + return; + } + + float scale = renodx_canvas_internal_Pow10f(decimals); + float magnitude = negative ? -value : value; + float integer_part = trunc(magnitude); + float fractional_part = roundEven(fract(magnitude) * scale); + if (fractional_part >= scale) { + integer_part += 1.0; + fractional_part -= scale; + } + + float digits = max_digits > 0.0 + ? max_digits + : renodx_canvas_internal_IntegerDigitCount(integer_part); + vec2 origin = context.cursor; + float total_digits = renodx_canvas_internal_FloatFieldGlyphCount( + digits, decimals, reserve_sign, negative); + renodx_canvas_AdvanceCursor(context, total_digits); + + vec2 local = context.position - origin; + if (local.x >= 0.0 && local.y >= 0.0 && local.y < context.glyph_size.y) { + float glyph_index = floor(local.x / context.glyph_size.x); + if (glyph_index < total_digits) { + vec2 glyph_origin = origin + vec2(glyph_index * context.glyph_size.x, 0.0); + uvec4 glyph = renodx_canvas_internal_FloatGlyphAt( + glyph_index, + integer_part, + fractional_part, + digits, + decimals, + negative, + leading_zeros, + reserve_sign); + if (any(notEqual(glyph, uvec4(0u)))) { + renodx_canvas_DrawGlyph(context, glyph, glyph_origin); + } + } + } +} + +void renodx_canvas_DrawFloat(inout renodx_canvas_Context context, float value) { + renodx_canvas_DrawFloat(context, value, 0.0, 2.0, false, false); +} + +void renodx_canvas_DrawFloat( + inout renodx_canvas_Context context, + float value, + float max_digits) { + renodx_canvas_DrawFloat(context, value, max_digits, 2.0, false, false); +} + +void renodx_canvas_DrawFloat( + inout renodx_canvas_Context context, + float value, + float max_digits, + float decimals) { + renodx_canvas_DrawFloat(context, value, max_digits, decimals, false, false); +} + +void renodx_canvas_DrawFloat( + inout renodx_canvas_Context context, + float value, + float max_digits, + float decimals, + bool leading_zeros) { + renodx_canvas_DrawFloat(context, value, max_digits, decimals, leading_zeros, false); +} + +#undef RENODX_CANVAS_GLYPH + +#endif // SRC_GAMES_RDR2VK_CANVAS_GLSL_ diff --git a/src/games/rdr2vk/common.glsl b/src/games/rdr2vk/common.glsl new file mode 100644 index 000000000..21528fbb9 --- /dev/null +++ b/src/games/rdr2vk/common.glsl @@ -0,0 +1,181 @@ +#include "./perceptual_color.glsl" +#include "./shared.h" + +// START INCLUDES +vec3 EncodeRDR2Gamma(vec3 color_linear) { + float curve_gamma = 2.2; + float curve_toe_threshold = 0.0031308; + float curve_power = 1.0 / curve_gamma; + float curve_offset = 0.055 * (curve_gamma - 1.0) / (2.4 - 1.0); // Observed: 0.0471429 + float curve_scale = 1.0 + curve_offset; // Observed: 1.0471429 + float curve_toe_slope = (pow(curve_toe_threshold, curve_power) * curve_scale - curve_offset) / curve_toe_threshold; // Observed: 9.2649536 + + return mix( + (pow(color_linear, vec3(curve_power)) * curve_scale) - vec3(curve_offset), + color_linear * curve_toe_slope, + lessThan(color_linear, vec3(curve_toe_threshold))); +} + +vec3 DecodeRDR2Gamma(vec3 color_encoded) { + float curve_gamma = 2.2; + float curve_toe_threshold = 0.0031308; + float curve_power = 1.0 / curve_gamma; + float curve_offset = 0.055 * (curve_gamma - 1.0) / (2.4 - 1.0); + float curve_scale = 1.0 + curve_offset; + float curve_toe_slope = (pow(curve_toe_threshold, curve_power) * curve_scale - curve_offset) / curve_toe_threshold; + float encoded_toe_threshold = curve_toe_threshold * curve_toe_slope; // Approximately 0.0290067 + + return mix( + pow((color_encoded + vec3(curve_offset)) / curve_scale, vec3(curve_gamma)), + color_encoded / curve_toe_slope, + lessThan(color_encoded, vec3(encoded_toe_threshold))); +} + +// --- sRGB ENCODING --- +float EncodeSRGB(float x) { + return mix( + x * 12.92, + 1.055 * pow(x, 1.0 / 2.4) - 0.055, + step(0.0031308, x)); +} + +vec3 EncodeSRGB(vec3 x) { + return mix( + x * 12.92, + 1.055 * pow(x, vec3(1.0 / 2.4)) - 0.055, + step(vec3(0.0031308), x)); +} + +// --- sRGB DECODING --- +float DecodeSRGB(float x) { + return mix( + x / 12.92, + pow((x + 0.055) / 1.055, 2.4), + step(0.04045, x)); +} + +vec3 DecodeSRGB(vec3 x) { + return mix( + x / 12.92, + pow((x + 0.055) / 1.055, vec3(2.4)), + step(vec3(0.04045), x)); +} + +// --- GAMMA ENCODING --- +float EncodeGamma(float x, float gamma) { + return pow(x, 1.0 / gamma); +} + +vec3 EncodeGamma(vec3 x, float gamma) { + return pow(x, vec3(1.0 / gamma)); +} + +// --- GAMMA DECODING --- +float DecodeGamma(float x, float gamma) { + return pow(x, gamma); +} + +vec3 DecodeGamma(vec3 x, float gamma) { + return pow(x, vec3(gamma)); +} + +// Fix or undo gamma mismatch by converting between sRGB and gamma 2.2 +float CorrectGammaMismatch(float x, bool inverse) { + return inverse + ? DecodeSRGB(EncodeGamma(x, 2.2)) // undo fix + : DecodeGamma(EncodeSRGB(x), 2.2); // apply fix +} + +vec3 CorrectGammaMismatch(vec3 x, bool inverse) { + vec3 s = sign(x); + vec3 a = abs(x); + + vec3 result = inverse + ? DecodeSRGB(EncodeGamma(a, 2.2)) + : DecodeGamma(EncodeSRGB(a), 2.2); + + return s * result; +} + +vec3 GammaSafe(vec3 x) { + if (RENODX_SDR_EOTF_EMULATION != 0.f && RENODX_TONE_MAP_TYPE != 1.f) { + return CorrectGammaMismatch(x, false); + } else { + return x; + } +} + +vec3 GammaSafe(vec3 x, bool inverse) { + if (RENODX_SDR_EOTF_EMULATION != 0.f && RENODX_TONE_MAP_TYPE != 1.f) { + return CorrectGammaMismatch(x, inverse); + } else { + return x; + } +} + +const mat3 BT709_TO_BT2020_MAT = mat3( + vec3(0.6274039149284363, 0.06909728795289993, 0.0163914393633604), + vec3(0.3292830288410187, 0.9195404052734375, 0.08801330626010895), + vec3(0.04331306740641594, 0.01136231515556574, 0.8955952525138855)); + +const mat3 BT2020_TO_BT709_MAT = mat3( + vec3(1.6604909896850586, -0.12455047667026520, -0.01815076358616352), + vec3(-0.5876411199569702, 1.1328998804092407, -0.10057889670133591), + vec3(-0.07284986227750778, -0.00834942236542702, 1.1187297105789185)); + +vec3 BT2020FromBT709(vec3 bt709) { + return BT709_TO_BT2020_MAT * bt709; +} + +vec3 BT709FromBT2020(vec3 bt2020) { + return BT2020_TO_BT709_MAT * bt2020; +} + +vec3 EncodePQ(vec3 color, float scaling) { + float M1 = 2610.f / 16384.f; // 0.1593017578125f; + float M2 = 128.f * (2523.f / 4096.f); // 78.84375f; + float C1 = 3424.f / 4096.f; // 0.8359375f; + float C2 = 32.f * (2413.f / 4096.f); // 18.8515625f; + float C3 = 32.f * (2392.f / 4096.f); // 18.6875f; + color *= (scaling / 10000.f); + vec3 y_m1 = pow(color, vec3(M1)); + return pow((vec3(C1) + vec3(C2) * y_m1) / (1.f + vec3(C3) * y_m1), vec3(M2)); +} +vec3 EncodePQ(vec3 color) { + return EncodePQ(color, 10000.f); +} + +vec3 DecodePQ(vec3 in_color, float scaling) { + float M1 = 2610.f / 16384.f; // 0.1593017578125f; + float M2 = 128.f * (2523.f / 4096.f); // 78.84375f; + float C1 = 3424.f / 4096.f; // 0.8359375f; + float C2 = 32.f * (2413.f / 4096.f); // 18.8515625f; + float C3 = 32.f * (2392.f / 4096.f); // 18.6875f; + + vec3 e_m12 = pow(in_color, 1.f / vec3(M2)); + vec3 out_color = pow(max(e_m12 - vec3(C1), 0) / (vec3(C2) - vec3(C3) * e_m12), + 1.f / vec3(M1)); + return out_color * (10000.f / scaling); +} +vec3 DecodePQ(vec3 color) { + return DecodePQ(color, 10000.f); +} + +// Safe divide (float & vec2 versions) +float DivideSafe(float a, float b, float fallback) { + return (b == 0.0) ? fallback : a / b; +} +float DivideSafe(float a, float b) { + return DivideSafe(a, b, 3.4028235e38); +} +vec2 DivideSafe(vec2 a, vec2 b, vec2 fallback) { + return vec2(DivideSafe(a.x, b.x, fallback.x), DivideSafe(a.y, b.y, fallback.y)); +} +vec2 DivideSafe(vec2 a, vec2 b) { + return DivideSafe(a, b, vec2(3.4028235e38)); +} +vec3 DivideSafe(vec3 a, vec3 b, vec3 fallback) { + return vec3(DivideSafe(a.x, b.x, fallback.x), DivideSafe(a.y, b.y, fallback.y), DivideSafe(a.z, b.z, fallback.z)); +} + +// END INCLUDES diff --git a/src/games/rdr2vk/metadata.json b/src/games/rdr2vk/metadata.json new file mode 100644 index 000000000..8a3f0d18f --- /dev/null +++ b/src/games/rdr2vk/metadata.json @@ -0,0 +1,28 @@ +{ + "$schema": "https://cdn.jsdelivr.net/gh/clshortfuse/renodx/renodx-metadata-schema.json", + "id": "rdr2vk", + "title": "Red Dead Redemption 2", + "variant": "Vulkan", + "maintainers": [ + "Musa" + ], + "summary": "Adds configurable HDR tone mapping and color grading to Red Dead Redemption 2's Vulkan renderer.", + "tags": [ + "HDR", + "Vulkan" + ], + "status": "stable", + "notes": [ + "Requires Vulkan, Exclusive Fullscreen, and HDR enabled in game." + ], + "deploy": { + "game_exe": "RDR2.exe", + "process_name": "RDR2.exe", + "api": "vulkan", + "steam_appid": 1174180, + "architecture": [ + "x64" + ], + "platform": "steam" + } +} \ No newline at end of file diff --git a/src/games/rdr2vk/output/0x14BF23D4.frag.glsl b/src/games/rdr2vk/output/0x14BF23D4.frag.glsl new file mode 100644 index 000000000..296b4e62d --- /dev/null +++ b/src/games/rdr2vk/output/0x14BF23D4.frag.glsl @@ -0,0 +1,152 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _11 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _83; + +layout(set = 0, binding = 96, scalar) readonly buffer _10_12 { + _11 _m0[]; +} +_12; + +layout(set = 0, binding = 23, std140) uniform _15_16 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_16; + +layout(set = 1, binding = 22, std140) uniform _17_18 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_18; + +layout(set = 1, binding = 34) uniform sampler _8; +layout(set = 1, binding = 36) uniform sampler _9; +layout(set = 0, binding = 131) uniform texture3D _19; +layout(set = 1, binding = 135) uniform texture2D _20; + +layout(location = 0) in vec4 _4; +layout(location = 1) in vec2 _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _92 = (_4 * _18._m5) + _18._m4; + _92.w = _92.w * texture(sampler2D(_20, _9), _5).x; + vec4 _113; + if (floatBitsToInt(_18._m10) != 0) { + vec4 _111 = textureLod(sampler3D(_19, _8), _92.xyz, 0.0); + _113 = vec4(_111.x, _111.y, _111.z, _92.w); + } else { + _113 = _92; + } + vec4 _163; + if (floatBitsToInt(_18._m7) != 0) { +#if 1 + _113.rgb = GammaSafe(_113.rgb); +#endif + + vec3 _125 = _113.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _143; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _143 = PQEncodeUI(_125); + } else { + float _136 = pow(abs((_125.x * _16._m0) / _16._m15), 0.1593017578125); + _143.x = pow((0.8359375 + (18.8515625 * _136)) / (1.0 + (18.6875 * _136)), 78.84375); + float _145 = pow(abs((_125.y * _16._m0) / _16._m15), 0.1593017578125); + _143.y = pow((0.8359375 + (18.8515625 * _145)) / (1.0 + (18.6875 * _145)), 78.84375); + float _154 = pow(abs((_125.z * _16._m0) / _16._m15), 0.1593017578125); + _143.z = pow((0.8359375 + (18.8515625 * _154)) / (1.0 + (18.6875 * _154)), 78.84375); + } +#else + float _136 = pow(abs((_125.x * _16._m0) / _16._m15), 0.1593017578125); + vec3 _143; + _143.x = pow((0.8359375 + (18.8515625 * _136)) / (1.0 + (18.6875 * _136)), 78.84375); + float _145 = pow(abs((_125.y * _16._m0) / _16._m15), 0.1593017578125); + _143.y = pow((0.8359375 + (18.8515625 * _145)) / (1.0 + (18.6875 * _145)), 78.84375); + float _154 = pow(abs((_125.z * _16._m0) / _16._m15), 0.1593017578125); + _143.z = pow((0.8359375 + (18.8515625 * _154)) / (1.0 + (18.6875 * _154)), 78.84375); +#endif + _163 = vec4(_143.x, _143.y, _143.z, _113.w); + } else { + _163 = _113; + } + vec3 _171 = mix(_163.xyz * _163.www, _163.xyz, bvec3(_18._m6 == 0.0)); + vec4 _172 = vec4(_171.x, _171.y, _171.z, _163.w); + float _176 = _12._m0[0u]._m0.w * _163.w; + _172.z = (_12._m0[0u]._m0.w != 1.0) ? (_176 * _176) : _171.z; + float _185 = _163.w * _12._m0[0u]._m0.x; + _172.w = _185; + vec4 _215; + if (floatBitsToInt(_18._m11) != 0) { + vec4 _201; + if (floatBitsToInt(_18._m8) != 0) { + vec4 _200 = _172; + _200.w = _185 * _18._m8; + _201 = _200; + } else { + _201 = _172; + } + vec4 _214; + if (floatBitsToInt(_18._m9) != 0) { + vec4 _213 = _201; + _213.w = (-0.5) * (cos(_201.w * 3.1415927410125732421875) - 1.0); + _214 = _213; + } else { + _214 = _201; + } + _215 = _214; + } else { + _215 = _172; + } + vec4 _218 = _215; + _218.w = clamp(_215.w, 0.0, 1.0); + _6 = _218; +} + diff --git a/src/games/rdr2vk/output/0x1B0D650C.frag.glsl b/src/games/rdr2vk/output/0x1B0D650C.frag.glsl new file mode 100644 index 000000000..8bc2c652b --- /dev/null +++ b/src/games/rdr2vk/output/0x1B0D650C.frag.glsl @@ -0,0 +1,148 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _9 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _75; + +layout(set = 0, binding = 96, scalar) readonly buffer _8_10 { + _9 _m0[]; +} +_10; + +layout(set = 0, binding = 23, std140) uniform _12_13 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_13; + +layout(set = 1, binding = 22, std140) uniform _14_15 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_15; + +layout(set = 1, binding = 34) uniform sampler _7; +layout(set = 0, binding = 131) uniform texture3D _16; + +layout(location = 0) in vec4 _4; +layout(location = 0) out vec4 _5; + +void main() { + vec4 _83 = (_4 * _15._m5) + _15._m4; + vec4 _96; + if (floatBitsToInt(_15._m10) != 0) { + vec4 _94 = textureLod(sampler3D(_16, _7), _83.xyz, 0.0); + _96 = vec4(_94.x, _94.y, _94.z, _83.w); + } else { + _96 = _83; + } + vec4 _146; + if (floatBitsToInt(_15._m7) != 0) { +#if 1 + _96.rgb = GammaSafe(_96.rgb); +#endif + vec3 _108 = _96.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); + +#if 1 + vec3 _126; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _126 = PQEncodeUI(_108); + } else { + float _119 = pow(abs((_108.x * _13._m0) / _13._m15), 0.1593017578125); + _126.x = pow((0.8359375 + (18.8515625 * _119)) / (1.0 + (18.6875 * _119)), 78.84375); + float _128 = pow(abs((_108.y * _13._m0) / _13._m15), 0.1593017578125); + _126.y = pow((0.8359375 + (18.8515625 * _128)) / (1.0 + (18.6875 * _128)), 78.84375); + float _137 = pow(abs((_108.z * _13._m0) / _13._m15), 0.1593017578125); + _126.z = pow((0.8359375 + (18.8515625 * _137)) / (1.0 + (18.6875 * _137)), 78.84375); + } +#else + float _119 = pow(abs((_108.x * _13._m0) / _13._m15), 0.1593017578125); + vec3 _126; + _126.x = pow((0.8359375 + (18.8515625 * _119)) / (1.0 + (18.6875 * _119)), 78.84375); + float _128 = pow(abs((_108.y * _13._m0) / _13._m15), 0.1593017578125); + _126.y = pow((0.8359375 + (18.8515625 * _128)) / (1.0 + (18.6875 * _128)), 78.84375); + float _137 = pow(abs((_108.z * _13._m0) / _13._m15), 0.1593017578125); + _126.z = pow((0.8359375 + (18.8515625 * _137)) / (1.0 + (18.6875 * _137)), 78.84375); +#endif + _146 = vec4(_126.x, _126.y, _126.z, _96.w); + } else { + _146 = _96; + } + vec3 _154 = mix(_146.xyz * _146.www, _146.xyz, bvec3(_15._m6 == 0.0)); + vec4 _155 = vec4(_154.x, _154.y, _154.z, _146.w); + float _159 = _10._m0[0u]._m0.w * _146.w; + _155.z = (_10._m0[0u]._m0.w != 1.0) ? (_159 * _159) : _154.z; + float _168 = _146.w * _10._m0[0u]._m0.x; + _155.w = _168; + vec4 _198; + if (floatBitsToInt(_15._m11) != 0) { + vec4 _184; + if (floatBitsToInt(_15._m8) != 0) { + vec4 _183 = _155; + _183.w = _168 * _15._m8; + _184 = _183; + } else { + _184 = _155; + } + vec4 _197; + if (floatBitsToInt(_15._m9) != 0) { + vec4 _196 = _184; + _196.w = (-0.5) * (cos(_184.w * 3.1415927410125732421875) - 1.0); + _197 = _196; + } else { + _197 = _184; + } + _198 = _197; + } else { + _198 = _155; + } + vec4 _201 = _198; + _201.w = clamp(_198.w, 0.0, 1.0); + _5 = _201; +} + diff --git a/src/games/rdr2vk/output/0x26B3FAA9.frag.glsl b/src/games/rdr2vk/output/0x26B3FAA9.frag.glsl new file mode 100644 index 000000000..4b83ea2c9 --- /dev/null +++ b/src/games/rdr2vk/output/0x26B3FAA9.frag.glsl @@ -0,0 +1,151 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _9 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _82; + +layout(set = 0, binding = 96, scalar) readonly buffer _8_10 { + _9 _m0[]; +} +_10; + +layout(set = 0, binding = 23, std140) uniform _13_14 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_14; + +layout(set = 1, binding = 22, std140) uniform _15_16 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_16; + +layout(set = 1, binding = 34) uniform sampler _7; +layout(set = 1, binding = 37) uniform sampler _17; +layout(set = 1, binding = 128) uniform texture2D _18; +layout(set = 0, binding = 131) uniform texture3D _19; + +layout(location = 0) in vec2 _4; +layout(location = 0) out vec4 _5; + +void main() { + vec4 _88 = texture(sampler2D(_18, _17), _4); + vec4 _94 = (_88 * _16._m5) + _16._m4; + vec4 _107; + if (floatBitsToInt(_16._m10) != 0) { + vec4 _105 = textureLod(sampler3D(_19, _7), _94.xyz, 0.0); + _107 = vec4(_105.x, _105.y, _105.z, _94.w); + } else { + _107 = _94; + } + vec4 _157; + if (floatBitsToInt(_16._m7) != 0) { +#if 1 + _107.rgb = GammaSafe(_107.rgb); +#endif + + vec3 _119 = _107.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _137; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _137 = PQEncodeUI(_119); + } else { + float _130 = pow(abs((_119.x * _14._m0) / _14._m15), 0.1593017578125); + _137.x = pow((0.8359375 + (18.8515625 * _130)) / (1.0 + (18.6875 * _130)), 78.84375); + float _139 = pow(abs((_119.y * _14._m0) / _14._m15), 0.1593017578125); + _137.y = pow((0.8359375 + (18.8515625 * _139)) / (1.0 + (18.6875 * _139)), 78.84375); + float _148 = pow(abs((_119.z * _14._m0) / _14._m15), 0.1593017578125); + _137.z = pow((0.8359375 + (18.8515625 * _148)) / (1.0 + (18.6875 * _148)), 78.84375); + } +#else + float _130 = pow(abs((_119.x * _14._m0) / _14._m15), 0.1593017578125); + vec3 _137; + _137.x = pow((0.8359375 + (18.8515625 * _130)) / (1.0 + (18.6875 * _130)), 78.84375); + float _139 = pow(abs((_119.y * _14._m0) / _14._m15), 0.1593017578125); + _137.y = pow((0.8359375 + (18.8515625 * _139)) / (1.0 + (18.6875 * _139)), 78.84375); + float _148 = pow(abs((_119.z * _14._m0) / _14._m15), 0.1593017578125); + _137.z = pow((0.8359375 + (18.8515625 * _148)) / (1.0 + (18.6875 * _148)), 78.84375); +#endif + _157 = vec4(_137.x, _137.y, _137.z, _107.w); + } else { + _157 = _107; + } + vec3 _165 = mix(_157.xyz * _157.www, _157.xyz, bvec3(_16._m6 == 0.0)); + vec4 _166 = vec4(_165.x, _165.y, _165.z, _157.w); + float _170 = _10._m0[0u]._m0.w * _157.w; + _166.z = (_10._m0[0u]._m0.w != 1.0) ? (_170 * _170) : _165.z; + float _179 = _157.w * _10._m0[0u]._m0.x; + _166.w = _179; + vec4 _209; + if (floatBitsToInt(_16._m11) != 0) { + vec4 _195; + if (floatBitsToInt(_16._m8) != 0) { + vec4 _194 = _166; + _194.w = _179 * _16._m8; + _195 = _194; + } else { + _195 = _166; + } + vec4 _208; + if (floatBitsToInt(_16._m9) != 0) { + vec4 _207 = _195; + _207.w = (-0.5) * (cos(_195.w * 3.1415927410125732421875) - 1.0); + _208 = _207; + } else { + _208 = _195; + } + _209 = _208; + } else { + _209 = _166; + } + vec4 _212 = _209; + _212.w = clamp(_209.w, 0.0, 1.0); + _5 = _212; +} + diff --git a/src/games/rdr2vk/output/0x6032A998.frag.glsl b/src/games/rdr2vk/output/0x6032A998.frag.glsl new file mode 100644 index 000000000..25a2dea90 --- /dev/null +++ b/src/games/rdr2vk/output/0x6032A998.frag.glsl @@ -0,0 +1,153 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _11 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _84; + +layout(set = 0, binding = 96, scalar) readonly buffer _10_12 { + _11 _m0[]; +} +_12; + +layout(set = 0, binding = 23, std140) uniform _15_16 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_16; + +layout(set = 1, binding = 22, std140) uniform _17_18 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_18; + +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 1, binding = 37) uniform sampler _19; +layout(set = 1, binding = 128) uniform texture2D _20; +layout(set = 0, binding = 131) uniform texture3D _21; + +layout(location = 0) in vec4 _4; +layout(location = 1) in vec4 _5; +layout(location = 2) in vec2 _6; +layout(location = 0) out vec4 _7; + +void main() { + vec4 _98 = (texture(sampler2D(_20, _19), _6).xxxx * _18._m5) + _18._m4; + _98.w = _98.w * _5.w; + vec4 _115; + if (floatBitsToInt(_18._m10) != 0) { + vec4 _113 = textureLod(sampler3D(_21, _9), _98.xyz, 0.0); + _115 = vec4(_113.x, _113.y, _113.z, _98.w); + } else { + _115 = _98; + } + vec4 _165; + if (floatBitsToInt(_18._m7) != 0) { +#if 1 + _115.rgb = GammaSafe(_115.rgb); +#endif + + vec3 _127 = _115.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _145; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _145 = PQEncodeUI(_127); + } else { + float _138 = pow(abs((_127.x * _16._m0) / _16._m15), 0.1593017578125); + _145.x = pow((0.8359375 + (18.8515625 * _138)) / (1.0 + (18.6875 * _138)), 78.84375); + float _147 = pow(abs((_127.y * _16._m0) / _16._m15), 0.1593017578125); + _145.y = pow((0.8359375 + (18.8515625 * _147)) / (1.0 + (18.6875 * _147)), 78.84375); + float _156 = pow(abs((_127.z * _16._m0) / _16._m15), 0.1593017578125); + _145.z = pow((0.8359375 + (18.8515625 * _156)) / (1.0 + (18.6875 * _156)), 78.84375); + } +#else + float _138 = pow(abs((_127.x * _16._m0) / _16._m15), 0.1593017578125); + vec3 _145; + _145.x = pow((0.8359375 + (18.8515625 * _138)) / (1.0 + (18.6875 * _138)), 78.84375); + float _147 = pow(abs((_127.y * _16._m0) / _16._m15), 0.1593017578125); + _145.y = pow((0.8359375 + (18.8515625 * _147)) / (1.0 + (18.6875 * _147)), 78.84375); + float _156 = pow(abs((_127.z * _16._m0) / _16._m15), 0.1593017578125); + _145.z = pow((0.8359375 + (18.8515625 * _156)) / (1.0 + (18.6875 * _156)), 78.84375); +#endif + _165 = vec4(_145.x, _145.y, _145.z, _115.w); + } else { + _165 = _115; + } + vec3 _173 = mix(_165.xyz * _165.www, _165.xyz, bvec3(_18._m6 == 0.0)); + vec4 _174 = vec4(_173.x, _173.y, _173.z, _165.w); + float _178 = _12._m0[0u]._m0.w * _165.w; + _174.z = (_12._m0[0u]._m0.w != 1.0) ? (_178 * _178) : _173.z; + float _187 = _165.w * _12._m0[0u]._m0.x; + _174.w = _187; + vec4 _217; + if (floatBitsToInt(_18._m11) != 0) { + vec4 _203; + if (floatBitsToInt(_18._m8) != 0) { + vec4 _202 = _174; + _202.w = _187 * _18._m8; + _203 = _202; + } else { + _203 = _174; + } + vec4 _216; + if (floatBitsToInt(_18._m9) != 0) { + vec4 _215 = _203; + _215.w = (-0.5) * (cos(_203.w * 3.1415927410125732421875) - 1.0); + _216 = _215; + } else { + _216 = _203; + } + _217 = _216; + } else { + _217 = _174; + } + vec4 _220 = _217; + _220.w = clamp(_217.w, 0.0, 1.0); + _7 = _220; +} + diff --git a/src/games/rdr2vk/output/0x76A78879.frag.glsl b/src/games/rdr2vk/output/0x76A78879.frag.glsl new file mode 100644 index 000000000..3376f401b --- /dev/null +++ b/src/games/rdr2vk/output/0x76A78879.frag.glsl @@ -0,0 +1,152 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _10 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _83; + +layout(set = 0, binding = 96, scalar) readonly buffer _9_11 { + _10 _m0[]; +} +_11; + +layout(set = 0, binding = 23, std140) uniform _14_15 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_15; + +layout(set = 1, binding = 22, std140) uniform _16_17 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_17; + +layout(set = 1, binding = 34) uniform sampler _8; +layout(set = 1, binding = 37) uniform sampler _18; +layout(set = 1, binding = 128) uniform texture2D _19; +layout(set = 0, binding = 131) uniform texture3D _20; + +layout(location = 0) in vec2 _4; +layout(location = 1) in vec4 _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _92 = (_5 * _17._m5) + _17._m4; + _92.w = _92.w * texture(sampler2D(_19, _18), _4).w; + vec4 _113; + if (floatBitsToInt(_17._m10) != 0) { + vec4 _111 = textureLod(sampler3D(_20, _8), _92.xyz, 0.0); + _113 = vec4(_111.x, _111.y, _111.z, _92.w); + } else { + _113 = _92; + } + vec4 _163; + if (floatBitsToInt(_17._m7) != 0) { +#if 1 + _113.rgb = GammaSafe(_113.rgb); +#endif + + vec3 _125 = _113.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _143; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _143 = PQEncodeUI(_125); + } else { + float _136 = pow(abs((_125.x * _15._m0) / _15._m15), 0.1593017578125); + _143.x = pow((0.8359375 + (18.8515625 * _136)) / (1.0 + (18.6875 * _136)), 78.84375); + float _145 = pow(abs((_125.y * _15._m0) / _15._m15), 0.1593017578125); + _143.y = pow((0.8359375 + (18.8515625 * _145)) / (1.0 + (18.6875 * _145)), 78.84375); + float _154 = pow(abs((_125.z * _15._m0) / _15._m15), 0.1593017578125); + _143.z = pow((0.8359375 + (18.8515625 * _154)) / (1.0 + (18.6875 * _154)), 78.84375); + } +#else + float _136 = pow(abs((_125.x * _15._m0) / _15._m15), 0.1593017578125); + vec3 _143; + _143.x = pow((0.8359375 + (18.8515625 * _136)) / (1.0 + (18.6875 * _136)), 78.84375); + float _145 = pow(abs((_125.y * _15._m0) / _15._m15), 0.1593017578125); + _143.y = pow((0.8359375 + (18.8515625 * _145)) / (1.0 + (18.6875 * _145)), 78.84375); + float _154 = pow(abs((_125.z * _15._m0) / _15._m15), 0.1593017578125); + _143.z = pow((0.8359375 + (18.8515625 * _154)) / (1.0 + (18.6875 * _154)), 78.84375); +#endif + _163 = vec4(_143.x, _143.y, _143.z, _113.w); + } else { + _163 = _113; + } + vec3 _171 = mix(_163.xyz * _163.www, _163.xyz, bvec3(_17._m6 == 0.0)); + vec4 _172 = vec4(_171.x, _171.y, _171.z, _163.w); + float _176 = _11._m0[0u]._m0.w * _163.w; + _172.z = (_11._m0[0u]._m0.w != 1.0) ? (_176 * _176) : _171.z; + float _185 = _163.w * _11._m0[0u]._m0.x; + _172.w = _185; + vec4 _215; + if (floatBitsToInt(_17._m11) != 0) { + vec4 _201; + if (floatBitsToInt(_17._m8) != 0) { + vec4 _200 = _172; + _200.w = _185 * _17._m8; + _201 = _200; + } else { + _201 = _172; + } + vec4 _214; + if (floatBitsToInt(_17._m9) != 0) { + vec4 _213 = _201; + _213.w = (-0.5) * (cos(_201.w * 3.1415927410125732421875) - 1.0); + _214 = _213; + } else { + _214 = _201; + } + _215 = _214; + } else { + _215 = _172; + } + vec4 _218 = _215; + _218.w = clamp(_215.w, 0.0, 1.0); + _6 = _218; +} + diff --git a/src/games/rdr2vk/output/0x7BE28339.frag.glsl b/src/games/rdr2vk/output/0x7BE28339.frag.glsl new file mode 100644 index 000000000..090b9f3ef --- /dev/null +++ b/src/games/rdr2vk/output/0x7BE28339.frag.glsl @@ -0,0 +1,147 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _7 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _72; + +layout(set = 0, binding = 96, scalar) readonly buffer _6_8 { + _7 _m0[]; +} +_8; + +layout(set = 0, binding = 23, std140) uniform _10_11 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_11; + +layout(set = 1, binding = 22, std140) uniform _12_13 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_13; + +layout(set = 1, binding = 34) uniform sampler _5; +layout(set = 0, binding = 131) uniform texture3D _14; + +layout(location = 0) out vec4 _3; + +void main() { + vec4 _81 = (_13._m3 * _13._m5) + _13._m4; + vec4 _94; + if (floatBitsToInt(_13._m10) != 0) { + vec4 _92 = textureLod(sampler3D(_14, _5), _81.xyz, 0.0); + _94 = vec4(_92.x, _92.y, _92.z, _81.w); + } else { + _94 = _81; + } + vec4 _144; + if (floatBitsToInt(_13._m7) != 0) { +#if 1 + _94.rgb = GammaSafe(_94.rgb); +#endif + + vec3 _106 = _94.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _124; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _124 = PQEncodeUI(_106); + } else { + float _117 = pow(abs((_106.x * _11._m0) / _11._m15), 0.1593017578125); + _124.x = pow((0.8359375 + (18.8515625 * _117)) / (1.0 + (18.6875 * _117)), 78.84375); + float _126 = pow(abs((_106.y * _11._m0) / _11._m15), 0.1593017578125); + _124.y = pow((0.8359375 + (18.8515625 * _126)) / (1.0 + (18.6875 * _126)), 78.84375); + float _135 = pow(abs((_106.z * _11._m0) / _11._m15), 0.1593017578125); + _124.z = pow((0.8359375 + (18.8515625 * _135)) / (1.0 + (18.6875 * _135)), 78.84375); + } +#else + float _117 = pow(abs((_106.x * _11._m0) / _11._m15), 0.1593017578125); + vec3 _124; + _124.x = pow((0.8359375 + (18.8515625 * _117)) / (1.0 + (18.6875 * _117)), 78.84375); + float _126 = pow(abs((_106.y * _11._m0) / _11._m15), 0.1593017578125); + _124.y = pow((0.8359375 + (18.8515625 * _126)) / (1.0 + (18.6875 * _126)), 78.84375); + float _135 = pow(abs((_106.z * _11._m0) / _11._m15), 0.1593017578125); + _124.z = pow((0.8359375 + (18.8515625 * _135)) / (1.0 + (18.6875 * _135)), 78.84375); +#endif + _144 = vec4(_124.x, _124.y, _124.z, _94.w); + } else { + _144 = _94; + } + vec3 _152 = mix(_144.xyz * _144.www, _144.xyz, bvec3(_13._m6 == 0.0)); + vec4 _153 = vec4(_152.x, _152.y, _152.z, _144.w); + float _157 = _8._m0[0u]._m0.w * _144.w; + _153.z = (_8._m0[0u]._m0.w != 1.0) ? (_157 * _157) : _152.z; + float _166 = _144.w * _8._m0[0u]._m0.x; + _153.w = _166; + vec4 _196; + if (floatBitsToInt(_13._m11) != 0) { + vec4 _182; + if (floatBitsToInt(_13._m8) != 0) { + vec4 _181 = _153; + _181.w = _166 * _13._m8; + _182 = _181; + } else { + _182 = _153; + } + vec4 _195; + if (floatBitsToInt(_13._m9) != 0) { + vec4 _194 = _182; + _194.w = (-0.5) * (cos(_182.w * 3.1415927410125732421875) - 1.0); + _195 = _194; + } else { + _195 = _182; + } + _196 = _195; + } else { + _196 = _153; + } + vec4 _199 = _196; + _199.w = clamp(_196.w, 0.0, 1.0); + _3 = _199; +} + diff --git a/src/games/rdr2vk/output/0x8B9C89F1.frag.glsl b/src/games/rdr2vk/output/0x8B9C89F1.frag.glsl new file mode 100644 index 000000000..abaa2a69a --- /dev/null +++ b/src/games/rdr2vk/output/0x8B9C89F1.frag.glsl @@ -0,0 +1,1034 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _12 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec2 _101; +vec2 _102; +vec3 _103; + +layout(set = 0, binding = 96, scalar) readonly buffer _11_13 { + _12 _m0[]; +} +_13; + +layout(set = 0, binding = 23, std140) uniform _16_17 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_17; + +layout(set = 1, binding = 22, std140) uniform _18_19 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_19; + +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 1, binding = 37) uniform sampler _20; +layout(set = 1, binding = 128) uniform texture2D _21; +layout(set = 0, binding = 131) uniform texture3D _22; + +layout(location = 0) in vec4 _4; +layout(location = 1) in vec4 _5; +layout(location = 2) in vec4 _6; +layout(location = 3) in vec4 _7; +layout(location = 0) out vec4 _8; + +void main() { + vec4 _926; + do { + vec2 _113; + _113.x = _6.x; + _113.y = _6.y; + vec4 _117 = textureLod(sampler2D(_21, _20), _113, 0.0); + float _118 = _117.y; + vec4 _120 = textureGather(sampler2D(_21, _20), _113, 1); + vec4 _122 = textureGatherOffset(sampler2D(_21, _20), _113, ivec2(-1), 1); + float _123 = _120.z; + float _124 = _120.x; + float _125 = _120.y; + float _126 = _122.w; + float _127 = _122.z; + float _128 = _122.x; + float _135 = max(max(_127, _128), max(_123, max(_124, _118))); + float _138 = _135 - min(min(_127, _128), min(_123, min(_124, _118))); + if (_138 < max(0.0, _135 * 0.063000001013278961181640625)) { + _926 = _117; + break; + } + vec4 _144 = textureLodOffset(sampler2D(_21, _20), _113, 0.0, ivec2(1, -1)); + float _145 = _144.y; + vec4 _147 = textureLodOffset(sampler2D(_21, _20), _113, 0.0, ivec2(-1, 1)); + float _148 = _147.y; + float _149 = _127 + _124; + float _150 = _128 + _123; + float _153 = (-2.0) * _118; + float _156 = _145 + _125; + float _162 = _126 + _148; + bool _182 = (abs(((-2.0) * _128) + _162) + ((abs(_153 + _149) * 2.0) + abs(((-2.0) * _123) + _156))) >= (abs(((-2.0) * _124) + (_148 + _125)) + ((abs(_153 + _150) * 2.0) + abs(((-2.0) * _127) + (_126 + _145)))); + bool _185 = !_182; + float _186 = _185 ? _128 : _127; + float _187 = _185 ? _123 : _124; + float _191; + if (_182) { + _191 = _6.w; + } else { + _191 = _6.z; + } + float _198 = abs(_186 - _118); + float _199 = abs(_187 - _118); + bool _200 = _198 >= _199; + float _205; + if (_200) { + _205 = -_191; + } else { + _205 = _191; + } + float _208 = clamp(abs(((((_149 + _150) * 2.0) + (_162 + _156)) * 0.083333335816860198974609375) - _118) * (1.0 / _138), 0.0, 1.0); + float _209 = _185 ? 0.0 : _6.z; + float _211 = _182 ? 0.0 : _6.w; + vec2 _217; + if (_185) { + vec2 _216 = _113; + _216.x = _6.x + (_205 * 0.5); + _217 = _216; + } else { + _217 = _113; + } + vec2 _224; + if (_182) { + vec2 _223 = _217; + _223.y = _217.y + (_205 * 0.5); + _224 = _223; + } else { + _224 = _217; + } + float _226 = _224.x - _209; + vec2 _227; + _227.x = _226; + _227.y = _224.y - _211; + float _231 = _224.x + _209; + vec2 _232; + _232.x = _231; + _232.y = _224.y + _211; + float _246 = max(_198, _199) * 0.25; + float _247 = ((!_200) ? (_187 + _118) : (_186 + _118)) * 0.5; + float _249 = (((-2.0) * _208) + 3.0) * (_208 * _208); + bool _250 = (_118 - _247) < 0.0; + float _251 = textureLod(sampler2D(_21, _20), _227, 0.0).y - _247; + float _252 = textureLod(sampler2D(_21, _20), _232, 0.0).y - _247; + bool _257 = !(abs(_251) >= _246); + vec2 _262; + if (_257) { + vec2 _261 = _227; + _261.x = _226 - _209; + _262 = _261; + } else { + _262 = _227; + } + vec2 _268; + if (_257) { + vec2 _267 = _262; + _267.y = _262.y - _211; + _268 = _267; + } else { + _268 = _262; + } + bool _269 = !(abs(_252) >= _246); + vec2 _275; + if (_269) { + vec2 _274 = _232; + _274.x = _231 + _209; + _275 = _274; + } else { + _275 = _232; + } + vec2 _281; + if (_269) { + vec2 _280 = _275; + _280.y = _275.y + _211; + _281 = _280; + } else { + _281 = _275; + } + vec2 _875; + vec2 _876; + float _877; + float _878; + if (_257 || _269) { + float _289; + if (_257) { + _289 = textureLod(sampler2D(_21, _20), _268, 0.0).y; + } else { + _289 = _251; + } + float _295; + if (_269) { + _295 = textureLod(sampler2D(_21, _20), _281, 0.0).y; + } else { + _295 = _252; + } + float _299; + if (_257) { + _299 = _289 - _247; + } else { + _299 = _289; + } + float _303; + if (_269) { + _303 = _295 - _247; + } else { + _303 = _295; + } + bool _308 = !(abs(_299) >= _246); + vec2 _314; + if (_308) { + vec2 _313 = _268; + _313.x = _268.x - _209; + _314 = _313; + } else { + _314 = _268; + } + vec2 _320; + if (_308) { + vec2 _319 = _314; + _319.y = _314.y - _211; + _320 = _319; + } else { + _320 = _314; + } + bool _321 = !(abs(_303) >= _246); + vec2 _328; + if (_321) { + vec2 _327 = _281; + _327.x = _281.x + _209; + _328 = _327; + } else { + _328 = _281; + } + vec2 _334; + if (_321) { + vec2 _333 = _328; + _333.y = _328.y + _211; + _334 = _333; + } else { + _334 = _328; + } + vec2 _871; + vec2 _872; + float _873; + float _874; + if (_308 || _321) { + float _342; + if (_308) { + _342 = textureLod(sampler2D(_21, _20), _320, 0.0).y; + } else { + _342 = _299; + } + float _348; + if (_321) { + _348 = textureLod(sampler2D(_21, _20), _334, 0.0).y; + } else { + _348 = _303; + } + float _352; + if (_308) { + _352 = _342 - _247; + } else { + _352 = _342; + } + float _356; + if (_321) { + _356 = _348 - _247; + } else { + _356 = _348; + } + bool _361 = !(abs(_352) >= _246); + vec2 _367; + if (_361) { + vec2 _366 = _320; + _366.x = _320.x - _209; + _367 = _366; + } else { + _367 = _320; + } + vec2 _373; + if (_361) { + vec2 _372 = _367; + _372.y = _367.y - _211; + _373 = _372; + } else { + _373 = _367; + } + bool _374 = !(abs(_356) >= _246); + vec2 _381; + if (_374) { + vec2 _380 = _334; + _380.x = _334.x + _209; + _381 = _380; + } else { + _381 = _334; + } + vec2 _387; + if (_374) { + vec2 _386 = _381; + _386.y = _381.y + _211; + _387 = _386; + } else { + _387 = _381; + } + vec2 _867; + vec2 _868; + float _869; + float _870; + if (_361 || _374) { + float _395; + if (_361) { + _395 = textureLod(sampler2D(_21, _20), _373, 0.0).y; + } else { + _395 = _352; + } + float _401; + if (_374) { + _401 = textureLod(sampler2D(_21, _20), _387, 0.0).y; + } else { + _401 = _356; + } + float _405; + if (_361) { + _405 = _395 - _247; + } else { + _405 = _395; + } + float _409; + if (_374) { + _409 = _401 - _247; + } else { + _409 = _401; + } + bool _414 = !(abs(_405) >= _246); + vec2 _420; + if (_414) { + vec2 _419 = _373; + _419.x = _373.x - _209; + _420 = _419; + } else { + _420 = _373; + } + vec2 _426; + if (_414) { + vec2 _425 = _420; + _425.y = _420.y - _211; + _426 = _425; + } else { + _426 = _420; + } + bool _427 = !(abs(_409) >= _246); + vec2 _434; + if (_427) { + vec2 _433 = _387; + _433.x = _387.x + _209; + _434 = _433; + } else { + _434 = _387; + } + vec2 _440; + if (_427) { + vec2 _439 = _434; + _439.y = _434.y + _211; + _440 = _439; + } else { + _440 = _434; + } + vec2 _863; + vec2 _864; + float _865; + float _866; + if (_414 || _427) { + float _448; + if (_414) { + _448 = textureLod(sampler2D(_21, _20), _426, 0.0).y; + } else { + _448 = _405; + } + float _454; + if (_427) { + _454 = textureLod(sampler2D(_21, _20), _440, 0.0).y; + } else { + _454 = _409; + } + float _458; + if (_414) { + _458 = _448 - _247; + } else { + _458 = _448; + } + float _462; + if (_427) { + _462 = _454 - _247; + } else { + _462 = _454; + } + bool _467 = !(abs(_458) >= _246); + vec2 _474; + if (_467) { + vec2 _473 = _426; + _473.x = _426.x - (_209 * 1.5); + _474 = _473; + } else { + _474 = _426; + } + vec2 _481; + if (_467) { + vec2 _480 = _474; + _480.y = _474.y - (_211 * 1.5); + _481 = _480; + } else { + _481 = _474; + } + bool _482 = !(abs(_462) >= _246); + vec2 _490; + if (_482) { + vec2 _489 = _440; + _489.x = _440.x + (_209 * 1.5); + _490 = _489; + } else { + _490 = _440; + } + vec2 _497; + if (_482) { + vec2 _496 = _490; + _496.y = _490.y + (_211 * 1.5); + _497 = _496; + } else { + _497 = _490; + } + vec2 _859; + vec2 _860; + float _861; + float _862; + if (_467 || _482) { + float _505; + if (_467) { + _505 = textureLod(sampler2D(_21, _20), _481, 0.0).y; + } else { + _505 = _458; + } + float _511; + if (_482) { + _511 = textureLod(sampler2D(_21, _20), _497, 0.0).y; + } else { + _511 = _462; + } + float _515; + if (_467) { + _515 = _505 - _247; + } else { + _515 = _505; + } + float _519; + if (_482) { + _519 = _511 - _247; + } else { + _519 = _511; + } + bool _524 = !(abs(_515) >= _246); + vec2 _531; + if (_524) { + vec2 _530 = _481; + _530.x = _481.x - (_209 * 2.0); + _531 = _530; + } else { + _531 = _481; + } + vec2 _538; + if (_524) { + vec2 _537 = _531; + _537.y = _531.y - (_211 * 2.0); + _538 = _537; + } else { + _538 = _531; + } + bool _539 = !(abs(_519) >= _246); + vec2 _547; + if (_539) { + vec2 _546 = _497; + _546.x = _497.x + (_209 * 2.0); + _547 = _546; + } else { + _547 = _497; + } + vec2 _554; + if (_539) { + vec2 _553 = _547; + _553.y = _547.y + (_211 * 2.0); + _554 = _553; + } else { + _554 = _547; + } + vec2 _855; + vec2 _856; + float _857; + float _858; + if (_524 || _539) { + float _562; + if (_524) { + _562 = textureLod(sampler2D(_21, _20), _538, 0.0).y; + } else { + _562 = _515; + } + float _568; + if (_539) { + _568 = textureLod(sampler2D(_21, _20), _554, 0.0).y; + } else { + _568 = _519; + } + float _572; + if (_524) { + _572 = _562 - _247; + } else { + _572 = _562; + } + float _576; + if (_539) { + _576 = _568 - _247; + } else { + _576 = _568; + } + bool _581 = !(abs(_572) >= _246); + vec2 _588; + if (_581) { + vec2 _587 = _538; + _587.x = _538.x - (_209 * 2.0); + _588 = _587; + } else { + _588 = _538; + } + vec2 _595; + if (_581) { + vec2 _594 = _588; + _594.y = _588.y - (_211 * 2.0); + _595 = _594; + } else { + _595 = _588; + } + bool _596 = !(abs(_576) >= _246); + vec2 _604; + if (_596) { + vec2 _603 = _554; + _603.x = _554.x + (_209 * 2.0); + _604 = _603; + } else { + _604 = _554; + } + vec2 _611; + if (_596) { + vec2 _610 = _604; + _610.y = _604.y + (_211 * 2.0); + _611 = _610; + } else { + _611 = _604; + } + vec2 _851; + vec2 _852; + float _853; + float _854; + if (_581 || _596) { + float _619; + if (_581) { + _619 = textureLod(sampler2D(_21, _20), _595, 0.0).y; + } else { + _619 = _572; + } + float _625; + if (_596) { + _625 = textureLod(sampler2D(_21, _20), _611, 0.0).y; + } else { + _625 = _576; + } + float _629; + if (_581) { + _629 = _619 - _247; + } else { + _629 = _619; + } + float _633; + if (_596) { + _633 = _625 - _247; + } else { + _633 = _625; + } + bool _638 = !(abs(_629) >= _246); + vec2 _645; + if (_638) { + vec2 _644 = _595; + _644.x = _595.x - (_209 * 2.0); + _645 = _644; + } else { + _645 = _595; + } + vec2 _652; + if (_638) { + vec2 _651 = _645; + _651.y = _645.y - (_211 * 2.0); + _652 = _651; + } else { + _652 = _645; + } + bool _653 = !(abs(_633) >= _246); + vec2 _661; + if (_653) { + vec2 _660 = _611; + _660.x = _611.x + (_209 * 2.0); + _661 = _660; + } else { + _661 = _611; + } + vec2 _668; + if (_653) { + vec2 _667 = _661; + _667.y = _661.y + (_211 * 2.0); + _668 = _667; + } else { + _668 = _661; + } + vec2 _847; + vec2 _848; + float _849; + float _850; + if (_638 || _653) { + float _676; + if (_638) { + _676 = textureLod(sampler2D(_21, _20), _652, 0.0).y; + } else { + _676 = _629; + } + float _682; + if (_653) { + _682 = textureLod(sampler2D(_21, _20), _668, 0.0).y; + } else { + _682 = _633; + } + float _686; + if (_638) { + _686 = _676 - _247; + } else { + _686 = _676; + } + float _690; + if (_653) { + _690 = _682 - _247; + } else { + _690 = _682; + } + bool _695 = !(abs(_686) >= _246); + vec2 _702; + if (_695) { + vec2 _701 = _652; + _701.x = _652.x - (_209 * 2.0); + _702 = _701; + } else { + _702 = _652; + } + vec2 _709; + if (_695) { + vec2 _708 = _702; + _708.y = _702.y - (_211 * 2.0); + _709 = _708; + } else { + _709 = _702; + } + bool _710 = !(abs(_690) >= _246); + vec2 _718; + if (_710) { + vec2 _717 = _668; + _717.x = _668.x + (_209 * 2.0); + _718 = _717; + } else { + _718 = _668; + } + vec2 _725; + if (_710) { + vec2 _724 = _718; + _724.y = _718.y + (_211 * 2.0); + _725 = _724; + } else { + _725 = _718; + } + vec2 _843; + vec2 _844; + float _845; + float _846; + if (_695 || _710) { + float _733; + if (_695) { + _733 = textureLod(sampler2D(_21, _20), _709, 0.0).y; + } else { + _733 = _686; + } + float _739; + if (_710) { + _739 = textureLod(sampler2D(_21, _20), _725, 0.0).y; + } else { + _739 = _690; + } + float _743; + if (_695) { + _743 = _733 - _247; + } else { + _743 = _733; + } + float _747; + if (_710) { + _747 = _739 - _247; + } else { + _747 = _739; + } + bool _752 = !(abs(_743) >= _246); + vec2 _759; + if (_752) { + vec2 _758 = _709; + _758.x = _709.x - (_209 * 4.0); + _759 = _758; + } else { + _759 = _709; + } + vec2 _766; + if (_752) { + vec2 _765 = _759; + _765.y = _759.y - (_211 * 4.0); + _766 = _765; + } else { + _766 = _759; + } + bool _767 = !(abs(_747) >= _246); + vec2 _775; + if (_767) { + vec2 _774 = _725; + _774.x = _725.x + (_209 * 4.0); + _775 = _774; + } else { + _775 = _725; + } + vec2 _782; + if (_767) { + vec2 _781 = _775; + _781.y = _775.y + (_211 * 4.0); + _782 = _781; + } else { + _782 = _775; + } + vec2 _839; + vec2 _840; + float _841; + float _842; + if (_752 || _767) { + float _790; + if (_752) { + _790 = textureLod(sampler2D(_21, _20), _766, 0.0).y; + } else { + _790 = _743; + } + float _796; + if (_767) { + _796 = textureLod(sampler2D(_21, _20), _782, 0.0).y; + } else { + _796 = _747; + } + float _800; + if (_752) { + _800 = _790 - _247; + } else { + _800 = _790; + } + float _804; + if (_767) { + _804 = _796 - _247; + } else { + _804 = _796; + } + bool _809 = !(abs(_800) >= _246); + vec2 _816; + if (_809) { + vec2 _815 = _766; + _815.x = _766.x - (_209 * 8.0); + _816 = _815; + } else { + _816 = _766; + } + vec2 _823; + if (_809) { + vec2 _822 = _816; + _822.y = _816.y - (_211 * 8.0); + _823 = _822; + } else { + _823 = _816; + } + bool _824 = !(abs(_804) >= _246); + vec2 _831; + if (_824) { + vec2 _830 = _782; + _830.x = _782.x + (_209 * 8.0); + _831 = _830; + } else { + _831 = _782; + } + vec2 _838; + if (_824) { + vec2 _837 = _831; + _837.y = _831.y + (_211 * 8.0); + _838 = _837; + } else { + _838 = _831; + } + _839 = _838; + _840 = _823; + _841 = _804; + _842 = _800; + } else { + _839 = _782; + _840 = _766; + _841 = _747; + _842 = _743; + } + _843 = _839; + _844 = _840; + _845 = _841; + _846 = _842; + } else { + _843 = _725; + _844 = _709; + _845 = _690; + _846 = _686; + } + _847 = _843; + _848 = _844; + _849 = _845; + _850 = _846; + } else { + _847 = _668; + _848 = _652; + _849 = _633; + _850 = _629; + } + _851 = _847; + _852 = _848; + _853 = _849; + _854 = _850; + } else { + _851 = _611; + _852 = _595; + _853 = _576; + _854 = _572; + } + _855 = _851; + _856 = _852; + _857 = _853; + _858 = _854; + } else { + _855 = _554; + _856 = _538; + _857 = _519; + _858 = _515; + } + _859 = _855; + _860 = _856; + _861 = _857; + _862 = _858; + } else { + _859 = _497; + _860 = _481; + _861 = _462; + _862 = _458; + } + _863 = _859; + _864 = _860; + _865 = _861; + _866 = _862; + } else { + _863 = _440; + _864 = _426; + _865 = _409; + _866 = _405; + } + _867 = _863; + _868 = _864; + _869 = _865; + _870 = _866; + } else { + _867 = _387; + _868 = _373; + _869 = _356; + _870 = _352; + } + _871 = _867; + _872 = _868; + _873 = _869; + _874 = _870; + } else { + _871 = _334; + _872 = _320; + _873 = _303; + _874 = _299; + } + _875 = _871; + _876 = _872; + _877 = _873; + _878 = _874; + } else { + _875 = _281; + _876 = _268; + _877 = _252; + _878 = _251; + } + float _887; + if (_185) { + _887 = _6.y - _876.y; + } else { + _887 = _6.x - _876.x; + } + float _892; + if (_185) { + _892 = _875.y - _6.y; + } else { + _892 = _875.x - _6.x; + } + float _906 = max(((_887 < _892) ? ((_878 < 0.0) != _250) : ((_877 < 0.0) != _250)) ? ((min(_887, _892) * ((-1.0) / (_892 + _887))) + 0.5) : 0.0, _249 * _249); + vec2 _912; + if (_185) { + vec2 _911 = _113; + _911.x = _6.x + (_906 * _205); + _912 = _911; + } else { + _912 = _113; + } + vec2 _919; + if (_182) { + vec2 _918 = _912; + _918.y = _912.y + (_906 * _205); + _919 = _918; + } else { + _919 = _912; + } + _926 = vec4(textureLod(sampler2D(_21, _20), _919, 0.0).xyz, _118); + break; + } while (false); + vec4 _939 = (vec4(_926.xyz, texture(sampler2D(_21, _20), _6.xy).w) * _19._m5) + _19._m4; + _939.w = _939.w * _5.w; + vec4 _956; + if (floatBitsToInt(_19._m10) != 0) { + vec4 _954 = textureLod(sampler3D(_22, _10), _939.xyz, 0.0); + _956 = vec4(_954.x, _954.y, _954.z, _939.w); + } else { + _956 = _939; + } + vec4 _1006; + if (floatBitsToInt(_19._m7) != 0) { +#if 1 + _956.rgb = GammaSafe(_956.rgb); +#endif + + vec3 _968 = _956.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _986; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _986 = PQEncodeUI(_968); + } else { + float _979 = pow(abs((_968.x * _17._m0) / _17._m15), 0.1593017578125); + _986.x = pow((0.8359375 + (18.8515625 * _979)) / (1.0 + (18.6875 * _979)), 78.84375); + float _988 = pow(abs((_968.y * _17._m0) / _17._m15), 0.1593017578125); + _986.y = pow((0.8359375 + (18.8515625 * _988)) / (1.0 + (18.6875 * _988)), 78.84375); + float _997 = pow(abs((_968.z * _17._m0) / _17._m15), 0.1593017578125); + _986.z = pow((0.8359375 + (18.8515625 * _997)) / (1.0 + (18.6875 * _997)), 78.84375); + } +#else + float _979 = pow(abs((_968.x * _17._m0) / _17._m15), 0.1593017578125); + vec3 _986; + _986.x = pow((0.8359375 + (18.8515625 * _979)) / (1.0 + (18.6875 * _979)), 78.84375); + float _988 = pow(abs((_968.y * _17._m0) / _17._m15), 0.1593017578125); + _986.y = pow((0.8359375 + (18.8515625 * _988)) / (1.0 + (18.6875 * _988)), 78.84375); + float _997 = pow(abs((_968.z * _17._m0) / _17._m15), 0.1593017578125); + _986.z = pow((0.8359375 + (18.8515625 * _997)) / (1.0 + (18.6875 * _997)), 78.84375); +#endif + _1006 = vec4(_986.x, _986.y, _986.z, _956.w); + } else { + _1006 = _956; + } + vec3 _1014 = mix(_1006.xyz * _1006.www, _1006.xyz, bvec3(_19._m6 == 0.0)); + vec4 _1015 = vec4(_1014.x, _1014.y, _1014.z, _1006.w); + float _1019 = _13._m0[0u]._m0.w * _1006.w; + _1015.z = (_13._m0[0u]._m0.w != 1.0) ? (_1019 * _1019) : _1014.z; + float _1028 = _1006.w * _13._m0[0u]._m0.x; + _1015.w = _1028; + vec4 _1058; + if (floatBitsToInt(_19._m11) != 0) { + vec4 _1044; + if (floatBitsToInt(_19._m8) != 0) { + vec4 _1043 = _1015; + _1043.w = _1028 * _19._m8; + _1044 = _1043; + } else { + _1044 = _1015; + } + vec4 _1057; + if (floatBitsToInt(_19._m9) != 0) { + vec4 _1056 = _1044; + _1056.w = (-0.5) * (cos(_1044.w * 3.1415927410125732421875) - 1.0); + _1057 = _1056; + } else { + _1057 = _1044; + } + _1058 = _1057; + } else { + _1058 = _1015; + } + vec4 _1061 = _1058; + _1061.w = clamp(_1058.w, 0.0, 1.0); + _8 = _1061; +} + diff --git a/src/games/rdr2vk/output/0xBCF843ED.frag.glsl b/src/games/rdr2vk/output/0xBCF843ED.frag.glsl new file mode 100644 index 000000000..09d9110e1 --- /dev/null +++ b/src/games/rdr2vk/output/0xBCF843ED.frag.glsl @@ -0,0 +1,154 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _9 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _82; + +layout(set = 0, binding = 96, scalar) readonly buffer _8_10 { + _9 _m0[]; +} +_10; + +layout(set = 0, binding = 23, std140) uniform _13_14 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_14; + +layout(set = 1, binding = 22, std140) uniform _15_16 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_16; + +layout(set = 1, binding = 34) uniform sampler _7; +layout(set = 1, binding = 37) uniform sampler _17; +layout(set = 1, binding = 128) uniform texture2D _18; +layout(set = 0, binding = 131) uniform texture3D _19; + +layout(location = 0) in vec2 _4; +layout(location = 0) out vec4 _5; + +void main() { + vec4 _88 = texture(sampler2D(_18, _17), _4); + vec4 _94 = (_88 * _16._m5) + _16._m4; + if (_94.w < 1.0) { + discard; + } + vec4 _111; + if (floatBitsToInt(_16._m10) != 0) { + vec4 _109 = textureLod(sampler3D(_19, _7), _94.xyz, 0.0); + _111 = vec4(_109.x, _109.y, _109.z, _94.w); + } else { + _111 = _94; + } + vec4 _161; + if (floatBitsToInt(_16._m7) != 0) { +#if 1 + _111.rgb = GammaSafe(_111.rgb); +#endif + + vec3 _123 = _111.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _141; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _141 = PQEncodeUI(_123); + } else { + float _134 = pow(abs((_123.x * _14._m0) / _14._m15), 0.1593017578125); + _141.x = pow((0.8359375 + (18.8515625 * _134)) / (1.0 + (18.6875 * _134)), 78.84375); + float _143 = pow(abs((_123.y * _14._m0) / _14._m15), 0.1593017578125); + _141.y = pow((0.8359375 + (18.8515625 * _143)) / (1.0 + (18.6875 * _143)), 78.84375); + float _152 = pow(abs((_123.z * _14._m0) / _14._m15), 0.1593017578125); + _141.z = pow((0.8359375 + (18.8515625 * _152)) / (1.0 + (18.6875 * _152)), 78.84375); + } +#else + float _134 = pow(abs((_123.x * _14._m0) / _14._m15), 0.1593017578125); + vec3 _141; + _141.x = pow((0.8359375 + (18.8515625 * _134)) / (1.0 + (18.6875 * _134)), 78.84375); + float _143 = pow(abs((_123.y * _14._m0) / _14._m15), 0.1593017578125); + _141.y = pow((0.8359375 + (18.8515625 * _143)) / (1.0 + (18.6875 * _143)), 78.84375); + float _152 = pow(abs((_123.z * _14._m0) / _14._m15), 0.1593017578125); + _141.z = pow((0.8359375 + (18.8515625 * _152)) / (1.0 + (18.6875 * _152)), 78.84375); +#endif + _161 = vec4(_141.x, _141.y, _141.z, _111.w); + } else { + _161 = _111; + } + vec3 _169 = mix(_161.xyz * _161.www, _161.xyz, bvec3(_16._m6 == 0.0)); + vec4 _170 = vec4(_169.x, _169.y, _169.z, _161.w); + float _174 = _10._m0[0u]._m0.w * _161.w; + _170.z = (_10._m0[0u]._m0.w != 1.0) ? (_174 * _174) : _169.z; + float _183 = _161.w * _10._m0[0u]._m0.x; + _170.w = _183; + vec4 _213; + if (floatBitsToInt(_16._m11) != 0) { + vec4 _199; + if (floatBitsToInt(_16._m8) != 0) { + vec4 _198 = _170; + _198.w = _183 * _16._m8; + _199 = _198; + } else { + _199 = _170; + } + vec4 _212; + if (floatBitsToInt(_16._m9) != 0) { + vec4 _211 = _199; + _211.w = (-0.5) * (cos(_199.w * 3.1415927410125732421875) - 1.0); + _212 = _211; + } else { + _212 = _199; + } + _213 = _212; + } else { + _213 = _170; + } + vec4 _216 = _213; + _216.w = clamp(_213.w, 0.0, 1.0); + _5 = _216; +} + diff --git a/src/games/rdr2vk/output/0xFCD82342.frag.glsl b/src/games/rdr2vk/output/0xFCD82342.frag.glsl new file mode 100644 index 000000000..7690d20b5 --- /dev/null +++ b/src/games/rdr2vk/output/0xFCD82342.frag.glsl @@ -0,0 +1,153 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require + +struct _11 { + vec4 _m0; + ivec4 _m1; + vec4 _m2; + ivec4 _m3; + int _m4; + int _m5; + int _m6; + int _m7; + int _m8; + uint _m9; + float _m10; +}; + +vec3 _84; + +layout(set = 0, binding = 96, scalar) readonly buffer _10_12 { + _11 _m0[]; +} +_12; + +layout(set = 0, binding = 23, std140) uniform _15_16 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_16; + +layout(set = 1, binding = 22, std140) uniform _17_18 { + vec4 _m0[2]; + vec4 _m1[2]; + vec4 _m2[2]; + vec4 _m3; + vec4 _m4; + vec4 _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +} +_18; + +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 1, binding = 37) uniform sampler _19; +layout(set = 1, binding = 128) uniform texture2D _20; +layout(set = 0, binding = 131) uniform texture3D _21; + +layout(location = 0) in vec4 _4; +layout(location = 1) in vec4 _5; +layout(location = 2) in vec2 _6; +layout(location = 0) out vec4 _7; + +void main() { + vec4 _97 = (texture(sampler2D(_20, _19), _6) * _18._m5) + _18._m4; + _97.w = _97.w * _5.w; + vec4 _114; + if (floatBitsToInt(_18._m10) != 0) { + vec4 _112 = textureLod(sampler3D(_21, _9), _97.xyz, 0.0); + _114 = vec4(_112.x, _112.y, _112.z, _97.w); + } else { + _114 = _97; + } + vec4 _164; + if (floatBitsToInt(_18._m7) != 0) { +#if 1 + _114.rgb = GammaSafe(_114.rgb); +#endif + + vec3 _126 = _114.xyz * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _144; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _144 = PQEncodeUI(_126); + } else { + float _137 = pow(abs((_126.x * _16._m0) / _16._m15), 0.1593017578125); + _144.x = pow((0.8359375 + (18.8515625 * _137)) / (1.0 + (18.6875 * _137)), 78.84375); + float _146 = pow(abs((_126.y * _16._m0) / _16._m15), 0.1593017578125); + _144.y = pow((0.8359375 + (18.8515625 * _146)) / (1.0 + (18.6875 * _146)), 78.84375); + float _155 = pow(abs((_126.z * _16._m0) / _16._m15), 0.1593017578125); + _144.z = pow((0.8359375 + (18.8515625 * _155)) / (1.0 + (18.6875 * _155)), 78.84375); + } +#else + float _137 = pow(abs((_126.x * _16._m0) / _16._m15), 0.1593017578125); + vec3 _144; + _144.x = pow((0.8359375 + (18.8515625 * _137)) / (1.0 + (18.6875 * _137)), 78.84375); + float _146 = pow(abs((_126.y * _16._m0) / _16._m15), 0.1593017578125); + _144.y = pow((0.8359375 + (18.8515625 * _146)) / (1.0 + (18.6875 * _146)), 78.84375); + float _155 = pow(abs((_126.z * _16._m0) / _16._m15), 0.1593017578125); + _144.z = pow((0.8359375 + (18.8515625 * _155)) / (1.0 + (18.6875 * _155)), 78.84375); +#endif + _164 = vec4(_144.x, _144.y, _144.z, _114.w); + } else { + _164 = _114; + } + vec3 _172 = mix(_164.xyz * _164.www, _164.xyz, bvec3(_18._m6 == 0.0)); + vec4 _173 = vec4(_172.x, _172.y, _172.z, _164.w); + float _177 = _12._m0[0u]._m0.w * _164.w; + _173.z = (_12._m0[0u]._m0.w != 1.0) ? (_177 * _177) : _172.z; + float _186 = _164.w * _12._m0[0u]._m0.x; + _173.w = _186; + vec4 _216; + if (floatBitsToInt(_18._m11) != 0) { + vec4 _202; + if (floatBitsToInt(_18._m8) != 0) { + vec4 _201 = _173; + _201.w = _186 * _18._m8; + _202 = _201; + } else { + _202 = _173; + } + vec4 _215; + if (floatBitsToInt(_18._m9) != 0) { + vec4 _214 = _202; + _214.w = (-0.5) * (cos(_202.w * 3.1415927410125732421875) - 1.0); + _215 = _214; + } else { + _215 = _202; + } + _216 = _215; + } else { + _216 = _173; + } + vec4 _219 = _216; + _219.w = clamp(_216.w, 0.0, 1.0); + _7 = _219; +} + diff --git a/src/games/rdr2vk/output/compiled/0x14BF23D4.frag.spv b/src/games/rdr2vk/output/compiled/0x14BF23D4.frag.spv new file mode 100644 index 000000000..ac57f3b7b Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x14BF23D4.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0x1B0D650C.frag.spv b/src/games/rdr2vk/output/compiled/0x1B0D650C.frag.spv new file mode 100644 index 000000000..af0c4c0bd Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x1B0D650C.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0x26B3FAA9.frag.spv b/src/games/rdr2vk/output/compiled/0x26B3FAA9.frag.spv new file mode 100644 index 000000000..92861ab40 Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x26B3FAA9.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0x6032A998.frag.spv b/src/games/rdr2vk/output/compiled/0x6032A998.frag.spv new file mode 100644 index 000000000..3e5081ec0 Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x6032A998.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0x76A78879.frag.spv b/src/games/rdr2vk/output/compiled/0x76A78879.frag.spv new file mode 100644 index 000000000..926995476 Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x76A78879.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0x7BE28339.frag.spv b/src/games/rdr2vk/output/compiled/0x7BE28339.frag.spv new file mode 100644 index 000000000..f7ab93fb7 Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x7BE28339.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0x8B9C89F1.frag.spv b/src/games/rdr2vk/output/compiled/0x8B9C89F1.frag.spv new file mode 100644 index 000000000..709c53471 Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0x8B9C89F1.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0xA383C448.frag.spv b/src/games/rdr2vk/output/compiled/0xA383C448.frag.spv new file mode 100644 index 000000000..12ad1576b Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0xA383C448.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0xBCF843ED.frag.spv b/src/games/rdr2vk/output/compiled/0xBCF843ED.frag.spv new file mode 100644 index 000000000..9c11b59d9 Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0xBCF843ED.frag.spv differ diff --git a/src/games/rdr2vk/output/compiled/0xFCD82342.frag.spv b/src/games/rdr2vk/output/compiled/0xFCD82342.frag.spv new file mode 100644 index 000000000..7370877fd Binary files /dev/null and b/src/games/rdr2vk/output/compiled/0xFCD82342.frag.spv differ diff --git a/src/games/rdr2vk/output/output.glsl b/src/games/rdr2vk/output/output.glsl new file mode 100644 index 000000000..4424d8c27 --- /dev/null +++ b/src/games/rdr2vk/output/output.glsl @@ -0,0 +1,23 @@ +#include "../common.glsl" + +vec3 ClampMaxChannel(vec3 color) { + if (RENODX_TONE_MAP_TYPE != 0.f && RENODX_TONE_MAP_TYPE != 1.f && CLAMP_PEAK != 0.f) { + float peak = RENODX_PEAK_WHITE_NITS; + float max_channel = max(max(max(color.r, color.g), color.b), peak); + color *= peak / max_channel; // Clamp overshoot + } + return color; +} + +vec3 PQEncodeUI(vec3 x) { + x *= vec3(RENODX_GRAPHICS_WHITE_NITS); + x = ClampMaxChannel(x); + return EncodePQ(max(vec3(0.0), x), 1.f); +} + +vec3 PQEncodeGame(vec3 x) { + x *= vec3(RENODX_DIFFUSE_WHITE_NITS); + x = ClampMaxChannel(x); + return EncodePQ(max(vec3(0.0), x), 1.f); +} + diff --git a/src/games/rdr2vk/output/output_main_0xA383C448.frag.glsl b/src/games/rdr2vk/output/output_main_0xA383C448.frag.glsl new file mode 100644 index 000000000..46eed32ff --- /dev/null +++ b/src/games/rdr2vk/output/output_main_0xA383C448.frag.glsl @@ -0,0 +1,439 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./output.glsl" + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _12 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _15 _m3; + vec2 _m4; +}; + +struct _17 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _18 { + int _m0; +}; + +struct _19 { + _18 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _16 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _17 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _18 _m16; + _18 _m17; + _19 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _21 { + vec3 _m0; + float _m1; +}; + +struct _22 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _23 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _24 { + float _m0; + _18 _m1; +}; + +struct _25 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _26 { + _18 _m0; + float _m1; + float _m2; +}; + +struct _28 { + int _m0; +}; + +struct _27 { + _18 _m0; + _28 _m1; + _28 _m2; +}; + +struct _29 { + _18 _m0; +}; + +struct _20 { + _21 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _22 _m4; + _23 _m5; + _24 _m6; + _25 _m7; + _26 _m8; + _27 _m9; + _29 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _30 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _31 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _32 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _33 { + vec4 _m0; + vec4 _m1; +}; + +struct _35 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _34 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _35 _m19[2]; +}; + +struct _36 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _37 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _38 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _11 { + float _m0[32]; + float _m1[32]; + _12 _m2; + _12 _m3; + _13 _m4; + _14 _m5; + _16 _m6; + _20 _m7; + _30 _m8; + _31 _m9; + float _m10; + vec2 _m11; + _32 _m12; + _33 _m13; + float _m14; + float _m15; + vec4 _m16; + _34 _m17; + _36 _m18; + _37 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _38 _m30; + int _m31; +}; + +vec3 _131; + +layout(set = 0, binding = 99, scalar) readonly buffer _10_39 { + _11 _m0[]; +} +_39; + +layout(set = 0, binding = 18, std140) uniform _44_45 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_45; + +layout(set = 1, binding = 17, std140) uniform _46_47 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + float _m5; + float _m6; + float _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; +} +_47; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 0, binding = 123) uniform texture2DArray _43; +layout(set = 1, binding = 187) uniform texture2D _48; +layout(set = 1, binding = 207) uniform texture3D _49; + +layout(location = 0) in vec4 _4; +layout(location = 1) in vec2 _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _133 = gl_FragCoord; + _133.w = 1.0 / _133.w; + vec4 _141 = textureLod(sampler2D(_48, _8), _5, 0.0); + vec3 _150 = _141.xyz; + vec3 _173 = mix(mix(pow((_150 + vec3(_45._m14)) / vec3(_45._m13), vec3(1.0 / _45._m12)), _150 / vec3(_45._m11), lessThan(_150, vec3(0.003130800090730190277099609375 / _45._m11))), _150, bvec3((_45._m3 != 0u) && (!(_45._m2 != 0u)))); + vec3 _245; + if (_45._m16 != 0u) { + uint _185 = uint(_47._m10.x); + vec3 _239; + if (_185 == 1u) { + _239 = (log2(_173 + vec3(1.0000000116860974230803549289703e-07)) * _47._m10.y) + vec3(_47._m10.z); + } else { + vec3 _238; + if (_185 == 2u) { + float _206 = pow(((_173.x * _47._m10.y) + _47._m10.z) * 9.9999997473787516355514526367188e-05, 0.1593017578125); + vec3 _213 = _173; + _213.x = pow((0.8359375 + (18.8515625 * _206)) / (1.0 + (18.6875 * _206)), 78.84375); + float _218 = pow(((_173.y * _47._m10.y) + _47._m10.z) * 9.9999997473787516355514526367188e-05, 0.1593017578125); + _213.y = pow((0.8359375 + (18.8515625 * _218)) / (1.0 + (18.6875 * _218)), 78.84375); + float _230 = pow(((_173.z * _47._m10.y) + _47._m10.z) * 9.9999997473787516355514526367188e-05, 0.1593017578125); + _213.z = pow((0.8359375 + (18.8515625 * _230)) / (1.0 + (18.6875 * _230)), 78.84375); + _238 = _213; + } else { + _238 = _173; + } + _239 = _238; + } + _245 = textureLod(sampler3D(_49, _9), _239, 0.0).xyz; + } else { + _245 = _173; + } + +#if 1 + _245.rgb = GammaSafe(_245.rgb); +#endif + + vec3 _246 = _245 * mat3(vec3(0.6274039745330810546875, 0.329281985759735107421875, 0.043313600122928619384765625), vec3(0.06909699738025665283203125, 0.919539988040924072265625, 0.0113612003624439239501953125), vec3(0.01639159955084323883056640625, 0.0880132019519805908203125, 0.895595014095306396484375)); +#if 1 + vec3 _264; + if (RENODX_TONE_MAP_TYPE != 0.f) { + _264 = PQEncodeUI(_246); + } else { + float _257 = pow(abs((_246.x * _45._m0) / _45._m15), 0.1593017578125); + _264.x = pow((0.8359375 + (18.8515625 * _257)) / (1.0 + (18.6875 * _257)), 78.84375); + float _266 = pow(abs((_246.y * _45._m0) / _45._m15), 0.1593017578125); + _264.y = pow((0.8359375 + (18.8515625 * _266)) / (1.0 + (18.6875 * _266)), 78.84375); + float _275 = pow(abs((_246.z * _45._m0) / _45._m15), 0.1593017578125); + _264.z = pow((0.8359375 + (18.8515625 * _275)) / (1.0 + (18.6875 * _275)), 78.84375); + } +#else + float _257 = pow(abs((_246.x * _45._m0) / _45._m15), 0.1593017578125); + vec3 _264; + _264.x = pow((0.8359375 + (18.8515625 * _257)) / (1.0 + (18.6875 * _257)), 78.84375); + float _266 = pow(abs((_246.y * _45._m0) / _45._m15), 0.1593017578125); + _264.y = pow((0.8359375 + (18.8515625 * _266)) / (1.0 + (18.6875 * _266)), 78.84375); + float _275 = pow(abs((_246.z * _45._m0) / _45._m15), 0.1593017578125); + _264.z = pow((0.8359375 + (18.8515625 * _275)) / (1.0 + (18.6875 * _275)), 78.84375); +#endif + vec3 _336; + if (floatBitsToInt(_47._m2.x) != 0) { + ivec4 _314 = ivec4(uvec4(uvec2(ivec2(uvec2(_133.xy))) & uvec2(63u), uint(int((floatBitsToInt(_47._m2.y) != 0) ? _39._m0[0u]._m22 : 63u) & 31), 0u)); + vec3 _322 = (vec3(texelFetch(_43, _314.xyz, _314.w).x) * 2.0) - vec3(1.0); + vec3 _333; + if (floatBitsToInt(_47._m2.z) != 0) { + _333 = vec3(ivec3(sign(_322))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_322))); + } else { + _333 = _322; + } + _336 = _264 + (_333 * vec3(_47._m2.w)); + } else { + _336 = _264; + } + _6 = vec4(_336, _141.w); +} + diff --git a/src/games/rdr2vk/perceptual_color.glsl b/src/games/rdr2vk/perceptual_color.glsl new file mode 100644 index 000000000..f8544be9b --- /dev/null +++ b/src/games/rdr2vk/perceptual_color.glsl @@ -0,0 +1,1038 @@ +#ifndef SRC_GAMES_RDR2VK_PERCEPTUAL_COLOR_GLSL_ +#define SRC_GAMES_RDR2VK_PERCEPTUAL_COLOR_GLSL_ + +// RDR2VK perceptual color transforms, grading, Yf, and PsychoV gamut mapping. +// Names are prefixed to replace HLSL namespaces. + +const mat3 renodx_color_macleod_boynton_XYZ_TO_LMS_2006 = mat3( + vec3(0.185082982238733, -0.134433056469973, 0.000789456671966863), + vec3(0.584081279463687, 0.405752392775348, -0.000912281325916184), + vec3(-0.0240722415044404, 0.0358252602217631, 0.0198490812339463)); + +const mat3 renodx_color_macleod_boynton_LMS_TO_XYZ_2006 = mat3( + vec3(2.628474773947687, 0.8765342837340055, -0.06425592569153735), + vec3(-3.761263499279893, 1.2003038085515867, 0.20476359921126536), + vec3(9.9763571339745, -1.1033785928646218, 49.93266413348867)); + +const mat3 renodx_color_macleod_boynton_BT709_TO_XYZ_MAT = mat3( + vec3(0.4123907993, 0.2126390059, 0.0193308187), + vec3(0.3575843394, 0.7151686788, 0.1191947798), + vec3(0.1804807884, 0.0721923154, 0.9505321522)); + +const mat3 renodx_color_macleod_boynton_XYZ_TO_BT709_MAT = mat3( + vec3(3.2409699419, -0.9692436363, 0.0556300797), + vec3(-1.5373831776, 1.8759675015, -0.2039769589), + vec3(-0.4986107603, 0.0415550574, 1.0569715142)); + +const mat3 renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT = mat3( + vec3(0.6369580483, 0.2627002120, 0.0000000000), + vec3(0.1446169036, 0.6779980715, 0.0280726930), + vec3(0.1688809752, 0.0593017165, 1.0609850577)); + +const mat3 renodx_color_macleod_boynton_XYZ_TO_BT2020_MAT = mat3( + vec3(1.7166511880, -0.6666843518, 0.0176398574), + vec3(-0.3556707838, 1.6164812366, -0.0427706133), + vec3(-0.2533662814, 0.0157685458, 0.9421031212)); + +const mat3 renodx_color_XYZ_TO_STOCKMAN_SHARP_LMS_MAT = mat3( + vec3(0.2670502842655792, -0.38706882411220156, 0.026727793989083093), + vec3(0.8471990148492798, 1.165429935890458, -0.02729131667566509), + vec3(-0.03470416612462053, 0.10302286696614202, 0.5333267257603284)); + +const mat3 renodx_color_STOCKMAN_SHARP_LMS_TO_XFYFZF_MAT = mat3( + vec3(1.94735469, 0.68990272, 0.0), + vec3(-1.41445123, 0.34832189, 0.0), + vec3(0.36476327, 0.0, 1.93485343)); + +const vec2 renodx_color_macleod_boynton_WHITE_POINT_D65 = vec2(0.31272, 0.32903); + +const float renodx_color_macleod_boynton_EPSILON = 1e-20; +const float renodx_color_macleod_boynton_INTERVAL_MAX = 1e30; +const float renodx_color_macleod_boynton_MB_NEAR_WHITE_EPSILON = 1e-14; + +float renodx_color_macleod_boynton_DivideSafe(float a, float b, float fallback) { + return (b == 0.0) ? fallback : (a / b); +} + +vec3 renodx_color_macleod_boynton_xyz_from_xyY(vec3 xyY) { + float x = xyY.x; + float y = xyY.y; + float Y = xyY.z; + float safe_y = max(y, 1e-10); + + float X = x * Y / safe_y; + float Z = (1.0 - x - y) * Y / safe_y; + return vec3(X, Y, Z); +} + +vec2 renodx_color_macleod_boynton_MB_From_LMS(vec3 lms) { + float t = lms.x + lms.y; + if (t <= 0.0) { + return vec2(0.0); + } + + return vec2( + renodx_color_macleod_boynton_DivideSafe(lms.x, t, 0.0), + renodx_color_macleod_boynton_DivideSafe(lms.z, t, 0.0)); +} + +vec3 renodx_color_macleod_boynton_LMS_From_MB_T(vec2 mb, float t) { + float r = mb.x; + float b = mb.y; + return vec3(r * t, (1.0 - r) * t, b * t); +} + +vec2 renodx_color_macleod_boynton_MB_White_D65() { + vec3 d65_xyz = renodx_color_macleod_boynton_xyz_from_xyY( + vec3(renodx_color_macleod_boynton_WHITE_POINT_D65, 1.0)); + vec3 d65_lms = renodx_color_macleod_boynton_XYZ_TO_LMS_2006 * d65_xyz; + return renodx_color_macleod_boynton_MB_From_LMS(d65_lms); +} + +vec3 renodx_color_macleod_boynton_TransferPurityBT2020( + vec3 rgb_target_bt2020_linear, vec3 rgb_source_bt2020_linear, float strength) { + if (strength <= 0.0) { + return max(rgb_target_bt2020_linear, vec3(0.0)); + } + + const float t_min = 1e-7; + vec2 white = renodx_color_macleod_boynton_MB_White_D65(); + + vec3 xyz_target = renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT * rgb_target_bt2020_linear; + vec3 lms_target = renodx_color_macleod_boynton_XYZ_TO_LMS_2006 * xyz_target; + float target_t = lms_target.x + lms_target.y; + if (target_t <= t_min) { + return max(rgb_target_bt2020_linear, vec3(0.0)); + } + + vec3 xyz_source = renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT * rgb_source_bt2020_linear; + vec3 lms_source = renodx_color_macleod_boynton_XYZ_TO_LMS_2006 * xyz_source; + float source_t = lms_source.x + lms_source.y; + if (source_t <= t_min) { + return max(rgb_target_bt2020_linear, vec3(0.0)); + } + + vec2 mb_target = renodx_color_macleod_boynton_MB_From_LMS(lms_target); + vec2 mb_source = renodx_color_macleod_boynton_MB_From_LMS(lms_source); + + vec2 target_offset = mb_target - white; + float target_len = length(target_offset); + if (target_len < renodx_color_macleod_boynton_MB_NEAR_WHITE_EPSILON) { + return max(rgb_target_bt2020_linear, vec3(0.0)); + } + + float source_len = length(mb_source - white); + float out_len = (strength >= 1.0) + ? source_len + : mix(target_len, source_len, clamp(strength, 0.0, 1.0)); + + vec2 target_dir = target_offset / target_len; + vec2 mb_out = white + target_dir * out_len; + vec3 lms_out = renodx_color_macleod_boynton_LMS_From_MB_T(mb_out, target_t); + vec3 xyz_out = renodx_color_macleod_boynton_LMS_TO_XYZ_2006 * lms_out; + vec3 rgb_out = renodx_color_macleod_boynton_XYZ_TO_BT2020_MAT * xyz_out; + return max(rgb_out, vec3(0.0)); +} + +void renodx_color_macleod_boynton_IntervalLower0(float a, float b, out float lo, out float hi) { + if (abs(a) < renodx_color_macleod_boynton_EPSILON) { + if (b >= 0.0) { + lo = -renodx_color_macleod_boynton_INTERVAL_MAX; + hi = renodx_color_macleod_boynton_INTERVAL_MAX; + } else { + lo = 1.0; + hi = 0.0; + } + return; + } + + float t0 = renodx_color_macleod_boynton_DivideSafe(-b, a, 0.0); + if (a > 0.0) { + lo = t0; + hi = renodx_color_macleod_boynton_INTERVAL_MAX; + } else { + lo = -renodx_color_macleod_boynton_INTERVAL_MAX; + hi = t0; + } +} + +struct renodx_color_macleod_boynton_MBPurityDebug { + vec3 rgbOut; + float purityCur01; +}; + +renodx_color_macleod_boynton_MBPurityDebug renodx_color_macleod_boynton_ApplyInternal( + vec3 rgb_linear, float purity_value, float curve_gamma, + vec2 mb_white_override, float t_min, + mat3 rgb_to_xyz_mat, mat3 xyz_to_rgb_mat) { + renodx_color_macleod_boynton_MBPurityDebug result; + result.rgbOut = rgb_linear; + result.purityCur01 = 0.0; + + vec3 xyz = rgb_to_xyz_mat * rgb_linear; + vec3 lms = renodx_color_macleod_boynton_XYZ_TO_LMS_2006 * xyz; + + float t = lms.x + lms.y; + if (t <= t_min) { + return result; + } + + vec2 white = (mb_white_override.x >= 0.0 && mb_white_override.y >= 0.0) + ? mb_white_override + : renodx_color_macleod_boynton_MB_White_D65(); + + vec2 mb0 = renodx_color_macleod_boynton_MB_From_LMS(lms); + vec2 direction = mb0 - white; + if (dot(direction, direction) < renodx_color_macleod_boynton_MB_NEAR_WHITE_EPSILON) { + return result; + } + + vec3 lms_t0 = renodx_color_macleod_boynton_LMS_From_MB_T(white, t); + vec3 xyz_t0 = renodx_color_macleod_boynton_LMS_TO_XYZ_2006 * lms_t0; + vec3 rgb_t0 = xyz_to_rgb_mat * xyz_t0; + + vec3 a = rgb_linear - rgb_t0; + + float t_lo = 0.0; + float t_hi = renodx_color_macleod_boynton_INTERVAL_MAX; + float lo; + float hi; + + renodx_color_macleod_boynton_IntervalLower0(a.x, rgb_t0.x, lo, hi); + t_lo = max(t_lo, lo); + t_hi = min(t_hi, hi); + renodx_color_macleod_boynton_IntervalLower0(a.y, rgb_t0.y, lo, hi); + t_lo = max(t_lo, lo); + t_hi = min(t_hi, hi); + renodx_color_macleod_boynton_IntervalLower0(a.z, rgb_t0.z, lo, hi); + t_lo = max(t_lo, lo); + t_hi = min(t_hi, hi); + + if (t_hi < t_lo) { + result.rgbOut = max(rgb_linear, vec3(0.0)); + return result; + } + + float t_max = max(0.0, t_hi); + float p_cur = (t_max > renodx_color_macleod_boynton_EPSILON) + ? renodx_color_macleod_boynton_DivideSafe(1.0, t_max, 0.0) + : 0.0; + result.purityCur01 = clamp(p_cur, 0.0, 1.0); + + float purity = pow(clamp(purity_value, 0.0, 1.0), max(curve_gamma, 1e-6)); + float t_final = purity * t_max; + + vec2 mb_final = white + t_final * direction; + vec3 lms_final = renodx_color_macleod_boynton_LMS_From_MB_T(mb_final, t); + vec3 xyz_final = renodx_color_macleod_boynton_LMS_TO_XYZ_2006 * lms_final; + vec3 rgb_final = xyz_to_rgb_mat * xyz_final; + result.rgbOut = max(rgb_final, vec3(0.0)); + return result; +} + +renodx_color_macleod_boynton_MBPurityDebug renodx_color_macleod_boynton_ApplyBT2020( + vec3 rgb2020_linear, float purity01, float curve_gamma, vec2 mb_white_override, + float t_min) { + return renodx_color_macleod_boynton_ApplyInternal( + rgb2020_linear, purity01, curve_gamma, mb_white_override, t_min, + renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT, + renodx_color_macleod_boynton_XYZ_TO_BT2020_MAT); +} + +float renodx_color_yf_from_LMS(vec3 lms) { + return (renodx_color_STOCKMAN_SHARP_LMS_TO_XFYFZF_MAT * lms).y; +} + +float renodx_color_yf_from_BT709(vec3 bt709_linear) { + vec3 xyz = renodx_color_macleod_boynton_BT709_TO_XYZ_MAT * bt709_linear; + return renodx_color_yf_from_LMS(renodx_color_XYZ_TO_STOCKMAN_SHARP_LMS_MAT * xyz); +} + +float renodx_color_yf_from_BT2020(vec3 bt2020_linear) { + vec3 xyz = renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT * bt2020_linear; + return renodx_color_yf_from_LMS(renodx_color_XYZ_TO_STOCKMAN_SHARP_LMS_MAT * xyz); +} + +struct UserGradingConfig { + float exposure; + float highlights; + float contrast_highlights; + float shadows; + float contrast_shadows; + float contrast; + float flare; + float gamma; + float saturation; + float dechroma; + float highlight_saturation; + float hue_emulation; + float purity_emulation; +}; + +float renodx_usergrading_DivideSafe(float a, float b, float fallback) { + return (b == 0.0) ? fallback : (a / b); +} + +float renodx_usergrading_SafeDivision(float quotient, float divisor, float fallback) { + return renodx_usergrading_DivideSafe(quotient, divisor, fallback); +} + +float renodx_usergrading_saturate(float x) { + return clamp(x, 0.0, 1.0); +} + +vec3 renodx_usergrading_Luminance(vec3 color, float incorrect_y, float correct_y, float strength) { + float ratio = renodx_usergrading_DivideSafe(correct_y, incorrect_y, 1.0); + return color * mix(1.0, ratio, strength); +} + +float Highlights(float x, float highlights, float mid_gray) { + if (highlights == 1.0) return x; + + if (highlights > 1.0) { + float t = 0.0; + if (x > mid_gray) { + t = renodx_usergrading_saturate(log2(x / mid_gray) / log2(1.0 / mid_gray)); + } + t = t * t * t * (t * (t * 6.0 - 15.0) + 10.0); + return mix(x, mid_gray * pow(x / mid_gray, highlights), t); + } else { + float b = mid_gray * pow(x / mid_gray, 2.0 - highlights); + float t = 0.0; + if (x > mid_gray) { + t = renodx_usergrading_saturate(log2(x / mid_gray) / log2(1.0 / mid_gray)); + } + t = t * t * t * (t * (t * 6.0 - 15.0) + 10.0); + return renodx_usergrading_DivideSafe(x * x, mix(x, b, t), x); + } +} + +float Shadows(float x, float shadows, float mid_gray) { + if (shadows == 1.0) return x; + + float ratio = max(renodx_usergrading_DivideSafe(x, mid_gray, 0.0), 0.0); + float base_term = x * mid_gray; + float base_scale = renodx_usergrading_DivideSafe(base_term, ratio, 0.0); + + if (shadows > 1.0) { + float raised = x * (1.0 + renodx_usergrading_DivideSafe(base_term, pow(ratio, shadows), 0.0)); + float reference = x * (1.0 + base_scale); + float shadow_floor = mid_gray / 16.0; + float t = 1.0; + if (x > shadow_floor) { + t = renodx_usergrading_saturate(log2(x / mid_gray) / log2(shadow_floor / mid_gray)); + } + t = t * t * t * (t * (t * 6.0 - 15.0) + 10.0); + return x + (raised - reference) * t; + } else { + float lowered = x * (1.0 - renodx_usergrading_DivideSafe(base_term, pow(ratio, 2.0 - shadows), 0.0)); + float reference = x * (1.0 - base_scale); + float shadow_floor = mid_gray / 16.0; + float t = 1.0; + if (x > shadow_floor) { + t = renodx_usergrading_saturate(log2(x / mid_gray) / log2(shadow_floor / mid_gray)); + } + t = t * t * t * (t * (t * 6.0 - 15.0) + 10.0); + return x + (lowered - reference) * t; + } +} + +float ContrastAndFlare( + float x, float contrast, float contrast_highlights, float contrast_shadows, + float flare, float mid_gray) { + if (contrast == 1.0 && flare == 0.0 && contrast_highlights == 1.0 && contrast_shadows == 1.0) { + return x; + } + + float x_normalized = x / mid_gray; + float split_contrast = (x < mid_gray) ? contrast_shadows : contrast_highlights; + float flare_ratio = renodx_usergrading_DivideSafe(x_normalized + flare, x_normalized, 1.0); + float exponent = contrast * split_contrast * flare_ratio; + return pow(x_normalized, exponent) * mid_gray; +} + +vec3 ApplyLuminanceGrading(vec3 untonemapped, float lum, UserGradingConfig config, float mid_gray) { + if (config.exposure == 1.0 && config.shadows == 1.0 && config.highlights == 1.0 && config.contrast == 1.0 + && config.contrast_highlights == 1.0 && config.contrast_shadows == 1.0 && config.flare == 0.0 && config.gamma == 1.0) { + return untonemapped; + } + + vec3 color = untonemapped; + color *= config.exposure; + + float lum_gamma_adjusted = (lum < 1.0) ? pow(lum, config.gamma) : lum; + + float lum_contrasted = ContrastAndFlare( + lum_gamma_adjusted, + config.contrast, + config.contrast_highlights, + config.contrast_shadows, + config.flare, + mid_gray); + + float lum_highlighted = Highlights(lum_contrasted, config.highlights, mid_gray); + float lum_shadowed = Shadows(lum_highlighted, config.shadows, mid_gray); + float lum_final = lum_shadowed; + + color = renodx_usergrading_Luminance(color, lum, lum_final, 1.0); + return color; +} + +vec3 ApplyHueAndPurityGrading( + vec3 ungraded_bt2020, + vec3 reference_bt2020, + float lum, + UserGradingConfig config) { + vec3 color_bt2020 = ungraded_bt2020; + if (config.saturation == 1.0 && config.dechroma == 0.0 && config.hue_emulation == 0.0 && config.purity_emulation == 0.0 && config.highlight_saturation == 0.0) { + return color_bt2020; + } + + float curve_gamma = 1.0; + vec2 mb_white_override = vec2(-1.0); + float t_min = 1e-7; + + float kNearWhiteEpsilon = renodx_color_macleod_boynton_MB_NEAR_WHITE_EPSILON; + vec2 white = (mb_white_override.x >= 0.0 && mb_white_override.y >= 0.0) + ? mb_white_override + : renodx_color_macleod_boynton_MB_White_D65(); + + float color_purity01 = renodx_color_macleod_boynton_ApplyBT2020( + color_bt2020, 1.0, 1.0, mb_white_override, t_min) + .purityCur01; + + if (config.hue_emulation != 0.0 || config.purity_emulation != 0.0) { + float reference_purity01 = renodx_color_macleod_boynton_ApplyBT2020( + reference_bt2020, 1.0, 1.0, mb_white_override, t_min) + .purityCur01; + + float purity_current = color_purity01; + float purity_ratio = 1.0; + vec3 hue_seed_bt2020 = color_bt2020; + + if (config.hue_emulation != 0.0) { + vec3 target_lms = + renodx_color_macleod_boynton_XYZ_TO_LMS_2006 * (renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT * color_bt2020); + vec3 reference_lms = + renodx_color_macleod_boynton_XYZ_TO_LMS_2006 * (renodx_color_macleod_boynton_BT2020_TO_XYZ_MAT * reference_bt2020); + + float target_t = target_lms.x + target_lms.y; + if (target_t > t_min) { + vec2 target_direction = renodx_color_macleod_boynton_MB_From_LMS(target_lms) - white; + vec2 reference_direction = renodx_color_macleod_boynton_MB_From_LMS(reference_lms) - white; + + float target_len_sq = dot(target_direction, target_direction); + float reference_len_sq = dot(reference_direction, reference_direction); + + if (target_len_sq > kNearWhiteEpsilon || reference_len_sq > kNearWhiteEpsilon) { + vec2 target_unit = (target_len_sq > kNearWhiteEpsilon) + ? target_direction * inversesqrt(target_len_sq) + : vec2(0.0); + vec2 reference_unit = (reference_len_sq > kNearWhiteEpsilon) + ? reference_direction * inversesqrt(reference_len_sq) + : target_unit; + + if (target_len_sq <= kNearWhiteEpsilon) { + target_unit = reference_unit; + } + + vec2 blended_unit = mix(target_unit, reference_unit, config.hue_emulation); + float blended_len_sq = dot(blended_unit, blended_unit); + if (blended_len_sq <= kNearWhiteEpsilon) { + blended_unit = (config.hue_emulation >= 0.5) ? reference_unit : target_unit; + blended_len_sq = dot(blended_unit, blended_unit); + } + blended_unit *= inversesqrt(max(blended_len_sq, 1e-20)); + + float seed_len = sqrt(max(target_len_sq, 0.0)); + if (seed_len <= 1e-6) { + seed_len = sqrt(max(reference_len_sq, 0.0)); + } + seed_len = max(seed_len, 1e-6); + + hue_seed_bt2020 = + renodx_color_macleod_boynton_XYZ_TO_BT2020_MAT * (renodx_color_macleod_boynton_LMS_TO_XYZ_2006 * renodx_color_macleod_boynton_LMS_From_MB_T(white + blended_unit * seed_len, target_t)); + + float purity_post = renodx_color_macleod_boynton_ApplyBT2020( + hue_seed_bt2020, 1.0, 1.0, mb_white_override, t_min) + .purityCur01; + purity_ratio = renodx_usergrading_SafeDivision(purity_current, purity_post, 1.0); + purity_current = purity_post; + } + } + } + + if (config.purity_emulation != 0.0) { + float target_purity_ratio = renodx_usergrading_SafeDivision(reference_purity01, purity_current, 1.0); + purity_ratio = mix(purity_ratio, target_purity_ratio, config.purity_emulation); + } + + float applied_purity01 = renodx_usergrading_saturate(purity_current * max(purity_ratio, 0.0)); + color_bt2020 = renodx_color_macleod_boynton_ApplyBT2020( + hue_seed_bt2020, applied_purity01, curve_gamma, mb_white_override, t_min) + .rgbOut; + color_purity01 = applied_purity01; + } + + float purity_scale = 1.0; + + if (config.dechroma != 0.0) { + purity_scale *= mix(1.0, 0.0, renodx_usergrading_saturate(pow(lum / (10000.0 / 100.0), (1.0 - config.dechroma)))); + } + + if (config.highlight_saturation != 0.0) { + float percent_max = renodx_usergrading_saturate(lum * 100.0 / 10000.0); + float blowout_strength = 100.0; + float blowout_change = pow(1.0 - percent_max, blowout_strength * abs(config.highlight_saturation)); + if (config.highlight_saturation < 0.0) { + blowout_change = 2.0 - blowout_change; + } + + purity_scale *= blowout_change; + } + + purity_scale *= config.saturation; + + if (purity_scale != 1.0) { + float scaled_purity01 = renodx_usergrading_saturate(color_purity01 * max(purity_scale, 0.0)); + color_bt2020 = renodx_color_macleod_boynton_ApplyBT2020( + color_bt2020, scaled_purity01, curve_gamma, mb_white_override, t_min) + .rgbOut; + } + + return color_bt2020; +} + + + +// GLSL port of the BT.709-bound device-hull compression used by PsychoV test22. +const vec3 renodx_tonemap_psycho22_LMS_WEIGHTS = vec3( + 0.68990272, + 0.34832189, + 0.0371597069161); + +const mat3 renodx_tonemap_psycho22_STOCKMAN_LMS_TO_XYZ_MAT = mat3( + vec3(1.8114629636873623, 0.6069124057314326, -0.0597250591701978), + vec3(-1.3081492612535468, 0.4159062592830001, 0.08684090099781155), + vec3(0.37056946406094754, -0.04084825533137022, 1.8543617734965625)); + +const float renodx_tonemap_psycho22_GAMUT_EPSILON = 1e-20; +const float renodx_tonemap_psycho22_MB_NEAR_WHITE_EPSILON = 1e-14; +const float renodx_tonemap_psycho22_CIE1702_RAY_T_MAX = 1e20; +const int renodx_tonemap_psycho22_CIE1702_EDGE_COUNT = 7; + +const vec2 renodx_tonemap_psycho22_CIE1702_HALFSPACE_NORMALS[renodx_tonemap_psycho22_CIE1702_EDGE_COUNT] = vec2[]( + vec2(-0.043889, -0.006807), + vec2(-0.007821, -0.008564), + vec2(-0.000604, -0.007942), + vec2(0.0, -0.080835), + vec2(0.953597, 0.307020), + vec2(-0.060969, 0.019752), + vec2(-0.106895, 0.004035)); + +const float renodx_tonemap_psycho22_CIE1702_HALFSPACE_NUMERATORS[renodx_tonemap_psycho22_CIE1702_EDGE_COUNT] = float[]( + 0.0065035249, + 0.00104900495, + 0.000207697044, + 0.00165556648, + 0.252472349, + 0.0241967351, + 0.0199621232); + +vec3 renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3 bt709) { + return renodx_color_XYZ_TO_STOCKMAN_SHARP_LMS_MAT + * (renodx_color_macleod_boynton_BT709_TO_XYZ_MAT * bt709); +} + +vec3 renodx_tonemap_psycho22_BT709FromStockmanLMS(vec3 lms) { + return renodx_color_macleod_boynton_XYZ_TO_BT709_MAT + * (renodx_tonemap_psycho22_STOCKMAN_LMS_TO_XYZ_MAT * lms); +} + +vec3 renodx_tonemap_psycho22_WeighLMS(vec3 lms) { + return lms * renodx_tonemap_psycho22_LMS_WEIGHTS; +} + +vec3 renodx_tonemap_psycho22_UnweighLMS(vec3 weighted_lms) { + return weighted_lms / renodx_tonemap_psycho22_LMS_WEIGHTS; +} + +vec3 renodx_tonemap_psycho22_DivideSafe(vec3 numerator, vec3 denominator, vec3 fallback) { + return vec3( + renodx_color_macleod_boynton_DivideSafe(numerator.x, denominator.x, fallback.x), + renodx_color_macleod_boynton_DivideSafe(numerator.y, denominator.y, fallback.y), + renodx_color_macleod_boynton_DivideSafe(numerator.z, denominator.z, fallback.z)); +} + +vec3 renodx_tonemap_psycho22_MBFromWeightedLMS(vec3 weighted_lms) { + float y_mb = max(weighted_lms.x + weighted_lms.y, 0.0); + float inverse_y = renodx_color_macleod_boynton_DivideSafe(1.0, y_mb, 0.0); + return vec3(weighted_lms.x * inverse_y, weighted_lms.z * inverse_y, y_mb); +} + +vec3 renodx_tonemap_psycho22_WeightedLMSFromMB(vec2 mb, float y_mb) { + return vec3(mb.x, 1.0 - mb.x, mb.y) * y_mb; +} + +vec2 renodx_tonemap_psycho22_CIE1702WhiteChromaticity() { + vec3 d65_xyz = renodx_color_macleod_boynton_xyz_from_xyY( + vec3(renodx_color_macleod_boynton_WHITE_POINT_D65, 1.0)); + return renodx_tonemap_psycho22_MBFromWeightedLMS( + renodx_tonemap_psycho22_WeighLMS( + renodx_color_XYZ_TO_STOCKMAN_SHARP_LMS_MAT * d65_xyz)) + .xy; +} + +float renodx_tonemap_psycho22_RayExitTCIE1702(vec2 origin, vec2 direction) { + if (dot(direction, direction) <= renodx_tonemap_psycho22_MB_NEAR_WHITE_EPSILON) { + return renodx_tonemap_psycho22_CIE1702_RAY_T_MAX; + } + + vec2 white_to_origin = renodx_tonemap_psycho22_CIE1702WhiteChromaticity() - origin; + float t_best = renodx_tonemap_psycho22_CIE1702_RAY_T_MAX; + bool hit_any = false; + + for (int i = 0; i < renodx_tonemap_psycho22_CIE1702_EDGE_COUNT; ++i) { + vec2 halfspace_normal = renodx_tonemap_psycho22_CIE1702_HALFSPACE_NORMALS[i]; + float denominator = dot(halfspace_normal, direction); + float numerator = renodx_tonemap_psycho22_CIE1702_HALFSPACE_NUMERATORS[i] + + dot(halfspace_normal, white_to_origin); + float t = denominator > 1e-8 + ? numerator / denominator + : renodx_tonemap_psycho22_CIE1702_RAY_T_MAX; + t_best = min(t_best, t); + hit_any = hit_any || (denominator > 1e-8); + } + + return hit_any ? max(t_best, 0.0) : renodx_tonemap_psycho22_CIE1702_RAY_T_MAX; +} + +float renodx_tonemap_psycho22_Cross2(vec2 a, vec2 b) { + return a.x * b.y - a.y * b.x; +} + +bool renodx_tonemap_psycho22_RaySegmentHit2D( + vec2 origin, vec2 direction, vec2 a, vec2 b, out float t_hit) { + t_hit = 0.0; + vec2 edge = b - a; + float denominator = renodx_tonemap_psycho22_Cross2(direction, edge); + if (abs(denominator) <= renodx_tonemap_psycho22_GAMUT_EPSILON) return false; + + vec2 a_origin = a - origin; + float t = renodx_tonemap_psycho22_Cross2(a_origin, edge) / denominator; + float u = renodx_tonemap_psycho22_Cross2(a_origin, direction) / denominator; + if (t < 0.0 || u < 0.0 || u > 1.0) return false; + + t_hit = t; + return true; +} + +float renodx_tonemap_psycho22_RayMaxTRGBTriangleInMB( + vec2 origin, vec2 direction, vec2 r, vec2 g, vec2 b, out bool has_solution) { + has_solution = false; + if (dot(direction, direction) <= renodx_tonemap_psycho22_MB_NEAR_WHITE_EPSILON) return 0.0; + + float t_best = 3.402823466e38; + float t_hit; + bool hit_any = false; + + if (renodx_tonemap_psycho22_RaySegmentHit2D(origin, direction, r, g, t_hit)) { + t_best = min(t_best, t_hit); + hit_any = true; + } + if (renodx_tonemap_psycho22_RaySegmentHit2D(origin, direction, g, b, t_hit)) { + t_best = min(t_best, t_hit); + hit_any = true; + } + if (renodx_tonemap_psycho22_RaySegmentHit2D(origin, direction, b, r, t_hit)) { + t_best = min(t_best, t_hit); + hit_any = true; + } + + has_solution = hit_any; + return hit_any ? max(t_best, 0.0) : 0.0; +} + +float renodx_tonemap_psycho22_NeutwoPeakClip(float x, float peak, float clip) { + float peak_safe = max(peak, 0.0); + float clip_safe = max(clip, peak_safe); + float x_squared = x * x; + float clip_squared = clip_safe * clip_safe; + float peak_squared = peak_safe * peak_safe; + float denominator_squared = fma( + x_squared, clip_squared - peak_squared, clip_squared * peak_squared); + return (clip_safe * peak_safe * x) + * inversesqrt(max(denominator_squared, renodx_tonemap_psycho22_GAMUT_EPSILON)); +} + +float renodx_tonemap_psycho22_NeutwoScaleFromRayT(float t_peak, float t_clip) { + float t_peak_safe = max(t_peak, 0.0); + float t_clip_safe = max(t_clip, t_peak_safe); + return clamp( + renodx_tonemap_psycho22_NeutwoPeakClip(1.0, t_peak_safe, t_clip_safe), + 0.0, + 1.0); +} + +float renodx_tonemap_psycho22_SoftCompressionActivationFromRayT(float t_peak) { + float outside = 1.0 - clamp(t_peak, 0.0, 1.0); + return renodx_color_macleod_boynton_DivideSafe(outside, outside + 0.08, 0.0); +} + +vec3 renodx_tonemap_psycho22_ClampWeightedLMSToCIE1702(vec3 weighted_lms) { + vec3 weighted_lms_clamped = max(weighted_lms, vec3(0.0)); + vec3 mb = renodx_tonemap_psycho22_MBFromWeightedLMS(weighted_lms_clamped); + float y_mb = mb.z; + if (!(y_mb > renodx_tonemap_psycho22_GAMUT_EPSILON)) { + return vec3(weighted_lms_clamped.xy, 0.0); + } + + vec2 white = renodx_tonemap_psycho22_CIE1702WhiteChromaticity(); + vec2 direction = mb.xy - white; + if (dot(direction, direction) <= renodx_tonemap_psycho22_MB_NEAR_WHITE_EPSILON) { + return weighted_lms_clamped; + } + + float t_clip = renodx_tonemap_psycho22_RayExitTCIE1702(white, direction); + float t_final = min(1.0, t_clip); + return renodx_tonemap_psycho22_WeightedLMSFromMB(white + direction * t_final, y_mb); +} + +void renodx_tonemap_psycho22_MakeBT709TriangleInAdaptiveMB( + vec3 current_adaptive_state_lms, out vec2 r, out vec2 g, out vec2 b) { + vec3 weighted_r = renodx_tonemap_psycho22_WeighLMS( + renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(1.0, 0.0, 0.0))) + / current_adaptive_state_lms; + vec3 weighted_g = renodx_tonemap_psycho22_WeighLMS( + renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(0.0, 1.0, 0.0))) + / current_adaptive_state_lms; + vec3 weighted_b = renodx_tonemap_psycho22_WeighLMS( + renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(0.0, 0.0, 1.0))) + / current_adaptive_state_lms; + + r = renodx_tonemap_psycho22_MBFromWeightedLMS(weighted_r).xy; + g = renodx_tonemap_psycho22_MBFromWeightedLMS(weighted_g).xy; + b = renodx_tonemap_psycho22_MBFromWeightedLMS(weighted_b).xy; +} + +vec3 renodx_tonemap_psycho22_GamutCompressAdaptiveRelativeWeightedLMSBoundBT709( + vec3 relative_weighted_lms, vec3 current_adaptive_state_lms, float strength) { + vec3 weighted_lms_clamped = renodx_tonemap_psycho22_ClampWeightedLMSToCIE1702( + max(relative_weighted_lms, vec3(0.0))); + vec3 mb = renodx_tonemap_psycho22_MBFromWeightedLMS(weighted_lms_clamped); + float y_mb = mb.z; + if (!(y_mb > renodx_tonemap_psycho22_GAMUT_EPSILON)) { + return vec3(weighted_lms_clamped.xy, 0.0); + } + + vec2 white = renodx_tonemap_psycho22_CIE1702WhiteChromaticity(); + vec2 direction = mb.xy - white; + if (dot(direction, direction) <= renodx_tonemap_psycho22_MB_NEAR_WHITE_EPSILON) { + return weighted_lms_clamped; + } + + vec2 bound_r; + vec2 bound_g; + vec2 bound_b; + renodx_tonemap_psycho22_MakeBT709TriangleInAdaptiveMB( + current_adaptive_state_lms, bound_r, bound_g, bound_b); + + bool has_peak = false; + float t_peak = renodx_tonemap_psycho22_RayMaxTRGBTriangleInMB( + white, direction, bound_r, bound_g, bound_b, has_peak); + float t_clip = renodx_tonemap_psycho22_RayExitTCIE1702(white, direction); + if (!has_peak) { + t_peak = t_clip; + } + + float t_hard = clamp(t_peak, 0.0, 1.0); + float t_soft = renodx_tonemap_psycho22_NeutwoScaleFromRayT( + min(t_peak, t_clip), t_clip); + float soft_mix = clamp(strength, 0.0, 1.0) + * renodx_tonemap_psycho22_SoftCompressionActivationFromRayT(t_peak); + float t_final = mix(t_hard, t_soft, soft_mix); + + return renodx_tonemap_psycho22_WeightedLMSFromMB( + white + t_final * direction, y_mb); +} + + const float renodx_tonemap_psycho23_EPSILON = 1e-6; + const float renodx_tonemap_psycho23_REFERENCE_SIMULTANEOUS_RANGE_LOG10 = 3.7; + const float renodx_tonemap_psycho23_REFERENCE_CENTERED_RANGE_SIDE_COUNT = 2.0; + const float renodx_tonemap_psycho23_HEADROOM_RATIO_FALLBACK = 1.0; + const float renodx_tonemap_psycho23_MIN_AUTO_COMPRESSION = 1.0; + + // Empirical signed-opponent appearance controls from PsychoV23. + const float renodx_tonemap_psycho23_RED_RETENTION = 1.5; + const float renodx_tonemap_psycho23_GREEN_RETENTION = 2.0; + const float renodx_tonemap_psycho23_BLUE_RETENTION = 1.0; + const float renodx_tonemap_psycho23_YELLOW_RETENTION = 3.0; + + float renodx_tonemap_psycho23_YfFromLMS(vec3 lms) { + vec3 weighted_lms = renodx_tonemap_psycho22_WeighLMS(lms); + return max(weighted_lms.x + weighted_lms.y, renodx_tonemap_psycho23_EPSILON); + } + + float renodx_tonemap_psycho23_AutoCompressionFromCenteredReferenceRange( + float anchor_out_yf, float peak_yf) { + float peak_over_anchor = renodx_color_macleod_boynton_DivideSafe( + max(peak_yf, renodx_tonemap_psycho23_EPSILON), + max(anchor_out_yf, renodx_tonemap_psycho23_EPSILON), + renodx_tonemap_psycho23_HEADROOM_RATIO_FALLBACK); + peak_over_anchor = max( + peak_over_anchor, + 1.0 + renodx_tonemap_psycho23_EPSILON); + + float reference_one_side_range_log10 = + renodx_tonemap_psycho23_REFERENCE_SIMULTANEOUS_RANGE_LOG10 + / renodx_tonemap_psycho23_REFERENCE_CENTERED_RANGE_SIDE_COUNT; + float actual_above_adaptation_range_log10 = max( + log2(peak_over_anchor) / log2(10.0), + renodx_tonemap_psycho23_EPSILON); + + return max( + reference_one_side_range_log10 / actual_above_adaptation_range_log10, + renodx_tonemap_psycho23_MIN_AUTO_COMPRESSION); + } + + vec3 renodx_tonemap_psycho23_ToAdaptiveRelativeWeightedLMS( + vec3 lms_input, vec3 current_adaptive_state_lms) { + return renodx_tonemap_psycho22_DivideSafe( + renodx_tonemap_psycho22_WeighLMS(lms_input), + current_adaptive_state_lms, + vec3(0.0)); + } + + vec3 renodx_tonemap_psycho23_FromAdaptiveRelativeWeightedLMS( + vec3 relative_weighted_lms, vec3 current_adaptive_state_lms) { + return relative_weighted_lms + * max(current_adaptive_state_lms, vec3(renodx_tonemap_psycho23_EPSILON)); + } + + vec3 renodx_tonemap_psycho23_AdaptiveRelativeWeightedNeutral() { + return renodx_tonemap_psycho22_WeighLMS(vec3(1.0)); + } + + vec3 renodx_tonemap_psycho23_OpponentACCFromWeightedDelta(vec3 delta_weighted_lms) { + vec3 neutral_weighted = renodx_tonemap_psycho23_AdaptiveRelativeWeightedNeutral(); + float m_to_l = renodx_color_macleod_boynton_DivideSafe( + neutral_weighted.x, + neutral_weighted.y, + 0.0); + float s_to_lm = renodx_color_macleod_boynton_DivideSafe( + neutral_weighted.x + neutral_weighted.y, + neutral_weighted.z, + 0.0); + + return vec3( + delta_weighted_lms.x + delta_weighted_lms.y, + delta_weighted_lms.x - m_to_l * delta_weighted_lms.y, + -delta_weighted_lms.x - delta_weighted_lms.y + + s_to_lm * delta_weighted_lms.z); + } + + vec3 renodx_tonemap_psycho23_WeightedDeltaFromOpponentACC(vec3 acc) { + vec3 neutral_weighted = renodx_tonemap_psycho23_AdaptiveRelativeWeightedNeutral(); + float m_to_l = renodx_color_macleod_boynton_DivideSafe( + neutral_weighted.x, + neutral_weighted.y, + 0.0); + float s_to_lm = renodx_color_macleod_boynton_DivideSafe( + neutral_weighted.x + neutral_weighted.y, + neutral_weighted.z, + 0.0); + + float delta_m = renodx_color_macleod_boynton_DivideSafe( + acc.x - acc.y, + 1.0 + m_to_l, + 0.0); + float delta_l = acc.x - delta_m; + float delta_s = renodx_color_macleod_boynton_DivideSafe( + acc.z + acc.x, + s_to_lm, + 0.0); + return vec3(delta_l, delta_m, delta_s); + } + + float renodx_tonemap_psycho23_SignedOpponentRetention( + float white_progress, float retention_exponent) { + return 1.0 - pow( + clamp(white_progress, 0.0, 1.0), + max(retention_exponent, renodx_tonemap_psycho23_EPSILON)); + } + + vec3 renodx_tonemap_psycho23_ApplySignedOpponentRetention( + vec3 compressed_lms, + vec3 source_lms, + vec3 adaptive_state_lms, + vec3 peak_lms, + float white_progress) { + if (white_progress <= 0.0 + || min(source_lms.x, min(source_lms.y, source_lms.z)) <= 0.0) { + return compressed_lms; + } + + vec3 source_weighted = renodx_tonemap_psycho23_ToAdaptiveRelativeWeightedLMS( + source_lms, + adaptive_state_lms); + vec3 adapted_neutral = renodx_tonemap_psycho23_AdaptiveRelativeWeightedNeutral(); + float adapted_neutral_yf = adapted_neutral.x + adapted_neutral.y; + float source_yf = source_weighted.x + source_weighted.y; + + if (source_yf <= renodx_tonemap_psycho23_EPSILON + || adapted_neutral_yf <= renodx_tonemap_psycho23_EPSILON) { + return compressed_lms; + } + + vec3 source_neutral = adapted_neutral + * renodx_color_macleod_boynton_DivideSafe( + source_yf, + adapted_neutral_yf, + 1.0); + vec3 source_acc = renodx_tonemap_psycho23_OpponentACCFromWeightedDelta( + source_weighted - source_neutral) + / source_yf; + + float red_retention = renodx_tonemap_psycho23_SignedOpponentRetention( + white_progress, + renodx_tonemap_psycho23_RED_RETENTION); + float green_retention = renodx_tonemap_psycho23_SignedOpponentRetention( + white_progress, + renodx_tonemap_psycho23_GREEN_RETENTION); + float blue_retention = renodx_tonemap_psycho23_SignedOpponentRetention( + white_progress, + renodx_tonemap_psycho23_BLUE_RETENTION); + float yellow_retention = renodx_tonemap_psycho23_SignedOpponentRetention( + white_progress, + renodx_tonemap_psycho23_YELLOW_RETENTION); + + float rg_out = max(source_acc.y, 0.0) * red_retention + - max(-source_acc.y, 0.0) * green_retention; + float yv_out = max(source_acc.z, 0.0) * blue_retention + - max(-source_acc.z, 0.0) * yellow_retention; + + vec3 compressed_weighted = renodx_tonemap_psycho23_ToAdaptiveRelativeWeightedLMS( + compressed_lms, + adaptive_state_lms); + float target_yf = compressed_weighted.x + compressed_weighted.y; + if (target_yf <= renodx_tonemap_psycho23_EPSILON) { + return compressed_lms; + } + + vec3 peak_weighted = renodx_tonemap_psycho23_ToAdaptiveRelativeWeightedLMS( + peak_lms, + adaptive_state_lms); + float peak_weighted_yf = peak_weighted.x + peak_weighted.y; + if (peak_weighted_yf <= renodx_tonemap_psycho23_EPSILON) { + return compressed_lms; + } + + vec3 target_neutral = peak_weighted + * renodx_color_macleod_boynton_DivideSafe( + target_yf, + peak_weighted_yf, + 1.0); + vec3 target_delta = renodx_tonemap_psycho23_WeightedDeltaFromOpponentACC( + vec3(0.0, rg_out * target_yf, yv_out * target_yf)); + vec3 output_lms = renodx_tonemap_psycho22_UnweighLMS( + renodx_tonemap_psycho23_FromAdaptiveRelativeWeightedLMS( + target_neutral + target_delta, + adaptive_state_lms)); + + float compressed_yf = renodx_tonemap_psycho23_YfFromLMS(compressed_lms); + float output_yf = renodx_tonemap_psycho23_YfFromLMS(output_lms); + if (output_yf <= renodx_tonemap_psycho23_EPSILON) { + return compressed_lms; + } + + return output_lms + * renodx_color_macleod_boynton_DivideSafe( + compressed_yf, + output_yf, + 1.0); + } + + vec3 renodx_tonemap_psycho23_ApplySignedOpponentRetentionAndGamutCompressionLMS( + vec3 precompression_lms, + vec3 compressed_lms, + vec3 input_adaptive_state_lms, + vec3 output_anchor_lms, + vec3 peak_white_lms, + float hue_restore, + float gamut_compression) { + float anchor_yf = renodx_tonemap_psycho23_YfFromLMS(output_anchor_lms); + float peak_yf = renodx_tonemap_psycho23_YfFromLMS(peak_white_lms); + float output_yf = renodx_tonemap_psycho23_YfFromLMS(compressed_lms); + + // Measure white convergence from the actual compressed output because the + // RDR2 shoulder is Neutwo rather than PsychoV's analytic compression curve. + float compression_power = renodx_tonemap_psycho23_AutoCompressionFromCenteredReferenceRange( + anchor_yf, + peak_yf); + float anchor_over_peak = clamp( + renodx_color_macleod_boynton_DivideSafe(anchor_yf, peak_yf, 1.0), + 0.0, + 1.0); + float output_over_peak = max( + renodx_color_macleod_boynton_DivideSafe(output_yf, peak_yf, 0.0), + 0.0); + float anchor_powered = pow( + max(anchor_over_peak, renodx_tonemap_psycho23_EPSILON), + compression_power); + float white_progress = clamp( + renodx_color_macleod_boynton_DivideSafe( + pow(output_over_peak, compression_power) - anchor_powered, + 1.0 - anchor_powered, + 0.0), + 0.0, + 1.0); + + vec3 opponent_retained_lms = renodx_tonemap_psycho23_ApplySignedOpponentRetention( + compressed_lms, + precompression_lms, + input_adaptive_state_lms, + peak_white_lms, + white_progress); + vec3 hue_restored_lms = mix( + compressed_lms, + opponent_retained_lms, + clamp(hue_restore, 0.0, 1.0)); + + vec3 display_relative_weighted = renodx_tonemap_psycho23_ToAdaptiveRelativeWeightedLMS( + hue_restored_lms, + input_adaptive_state_lms); + if (gamut_compression != 0.0) { + display_relative_weighted = renodx_tonemap_psycho22_GamutCompressAdaptiveRelativeWeightedLMSBoundBT709( + display_relative_weighted, + input_adaptive_state_lms, + gamut_compression); + } + + return renodx_tonemap_psycho22_UnweighLMS( + renodx_tonemap_psycho23_FromAdaptiveRelativeWeightedLMS( + display_relative_weighted, + input_adaptive_state_lms)); + } + +vec3 renodx_tonemap_psycho22_GamutCompressBT709( + vec3 bt709, vec3 current_adaptive_state_bt709, float strength) { + vec3 current_adaptive_state_lms = renodx_tonemap_psycho22_StockmanLMSFromBT709( + current_adaptive_state_bt709); + vec3 relative_weighted_lms = renodx_tonemap_psycho22_DivideSafe( + renodx_tonemap_psycho22_WeighLMS( + renodx_tonemap_psycho22_StockmanLMSFromBT709(bt709)), + current_adaptive_state_lms, + vec3(0.0)); + + relative_weighted_lms = renodx_tonemap_psycho22_GamutCompressAdaptiveRelativeWeightedLMSBoundBT709( + relative_weighted_lms, + current_adaptive_state_lms, + strength); + + vec3 output_lms = renodx_tonemap_psycho22_UnweighLMS( + relative_weighted_lms * max(current_adaptive_state_lms, vec3(1e-6))); + return renodx_tonemap_psycho22_BT709FromStockmanLMS(output_lms); +} + + +#endif // SRC_GAMES_RDR2VK_PERCEPTUAL_COLOR_GLSL_ diff --git a/src/games/rdr2vk/shared.h b/src/games/rdr2vk/shared.h new file mode 100644 index 000000000..4eb16ae6d --- /dev/null +++ b/src/games/rdr2vk/shared.h @@ -0,0 +1,71 @@ +#ifndef SRC_RDR2_SHARED_H_ +#define SRC_RDR2_SHARED_H_ + +#define CLAMP_PEAK 1 + +struct ShaderInjectData { + float tone_map_type; + float peak_white_nits; + float diffuse_white_nits; + float graphics_white_nits; + + float sdr_eotf_emulation; + + float tone_map_gamma; + float tone_map_highlights; + float tone_map_shadows; + float tone_map_contrast; + float tone_map_saturation; + float tone_map_highlight_saturation; + float tone_map_flare; + float tone_map_dechroma; + float custom_lut_strength; + + float custom_vignette; + float custom_dithering; + float custom_random; + + float custom_grain_strength; + float custom_lut_encoding; + float custom_unclamp_highlights; + + float is_tonemapped; +}; + +#ifndef __cplusplus +layout(push_constant) uniform PushData { + ShaderInjectData shader_injection; +}; + +#define RENODX_TONE_MAP_TYPE shader_injection.tone_map_type +#define RENODX_PEAK_WHITE_NITS shader_injection.peak_white_nits +#define RENODX_DIFFUSE_WHITE_NITS shader_injection.diffuse_white_nits +#define RENODX_GRAPHICS_WHITE_NITS shader_injection.graphics_white_nits +#define RENODX_SDR_EOTF_EMULATION shader_injection.sdr_eotf_emulation +#define RENODX_TONE_MAP_BLEND_STRENGTH 0.5f + +#define RENODX_TONE_MAP_GAMMA shader_injection.tone_map_gamma +#define RENODX_TONE_MAP_HIGHLIGHTS shader_injection.tone_map_highlights +#define RENODX_TONE_MAP_SHADOWS shader_injection.tone_map_shadows +#define RENODX_TONE_MAP_CONTRAST shader_injection.tone_map_contrast +#define RENODX_TONE_MAP_SATURATION shader_injection.tone_map_saturation +#define RENODX_TONE_MAP_HIGHLIGHT_SATURATION shader_injection.tone_map_highlight_saturation +#define RENODX_TONE_MAP_FLARE shader_injection.tone_map_flare +#define RENODX_TONE_MAP_DECHROMA shader_injection.tone_map_dechroma + +#define CUSTOM_LUT_STRENGTH shader_injection.custom_lut_strength + +#define CUSTOM_VIGNETTE shader_injection.custom_vignette +#define CUSTOM_RANDOM shader_injection.custom_random +#define CUSTOM_DITHERING shader_injection.custom_dithering +#define CUSTOM_GRAIN_STRENGTH shader_injection.custom_grain_strength + +#define CUSTOM_LUT_ENCODING shader_injection.custom_lut_encoding + +#define UNCLAMP_HIGHLIGHTS shader_injection.custom_unclamp_highlights + +#define IS_TONEMAPPED shader_injection.is_tonemapped + +#endif // __cplusplus + +#endif // SRC_RDR2_SHARED_H_ diff --git a/src/games/rdr2vk/tonemap/0x809F5852.frag.glsl b/src/games/rdr2vk/tonemap/0x809F5852.frag.glsl new file mode 100644 index 000000000..9f2af65f7 --- /dev/null +++ b/src/games/rdr2vk/tonemap/0x809F5852.frag.glsl @@ -0,0 +1,865 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _12 { + float _m0; +}; + +struct _14 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _13 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _14 _m5; +}; + +struct _16 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _19 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _15 { + _16 _m0[2]; + _17 _m1; + _18 _m2; + _19 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _21 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _20 { + _21 _m0; + _22 _m1; + _23 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _24 { + vec4 _m0[5]; +}; + +struct _25 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _27 { + int _m0; + int _m1; +}; + +struct _28 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _11 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _12 _m41; + _13 _m42; + _15 _m43; + _20 _m44; + _24 _m45; + _25 _m46; + _26 _m47[5]; + vec4 _m48; + _27 _m49; + vec4 _m50; + _28 _m51; +}; + +struct _32 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _33 { + float _m0; +}; + +struct _35 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _34 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _35 _m3; + vec2 _m4; +}; + +struct _37 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _38 { + int _m0; +}; + +struct _39 { + _38 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _36 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _37 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _38 _m16; + _38 _m17; + _39 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _41 { + vec3 _m0; + float _m1; +}; + +struct _42 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _43 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _44 { + float _m0; + _38 _m1; +}; + +struct _45 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _46 { + _38 _m0; + float _m1; + float _m2; +}; + +struct _48 { + int _m0; +}; + +struct _47 { + _38 _m0; + _48 _m1; + _48 _m2; +}; + +struct _49 { + _38 _m0; +}; + +struct _40 { + _41 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _42 _m4; + _43 _m5; + _44 _m6; + _45 _m7; + _46 _m8; + _47 _m9; + _49 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _50 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _51 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _54 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _55 _m19[2]; +}; + +struct _56 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _57 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _58 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _31 { + float _m0[32]; + float _m1[32]; + _32 _m2; + _32 _m3; + _33 _m4; + _34 _m5; + _36 _m6; + _40 _m7; + _50 _m8; + _51 _m9; + float _m10; + vec2 _m11; + _52 _m12; + _53 _m13; + float _m14; + float _m15; + vec4 _m16; + _54 _m17; + _56 _m18; + _57 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _58 _m30; + int _m31; +}; + +struct _85 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _86 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _84 { + _85 _m0; + _86 _m1[11]; +}; + +float _252; + +layout(set = 0, binding = 98, scalar) readonly buffer _10_29 { + _11 _m0[]; +} +_29; + +layout(set = 0, binding = 99, scalar) readonly buffer _30_59 { + _31 _m0[]; +} +_59; + +layout(set = 0, binding = 20, std140) uniform _65_66 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_66; + +layout(set = 1, binding = 16, std140) uniform _67_68 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_68; + +layout(set = 0, binding = 214, std430) readonly buffer _83_87 { + _84 _m0[]; +} +_87; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 0, binding = 121) uniform texture2DArray _62; +layout(set = 0, binding = 140) uniform texture2D _63; +layout(set = 1, binding = 174) uniform texture2D _69; +layout(set = 1, binding = 177) uniform texture2D _70; +layout(set = 1, binding = 185) uniform texture1D _72; +layout(set = 1, binding = 40) uniform sampler _73; +layout(set = 1, binding = 186) uniform texture2D _74; +layout(set = 1, binding = 196) uniform texture2D _75; +layout(set = 1, binding = 197) uniform texture2D _76; +layout(set = 1, binding = 202) uniform texture2D _77; +layout(set = 1, binding = 203) uniform texture2D _78; +layout(set = 1, binding = 205) uniform texture2D _79; +layout(set = 1, binding = 206) uniform texture2D _80; +layout(set = 1, binding = 207) uniform texture2D _81; +layout(set = 1, binding = 212) uniform samplerBuffer _82; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _262 = texture(sampler2D(_80, _8), _4.xy); + vec2 _263 = _262.xy; + float _274 = _68._m0.z / ((1.0 + _68._m0.w) - textureLod(sampler2D(_69, _8), _263, 0.0).x); + vec4 _278 = texture(sampler2D(_74, _73), _263); + vec3 _292 = vec4(vec4(_278.xyz, 0.0).xyz * _29._m0[0u]._m1.w, _252).xyz; + vec4 _295 = texelFetch(_82, int(0u)); + vec4 _296 = texelFetch(_82, int(1u)); + bool _326; + vec3 _327; + if (floatBitsToInt(_68._m61) != 0) { + vec4 _312 = texture(sampler2D(_79, _73), _4.xy); + float _313 = _312.w; + bool _315 = (_313 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _324; + if (_315) { + _324 = _312.xyz; + } else { + _324 = _312.xyz + (_292 * (1.0 - _313)); + } + _326 = _315 ? true : false; + _327 = _324; + } else { + _326 = false; + _327 = _292; + } + vec3 _331 = min(_327 * texelFetch(_63, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _332 = !_326; + float _445; + vec3 _446; + if (_332) { + float _391; + if (floatBitsToInt(_68._m70.x) != 0) { + float _354 = clamp(dot(texture(sampler2D(_70, _9), _263).xyz * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _68._m72.z, _68._m72.w); + float _377 = clamp(((((_68._m70.y * log(_354 + _68._m72.x)) + _68._m70.z) - 10.0) + (_68._m72.y * _354)) + _68._m65.w, _68._m66.x, _68._m66.y); + _391 = pow(2.0, mix(_5, clamp(_377 + ((abs(_377) * _68._m66.z) * float(int(sign(_377)))), _68._m66.x, _68._m66.y), clamp(_68._m70.x, 0.0, 1.0))); + } else { + _391 = _4.z; + } + vec3 _444; + if (floatBitsToInt(_68._m51.w) != 0) { + vec2 _420 = ((_4.xy - _68._m50.xy) * mat2(vec2(_68._m52.x, _68._m52.y), vec2(_68._m52.z, _68._m52.w))) * _68._m50.zw; + float _424 = CUSTOM_VIGNETTE * max((dot(_420, _420) - _68._m53.x) * _68._m53.w, 0.0); + bool _425 = _424 < 1.0; + _444 = mix(_331, (_331 * _68._m51.xyz) * _68._m51.w, vec3(_425 ? (_425 ? (1.0 - pow(2.0, (-10.0) * _424)) : 1.0) : (0.9980499744415283203125 + (((_424 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_424 - 2.0)) : 0.0)))); + } else { + _444 = _331; + } + _445 = _391; + _446 = _444; + } else { + _445 = _4.z; + _446 = _331; + } + vec3 _483 = _446 * mix(mix(_68._m54.xyz, _68._m56.xyz, vec3(clamp(clamp(_4.y * _68._m57.y, 0.0, 1.0) + _68._m54.w, 0.0, 1.0))), mix(_68._m56.xyz, _68._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _68._m56.w, 0.0, 1.0) * _68._m57.x, 0.0, 1.0) - _68._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _486 = _66._m3 != 0u; +#if 1 + vec3 _549 = ApplyToneMap(_483, _486, _445, _66._m6, _66._m4, _66._m10, _295.rgb, _296); +#else + vec3 _549; + if (_486) { + vec3 _526 = max(vec3(0.0), _483 * (_445 / _66._m6)); + vec3 _529 = _526 * _295.x; + _549 = (((((_526 * (_529 + vec3(_296.x))) + vec3(_296.y)) / ((_526 * (_529 + vec3(_295.y))) + vec3(_296.z))) - vec3(_296.w)) * ((_66._m4 != 0u) ? _66._m10 : _295.z)) * _66._m6; + } else { + vec3 _492 = max(vec3(0.0), _483 * _445); + vec3 _495 = _492 * _295.x; + _549 = clamp(((((_492 * (_495 + vec3(_296.x))) + vec3(_296.y)) / ((_492 * (_495 + vec3(_295.y))) + vec3(_296.z))) - vec3(_296.w)) * _295.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _597; + if (_332) { + vec3 _596; + if (floatBitsToInt(_68._m47.w) != 0) { + vec2 _582 = ((_4.xy - _68._m46.xy) * mat2(vec2(_68._m48.x, _68._m48.y), vec2(_68._m48.z, _68._m48.w))) * _68._m46.zw; + _596 = mix(_549, _68._m47.xyz, vec3(_68._m47.w * texture(sampler1D(_72, _9), min(1.0, max((dot(_582, _582) - _68._m49.x) * _68._m49.w, 0.0))).w)); + } else { + _596 = _549; + } + _597 = _596; + } else { + _597 = _549; + } + bool _618 = _486 && (!(_66._m2 != 0u)); + +#if 1 + vec3 _620 = EncodeLUTInput(_597, _66._m11, _66._m12, _66._m13, _66._m14, _618); +#else + vec3 _620 = mix(mix((pow(_597, vec3(_66._m12)) * _66._m13) - vec3(_66._m14), _597 * _66._m11, lessThan(_597, vec3(0.003130800090730190277099609375))), _597, bvec3(_618)); +#endif + + vec3 _622 = max(_620 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _623 = _622.y; + vec3 _648 = mix(_620, clamp((_68._m81.xyz * (_623 * ((1.33000004291534423828125 * (1.0 + ((_623 + _622.z) / _622.x))) - 1.67999994754791259765625))) * _68._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + dot(_292 * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)))) * _68._m82.x) + _68._m82.y, 0.0, 1.0))); + vec3 _678; + if (floatBitsToInt(_68._m84.w) != 0) { + _678 = mix(_648, texture(sampler2D(_81, _9), ((((_4.xy - vec2(0.5)) * _68._m84.z) / mix(_68._m85.wx, _68._m85.zy, _4.yx)) - _68._m84.xy) + vec2(0.5)).xyz, vec3(_68._m84.w)); + } else { + _678 = _648; + } + float _703 = 1.0; + vec3 _836; + if (_332) { +#if 1 + vec3 _704 = CompressLUTInput(_678, _618, _66._m5, _66._m7, _66._m8, _66._m9, _703); +#else + float _697 = max(max(_678.x, max(_678.y, _678.z)), 9.9999997473787516355514526367188e-05); + _703 = (_618 && (!(_66._m5 != 0u))) ? 1.0 : (((_697 > _66._m7) ? ((_697 * _66._m8) + _66._m9) : _697) / _697); + vec3 _704 = _678 * _703; +#endif + float _707 = _704.z; + float _709 = floor(_707 * 14.99989986419677734375); + float _715 = (_709 * 0.0625) + (_704.x * 0.05859375); + float _717 = _704.y * 0.9375; + vec4 _721 = texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_715, _717)); + vec4 _727 = texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_715 + 0.0625, _717)); + vec3 _730 = mix(_721.xyz, _727.xyz, vec3((_707 * 15.0) - _709)); + vec3 _833; + if (_87._m0[0u]._m0._m0 > 0) { + float _764 = _730.z; + float _766 = floor(_764 * 14.99989986419677734375); + float _772 = (_766 * 0.0625) + (_730.x * 0.05859375); + float _774 = _730.y * 0.9375; + vec3 _789 = mix(_730, mix(texture(sampler2D(_75, _9), vec2(0.001953125, 0.03125) + vec2(_772, _774)).xyz, texture(sampler2D(_75, _9), vec2(0.001953125, 0.03125) + vec2(_772 + 0.0625, _774)).xyz, vec3((_764 * 15.0) - _766)), vec3(clamp(((_274 < _87._m0[0u]._m1[0]._m2) ? clamp((_274 - _87._m0[0u]._m1[0]._m0) * _87._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_274 - _87._m0[0u]._m1[0]._m2) * _87._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _87._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _801 = _789.z; + float _803 = floor(_801 * 14.99989986419677734375); + float _809 = (_803 * 0.0625) + (_789.x * 0.05859375); + float _811 = _789.y * 0.9375; + _833 = mix(_789, mix(_789, mix(texture(sampler2D(_76, _9), vec2(0.001953125, 0.03125) + vec2(_809, _811)).xyz, texture(sampler2D(_76, _9), vec2(0.001953125, 0.03125) + vec2(_809 + 0.0625, _811)).xyz, vec3((_801 * 15.0) - _803)), vec3(clamp(((_274 < _87._m0[0u]._m1[1]._m2) ? clamp((_274 - _87._m0[0u]._m1[1]._m0) * _87._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_274 - _87._m0[0u]._m1[1]._m2) * _87._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _87._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_78, _9), _263).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _833 = _730; + } + _836 = _833; + } else { + _836 = _678; + } + +#if 1 + _836 = DecodeLUTInput(_836, _678, _703); +#endif + + vec4 _841 = vec4(_836, dot(_836, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _842 = _841.xyz; + ivec4 _885 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_59._m0[0u]._m22) & 31), 0u)); + vec3 _893 = (vec3(texelFetch(_62, _885.xyz, _885.w).x) * 2.0) - vec3(1.0); + vec3 _904; + if (_486) { + _904 = vec3(ivec3(sign(_893))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_893))); + } else { + _904 = _893; + } + vec3 _906 = _842 + CUSTOM_DITHERING * (_904 * mix(_68._m39.xyz, _68._m40.xyz, pow(clamp((mix(vec3(max(_836.x, max(_836.y, _836.z))), _842, bvec3(floatBitsToInt(_68._m41.w) != 0)) - _68._m42.xyz) * _68._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_68._m42.w)))); + vec4 _907 = vec4(_906.x, _906.y, _906.z, _841.w); + vec4 _912; + if (!_486) { + _912 = clamp(_907, vec4(0.0), vec4(1.0)); + } else { + _912 = _907; + } + _6 = _912; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/0x9B304112.frag.glsl b/src/games/rdr2vk/tonemap/0x9B304112.frag.glsl new file mode 100644 index 000000000..43426ab76 --- /dev/null +++ b/src/games/rdr2vk/tonemap/0x9B304112.frag.glsl @@ -0,0 +1,69 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +layout(set = 1, binding = 31, std140) uniform _6_7 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + vec4 _m6; + float _m7; + float _m8; + float _m9; +} +_7; + +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 1, binding = 128) uniform texture2D _11; +layout(set = 1, binding = 129) uniform texture1D _13; +layout(set = 1, binding = 130) uniform texture2D _14; +layout(set = 1, binding = 131) uniform texture2D _15; +layout(set = 1, binding = 132) uniform texture2D _16; +layout(set = 1, binding = 133) uniform texture2D _17; + +layout(location = 0) in vec2 _4; +layout(location = 0) out vec4 _5; + +void main() { + vec2 _88 = ((_4 - _7._m3) * mat2(vec2(_7._m5.x, _7._m5.y), vec2(_7._m5.z, _7._m5.w))) * _7._m4; + vec3 _104 = mix(texture(sampler2D(_11, _9), _4).xyz, _7._m6.xyz, vec3(texture(sampler1D(_13, _9), min(1.0, max((dot(_88, _88) - _7._m7) * _7._m8, 0.0))).w * _7._m6.w)); + float _106 = _104.z; + float _108 = floor(_106 * 14.99989986419677734375); + float _114 = (_108 * 0.0625) + (_104.x * 0.05859375); + float _116 = _104.y * 0.9375; + vec3 _129 = mix(texture(sampler2D(_16, _9), vec2(0.001953125, 0.03125) + vec2(_114, _116)).xyz, texture(sampler2D(_16, _9), vec2(0.001953125, 0.03125) + vec2(_114 + 0.0625, _116)).xyz, vec3((_106 * 15.0) - _108)); + vec4 _132 = texture(sampler2D(_17, _9), _4); + float _133 = _132.x; + float _135 = _129.z; + float _137 = floor(_135 * 14.99989986419677734375); + float _143 = (_137 * 0.0625) + (_129.x * 0.05859375); + float _145 = _129.y * 0.9375; + vec2 _147 = vec2(0.001953125, 0.03125) + vec2(_143, _145); + vec4 _149 = texture(sampler2D(_14, _9), _147); + vec2 _153 = vec2(0.001953125, 0.03125) + vec2(_143 + 0.0625, _145); + vec4 _155 = texture(sampler2D(_14, _9), _153); + vec3 _157 = vec3((_135 * 15.0) - _137); + vec3 _158 = mix(_149.xyz, _155.xyz, _157); + vec4 _161 = texture(sampler2D(_15, _9), _147); + vec4 _164 = texture(sampler2D(_15, _9), _153); + vec3 _166 = mix(_161.xyz, _164.xyz, _157); + vec3 _179; + vec3 _180; + if (floatBitsToInt(_7._m9) != 0) { + float _173 = _7._m9 * _133; + _179 = _166 * ((1.0 + _173) - _7._m9); + _180 = _158 * (1.0 - _173); + } else { + _179 = _166; + _180 = _158; + } + _5 = vec4(mix(_180, _179, vec3(_133)), 1.0); + + + _5.rgb = ApplyGradingAndDisplayMap(_5.rgb, _4.xy); +} + diff --git a/src/games/rdr2vk/tonemap/0xA2ED1CB7.frag.glsl b/src/games/rdr2vk/tonemap/0xA2ED1CB7.frag.glsl new file mode 100644 index 000000000..87112d7f4 --- /dev/null +++ b/src/games/rdr2vk/tonemap/0xA2ED1CB7.frag.glsl @@ -0,0 +1,971 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#if defined(GL_EXT_control_flow_attributes) +#extension GL_EXT_control_flow_attributes : require +#define SPIRV_CROSS_FLATTEN [[flatten]] +#define SPIRV_CROSS_BRANCH [[dont_flatten]] +#define SPIRV_CROSS_UNROLL [[unroll]] +#define SPIRV_CROSS_LOOP [[dont_unroll]] +#else +#define SPIRV_CROSS_FLATTEN +#define SPIRV_CROSS_BRANCH +#define SPIRV_CROSS_UNROLL +#define SPIRV_CROSS_LOOP +#endif +#extension GL_EXT_samplerless_texture_functions : require + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _15 _m5; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; +}; + +struct _19 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _20 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _16 { + _17 _m0[2]; + _18 _m1; + _19 _m2; + _20 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; +}; + +struct _24 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _21 { + _22 _m0; + _23 _m1; + _24 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _25 { + vec4 _m0[5]; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _27 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _28 { + int _m0; + int _m1; +}; + +struct _29 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _12 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _13 _m41; + _14 _m42; + _16 _m43; + _21 _m44; + _25 _m45; + _26 _m46; + _27 _m47[5]; + vec4 _m48; + _28 _m49; + vec4 _m50; + _29 _m51; +}; + +struct _33 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _34 { + float _m0; +}; + +struct _36 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _35 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _36 _m3; + vec2 _m4; +}; + +struct _38 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _39 { + int _m0; +}; + +struct _40 { + _39 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _37 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _38 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _39 _m16; + _39 _m17; + _40 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _42 { + vec3 _m0; + float _m1; +}; + +struct _43 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _44 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _45 { + float _m0; + _39 _m1; +}; + +struct _46 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _47 { + _39 _m0; + float _m1; + float _m2; +}; + +struct _49 { + int _m0; +}; + +struct _48 { + _39 _m0; + _49 _m1; + _49 _m2; +}; + +struct _50 { + _39 _m0; +}; + +struct _41 { + _42 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _43 _m4; + _44 _m5; + _45 _m6; + _46 _m7; + _47 _m8; + _48 _m9; + _50 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _51 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _54 { + vec4 _m0; + vec4 _m1; +}; + +struct _56 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _56 _m19[2]; +}; + +struct _57 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _58 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _59 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _32 { + float _m0[32]; + float _m1[32]; + _33 _m2; + _33 _m3; + _34 _m4; + _35 _m5; + _37 _m6; + _41 _m7; + _51 _m8; + _52 _m9; + float _m10; + vec2 _m11; + _53 _m12; + _54 _m13; + float _m14; + float _m15; + vec4 _m16; + _55 _m17; + _57 _m18; + _58 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _59 _m30; + int _m31; +}; + +struct _92 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _93 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _91 { + _92 _m0; + _93 _m1[11]; +}; + +float _290; + +layout(set = 0, binding = 98, scalar) readonly buffer _11_30 { + _12 _m0[]; +} +_30; + +layout(set = 0, binding = 99, scalar) readonly buffer _31_60 { + _32 _m0[]; +} +_60; + +layout(set = 0, binding = 20, std140) uniform _66_67 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_67; + +layout(set = 1, binding = 16, std140) uniform _68_69 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_69; + +layout(set = 0, binding = 214, std430) readonly buffer _90_94 { + _91 _m0[]; +} +_94; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 33) uniform sampler _9; +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 0, binding = 121) uniform texture2DArray _63; +layout(set = 0, binding = 140) uniform texture2D _64; +layout(set = 1, binding = 173) uniform texture2D _70; +layout(set = 1, binding = 174) uniform texture2D _71; +layout(set = 1, binding = 177) uniform texture2D _72; +layout(set = 1, binding = 185) uniform texture1D _74; +layout(set = 1, binding = 40) uniform sampler _75; +layout(set = 1, binding = 186) uniform texture2D _76; +layout(set = 1, binding = 189) uniform texture2D _77; +layout(set = 1, binding = 190) uniform texture2D _78; +layout(set = 1, binding = 191) uniform texture2D _79; +layout(set = 1, binding = 196) uniform texture2D _80; +layout(set = 1, binding = 197) uniform texture2D _81; +layout(set = 1, binding = 202) uniform texture2D _82; +layout(set = 1, binding = 203) uniform texture2D _83; +layout(set = 1, binding = 205) uniform texture2D _84; +layout(set = 1, binding = 206) uniform texture2D _85; +layout(set = 1, binding = 207) uniform texture2D _86; +layout(set = 1, binding = 209) uniform texture2D _87; +layout(set = 1, binding = 210) uniform texture2D _88; +layout(set = 1, binding = 212) uniform samplerBuffer _89; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _300 = texture(sampler2D(_85, _8), _4.xy); + vec2 _301 = _300.xy; + float _309 = 1.0 + _69._m0.w; + float _312 = _69._m0.z / (_309 - textureLod(sampler2D(_71, _8), _301, 0.0).x); + vec4 _316 = texture(sampler2D(_76, _75), _301); + vec4 _341 = textureLod(sampler2D(_88, _8), _301 * _69._m80.xy, 0.0) * 1.0; + float _342 = _341.z; + vec4 _499; + SPIRV_CROSS_BRANCH + if ((_342 >= 1.0) && (_341.w < 2.0)) { + float _360 = min(length(textureLod(sampler2D(_87, _8), _301, 0.0).xy * _69._m20.x), _69._m20.z); + float _363 = min(_342, 2.0); + vec2 _364 = (_341.xy / vec2(_342)) * _363; + int _367 = int(min(2.0, 1.0 + _363)); + vec2 _371 = _364 * _69._m63.xy; + float _373 = float(_367) - 0.5; + float _374 = _373 / _363; + vec2 _376 = (-_364) * _69._m63.xy; + vec2 _379 = vec2(uvec2(gl_FragCoord.xy) & uvec2(1u)); + float _393 = ((((_379.x * 2.0) - 1.0) * ((_379.y * 2.0) - 1.0)) * _69._m20.w) * clamp((_363 - 2.0) * 0.5, 0.0, 1.0); + float _394 = 0.5 + _393; + float _395 = 0.5 - _393; + vec4 _397; + _397 = vec4(0.0); + for (int _400 = 0; _400 < _367;) { + float _404 = float(_400); + float _405 = _404 + _394; + vec2 _408 = _301 + (_371 * (_405 / _373)); + float _414 = min(length(textureLod(sampler2D(_87, _8), _408, 0.0).xy * _69._m20.x), _69._m20.z); + float _420 = _69._m0.z / (_309 - textureLod(sampler2D(_70, _8), _408, 0.0).x); + float _425 = _360 * _374; + float _442 = _404 + _395; + vec2 _445 = _301 + (_376 * (_442 / _373)); + float _451 = min(length(textureLod(sampler2D(_87, _8), _445, 0.0).xy * _69._m20.x), _69._m20.z); + float _456 = _69._m0.z / (_309 - textureLod(sampler2D(_70, _8), _445, 0.0).x); + float _473 = (1.0 - clamp((1.0 - _451) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_456 - _312)), vec2(0.0), vec2(1.0)), clamp(vec2(_425, _451 * _374) - vec2(max(_442 - 1.0, 0.0)), vec2(0.0), vec2(1.0))); + bvec2 _479 = bvec2(_420 > _456, _451 > _414); + float _481 = all(_479) ? _473 : ((1.0 - clamp((1.0 - _414) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_420 - _312)), vec2(0.0), vec2(1.0)), clamp(vec2(_425, _414 * _374) - vec2(max(_405 - 1.0, 0.0)), vec2(0.0), vec2(1.0)))); + float _483 = any(_479) ? _473 : _481; + _397 = (_397 + vec4(textureLod(sampler2D(_78, _9), _445, 0.0).xyz * _483, _483)) + vec4(textureLod(sampler2D(_78, _9), _408, 0.0).xyz * _481, _481); + _400++; + continue; + } + _499 = _397 / vec4(float(2 * _367)); + } else { + _499 = vec4(0.0); + } + vec4 _507 = textureLod(sampler2D(_79, _9), _301, 0.0); + vec3 _512 = _507.xyz + ((_499.xyz + (vec4(vec4(_316.xyz, 0.0).xyz * _30._m0[0u]._m1.w, _290).xyz * (1.0 - _499.w))) * (1.0 - _507.w)); + vec4 _515 = texelFetch(_89, int(0u)); + vec4 _516 = texelFetch(_89, int(1u)); + float _521 = dot(_512 * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _546; + vec3 _547; + if (floatBitsToInt(_69._m61) != 0) { + vec4 _532 = texture(sampler2D(_84, _75), _4.xy); + float _533 = _532.w; + bool _535 = (_533 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _544; + if (_535) { + _544 = _532.xyz; + } else { + _544 = _532.xyz + (_512 * (1.0 - _533)); + } + _546 = _535 ? true : false; + _547 = _544; + } else { + _546 = false; + _547 = _512; + } + vec3 _551 = min(_547 * texelFetch(_64, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _552 = !_546; + float _688; + vec3 _689; + if (_552) { + float _611; + if (floatBitsToInt(_69._m70.x) != 0) { + float _574 = clamp(dot(texture(sampler2D(_72, _10), _301).xyz * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _69._m72.z, _69._m72.w); + float _597 = clamp(((((_69._m70.y * log(_574 + _69._m72.x)) + _69._m70.z) - 10.0) + (_69._m72.y * _574)) + _69._m65.w, _69._m66.x, _69._m66.y); + _611 = pow(2.0, mix(_5, clamp(_597 + ((abs(_597) * _69._m66.z) * float(int(sign(_597)))), _69._m66.x, _69._m66.y), clamp(_69._m70.x, 0.0, 1.0))); + } else { + _611 = _4.z; + } + vec4 _624 = texture(sampler2D(_77, _10), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _69._m16.w) + _69._m16.xy)); + vec3 _634 = max(_551 * vec3(0.5), _551 + vec3((_521 * (_624.w - 0.5)) * _69._m16.z)); + vec3 _687; + if (floatBitsToInt(_69._m51.w) != 0) { + vec2 _663 = ((_4.xy - _69._m50.xy) * mat2(vec2(_69._m52.x, _69._m52.y), vec2(_69._m52.z, _69._m52.w))) * _69._m50.zw; + float _667 = CUSTOM_VIGNETTE * max((dot(_663, _663) - _69._m53.x) * _69._m53.w, 0.0); + bool _668 = _667 < 1.0; + _687 = mix(_634, (_634 * _69._m51.xyz) * _69._m51.w, vec3(_668 ? (_668 ? (1.0 - pow(2.0, (-10.0) * _667)) : 1.0) : (0.9980499744415283203125 + (((_667 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_667 - 2.0)) : 0.0)))); + } else { + _687 = _634; + } + _688 = _611; + _689 = _687; + } else { + _688 = _4.z; + _689 = _551; + } + vec3 _726 = _689 * mix(mix(_69._m54.xyz, _69._m56.xyz, vec3(clamp(clamp(_4.y * _69._m57.y, 0.0, 1.0) + _69._m54.w, 0.0, 1.0))), mix(_69._m56.xyz, _69._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _69._m56.w, 0.0, 1.0) * _69._m57.x, 0.0, 1.0) - _69._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _729 = _67._m3 != 0u; +#if 1 + vec3 _792 = ApplyToneMap(_726, _729, _688, _67._m6, _67._m4, _67._m10, _515.rgb, _516); +#else + vec3 _792; + if (_729) { + vec3 _769 = max(vec3(0.0), _726 * (_688 / _67._m6)); + vec3 _772 = _769 * _515.x; + _792 = (((((_769 * (_772 + vec3(_516.x))) + vec3(_516.y)) / ((_769 * (_772 + vec3(_515.y))) + vec3(_516.z))) - vec3(_516.w)) * ((_67._m4 != 0u) ? _67._m10 : _515.z)) * _67._m6; + } else { + vec3 _735 = max(vec3(0.0), _726 * _688); + vec3 _738 = _735 * _515.x; + _792 = clamp(((((_735 * (_738 + vec3(_516.x))) + vec3(_516.y)) / ((_735 * (_738 + vec3(_515.y))) + vec3(_516.z))) - vec3(_516.w)) * _515.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _840; + if (_552) { + vec3 _839; + if (floatBitsToInt(_69._m47.w) != 0) { + vec2 _825 = ((_4.xy - _69._m46.xy) * mat2(vec2(_69._m48.x, _69._m48.y), vec2(_69._m48.z, _69._m48.w))) * _69._m46.zw; + _839 = mix(_792, _69._m47.xyz, vec3(_69._m47.w * texture(sampler1D(_74, _10), min(1.0, max((dot(_825, _825) - _69._m49.x) * _69._m49.w, 0.0))).w)); + } else { + _839 = _792; + } + _840 = _839; + } else { + _840 = _792; + } + bool _861 = _729 && (!(_67._m2 != 0u)); + +#if 1 + vec3 _863 = EncodeLUTInput(_840, _67._m11, _67._m12, _67._m13, _67._m14, _861); +#else + vec3 _863 = mix(mix((pow(_840, vec3(_67._m12)) * _67._m13) - vec3(_67._m14), _840 * _67._m11, lessThan(_840, vec3(0.003130800090730190277099609375))), _840, bvec3(_861)); +#endif + + vec3 _1019; + if (_552 && (floatBitsToInt(_69._m19.x) != 0)) { + vec2 _875 = _4.xy * _69._m17.w; + float _941 = (((((((fract(sin(dot(_875 + vec2(0.070000000298023223876953125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_875 + vec2(0.10999999940395355224609375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_875 + vec2(0.12999999523162841796875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_875 + vec2(0.17000000178813934326171875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_875 + vec2(0.189999997615814208984375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_875 + vec2(0.23000000417232513427734375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_875 + vec2(0.2899999916553497314453125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_875 + vec2(0.310000002384185791015625 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _943 = clamp(_941 + _69._m17.z, 0.0, 1.0); + vec3 _1018; + do { + if (!(floatBitsToInt(_69._m18.w) != 0)) { + _1018 = vec3(_943); + break; + } + float _966; + if (floatBitsToInt(_69._m18.y) != 0) { + float _961 = dot(_863, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _966 = mix(_943, _943 * 0.5, (_961 * _961) * _961); + } else { + _966 = _943; + } + vec3 _1017; + if (floatBitsToInt(_69._m19.z) != 0) { + vec3 _999 = vec3(_966); + vec3 _1001 = _999 * 2.0; + _1017 = mix(_863, mix(((_863 * 2.0) * (vec3(1.0) - _999)) + (sqrt(_863) * (_1001 - vec3(1.0))), (_1001 * _863) + ((_863 * _863) * (vec3(1.0) - _1001)), lessThan(_999, vec3(0.5))), vec3(_69._m18.x)); + } else { + vec3 _998; + if (floatBitsToInt(_69._m19.w) != 0) { + vec3 _986 = vec3(_966); + _998 = mix(_863, mix(vec3(1.0) - (((vec3(1.0) - _986) * 2.0) * (vec3(1.0) - _863)), (_986 * 2.0) * _863, lessThan(_863, vec3(0.5))), vec3(_69._m18.x)); + } else { + _998 = clamp(max(_863 * 0.02500000037252902984619140625, _863 + vec3((_966 - 0.5) * _69._m18.x)), vec3(0.0), vec3(1.0)); + } + _1017 = _998; + } + _1018 = _1017; + break; + } while (false); + _1019 = _1018; + } else { + _1019 = _863; + } + vec3 _1021 = max(_1019 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _1022 = _1021.y; + vec3 _1047 = mix(_1019, clamp((_69._m81.xyz * (_1022 * ((1.33000004291534423828125 * (1.0 + ((_1022 + _1021.z) / _1021.x))) - 1.67999994754791259765625))) * _69._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _521)) * _69._m82.x) + _69._m82.y, 0.0, 1.0))); + vec3 _1077; + if (floatBitsToInt(_69._m84.w) != 0) { + _1077 = mix(_1047, texture(sampler2D(_86, _10), ((((_4.xy - vec2(0.5)) * _69._m84.z) / mix(_69._m85.wx, _69._m85.zy, _4.yx)) - _69._m84.xy) + vec2(0.5)).xyz, vec3(_69._m84.w)); + } else { + _1077 = _1047; + } + float _1102 = 1.0; + vec3 _1235; + if (_552) { +#if 1 + vec3 _1103 = CompressLUTInput(_1077, _861, _67._m5, _67._m7, _67._m8, _67._m9, _1102); +#else + float _1096 = max(max(_1077.x, max(_1077.y, _1077.z)), 9.9999997473787516355514526367188e-05); + _1102 = (_861 && (!(_67._m5 != 0u))) ? 1.0 : (((_1096 > _67._m7) ? ((_1096 * _67._m8) + _67._m9) : _1096) / _1096); + vec3 _1103 = _1077 * _1102; +#endif + float _1106 = _1103.z; + float _1108 = floor(_1106 * 14.99989986419677734375); + float _1114 = (_1108 * 0.0625) + (_1103.x * 0.05859375); + float _1116 = _1103.y * 0.9375; + vec4 _1120 = texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1114, _1116)); + vec4 _1126 = texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1114 + 0.0625, _1116)); + vec3 _1129 = mix(_1120.xyz, _1126.xyz, vec3((_1106 * 15.0) - _1108)); + vec3 _1232; + if (_94._m0[0u]._m0._m0 > 0) { + float _1163 = _1129.z; + float _1165 = floor(_1163 * 14.99989986419677734375); + float _1171 = (_1165 * 0.0625) + (_1129.x * 0.05859375); + float _1173 = _1129.y * 0.9375; + vec3 _1188 = mix(_1129, mix(texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1171, _1173)).xyz, texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1171 + 0.0625, _1173)).xyz, vec3((_1163 * 15.0) - _1165)), vec3(clamp(((_312 < _94._m0[0u]._m1[0]._m2) ? clamp((_312 - _94._m0[0u]._m1[0]._m0) * _94._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_312 - _94._m0[0u]._m1[0]._m2) * _94._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _94._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _1200 = _1188.z; + float _1202 = floor(_1200 * 14.99989986419677734375); + float _1208 = (_1202 * 0.0625) + (_1188.x * 0.05859375); + float _1210 = _1188.y * 0.9375; + _1232 = mix(_1188, mix(_1188, mix(texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1208, _1210)).xyz, texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1208 + 0.0625, _1210)).xyz, vec3((_1200 * 15.0) - _1202)), vec3(clamp(((_312 < _94._m0[0u]._m1[1]._m2) ? clamp((_312 - _94._m0[0u]._m1[1]._m0) * _94._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_312 - _94._m0[0u]._m1[1]._m2) * _94._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _94._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_83, _10), _301).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _1232 = _1129; + } + _1235 = _1232; + } else { + _1235 = _1077; + } + +#if 1 + _1235 = DecodeLUTInput(_1235, _1077, _1102); +#endif + + vec4 _1240 = vec4(_1235, dot(_1235, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1241 = _1240.xyz; + ivec4 _1283 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_60._m0[0u]._m22) & 31), 0u)); + vec3 _1291 = (vec3(texelFetch(_63, _1283.xyz, _1283.w).x) * 2.0) - vec3(1.0); + vec3 _1302; + if (_729) { + _1302 = vec3(ivec3(sign(_1291))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1291))); + } else { + _1302 = _1291; + } + vec3 _1304 = _1241 + CUSTOM_DITHERING * (_1302 * mix(_69._m39.xyz, _69._m40.xyz, pow(clamp((mix(vec3(max(_1235.x, max(_1235.y, _1235.z))), _1241, bvec3(floatBitsToInt(_69._m41.w) != 0)) - _69._m42.xyz) * _69._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_69._m42.w)))); + vec4 _1305 = vec4(_1304.x, _1304.y, _1304.z, _1240.w); + vec4 _1310; + if (!_729) { + _1310 = clamp(_1305, vec4(0.0), vec4(1.0)); + } else { + _1310 = _1305; + } + _6 = _1310; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/0xCD6F15F2.frag.glsl b/src/games/rdr2vk/tonemap/0xCD6F15F2.frag.glsl new file mode 100644 index 000000000..79bc7a162 --- /dev/null +++ b/src/games/rdr2vk/tonemap/0xCD6F15F2.frag.glsl @@ -0,0 +1,69 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +layout(set = 1, binding = 31, std140) uniform _6_7 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + vec4 _m6; + float _m7; + float _m8; + float _m9; +} +_7; + +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 1, binding = 128) uniform texture2D _11; +layout(set = 1, binding = 130) uniform texture2D _12; +layout(set = 1, binding = 131) uniform texture2D _13; +layout(set = 1, binding = 132) uniform texture2D _14; +layout(set = 1, binding = 133) uniform texture2D _15; + +layout(location = 0) in vec2 _4; +layout(location = 0) out vec4 _5; + +void main() { + vec4 _48 = texture(sampler2D(_11, _9), _4); + float _50 = _48.z; + float _52 = floor(_50 * 14.99989986419677734375); + float _58 = (_52 * 0.0625) + (_48.x * 0.05859375); + float _60 = _48.y * 0.9375; + vec4 _64 = texture(sampler2D(_14, _9), vec2(0.001953125, 0.03125) + vec2(_58, _60)); + vec4 _70 = texture(sampler2D(_14, _9), vec2(0.001953125, 0.03125) + vec2(_58 + 0.0625, _60)); + vec3 _73 = mix(_64.xyz, _70.xyz, vec3((_50 * 15.0) - _52)); + vec4 _76 = texture(sampler2D(_15, _9), _4); + float _77 = _76.x; + float _79 = _73.z; + float _81 = floor(_79 * 14.99989986419677734375); + float _87 = (_81 * 0.0625) + (_73.x * 0.05859375); + float _89 = _73.y * 0.9375; + vec2 _91 = vec2(0.001953125, 0.03125) + vec2(_87, _89); + vec4 _93 = texture(sampler2D(_12, _9), _91); + vec2 _97 = vec2(0.001953125, 0.03125) + vec2(_87 + 0.0625, _89); + vec4 _99 = texture(sampler2D(_12, _9), _97); + vec3 _101 = vec3((_79 * 15.0) - _81); + vec3 _102 = mix(_93.xyz, _99.xyz, _101); + vec4 _105 = texture(sampler2D(_13, _9), _91); + vec4 _108 = texture(sampler2D(_13, _9), _97); + vec3 _110 = mix(_105.xyz, _108.xyz, _101); + vec3 _123; + vec3 _124; + if (floatBitsToInt(_7._m9) != 0) { + float _117 = _7._m9 * _77; + _123 = _110 * ((1.0 + _117) - _7._m9); + _124 = _102 * (1.0 - _117); + } else { + _123 = _110; + _124 = _102; + } + _5 = vec4(mix(_124, _123, vec3(_77)), 1.0); + + + _5.rgb = ApplyGradingAndDisplayMap(_5.rgb, _4.xy); +} + diff --git a/src/games/rdr2vk/tonemap/0xCF7FE0D7.frag.glsl b/src/games/rdr2vk/tonemap/0xCF7FE0D7.frag.glsl new file mode 100644 index 000000000..478cd1235 --- /dev/null +++ b/src/games/rdr2vk/tonemap/0xCF7FE0D7.frag.glsl @@ -0,0 +1,906 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _12 { + float _m0; +}; + +struct _14 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _13 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _14 _m5; +}; + +struct _16 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _19 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _15 { + _16 _m0[2]; + _17 _m1; + _18 _m2; + _19 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _21 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _20 { + _21 _m0; + _22 _m1; + _23 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _24 { + vec4 _m0[5]; +}; + +struct _25 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _27 { + int _m0; + int _m1; +}; + +struct _28 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _11 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _12 _m41; + _13 _m42; + _15 _m43; + _20 _m44; + _24 _m45; + _25 _m46; + _26 _m47[5]; + vec4 _m48; + _27 _m49; + vec4 _m50; + _28 _m51; +}; + +struct _32 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _33 { + float _m0; +}; + +struct _35 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _34 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _35 _m3; + vec2 _m4; +}; + +struct _37 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _38 { + int _m0; +}; + +struct _39 { + _38 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _36 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _37 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _38 _m16; + _38 _m17; + _39 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _41 { + vec3 _m0; + float _m1; +}; + +struct _42 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _43 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _44 { + float _m0; + _38 _m1; +}; + +struct _45 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _46 { + _38 _m0; + float _m1; + float _m2; +}; + +struct _48 { + int _m0; +}; + +struct _47 { + _38 _m0; + _48 _m1; + _48 _m2; +}; + +struct _49 { + _38 _m0; +}; + +struct _40 { + _41 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _42 _m4; + _43 _m5; + _44 _m6; + _45 _m7; + _46 _m8; + _47 _m9; + _49 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _50 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _51 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _54 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _55 _m19[2]; +}; + +struct _56 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _57 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _58 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _31 { + float _m0[32]; + float _m1[32]; + _32 _m2; + _32 _m3; + _33 _m4; + _34 _m5; + _36 _m6; + _40 _m7; + _50 _m8; + _51 _m9; + float _m10; + vec2 _m11; + _52 _m12; + _53 _m13; + float _m14; + float _m15; + vec4 _m16; + _54 _m17; + _56 _m18; + _57 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _58 _m30; + int _m31; +}; + +struct _85 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _86 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _84 { + _85 _m0; + _86 _m1[11]; +}; + +float _273; + +layout(set = 0, binding = 98, scalar) readonly buffer _10_29 { + _11 _m0[]; +} +_29; + +layout(set = 0, binding = 99, scalar) readonly buffer _30_59 { + _31 _m0[]; +} +_59; + +layout(set = 0, binding = 20, std140) uniform _65_66 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_66; + +layout(set = 1, binding = 16, std140) uniform _67_68 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_68; + +layout(set = 0, binding = 214, std430) readonly buffer _83_87 { + _84 _m0[]; +} +_87; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 0, binding = 121) uniform texture2DArray _62; +layout(set = 0, binding = 140) uniform texture2D _63; +layout(set = 1, binding = 174) uniform texture2D _69; +layout(set = 1, binding = 177) uniform texture2D _70; +layout(set = 1, binding = 185) uniform texture1D _72; +layout(set = 1, binding = 40) uniform sampler _73; +layout(set = 1, binding = 186) uniform texture2D _74; +layout(set = 1, binding = 189) uniform texture2D _75; +layout(set = 1, binding = 196) uniform texture2D _76; +layout(set = 1, binding = 197) uniform texture2D _77; +layout(set = 1, binding = 202) uniform texture2D _78; +layout(set = 1, binding = 203) uniform texture2D _79; +layout(set = 1, binding = 205) uniform texture2D _80; +layout(set = 1, binding = 207) uniform texture2D _81; +layout(set = 1, binding = 212) uniform samplerBuffer _82; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + float _291 = _68._m0.z / ((1.0 + _68._m0.w) - textureLod(sampler2D(_69, _8), _4.xy, 0.0).x); + vec4 _295 = texture(sampler2D(_74, _73), _4.xy); + vec3 _309 = vec4(vec4(_295.xyz, 0.0).xyz * _29._m0[0u]._m1.w, _273).xyz; + vec4 _312 = texelFetch(_82, int(0u)); + vec4 _313 = texelFetch(_82, int(1u)); + float _318 = dot(_309 * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _343; + vec3 _344; + if (floatBitsToInt(_68._m61) != 0) { + vec4 _329 = texture(sampler2D(_80, _73), _4.xy); + float _330 = _329.w; + bool _332 = (_330 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _341; + if (_332) { + _341 = _329.xyz; + } else { + _341 = _329.xyz + (_309 * (1.0 - _330)); + } + _343 = _332 ? true : false; + _344 = _341; + } else { + _343 = false; + _344 = _309; + } + vec3 _348 = min(_344 * texelFetch(_63, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _349 = !_343; + float _485; + vec3 _486; + if (_349) { + float _408; + if (floatBitsToInt(_68._m70.x) != 0) { + float _371 = clamp(dot(texture(sampler2D(_70, _9), _4.xy).xyz * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _68._m72.z, _68._m72.w); + float _394 = clamp(((((_68._m70.y * log(_371 + _68._m72.x)) + _68._m70.z) - 10.0) + (_68._m72.y * _371)) + _68._m65.w, _68._m66.x, _68._m66.y); + _408 = pow(2.0, mix(_5, clamp(_394 + ((abs(_394) * _68._m66.z) * float(int(sign(_394)))), _68._m66.x, _68._m66.y), clamp(_68._m70.x, 0.0, 1.0))); + } else { + _408 = _4.z; + } + vec4 _421 = texture(sampler2D(_75, _9), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _68._m16.w) + _68._m16.xy)); + vec3 _431 = max(_348 * vec3(0.5), _348 + vec3((_318 * (_421.w - 0.5)) * _68._m16.z)); + vec3 _484; + if (floatBitsToInt(_68._m51.w) != 0) { + vec2 _460 = ((_4.xy - _68._m50.xy) * mat2(vec2(_68._m52.x, _68._m52.y), vec2(_68._m52.z, _68._m52.w))) * _68._m50.zw; + float _464 = CUSTOM_VIGNETTE * max((dot(_460, _460) - _68._m53.x) * _68._m53.w, 0.0); + bool _465 = _464 < 1.0; + _484 = mix(_431, (_431 * _68._m51.xyz) * _68._m51.w, vec3(_465 ? (_465 ? (1.0 - pow(2.0, (-10.0) * _464)) : 1.0) : (0.9980499744415283203125 + (((_464 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_464 - 2.0)) : 0.0)))); + } else { + _484 = _431; + } + _485 = _408; + _486 = _484; + } else { + _485 = _4.z; + _486 = _348; + } + vec3 _523 = _486 * mix(mix(_68._m54.xyz, _68._m56.xyz, vec3(clamp(clamp(_4.y * _68._m57.y, 0.0, 1.0) + _68._m54.w, 0.0, 1.0))), mix(_68._m56.xyz, _68._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _68._m56.w, 0.0, 1.0) * _68._m57.x, 0.0, 1.0) - _68._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _526 = _66._m3 != 0u; +#if 1 + vec3 _589 = ApplyToneMap(_523, _526, _485, _66._m6, _66._m4, _66._m10, _312.rgb, _313); +#else + vec3 _589; + if (_526) { + vec3 _566 = max(vec3(0.0), _523 * (_485 / _66._m6)); + vec3 _569 = _566 * _312.x; + _589 = (((((_566 * (_569 + vec3(_313.x))) + vec3(_313.y)) / ((_566 * (_569 + vec3(_312.y))) + vec3(_313.z))) - vec3(_313.w)) * ((_66._m4 != 0u) ? _66._m10 : _312.z)) * _66._m6; + } else { + vec3 _532 = max(vec3(0.0), _523 * _485); + vec3 _535 = _532 * _312.x; + _589 = clamp(((((_532 * (_535 + vec3(_313.x))) + vec3(_313.y)) / ((_532 * (_535 + vec3(_312.y))) + vec3(_313.z))) - vec3(_313.w)) * _312.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _637; + if (_349) { + vec3 _636; + if (floatBitsToInt(_68._m47.w) != 0) { + vec2 _622 = ((_4.xy - _68._m46.xy) * mat2(vec2(_68._m48.x, _68._m48.y), vec2(_68._m48.z, _68._m48.w))) * _68._m46.zw; + _636 = mix(_589, _68._m47.xyz, vec3(_68._m47.w * texture(sampler1D(_72, _9), min(1.0, max((dot(_622, _622) - _68._m49.x) * _68._m49.w, 0.0))).w)); + } else { + _636 = _589; + } + _637 = _636; + } else { + _637 = _589; + } + bool _658 = _526 && (!(_66._m2 != 0u)); + +#if 1 + vec3 _660 = EncodeLUTInput(_637, _66._m11, _66._m12, _66._m13, _66._m14, _658); +#else + vec3 _660 = mix(mix((pow(_637, vec3(_66._m12)) * _66._m13) - vec3(_66._m14), _637 * _66._m11, lessThan(_637, vec3(0.003130800090730190277099609375))), _637, bvec3(_658)); +#endif + + vec3 _816; + if (_349 && (floatBitsToInt(_68._m19.x) != 0)) { + vec2 _672 = _4.xy * _68._m17.w; + float _738 = (((((((fract(sin(dot(_672 + vec2(0.070000000298023223876953125 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_672 + vec2(0.10999999940395355224609375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_672 + vec2(0.12999999523162841796875 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_672 + vec2(0.17000000178813934326171875 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_672 + vec2(0.189999997615814208984375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_672 + vec2(0.23000000417232513427734375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_672 + vec2(0.2899999916553497314453125 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_672 + vec2(0.310000002384185791015625 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _740 = clamp(_738 + _68._m17.z, 0.0, 1.0); + vec3 _815; + do { + if (!(floatBitsToInt(_68._m18.w) != 0)) { + _815 = vec3(_740); + break; + } + float _763; + if (floatBitsToInt(_68._m18.y) != 0) { + float _758 = dot(_660, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _763 = mix(_740, _740 * 0.5, (_758 * _758) * _758); + } else { + _763 = _740; + } + vec3 _814; + if (floatBitsToInt(_68._m19.z) != 0) { + vec3 _796 = vec3(_763); + vec3 _798 = _796 * 2.0; + _814 = mix(_660, mix(((_660 * 2.0) * (vec3(1.0) - _796)) + (sqrt(_660) * (_798 - vec3(1.0))), (_798 * _660) + ((_660 * _660) * (vec3(1.0) - _798)), lessThan(_796, vec3(0.5))), vec3(_68._m18.x)); + } else { + vec3 _795; + if (floatBitsToInt(_68._m19.w) != 0) { + vec3 _783 = vec3(_763); + _795 = mix(_660, mix(vec3(1.0) - (((vec3(1.0) - _783) * 2.0) * (vec3(1.0) - _660)), (_783 * 2.0) * _660, lessThan(_660, vec3(0.5))), vec3(_68._m18.x)); + } else { + _795 = clamp(max(_660 * 0.02500000037252902984619140625, _660 + vec3((_763 - 0.5) * _68._m18.x)), vec3(0.0), vec3(1.0)); + } + _814 = _795; + } + _815 = _814; + break; + } while (false); + _816 = _815; + } else { + _816 = _660; + } + vec3 _818 = max(_816 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _819 = _818.y; + vec3 _844 = mix(_816, clamp((_68._m81.xyz * (_819 * ((1.33000004291534423828125 * (1.0 + ((_819 + _818.z) / _818.x))) - 1.67999994754791259765625))) * _68._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _318)) * _68._m82.x) + _68._m82.y, 0.0, 1.0))); + vec3 _874; + if (floatBitsToInt(_68._m84.w) != 0) { + _874 = mix(_844, texture(sampler2D(_81, _9), ((((_4.xy - vec2(0.5)) * _68._m84.z) / mix(_68._m85.wx, _68._m85.zy, _4.yx)) - _68._m84.xy) + vec2(0.5)).xyz, vec3(_68._m84.w)); + } else { + _874 = _844; + } + float _899 = 1.0; + vec3 _1032; + if (_349) { +#if 1 + vec3 _900 = CompressLUTInput(_874, _658, _66._m5, _66._m7, _66._m8, _66._m9, _899); +#else + float _893 = max(max(_874.x, max(_874.y, _874.z)), 9.9999997473787516355514526367188e-05); + _899 = (_658 && (!(_66._m5 != 0u))) ? 1.0 : (((_893 > _66._m7) ? ((_893 * _66._m8) + _66._m9) : _893) / _893); + vec3 _900 = _874 * _899; +#endif + float _903 = _900.z; + float _905 = floor(_903 * 14.99989986419677734375); + float _911 = (_905 * 0.0625) + (_900.x * 0.05859375); + float _913 = _900.y * 0.9375; + vec4 _917 = texture(sampler2D(_78, _9), vec2(0.001953125, 0.03125) + vec2(_911, _913)); + vec4 _923 = texture(sampler2D(_78, _9), vec2(0.001953125, 0.03125) + vec2(_911 + 0.0625, _913)); + vec3 _926 = mix(_917.xyz, _923.xyz, vec3((_903 * 15.0) - _905)); + vec3 _1029; + if (_87._m0[0u]._m0._m0 > 0) { + float _960 = _926.z; + float _962 = floor(_960 * 14.99989986419677734375); + float _968 = (_962 * 0.0625) + (_926.x * 0.05859375); + float _970 = _926.y * 0.9375; + vec3 _985 = mix(_926, mix(texture(sampler2D(_76, _9), vec2(0.001953125, 0.03125) + vec2(_968, _970)).xyz, texture(sampler2D(_76, _9), vec2(0.001953125, 0.03125) + vec2(_968 + 0.0625, _970)).xyz, vec3((_960 * 15.0) - _962)), vec3(clamp(((_291 < _87._m0[0u]._m1[0]._m2) ? clamp((_291 - _87._m0[0u]._m1[0]._m0) * _87._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_291 - _87._m0[0u]._m1[0]._m2) * _87._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _87._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _997 = _985.z; + float _999 = floor(_997 * 14.99989986419677734375); + float _1005 = (_999 * 0.0625) + (_985.x * 0.05859375); + float _1007 = _985.y * 0.9375; + _1029 = mix(_985, mix(_985, mix(texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_1005, _1007)).xyz, texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_1005 + 0.0625, _1007)).xyz, vec3((_997 * 15.0) - _999)), vec3(clamp(((_291 < _87._m0[0u]._m1[1]._m2) ? clamp((_291 - _87._m0[0u]._m1[1]._m0) * _87._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_291 - _87._m0[0u]._m1[1]._m2) * _87._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _87._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_79, _9), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _1029 = _926; + } + _1032 = _1029; + } else { + _1032 = _874; + } + +#if 1 + _1032 = DecodeLUTInput(_1032, _874, _899); +#endif + + vec4 _1037 = vec4(_1032, dot(_1032, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1038 = _1037.xyz; + ivec4 _1081 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_59._m0[0u]._m22) & 31), 0u)); + vec3 _1089 = (vec3(texelFetch(_62, _1081.xyz, _1081.w).x) * 2.0) - vec3(1.0); + vec3 _1100; + if (_526) { + _1100 = vec3(ivec3(sign(_1089))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1089))); + } else { + _1100 = _1089; + } + vec3 _1102 = _1038 + CUSTOM_DITHERING * (_1100 * mix(_68._m39.xyz, _68._m40.xyz, pow(clamp((mix(vec3(max(_1032.x, max(_1032.y, _1032.z))), _1038, bvec3(floatBitsToInt(_68._m41.w) != 0)) - _68._m42.xyz) * _68._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_68._m42.w)))); + vec4 _1103 = vec4(_1102.x, _1102.y, _1102.z, _1037.w); + vec4 _1108; + if (!_526) { + _1108 = clamp(_1103, vec4(0.0), vec4(1.0)); + } else { + _1108 = _1103; + } + _6 = _1108; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/0xDD04030E.frag.glsl b/src/games/rdr2vk/tonemap/0xDD04030E.frag.glsl new file mode 100644 index 000000000..c3c8ec59d --- /dev/null +++ b/src/games/rdr2vk/tonemap/0xDD04030E.frag.glsl @@ -0,0 +1,1021 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#if defined(GL_EXT_control_flow_attributes) +#extension GL_EXT_control_flow_attributes : require +#define SPIRV_CROSS_FLATTEN [[flatten]] +#define SPIRV_CROSS_BRANCH [[dont_flatten]] +#define SPIRV_CROSS_UNROLL [[unroll]] +#define SPIRV_CROSS_LOOP [[dont_unroll]] +#else +#define SPIRV_CROSS_FLATTEN +#define SPIRV_CROSS_BRANCH +#define SPIRV_CROSS_UNROLL +#define SPIRV_CROSS_LOOP +#endif +#extension GL_EXT_samplerless_texture_functions : require + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _15 _m5; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; +}; + +struct _19 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _20 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _16 { + _17 _m0[2]; + _18 _m1; + _19 _m2; + _20 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; +}; + +struct _24 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _21 { + _22 _m0; + _23 _m1; + _24 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _25 { + vec4 _m0[5]; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _27 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _28 { + int _m0; + int _m1; +}; + +struct _29 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _12 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _13 _m41; + _14 _m42; + _16 _m43; + _21 _m44; + _25 _m45; + _26 _m46; + _27 _m47[5]; + vec4 _m48; + _28 _m49; + vec4 _m50; + _29 _m51; +}; + +struct _33 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _34 { + float _m0; +}; + +struct _36 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _35 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _36 _m3; + vec2 _m4; +}; + +struct _38 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _39 { + int _m0; +}; + +struct _40 { + _39 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _37 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _38 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _39 _m16; + _39 _m17; + _40 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _42 { + vec3 _m0; + float _m1; +}; + +struct _43 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _44 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _45 { + float _m0; + _39 _m1; +}; + +struct _46 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _47 { + _39 _m0; + float _m1; + float _m2; +}; + +struct _49 { + int _m0; +}; + +struct _48 { + _39 _m0; + _49 _m1; + _49 _m2; +}; + +struct _50 { + _39 _m0; +}; + +struct _41 { + _42 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _43 _m4; + _44 _m5; + _45 _m6; + _46 _m7; + _47 _m8; + _48 _m9; + _50 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _51 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _54 { + vec4 _m0; + vec4 _m1; +}; + +struct _56 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _56 _m19[2]; +}; + +struct _57 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _58 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _59 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _32 { + float _m0[32]; + float _m1[32]; + _33 _m2; + _33 _m3; + _34 _m4; + _35 _m5; + _37 _m6; + _41 _m7; + _51 _m8; + _52 _m9; + float _m10; + vec2 _m11; + _53 _m12; + _54 _m13; + float _m14; + float _m15; + vec4 _m16; + _55 _m17; + _57 _m18; + _58 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _59 _m30; + int _m31; +}; + +struct _97 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _98 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _96 { + _97 _m0; + _98 _m1[11]; +}; + +float _295; + +layout(set = 0, binding = 98, scalar) readonly buffer _11_30 { + _12 _m0[]; +} +_30; + +layout(set = 0, binding = 99, scalar) readonly buffer _31_60 { + _32 _m0[]; +} +_60; + +layout(set = 0, binding = 20, std140) uniform _66_67 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_67; + +layout(set = 1, binding = 16, std140) uniform _68_69 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_69; + +layout(set = 0, binding = 214, std430) readonly buffer _95_99 { + _96 _m0[]; +} +_99; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 33) uniform sampler _9; +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 0, binding = 121) uniform texture2DArray _63; +layout(set = 0, binding = 140) uniform texture2D _64; +layout(set = 1, binding = 173) uniform texture2D _70; +layout(set = 1, binding = 174) uniform texture2D _71; +layout(set = 1, binding = 177) uniform texture2D _72; +layout(set = 1, binding = 185) uniform texture1D _74; +layout(set = 1, binding = 40) uniform sampler _75; +layout(set = 1, binding = 186) uniform texture2D _76; +layout(set = 1, binding = 189) uniform texture2D _77; +layout(set = 1, binding = 190) uniform texture2D _78; +layout(set = 1, binding = 191) uniform texture2D _79; +layout(set = 1, binding = 194) uniform texture2D _80; +layout(set = 1, binding = 196) uniform texture2D _81; +layout(set = 1, binding = 197) uniform texture2D _82; +layout(set = 1, binding = 198) uniform texture2D _83; +layout(set = 1, binding = 199) uniform texture2D _84; +layout(set = 1, binding = 200) uniform texture2D _85; +layout(set = 1, binding = 201) uniform texture2D _86; +layout(set = 1, binding = 202) uniform texture2D _87; +layout(set = 1, binding = 203) uniform texture2D _88; +layout(set = 1, binding = 204) uniform texture2D _89; +layout(set = 1, binding = 205) uniform texture2D _90; +layout(set = 1, binding = 207) uniform texture2D _91; +layout(set = 1, binding = 209) uniform texture2D _92; +layout(set = 1, binding = 210) uniform texture2D _93; +layout(set = 1, binding = 212) uniform samplerBuffer _94; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + float _310 = 1.0 + _69._m0.w; + float _313 = _69._m0.z / (_310 - textureLod(sampler2D(_71, _8), _4.xy, 0.0).x); + vec4 _317 = texture(sampler2D(_76, _75), _4.xy); + vec4 _342 = textureLod(sampler2D(_93, _8), _4.xy * _69._m80.xy, 0.0) * 1.0; + float _343 = _342.z; + vec4 _500; + SPIRV_CROSS_BRANCH + if ((_343 >= 1.0) && (_342.w < 2.0)) { + float _361 = min(length(textureLod(sampler2D(_92, _8), _4.xy, 0.0).xy * _69._m20.x), _69._m20.z); + float _364 = min(_343, 2.0); + vec2 _365 = (_342.xy / vec2(_343)) * _364; + int _368 = int(min(2.0, 1.0 + _364)); + vec2 _372 = _365 * _69._m63.xy; + float _374 = float(_368) - 0.5; + float _375 = _374 / _364; + vec2 _377 = (-_365) * _69._m63.xy; + vec2 _380 = vec2(uvec2(gl_FragCoord.xy) & uvec2(1u)); + float _394 = ((((_380.x * 2.0) - 1.0) * ((_380.y * 2.0) - 1.0)) * _69._m20.w) * clamp((_364 - 2.0) * 0.5, 0.0, 1.0); + float _395 = 0.5 + _394; + float _396 = 0.5 - _394; + vec4 _398; + _398 = vec4(0.0); + for (int _401 = 0; _401 < _368;) { + float _405 = float(_401); + float _406 = _405 + _395; + vec2 _409 = _4.xy + (_372 * (_406 / _374)); + float _415 = min(length(textureLod(sampler2D(_92, _8), _409, 0.0).xy * _69._m20.x), _69._m20.z); + float _421 = _69._m0.z / (_310 - textureLod(sampler2D(_70, _8), _409, 0.0).x); + float _426 = _361 * _375; + float _443 = _405 + _396; + vec2 _446 = _4.xy + (_377 * (_443 / _374)); + float _452 = min(length(textureLod(sampler2D(_92, _8), _446, 0.0).xy * _69._m20.x), _69._m20.z); + float _457 = _69._m0.z / (_310 - textureLod(sampler2D(_70, _8), _446, 0.0).x); + float _474 = (1.0 - clamp((1.0 - _452) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_457 - _313)), vec2(0.0), vec2(1.0)), clamp(vec2(_426, _452 * _375) - vec2(max(_443 - 1.0, 0.0)), vec2(0.0), vec2(1.0))); + bvec2 _480 = bvec2(_421 > _457, _452 > _415); + float _482 = all(_480) ? _474 : ((1.0 - clamp((1.0 - _415) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_421 - _313)), vec2(0.0), vec2(1.0)), clamp(vec2(_426, _415 * _375) - vec2(max(_406 - 1.0, 0.0)), vec2(0.0), vec2(1.0)))); + float _484 = any(_480) ? _474 : _482; + _398 = (_398 + vec4(textureLod(sampler2D(_78, _9), _446, 0.0).xyz * _484, _484)) + vec4(textureLod(sampler2D(_78, _9), _409, 0.0).xyz * _482, _482); + _401++; + continue; + } + _500 = _398 / vec4(float(2 * _368)); + } else { + _500 = vec4(0.0); + } + vec4 _508 = textureLod(sampler2D(_79, _9), _4.xy, 0.0); + vec3 _513 = _508.xyz + ((_500.xyz + (vec4(vec4(_317.xyz, 0.0).xyz * _30._m0[0u]._m1.w, _295).xyz * (1.0 - _500.w))) * (1.0 - _508.w)); + vec4 _516 = texelFetch(_94, int(0u)); + vec4 _517 = texelFetch(_94, int(1u)); + float _522 = dot(_513 * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _547; + vec3 _548; + if (floatBitsToInt(_69._m61) != 0) { + vec4 _533 = texture(sampler2D(_90, _75), _4.xy); + float _534 = _533.w; + bool _536 = (_534 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _545; + if (_536) { + _545 = _533.xyz; + } else { + _545 = _533.xyz + (_513 * (1.0 - _534)); + } + _547 = _536 ? true : false; + _548 = _545; + } else { + _547 = false; + _548 = _513; + } + vec3 _552 = min(_548 * texelFetch(_64, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _553 = !_547; + float _689; + vec3 _690; + if (_553) { + float _612; + if (floatBitsToInt(_69._m70.x) != 0) { + float _575 = clamp(dot(texture(sampler2D(_72, _10), _4.xy).xyz * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _69._m72.z, _69._m72.w); + float _598 = clamp(((((_69._m70.y * log(_575 + _69._m72.x)) + _69._m70.z) - 10.0) + (_69._m72.y * _575)) + _69._m65.w, _69._m66.x, _69._m66.y); + _612 = pow(2.0, mix(_5, clamp(_598 + ((abs(_598) * _69._m66.z) * float(int(sign(_598)))), _69._m66.x, _69._m66.y), clamp(_69._m70.x, 0.0, 1.0))); + } else { + _612 = _4.z; + } + vec4 _625 = texture(sampler2D(_77, _10), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _69._m16.w) + _69._m16.xy)); + vec3 _635 = max(_552 * vec3(0.5), _552 + vec3((_522 * (_625.w - 0.5)) * _69._m16.z)); + vec3 _688; + if (floatBitsToInt(_69._m51.w) != 0) { + vec2 _664 = ((_4.xy - _69._m50.xy) * mat2(vec2(_69._m52.x, _69._m52.y), vec2(_69._m52.z, _69._m52.w))) * _69._m50.zw; + float _668 = CUSTOM_VIGNETTE * max((dot(_664, _664) - _69._m53.x) * _69._m53.w, 0.0); + bool _669 = _668 < 1.0; + _688 = mix(_635, (_635 * _69._m51.xyz) * _69._m51.w, vec3(_669 ? (_669 ? (1.0 - pow(2.0, (-10.0) * _668)) : 1.0) : (0.9980499744415283203125 + (((_668 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_668 - 2.0)) : 0.0)))); + } else { + _688 = _635; + } + _689 = _612; + _690 = _688; + } else { + _689 = _4.z; + _690 = _552; + } + vec3 _727 = _690 * mix(mix(_69._m54.xyz, _69._m56.xyz, vec3(clamp(clamp(_4.y * _69._m57.y, 0.0, 1.0) + _69._m54.w, 0.0, 1.0))), mix(_69._m56.xyz, _69._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _69._m56.w, 0.0, 1.0) * _69._m57.x, 0.0, 1.0) - _69._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _730 = _67._m3 != 0u; +#if 1 + vec3 _793 = ApplyToneMap(_727, _730, _689, _67._m6, _67._m4, _67._m10, _516.rgb, _517); +#else + vec3 _793; + if (_730) { + vec3 _770 = max(vec3(0.0), _727 * (_689 / _67._m6)); + vec3 _773 = _770 * _516.x; + _793 = (((((_770 * (_773 + vec3(_517.x))) + vec3(_517.y)) / ((_770 * (_773 + vec3(_516.y))) + vec3(_517.z))) - vec3(_517.w)) * ((_67._m4 != 0u) ? _67._m10 : _516.z)) * _67._m6; + } else { + vec3 _736 = max(vec3(0.0), _727 * _689); + vec3 _739 = _736 * _516.x; + _793 = clamp(((((_736 * (_739 + vec3(_517.x))) + vec3(_517.y)) / ((_736 * (_739 + vec3(_516.y))) + vec3(_517.z))) - vec3(_517.w)) * _516.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _841; + if (_553) { + vec3 _840; + if (floatBitsToInt(_69._m47.w) != 0) { + vec2 _826 = ((_4.xy - _69._m46.xy) * mat2(vec2(_69._m48.x, _69._m48.y), vec2(_69._m48.z, _69._m48.w))) * _69._m46.zw; + _840 = mix(_793, _69._m47.xyz, vec3(_69._m47.w * texture(sampler1D(_74, _10), min(1.0, max((dot(_826, _826) - _69._m49.x) * _69._m49.w, 0.0))).w)); + } else { + _840 = _793; + } + _841 = _840; + } else { + _841 = _793; + } + bool _862 = _730 && (!(_67._m2 != 0u)); +#if 1 + vec3 _864 = EncodeLUTInput(_841, _67._m11, _67._m12, _67._m13, _67._m14, _862); +#else + vec3 _864 = mix(mix((pow(_841, vec3(_67._m12)) * _67._m13) - vec3(_67._m14), _841 * _67._m11, lessThan(_841, vec3(0.003130800090730190277099609375))), _841, bvec3(_862)); +#endif + + vec3 _1020; + if (_553 && (floatBitsToInt(_69._m19.x) != 0)) { + vec2 _876 = _4.xy * _69._m17.w; + float _942 = (((((((fract(sin(dot(_876 + vec2(0.070000000298023223876953125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_876 + vec2(0.10999999940395355224609375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_876 + vec2(0.12999999523162841796875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_876 + vec2(0.17000000178813934326171875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_876 + vec2(0.189999997615814208984375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_876 + vec2(0.23000000417232513427734375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_876 + vec2(0.2899999916553497314453125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_876 + vec2(0.310000002384185791015625 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _944 = clamp(_942 + _69._m17.z, 0.0, 1.0); + vec3 _1019; + do { + if (!(floatBitsToInt(_69._m18.w) != 0)) { + _1019 = vec3(_944); + break; + } + float _967; + if (floatBitsToInt(_69._m18.y) != 0) { + float _962 = dot(_864, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _967 = mix(_944, _944 * 0.5, (_962 * _962) * _962); + } else { + _967 = _944; + } + vec3 _1018; + if (floatBitsToInt(_69._m19.z) != 0) { + vec3 _1000 = vec3(_967); + vec3 _1002 = _1000 * 2.0; + _1018 = mix(_864, mix(((_864 * 2.0) * (vec3(1.0) - _1000)) + (sqrt(_864) * (_1002 - vec3(1.0))), (_1002 * _864) + ((_864 * _864) * (vec3(1.0) - _1002)), lessThan(_1000, vec3(0.5))), vec3(_69._m18.x)); + } else { + vec3 _999; + if (floatBitsToInt(_69._m19.w) != 0) { + vec3 _987 = vec3(_967); + _999 = mix(_864, mix(vec3(1.0) - (((vec3(1.0) - _987) * 2.0) * (vec3(1.0) - _864)), (_987 * 2.0) * _864, lessThan(_864, vec3(0.5))), vec3(_69._m18.x)); + } else { + _999 = clamp(max(_864 * 0.02500000037252902984619140625, _864 + vec3((_967 - 0.5) * _69._m18.x)), vec3(0.0), vec3(1.0)); + } + _1018 = _999; + } + _1019 = _1018; + break; + } while (false); + _1020 = _1019; + } else { + _1020 = _864; + } + vec3 _1022 = max(_1020 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _1023 = _1022.y; + vec3 _1048 = mix(_1020, clamp((_69._m81.xyz * (_1023 * ((1.33000004291534423828125 * (1.0 + ((_1023 + _1022.z) / _1022.x))) - 1.67999994754791259765625))) * _69._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _522)) * _69._m82.x) + _69._m82.y, 0.0, 1.0))); + vec3 _1078; + if (floatBitsToInt(_69._m84.w) != 0) { + _1078 = mix(_1048, texture(sampler2D(_91, _10), ((((_4.xy - vec2(0.5)) * _69._m84.z) / mix(_69._m85.wx, _69._m85.zy, _4.yx)) - _69._m84.xy) + vec2(0.5)).xyz, vec3(_69._m84.w)); + } else { + _1078 = _1048; + } + float _1103 = 1.0; + vec3 _1389; + if (_553) { +#if 1 + vec3 _1104 = CompressLUTInput(_1078, _862, _67._m5, _67._m7, _67._m8, _67._m9, _1103); +#else + float _1097 = max(max(_1078.x, max(_1078.y, _1078.z)), 9.9999997473787516355514526367188e-05); + _1103 = (_862 && (!(_67._m5 != 0u))) ? 1.0 : (((_1097 > _67._m7) ? ((_1097 * _67._m8) + _67._m9) : _1097) / _1097); + vec3 _1104 = _1078 * _1103; +#endif + float _1107 = _1104.z; + float _1109 = floor(_1107 * 14.99989986419677734375); + float _1115 = (_1109 * 0.0625) + (_1104.x * 0.05859375); + float _1117 = _1104.y * 0.9375; + vec4 _1121 = texture(sampler2D(_87, _10), vec2(0.001953125, 0.03125) + vec2(_1115, _1117)); + vec4 _1127 = texture(sampler2D(_87, _10), vec2(0.001953125, 0.03125) + vec2(_1115 + 0.0625, _1117)); + vec3 _1130 = mix(_1121.xyz, _1127.xyz, vec3((_1107 * 15.0) - _1109)); + vec3 _1386; + if (_99._m0[0u]._m0._m0 > 0) { + vec4 _1138 = texture(sampler2D(_80, _8), _4.xy); + vec4 _1141 = _1138 * _99._m0[0u]._m0._m1; + vec4 _1144 = texture(sampler2D(_89, _10), _4.xy); + float _1146 = dot(_1144.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + float _1148 = clamp(_1141.x, 0.0, 1.0); + float _1150 = _1146 * _1148; + vec3 _1180; + if (_1150 != 0.0) { + float _1154 = _1130.z; + float _1156 = floor(_1154 * 14.99989986419677734375); + float _1162 = (_1156 * 0.0625) + (_1130.x * 0.05859375); + float _1164 = _1130.y * 0.9375; + _1180 = mix(_1130, mix(texture(sampler2D(_83, _10), vec2(0.001953125, 0.03125) + vec2(_1162, _1164)).xyz, texture(sampler2D(_83, _10), vec2(0.001953125, 0.03125) + vec2(_1162 + 0.0625, _1164)).xyz, vec3((_1154 * 15.0) - _1156)), vec3(_1150)); + } else { + _1180 = _1130; + } + float _1182 = clamp(_1141.y, 0.0, 1.0); + float _1184 = _1146 * _1182; + vec3 _1214; + if (_1184 != 0.0) { + float _1190 = floor(_1180.z * 14.99989986419677734375); + float _1196 = (_1190 * 0.0625) + (_1180.x * 0.05859375); + float _1198 = _1180.y * 0.9375; + _1214 = mix(_1180, mix(texture(sampler2D(_84, _10), vec2(0.001953125, 0.03125) + vec2(_1196, _1198)).xyz, texture(sampler2D(_84, _10), vec2(0.001953125, 0.03125) + vec2(_1196 + 0.0625, _1198)).xyz, vec3((_1180.z * 15.0) - _1190)), vec3(_1184)); + } else { + _1214 = _1180; + } + float _1216 = clamp(_1141.z, 0.0, 1.0); + float _1218 = _1146 * _1216; + vec3 _1248; + if (_1218 != 0.0) { + float _1224 = floor(_1214.z * 14.99989986419677734375); + float _1230 = (_1224 * 0.0625) + (_1214.x * 0.05859375); + float _1232 = _1214.y * 0.9375; + _1248 = mix(_1214, mix(texture(sampler2D(_85, _10), vec2(0.001953125, 0.03125) + vec2(_1230, _1232)).xyz, texture(sampler2D(_85, _10), vec2(0.001953125, 0.03125) + vec2(_1230 + 0.0625, _1232)).xyz, vec3((_1214.z * 15.0) - _1224)), vec3(_1218)); + } else { + _1248 = _1214; + } + float _1250 = clamp(_1141.w, 0.0, 1.0); + float _1252 = _1146 * _1250; + vec3 _1282; + if (_1252 != 0.0) { + float _1258 = floor(_1248.z * 14.99989986419677734375); + float _1264 = (_1258 * 0.0625) + (_1248.x * 0.05859375); + float _1266 = _1248.y * 0.9375; + _1282 = mix(_1248, mix(texture(sampler2D(_86, _10), vec2(0.001953125, 0.03125) + vec2(_1264, _1266)).xyz, texture(sampler2D(_86, _10), vec2(0.001953125, 0.03125) + vec2(_1264 + 0.0625, _1266)).xyz, vec3((_1248.z * 15.0) - _1258)), vec3(_1252)); + } else { + _1282 = _1248; + } + float _1318 = floor(_1282.z * 14.99989986419677734375); + float _1324 = (_1318 * 0.0625) + (_1282.x * 0.05859375); + float _1326 = _1282.y * 0.9375; + vec3 _1341 = mix(_1282, mix(texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1324, _1326)).xyz, texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1324 + 0.0625, _1326)).xyz, vec3((_1282.z * 15.0) - _1318)), vec3(clamp(((_313 < _99._m0[0u]._m1[0]._m2) ? clamp((_313 - _99._m0[0u]._m1[0]._m0) * _99._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_313 - _99._m0[0u]._m1[0]._m2) * _99._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _99._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _1353 = _1341.z; + float _1355 = floor(_1353 * 14.99989986419677734375); + float _1361 = (_1355 * 0.0625) + (_1341.x * 0.05859375); + float _1363 = _1341.y * 0.9375; + _1386 = mix(_1341, mix(_1341, mix(texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1361, _1363)).xyz, texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1361 + 0.0625, _1363)).xyz, vec3((_1353 * 15.0) - _1355)), vec3(clamp(((_313 < _99._m0[0u]._m1[1]._m2) ? clamp((_313 - _99._m0[0u]._m1[1]._m0) * _99._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_313 - _99._m0[0u]._m1[1]._m2) * _99._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _99._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_88, _10), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) * (1.0 - clamp(((_1148 + _1182) + _1216) + _1250, 0.0, 1.0)))); + } else { + _1386 = _1130; + } + _1389 = _1386; + } else { + _1389 = _1078; + } + +#if 1 + _1389 = DecodeLUTInput(_1389, _1078, _1103); +#endif + + vec4 _1394 = vec4(_1389, dot(_1389, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1395 = _1394.xyz; + ivec4 _1437 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_60._m0[0u]._m22) & 31), 0u)); + vec3 _1445 = (vec3(texelFetch(_63, _1437.xyz, _1437.w).x) * 2.0) - vec3(1.0); + vec3 _1456; + if (_730) { + _1456 = vec3(ivec3(sign(_1445))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1445))); + } else { + _1456 = _1445; + } + vec3 _1458 = _1395 + CUSTOM_DITHERING * (_1456 * mix(_69._m39.xyz, _69._m40.xyz, pow(clamp((mix(vec3(max(_1389.x, max(_1389.y, _1389.z))), _1395, bvec3(floatBitsToInt(_69._m41.w) != 0)) - _69._m42.xyz) * _69._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_69._m42.w)))); + vec4 _1459 = vec4(_1458.x, _1458.y, _1458.z, _1394.w); + vec4 _1464; + if (!_730) { + _1464 = clamp(_1459, vec4(0.0), vec4(1.0)); + } else { + _1464 = _1459; + } + _6 = _1464; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/calibration_image_0xB17FDFCC.frag.glsl b/src/games/rdr2vk/tonemap/calibration_image_0xB17FDFCC.frag.glsl new file mode 100644 index 000000000..45b6f2855 --- /dev/null +++ b/src/games/rdr2vk/tonemap/calibration_image_0xB17FDFCC.frag.glsl @@ -0,0 +1,99 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +layout(set = 0, binding = 18, std140) uniform _11_12 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_12; + +layout(set = 1, binding = 17, std140) uniform _13_14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + float _m5; + float _m6; + float _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; +} +_14; + +layout(set = 1, binding = 37) uniform sampler _8; +layout(set = 1, binding = 104) uniform texture2D _10; + +layout(location = 0) in vec4 _4; +layout(location = 1) in vec2 _5; +layout(location = 0) out vec4 _6; + +void main() { + vec3 _60 = textureLod(sampler2D(_10, _8), _5, 0.0).xyz; + if (RENODX_TONE_MAP_TYPE == 0.f) { + _6 = vec4((_60 * ((_12._m5 != 0u) ? mix(_12._m6 * _14._m2.y, _12._m6, smoothstep(_14._m2.z, _14._m2.w, dot(_60, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)))) : 1.0)) * _14._m2.x, 1.0); + } else if (RENODX_TONE_MAP_TYPE == 1.f || RENODX_TONE_MAP_TYPE == 2.f) { + vec3 color = _60; + + vec3 color_untonemapped = InverseReinhardScalablePiecewise(color, 0.951f, 0.4f); + + float peak_ratio = RENODX_PEAK_WHITE_NITS / RENODX_DIFFUSE_WHITE_NITS; + vec3 color_tonemapped; + if (RENODX_TONE_MAP_TYPE == 1.f) { + float precompression_yf = renodx_color_yf_from_BT709(color_untonemapped); + color_tonemapped = Neutwo(color_untonemapped, peak_ratio); + color_tonemapped *= DivideSafe( + precompression_yf, + renodx_color_yf_from_BT709(color_tonemapped), + 1.0); + } else { + vec3 bt709_white_lms = renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(1.0)); + vec3 precompression_lms = renodx_tonemap_psycho22_StockmanLMSFromBT709(color_untonemapped); + float precompression_yf = renodx_color_yf_from_LMS(precompression_lms); + vec3 peak_white_lms = renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(peak_ratio)); + vec3 compressed_lms = Neutwo(precompression_lms, peak_white_lms); + + vec3 tonemapped_lms = renodx_tonemap_psycho23_ApplySignedOpponentRetentionAndGamutCompressionLMS( + precompression_lms, + compressed_lms, + bt709_white_lms, + Neutwo(bt709_white_lms, peak_white_lms), + peak_white_lms, + 1.0, + 1.0); + tonemapped_lms *= DivideSafe( + precompression_yf, + renodx_color_yf_from_LMS(tonemapped_lms), + 1.0); + color_tonemapped = renodx_tonemap_psycho22_BT709FromStockmanLMS(tonemapped_lms); + } + + color_tonemapped = ApplyGradingAndDisplayMap(color_tonemapped, _5); + + _6 = vec4(color_tonemapped, 1.0); + } else { + _6 = vec4(_60, 1.0); + } +} + diff --git a/src/games/rdr2vk/tonemap/compiled/0x0C1275BE.frag.spv b/src/games/rdr2vk/tonemap/compiled/0x0C1275BE.frag.spv new file mode 100644 index 000000000..2b72fbc12 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0x0C1275BE.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0x4205843B.frag.spv b/src/games/rdr2vk/tonemap/compiled/0x4205843B.frag.spv new file mode 100644 index 000000000..cdf42bdf5 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0x4205843B.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0x54F0BD84.frag.spv b/src/games/rdr2vk/tonemap/compiled/0x54F0BD84.frag.spv new file mode 100644 index 000000000..aa4c0fa12 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0x54F0BD84.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0x809F5852.frag.spv b/src/games/rdr2vk/tonemap/compiled/0x809F5852.frag.spv new file mode 100644 index 000000000..08256cb55 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0x809F5852.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0x9B304112.frag.spv b/src/games/rdr2vk/tonemap/compiled/0x9B304112.frag.spv new file mode 100644 index 000000000..425e4bd40 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0x9B304112.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0x9F191B0B.frag.spv b/src/games/rdr2vk/tonemap/compiled/0x9F191B0B.frag.spv new file mode 100644 index 000000000..559f3a0dc Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0x9F191B0B.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0xA2ED1CB7.frag.spv b/src/games/rdr2vk/tonemap/compiled/0xA2ED1CB7.frag.spv new file mode 100644 index 000000000..218207abb Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0xA2ED1CB7.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0xB17FDFCC.frag.spv b/src/games/rdr2vk/tonemap/compiled/0xB17FDFCC.frag.spv new file mode 100644 index 000000000..5e896d321 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0xB17FDFCC.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0xCD6F15F2.frag.spv b/src/games/rdr2vk/tonemap/compiled/0xCD6F15F2.frag.spv new file mode 100644 index 000000000..dab0c8000 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0xCD6F15F2.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0xCF7FE0D7.frag.spv b/src/games/rdr2vk/tonemap/compiled/0xCF7FE0D7.frag.spv new file mode 100644 index 000000000..29beea9ea Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0xCF7FE0D7.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/compiled/0xDD04030E.frag.spv b/src/games/rdr2vk/tonemap/compiled/0xDD04030E.frag.spv new file mode 100644 index 000000000..fc775a1b0 Binary files /dev/null and b/src/games/rdr2vk/tonemap/compiled/0xDD04030E.frag.spv differ diff --git a/src/games/rdr2vk/tonemap/deadeye_0xDA9A5AA0.frag.glslx b/src/games/rdr2vk/tonemap/deadeye_0xDA9A5AA0.frag.glslx new file mode 100644 index 000000000..c2645f40d --- /dev/null +++ b/src/games/rdr2vk/tonemap/deadeye_0xDA9A5AA0.frag.glslx @@ -0,0 +1,960 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _12 { + float _m0; +}; + +struct _14 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _13 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _14 _m5; +}; + +struct _16 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _19 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _15 { + _16 _m0[2]; + _17 _m1; + _18 _m2; + _19 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _21 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _20 { + _21 _m0; + _22 _m1; + _23 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _24 { + vec4 _m0[5]; +}; + +struct _25 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _27 { + int _m0; + int _m1; +}; + +struct _28 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _11 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _12 _m41; + _13 _m42; + _15 _m43; + _20 _m44; + _24 _m45; + _25 _m46; + _26 _m47[5]; + vec4 _m48; + _27 _m49; + vec4 _m50; + _28 _m51; +}; + +struct _32 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _33 { + float _m0; +}; + +struct _35 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _34 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _35 _m3; + vec2 _m4; +}; + +struct _37 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _38 { + int _m0; +}; + +struct _39 { + _38 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _36 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _37 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _38 _m16; + _38 _m17; + _39 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _41 { + vec3 _m0; + float _m1; +}; + +struct _42 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _43 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _44 { + float _m0; + _38 _m1; +}; + +struct _45 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _46 { + _38 _m0; + float _m1; + float _m2; +}; + +struct _48 { + int _m0; +}; + +struct _47 { + _38 _m0; + _48 _m1; + _48 _m2; +}; + +struct _49 { + _38 _m0; +}; + +struct _40 { + _41 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _42 _m4; + _43 _m5; + _44 _m6; + _45 _m7; + _46 _m8; + _47 _m9; + _49 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _50 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _51 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _54 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _55 _m19[2]; +}; + +struct _56 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _57 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _58 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _31 { + float _m0[32]; + float _m1[32]; + _32 _m2; + _32 _m3; + _33 _m4; + _34 _m5; + _36 _m6; + _40 _m7; + _50 _m8; + _51 _m9; + float _m10; + vec2 _m11; + _52 _m12; + _53 _m13; + float _m14; + float _m15; + vec4 _m16; + _54 _m17; + _56 _m18; + _57 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _58 _m30; + int _m31; +}; + +struct _91 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _92 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _90 { + _91 _m0; + _92 _m1[11]; +}; + +float _279; + +layout(set = 0, binding = 98, scalar) readonly buffer _10_29 { + _11 _m0[]; +} +_29; + +layout(set = 0, binding = 99, scalar) readonly buffer _30_59 { + _31 _m0[]; +} +_59; + +layout(set = 0, binding = 20, std140) uniform _65_66 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_66; + +layout(set = 1, binding = 16, std140) uniform _67_68 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_68; + +layout(set = 0, binding = 214, std430) readonly buffer _89_93 { + _90 _m0[]; +} +_93; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 0, binding = 121) uniform texture2DArray _62; +layout(set = 0, binding = 140) uniform texture2D _63; +layout(set = 1, binding = 174) uniform texture2D _69; +layout(set = 1, binding = 177) uniform texture2D _70; +layout(set = 1, binding = 185) uniform texture1D _72; +layout(set = 1, binding = 40) uniform sampler _73; +layout(set = 1, binding = 186) uniform texture2D _74; +layout(set = 1, binding = 189) uniform texture2D _75; +layout(set = 1, binding = 194) uniform texture2D _76; +layout(set = 1, binding = 196) uniform texture2D _77; +layout(set = 1, binding = 197) uniform texture2D _78; +layout(set = 1, binding = 198) uniform texture2D _79; +layout(set = 1, binding = 199) uniform texture2D _80; +layout(set = 1, binding = 200) uniform texture2D _81; +layout(set = 1, binding = 201) uniform texture2D _82; +layout(set = 1, binding = 202) uniform texture2D _83; +layout(set = 1, binding = 203) uniform texture2D _84; +layout(set = 1, binding = 204) uniform texture2D _85; +layout(set = 1, binding = 205) uniform texture2D _86; +layout(set = 1, binding = 207) uniform texture2D _87; +layout(set = 1, binding = 212) uniform samplerBuffer _88; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + float _297 = _68._m0.z / ((1.0 + _68._m0.w) - textureLod(sampler2D(_69, _8), _4.xy, 0.0).x); + vec4 _301 = texture(sampler2D(_74, _73), _4.xy); + vec3 _315 = vec4(vec4(_301.xyz, 0.0).xyz * _29._m0[0u]._m1.w, _279).xyz; + vec4 _318 = texelFetch(_88, int(0u)); + vec4 _319 = texelFetch(_88, int(1u)); + float _324 = dot(_315 * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _349; + vec3 _350; + if (floatBitsToInt(_68._m61) != 0) { + vec4 _335 = texture(sampler2D(_86, _73), _4.xy); + float _336 = _335.w; + bool _338 = (_336 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _347; + if (_338) { + _347 = _335.xyz; + } else { + _347 = _335.xyz + (_315 * (1.0 - _336)); + } + _349 = _338 ? true : false; + _350 = _347; + } else { + _349 = false; + _350 = _315; + } + vec3 _354 = min(_350 * texelFetch(_63, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _355 = !_349; + float _491; + vec3 _492; + if (_355) { + float _414; + if (floatBitsToInt(_68._m70.x) != 0) { + float _377 = clamp(dot(texture(sampler2D(_70, _9), _4.xy).xyz * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _68._m72.z, _68._m72.w); + float _400 = clamp(((((_68._m70.y * log(_377 + _68._m72.x)) + _68._m70.z) - 10.0) + (_68._m72.y * _377)) + _68._m65.w, _68._m66.x, _68._m66.y); + _414 = pow(2.0, mix(_5, clamp(_400 + ((abs(_400) * _68._m66.z) * float(int(sign(_400)))), _68._m66.x, _68._m66.y), clamp(_68._m70.x, 0.0, 1.0))); + } else { + _414 = _4.z; + } + vec4 _427 = texture(sampler2D(_75, _9), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _68._m16.w) + _68._m16.xy)); + vec3 _437 = max(_354 * vec3(0.5), _354 + vec3((_324 * (_427.w - 0.5)) * _68._m16.z)); + vec3 _490; + if (floatBitsToInt(_68._m51.w) != 0) { + vec2 _466 = ((_4.xy - _68._m50.xy) * mat2(vec2(_68._m52.x, _68._m52.y), vec2(_68._m52.z, _68._m52.w))) * _68._m50.zw; + float _470 = CUSTOM_VIGNETTE * max((dot(_466, _466) - _68._m53.x) * _68._m53.w, 0.0); + bool _471 = _470 < 1.0; + _490 = mix(_437, (_437 * _68._m51.xyz) * _68._m51.w, vec3(_471 ? (_471 ? (1.0 - pow(2.0, (-10.0) * _470)) : 1.0) : (0.9980499744415283203125 + (((_470 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_470 - 2.0)) : 0.0)))); + } else { + _490 = _437; + } + _491 = _414; + _492 = _490; + } else { + _491 = _4.z; + _492 = _354; + } + vec3 _529 = _492 * mix(mix(_68._m54.xyz, _68._m56.xyz, vec3(clamp(clamp(_4.y * _68._m57.y, 0.0, 1.0) + _68._m54.w, 0.0, 1.0))), mix(_68._m56.xyz, _68._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _68._m56.w, 0.0, 1.0) * _68._m57.x, 0.0, 1.0) - _68._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _532 = _66._m3 != 0u; +#if 1 + vec3 _595 = ApplyToneMap(_529, _532, _491, _66._m6, _66._m4, _66._m10, _318.rgb, _319); +#else + vec3 _595; + if (_532) { + vec3 _572 = max(vec3(0.0), _529 * (_491 / _66._m6)); + vec3 _575 = _572 * _318.x; + _595 = (((((_572 * (_575 + vec3(_319.x))) + vec3(_319.y)) / ((_572 * (_575 + vec3(_318.y))) + vec3(_319.z))) - vec3(_319.w)) * ((_66._m4 != 0u) ? _66._m10 : _318.z)) * _66._m6; + } else { + vec3 _538 = max(vec3(0.0), _529 * _491); + vec3 _541 = _538 * _318.x; + _595 = clamp(((((_538 * (_541 + vec3(_319.x))) + vec3(_319.y)) / ((_538 * (_541 + vec3(_318.y))) + vec3(_319.z))) - vec3(_319.w)) * _318.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _643; + if (_355) { + vec3 _642; + if (floatBitsToInt(_68._m47.w) != 0) { + vec2 _628 = ((_4.xy - _68._m46.xy) * mat2(vec2(_68._m48.x, _68._m48.y), vec2(_68._m48.z, _68._m48.w))) * _68._m46.zw; + _642 = mix(_595, _68._m47.xyz, vec3(_68._m47.w * texture(sampler1D(_72, _9), min(1.0, max((dot(_628, _628) - _68._m49.x) * _68._m49.w, 0.0))).w)); + } else { + _642 = _595; + } + _643 = _642; + } else { + _643 = _595; + } + bool _664 = _532 && (!(_66._m2 != 0u)); + +#if 1 + vec3 _666 = EncodeLUTInput(_643, _66._m11, _66._m12, _66._m13, _66._m14, _664); +#else + vec3 _666 = mix(mix((pow(_643, vec3(_66._m12)) * _66._m13) - vec3(_66._m14), _643 * _66._m11, lessThan(_643, vec3(0.003130800090730190277099609375))), _643, bvec3(_664)); +#endif + + vec3 _822; + if (_355 && (floatBitsToInt(_68._m19.x) != 0)) { + vec2 _678 = _4.xy * _68._m17.w; + float _744 = (((((((fract(sin(dot(_678 + vec2(0.070000000298023223876953125 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_678 + vec2(0.10999999940395355224609375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_678 + vec2(0.12999999523162841796875 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_678 + vec2(0.17000000178813934326171875 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_678 + vec2(0.189999997615814208984375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_678 + vec2(0.23000000417232513427734375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_678 + vec2(0.2899999916553497314453125 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_678 + vec2(0.310000002384185791015625 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _746 = clamp(_744 + _68._m17.z, 0.0, 1.0); + vec3 _821; + do { + if (!(floatBitsToInt(_68._m18.w) != 0)) { + _821 = vec3(_746); + break; + } + float _769; + if (floatBitsToInt(_68._m18.y) != 0) { + float _764 = dot(_666, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _769 = mix(_746, _746 * 0.5, (_764 * _764) * _764); + } else { + _769 = _746; + } + vec3 _820; + if (floatBitsToInt(_68._m19.z) != 0) { + vec3 _802 = vec3(_769); + vec3 _804 = _802 * 2.0; + _820 = mix(_666, mix(((_666 * 2.0) * (vec3(1.0) - _802)) + (sqrt(_666) * (_804 - vec3(1.0))), (_804 * _666) + ((_666 * _666) * (vec3(1.0) - _804)), lessThan(_802, vec3(0.5))), vec3(_68._m18.x)); + } else { + vec3 _801; + if (floatBitsToInt(_68._m19.w) != 0) { + vec3 _789 = vec3(_769); + _801 = mix(_666, mix(vec3(1.0) - (((vec3(1.0) - _789) * 2.0) * (vec3(1.0) - _666)), (_789 * 2.0) * _666, lessThan(_666, vec3(0.5))), vec3(_68._m18.x)); + } else { + _801 = clamp(max(_666 * 0.02500000037252902984619140625, _666 + vec3((_769 - 0.5) * _68._m18.x)), vec3(0.0), vec3(1.0)); + } + _820 = _801; + } + _821 = _820; + break; + } while (false); + _822 = _821; + } else { + _822 = _666; + } + vec3 _824 = max(_822 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _825 = _824.y; + vec3 _850 = mix(_822, clamp((_68._m81.xyz * (_825 * ((1.33000004291534423828125 * (1.0 + ((_825 + _824.z) / _824.x))) - 1.67999994754791259765625))) * _68._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _324)) * _68._m82.x) + _68._m82.y, 0.0, 1.0))); + vec3 _880; + if (floatBitsToInt(_68._m84.w) != 0) { + _880 = mix(_850, texture(sampler2D(_87, _9), ((((_4.xy - vec2(0.5)) * _68._m84.z) / mix(_68._m85.wx, _68._m85.zy, _4.yx)) - _68._m84.xy) + vec2(0.5)).xyz, vec3(_68._m84.w)); + } else { + _880 = _850; + } + float _905 = 1.0; + vec3 _1191; + if (_355) { +#if 1 + vec3 _906 = CompressLUTInput(_880, _664, _66._m5, _66._m7, _66._m8, _66._m9, _905); +#else + float _899 = max(max(_880.x, max(_880.y, _880.z)), 9.9999997473787516355514526367188e-05); + _905 = (_664 && (!(_66._m5 != 0u))) ? 1.0 : (((_899 > _66._m7) ? ((_899 * _66._m8) + _66._m9) : _899) / _899); + vec3 _906 = _880 * _905; +#endif + float _909 = _906.z; + float _911 = floor(_909 * 14.99989986419677734375); + float _917 = (_911 * 0.0625) + (_906.x * 0.05859375); + float _919 = _906.y * 0.9375; + vec4 _923 = texture(sampler2D(_83, _9), vec2(0.001953125, 0.03125) + vec2(_917, _919)); + vec4 _929 = texture(sampler2D(_83, _9), vec2(0.001953125, 0.03125) + vec2(_917 + 0.0625, _919)); + vec3 _932 = mix(_923.xyz, _929.xyz, vec3((_909 * 15.0) - _911)); + vec3 _1188; + if (_93._m0[0u]._m0._m0 > 0) { + vec4 _940 = texture(sampler2D(_76, _8), _4.xy); + vec4 _943 = _940 * _93._m0[0u]._m0._m1; + vec4 _946 = texture(sampler2D(_85, _9), _4.xy); + float _948 = dot(_946.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + float _950 = clamp(_943.x, 0.0, 1.0); + float _952 = _948 * _950; + vec3 _982; + if (_952 != 0.0) { + float _956 = _932.z; + float _958 = floor(_956 * 14.99989986419677734375); + float _964 = (_958 * 0.0625) + (_932.x * 0.05859375); + float _966 = _932.y * 0.9375; + _982 = mix(_932, mix(texture(sampler2D(_79, _9), vec2(0.001953125, 0.03125) + vec2(_964, _966)).xyz, texture(sampler2D(_79, _9), vec2(0.001953125, 0.03125) + vec2(_964 + 0.0625, _966)).xyz, vec3((_956 * 15.0) - _958)), vec3(_952)); + } else { + _982 = _932; + } + float _984 = clamp(_943.y, 0.0, 1.0); + float _986 = _948 * _984; + vec3 _1016; + if (_986 != 0.0) { + float _992 = floor(_982.z * 14.99989986419677734375); + float _998 = (_992 * 0.0625) + (_982.x * 0.05859375); + float _1000 = _982.y * 0.9375; + _1016 = mix(_982, mix(texture(sampler2D(_80, _9), vec2(0.001953125, 0.03125) + vec2(_998, _1000)).xyz, texture(sampler2D(_80, _9), vec2(0.001953125, 0.03125) + vec2(_998 + 0.0625, _1000)).xyz, vec3((_982.z * 15.0) - _992)), vec3(_986)); + } else { + _1016 = _982; + } + float _1018 = clamp(_943.z, 0.0, 1.0); + float _1020 = _948 * _1018; + vec3 _1050; + if (_1020 != 0.0) { + float _1026 = floor(_1016.z * 14.99989986419677734375); + float _1032 = (_1026 * 0.0625) + (_1016.x * 0.05859375); + float _1034 = _1016.y * 0.9375; + _1050 = mix(_1016, mix(texture(sampler2D(_81, _9), vec2(0.001953125, 0.03125) + vec2(_1032, _1034)).xyz, texture(sampler2D(_81, _9), vec2(0.001953125, 0.03125) + vec2(_1032 + 0.0625, _1034)).xyz, vec3((_1016.z * 15.0) - _1026)), vec3(_1020)); + } else { + _1050 = _1016; + } + float _1052 = clamp(_943.w, 0.0, 1.0); + float _1054 = _948 * _1052; + vec3 _1084; + if (_1054 != 0.0) { + float _1060 = floor(_1050.z * 14.99989986419677734375); + float _1066 = (_1060 * 0.0625) + (_1050.x * 0.05859375); + float _1068 = _1050.y * 0.9375; + _1084 = mix(_1050, mix(texture(sampler2D(_82, _9), vec2(0.001953125, 0.03125) + vec2(_1066, _1068)).xyz, texture(sampler2D(_82, _9), vec2(0.001953125, 0.03125) + vec2(_1066 + 0.0625, _1068)).xyz, vec3((_1050.z * 15.0) - _1060)), vec3(_1054)); + } else { + _1084 = _1050; + } + float _1120 = floor(_1084.z * 14.99989986419677734375); + float _1126 = (_1120 * 0.0625) + (_1084.x * 0.05859375); + float _1128 = _1084.y * 0.9375; + vec3 _1143 = mix(_1084, mix(texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_1126, _1128)).xyz, texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_1126 + 0.0625, _1128)).xyz, vec3((_1084.z * 15.0) - _1120)), vec3(clamp(((_297 < _93._m0[0u]._m1[0]._m2) ? clamp((_297 - _93._m0[0u]._m1[0]._m0) * _93._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_297 - _93._m0[0u]._m1[0]._m2) * _93._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _93._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _1155 = _1143.z; + float _1157 = floor(_1155 * 14.99989986419677734375); + float _1163 = (_1157 * 0.0625) + (_1143.x * 0.05859375); + float _1165 = _1143.y * 0.9375; + _1188 = mix(_1143, mix(_1143, mix(texture(sampler2D(_78, _9), vec2(0.001953125, 0.03125) + vec2(_1163, _1165)).xyz, texture(sampler2D(_78, _9), vec2(0.001953125, 0.03125) + vec2(_1163 + 0.0625, _1165)).xyz, vec3((_1155 * 15.0) - _1157)), vec3(clamp(((_297 < _93._m0[0u]._m1[1]._m2) ? clamp((_297 - _93._m0[0u]._m1[1]._m0) * _93._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_297 - _93._m0[0u]._m1[1]._m2) * _93._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _93._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_84, _9), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) * (1.0 - clamp(((_950 + _984) + _1018) + _1052, 0.0, 1.0)))); + } else { + _1188 = _932; + } + _1191 = _1188; + } else { + _1191 = _880; + } + +#if 1 + _1191 = DecodeLUTInput(_1191, _880, _905); +#endif + + vec4 _1196 = vec4(_1191, dot(_1191, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1197 = _1196.xyz; + ivec4 _1240 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_59._m0[0u]._m22) & 31), 0u)); + vec3 _1248 = (vec3(texelFetch(_62, _1240.xyz, _1240.w).x) * 2.0) - vec3(1.0); + vec3 _1259; + if (_532) { + _1259 = vec3(ivec3(sign(_1248))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1248))); + } else { + _1259 = _1248; + } + vec3 _1261 = _1197 + CUSTOM_DITHERING * (_1259 * mix(_68._m39.xyz, _68._m40.xyz, pow(clamp((mix(vec3(max(_1191.x, max(_1191.y, _1191.z))), _1197, bvec3(floatBitsToInt(_68._m41.w) != 0)) - _68._m42.xyz) * _68._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_68._m42.w)))); + vec4 _1262 = vec4(_1261.x, _1261.y, _1261.z, _1196.w); + vec4 _1267; + if (!_532) { + _1267 = clamp(_1262, vec4(0.0), vec4(1.0)); + } else { + _1267 = _1262; + } + _6 = _1267; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/eagleeye_0x6B9382CA.frag.glslx b/src/games/rdr2vk/tonemap/eagleeye_0x6B9382CA.frag.glslx new file mode 100644 index 000000000..8c57f2236 --- /dev/null +++ b/src/games/rdr2vk/tonemap/eagleeye_0x6B9382CA.frag.glslx @@ -0,0 +1,1022 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#if defined(GL_EXT_control_flow_attributes) +#extension GL_EXT_control_flow_attributes : require +#define SPIRV_CROSS_FLATTEN [[flatten]] +#define SPIRV_CROSS_BRANCH [[dont_flatten]] +#define SPIRV_CROSS_UNROLL [[unroll]] +#define SPIRV_CROSS_LOOP [[dont_unroll]] +#else +#define SPIRV_CROSS_FLATTEN +#define SPIRV_CROSS_BRANCH +#define SPIRV_CROSS_UNROLL +#define SPIRV_CROSS_LOOP +#endif +#extension GL_EXT_samplerless_texture_functions : require + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _15 _m5; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; +}; + +struct _19 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _20 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _16 { + _17 _m0[2]; + _18 _m1; + _19 _m2; + _20 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; +}; + +struct _24 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _21 { + _22 _m0; + _23 _m1; + _24 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _25 { + vec4 _m0[5]; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _27 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _28 { + int _m0; + int _m1; +}; + +struct _29 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _12 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _13 _m41; + _14 _m42; + _16 _m43; + _21 _m44; + _25 _m45; + _26 _m46; + _27 _m47[5]; + vec4 _m48; + _28 _m49; + vec4 _m50; + _29 _m51; +}; + +struct _33 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _34 { + float _m0; +}; + +struct _36 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _35 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _36 _m3; + vec2 _m4; +}; + +struct _38 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _39 { + int _m0; +}; + +struct _40 { + _39 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _37 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _38 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _39 _m16; + _39 _m17; + _40 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _42 { + vec3 _m0; + float _m1; +}; + +struct _43 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _44 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _45 { + float _m0; + _39 _m1; +}; + +struct _46 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _47 { + _39 _m0; + float _m1; + float _m2; +}; + +struct _49 { + int _m0; +}; + +struct _48 { + _39 _m0; + _49 _m1; + _49 _m2; +}; + +struct _50 { + _39 _m0; +}; + +struct _41 { + _42 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _43 _m4; + _44 _m5; + _45 _m6; + _46 _m7; + _47 _m8; + _48 _m9; + _50 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _51 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _54 { + vec4 _m0; + vec4 _m1; +}; + +struct _56 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _56 _m19[2]; +}; + +struct _57 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _58 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _59 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _32 { + float _m0[32]; + float _m1[32]; + _33 _m2; + _33 _m3; + _34 _m4; + _35 _m5; + _37 _m6; + _41 _m7; + _51 _m8; + _52 _m9; + float _m10; + vec2 _m11; + _53 _m12; + _54 _m13; + float _m14; + float _m15; + vec4 _m16; + _55 _m17; + _57 _m18; + _58 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _59 _m30; + int _m31; +}; + +struct _98 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _99 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _97 { + _98 _m0; + _99 _m1[11]; +}; + +float _296; + +layout(set = 0, binding = 98, scalar) readonly buffer _11_30 { + _12 _m0[]; +} +_30; + +layout(set = 0, binding = 99, scalar) readonly buffer _31_60 { + _32 _m0[]; +} +_60; + +layout(set = 0, binding = 20, std140) uniform _66_67 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_67; + +layout(set = 1, binding = 16, std140) uniform _68_69 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_69; + +layout(set = 0, binding = 214, std430) readonly buffer _96_100 { + _97 _m0[]; +} +_100; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 33) uniform sampler _9; +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 0, binding = 121) uniform texture2DArray _63; +layout(set = 0, binding = 140) uniform texture2D _64; +layout(set = 1, binding = 173) uniform texture2D _70; +layout(set = 1, binding = 174) uniform texture2D _71; +layout(set = 1, binding = 177) uniform texture2D _72; +layout(set = 1, binding = 185) uniform texture1D _74; +layout(set = 1, binding = 40) uniform sampler _75; +layout(set = 1, binding = 186) uniform texture2D _76; +layout(set = 1, binding = 189) uniform texture2D _77; +layout(set = 1, binding = 190) uniform texture2D _78; +layout(set = 1, binding = 191) uniform texture2D _79; +layout(set = 1, binding = 194) uniform texture2D _80; +layout(set = 1, binding = 196) uniform texture2D _81; +layout(set = 1, binding = 197) uniform texture2D _82; +layout(set = 1, binding = 198) uniform texture2D _83; +layout(set = 1, binding = 199) uniform texture2D _84; +layout(set = 1, binding = 200) uniform texture2D _85; +layout(set = 1, binding = 201) uniform texture2D _86; +layout(set = 1, binding = 202) uniform texture2D _87; +layout(set = 1, binding = 203) uniform texture2D _88; +layout(set = 1, binding = 204) uniform texture2D _89; +layout(set = 1, binding = 205) uniform texture2D _90; +layout(set = 1, binding = 206) uniform texture2D _91; +layout(set = 1, binding = 207) uniform texture2D _92; +layout(set = 1, binding = 209) uniform texture2D _93; +layout(set = 1, binding = 210) uniform texture2D _94; +layout(set = 1, binding = 212) uniform samplerBuffer _95; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _306 = texture(sampler2D(_91, _8), _4.xy); + vec2 _307 = _306.xy; + float _315 = 1.0 + _69._m0.w; + float _318 = _69._m0.z / (_315 - textureLod(sampler2D(_71, _8), _307, 0.0).x); + vec4 _322 = texture(sampler2D(_76, _75), _307); + vec4 _347 = textureLod(sampler2D(_94, _8), _307 * _69._m80.xy, 0.0) * 1.0; + float _348 = _347.z; + vec4 _505; + SPIRV_CROSS_BRANCH + if ((_348 >= 1.0) && (_347.w < 2.0)) { + float _366 = min(length(textureLod(sampler2D(_93, _8), _307, 0.0).xy * _69._m20.x), _69._m20.z); + float _369 = min(_348, 2.0); + vec2 _370 = (_347.xy / vec2(_348)) * _369; + int _373 = int(min(2.0, 1.0 + _369)); + vec2 _377 = _370 * _69._m63.xy; + float _379 = float(_373) - 0.5; + float _380 = _379 / _369; + vec2 _382 = (-_370) * _69._m63.xy; + vec2 _385 = vec2(uvec2(gl_FragCoord.xy) & uvec2(1u)); + float _399 = ((((_385.x * 2.0) - 1.0) * ((_385.y * 2.0) - 1.0)) * _69._m20.w) * clamp((_369 - 2.0) * 0.5, 0.0, 1.0); + float _400 = 0.5 + _399; + float _401 = 0.5 - _399; + vec4 _403; + _403 = vec4(0.0); + for (int _406 = 0; _406 < _373;) { + float _410 = float(_406); + float _411 = _410 + _400; + vec2 _414 = _307 + (_377 * (_411 / _379)); + float _420 = min(length(textureLod(sampler2D(_93, _8), _414, 0.0).xy * _69._m20.x), _69._m20.z); + float _426 = _69._m0.z / (_315 - textureLod(sampler2D(_70, _8), _414, 0.0).x); + float _431 = _366 * _380; + float _448 = _410 + _401; + vec2 _451 = _307 + (_382 * (_448 / _379)); + float _457 = min(length(textureLod(sampler2D(_93, _8), _451, 0.0).xy * _69._m20.x), _69._m20.z); + float _462 = _69._m0.z / (_315 - textureLod(sampler2D(_70, _8), _451, 0.0).x); + float _479 = (1.0 - clamp((1.0 - _457) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_462 - _318)), vec2(0.0), vec2(1.0)), clamp(vec2(_431, _457 * _380) - vec2(max(_448 - 1.0, 0.0)), vec2(0.0), vec2(1.0))); + bvec2 _485 = bvec2(_426 > _462, _457 > _420); + float _487 = all(_485) ? _479 : ((1.0 - clamp((1.0 - _420) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_426 - _318)), vec2(0.0), vec2(1.0)), clamp(vec2(_431, _420 * _380) - vec2(max(_411 - 1.0, 0.0)), vec2(0.0), vec2(1.0)))); + float _489 = any(_485) ? _479 : _487; + _403 = (_403 + vec4(textureLod(sampler2D(_78, _9), _451, 0.0).xyz * _489, _489)) + vec4(textureLod(sampler2D(_78, _9), _414, 0.0).xyz * _487, _487); + _406++; + continue; + } + _505 = _403 / vec4(float(2 * _373)); + } else { + _505 = vec4(0.0); + } + vec4 _513 = textureLod(sampler2D(_79, _9), _307, 0.0); + vec3 _518 = _513.xyz + ((_505.xyz + (vec4(vec4(_322.xyz, 0.0).xyz * _30._m0[0u]._m1.w, _296).xyz * (1.0 - _505.w))) * (1.0 - _513.w)); + vec4 _521 = texelFetch(_95, int(0u)); + vec4 _522 = texelFetch(_95, int(1u)); + float _527 = dot(_518 * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _552; + vec3 _553; + if (floatBitsToInt(_69._m61) != 0) { + vec4 _538 = texture(sampler2D(_90, _75), _4.xy); + float _539 = _538.w; + bool _541 = (_539 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _550; + if (_541) { + _550 = _538.xyz; + } else { + _550 = _538.xyz + (_518 * (1.0 - _539)); + } + _552 = _541 ? true : false; + _553 = _550; + } else { + _552 = false; + _553 = _518; + } + vec3 _557 = min(_553 * texelFetch(_64, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _558 = !_552; + float _694; + vec3 _695; + if (_558) { + float _617; + if (floatBitsToInt(_69._m70.x) != 0) { + float _580 = clamp(dot(texture(sampler2D(_72, _10), _307).xyz * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _69._m72.z, _69._m72.w); + float _603 = clamp(((((_69._m70.y * log(_580 + _69._m72.x)) + _69._m70.z) - 10.0) + (_69._m72.y * _580)) + _69._m65.w, _69._m66.x, _69._m66.y); + _617 = pow(2.0, mix(_5, clamp(_603 + ((abs(_603) * _69._m66.z) * float(int(sign(_603)))), _69._m66.x, _69._m66.y), clamp(_69._m70.x, 0.0, 1.0))); + } else { + _617 = _4.z; + } + vec4 _630 = texture(sampler2D(_77, _10), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _69._m16.w) + _69._m16.xy)); + vec3 _640 = max(_557 * vec3(0.5), _557 + vec3((_527 * (_630.w - 0.5)) * _69._m16.z)); + vec3 _693; + if (floatBitsToInt(_69._m51.w) != 0) { + vec2 _669 = ((_4.xy - _69._m50.xy) * mat2(vec2(_69._m52.x, _69._m52.y), vec2(_69._m52.z, _69._m52.w))) * _69._m50.zw; + float _673 = CUSTOM_VIGNETTE * max((dot(_669, _669) - _69._m53.x) * _69._m53.w, 0.0); + bool _674 = _673 < 1.0; + _693 = mix(_640, (_640 * _69._m51.xyz) * _69._m51.w, vec3(_674 ? (_674 ? (1.0 - pow(2.0, (-10.0) * _673)) : 1.0) : (0.9980499744415283203125 + (((_673 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_673 - 2.0)) : 0.0)))); + } else { + _693 = _640; + } + _694 = _617; + _695 = _693; + } else { + _694 = _4.z; + _695 = _557; + } + vec3 _732 = _695 * mix(mix(_69._m54.xyz, _69._m56.xyz, vec3(clamp(clamp(_4.y * _69._m57.y, 0.0, 1.0) + _69._m54.w, 0.0, 1.0))), mix(_69._m56.xyz, _69._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _69._m56.w, 0.0, 1.0) * _69._m57.x, 0.0, 1.0) - _69._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _735 = _67._m3 != 0u; +#if 1 + vec3 _798 = ApplyToneMap(_732, _735, _694, _67._m6, _67._m4, _67._m10, _521.rgb, _522); +#else + vec3 _798; + if (_735) { + vec3 _775 = max(vec3(0.0), _732 * (_694 / _67._m6)); + vec3 _778 = _775 * _521.x; + _798 = (((((_775 * (_778 + vec3(_522.x))) + vec3(_522.y)) / ((_775 * (_778 + vec3(_521.y))) + vec3(_522.z))) - vec3(_522.w)) * ((_67._m4 != 0u) ? _67._m10 : _521.z)) * _67._m6; + } else { + vec3 _741 = max(vec3(0.0), _732 * _694); + vec3 _744 = _741 * _521.x; + _798 = clamp(((((_741 * (_744 + vec3(_522.x))) + vec3(_522.y)) / ((_741 * (_744 + vec3(_521.y))) + vec3(_522.z))) - vec3(_522.w)) * _521.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _846; + if (_558) { + vec3 _845; + if (floatBitsToInt(_69._m47.w) != 0) { + vec2 _831 = ((_4.xy - _69._m46.xy) * mat2(vec2(_69._m48.x, _69._m48.y), vec2(_69._m48.z, _69._m48.w))) * _69._m46.zw; + _845 = mix(_798, _69._m47.xyz, vec3(_69._m47.w * texture(sampler1D(_74, _10), min(1.0, max((dot(_831, _831) - _69._m49.x) * _69._m49.w, 0.0))).w)); + } else { + _845 = _798; + } + _846 = _845; + } else { + _846 = _798; + } + bool _867 = _735 && (!(_67._m2 != 0u)); +#if 1 + vec3 _869 = EncodeLUTInput(_846, _67._m11, _67._m12, _67._m13, _67._m14, _867); +#else + vec3 _869 = mix(mix((pow(_846, vec3(_67._m12)) * _67._m13) - vec3(_67._m14), _846 * _67._m11, lessThan(_846, vec3(0.003130800090730190277099609375))), _846, bvec3(_867)); +#endif + + vec3 _1025; + if (_558 && (floatBitsToInt(_69._m19.x) != 0)) { + vec2 _881 = _4.xy * _69._m17.w; + float _947 = (((((((fract(sin(dot(_881 + vec2(0.070000000298023223876953125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_881 + vec2(0.10999999940395355224609375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_881 + vec2(0.12999999523162841796875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_881 + vec2(0.17000000178813934326171875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_881 + vec2(0.189999997615814208984375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_881 + vec2(0.23000000417232513427734375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_881 + vec2(0.2899999916553497314453125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_881 + vec2(0.310000002384185791015625 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _949 = clamp(_947 + _69._m17.z, 0.0, 1.0); + vec3 _1024; + do { + if (!(floatBitsToInt(_69._m18.w) != 0)) { + _1024 = vec3(_949); + break; + } + float _972; + if (floatBitsToInt(_69._m18.y) != 0) { + float _967 = dot(_869, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _972 = mix(_949, _949 * 0.5, (_967 * _967) * _967); + } else { + _972 = _949; + } + vec3 _1023; + if (floatBitsToInt(_69._m19.z) != 0) { + vec3 _1005 = vec3(_972); + vec3 _1007 = _1005 * 2.0; + _1023 = mix(_869, mix(((_869 * 2.0) * (vec3(1.0) - _1005)) + (sqrt(_869) * (_1007 - vec3(1.0))), (_1007 * _869) + ((_869 * _869) * (vec3(1.0) - _1007)), lessThan(_1005, vec3(0.5))), vec3(_69._m18.x)); + } else { + vec3 _1004; + if (floatBitsToInt(_69._m19.w) != 0) { + vec3 _992 = vec3(_972); + _1004 = mix(_869, mix(vec3(1.0) - (((vec3(1.0) - _992) * 2.0) * (vec3(1.0) - _869)), (_992 * 2.0) * _869, lessThan(_869, vec3(0.5))), vec3(_69._m18.x)); + } else { + _1004 = clamp(max(_869 * 0.02500000037252902984619140625, _869 + vec3((_972 - 0.5) * _69._m18.x)), vec3(0.0), vec3(1.0)); + } + _1023 = _1004; + } + _1024 = _1023; + break; + } while (false); + _1025 = _1024; + } else { + _1025 = _869; + } + vec3 _1027 = max(_1025 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _1028 = _1027.y; + vec3 _1053 = mix(_1025, clamp((_69._m81.xyz * (_1028 * ((1.33000004291534423828125 * (1.0 + ((_1028 + _1027.z) / _1027.x))) - 1.67999994754791259765625))) * _69._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _527)) * _69._m82.x) + _69._m82.y, 0.0, 1.0))); + vec3 _1083; + if (floatBitsToInt(_69._m84.w) != 0) { + _1083 = mix(_1053, texture(sampler2D(_92, _10), ((((_4.xy - vec2(0.5)) * _69._m84.z) / mix(_69._m85.wx, _69._m85.zy, _4.yx)) - _69._m84.xy) + vec2(0.5)).xyz, vec3(_69._m84.w)); + } else { + _1083 = _1053; + } + float _1108 = 1.0; + vec3 _1394; + if (_558) { +#if 1 + vec3 _1109 = CompressLUTInput(_1083, _867, _67._m5, _67._m7, _67._m8, _67._m9, _1108); +#else + float _1102 = max(max(_1083.x, max(_1083.y, _1083.z)), 9.9999997473787516355514526367188e-05); + _1108 = (_867 && (!(_67._m5 != 0u))) ? 1.0 : (((_1102 > _67._m7) ? ((_1102 * _67._m8) + _67._m9) : _1102) / _1102); + vec3 _1109 = _1083 * _1108; +#endif + float _1112 = _1109.z; + float _1114 = floor(_1112 * 14.99989986419677734375); + float _1120 = (_1114 * 0.0625) + (_1109.x * 0.05859375); + float _1122 = _1109.y * 0.9375; + vec4 _1126 = texture(sampler2D(_87, _10), vec2(0.001953125, 0.03125) + vec2(_1120, _1122)); + vec4 _1132 = texture(sampler2D(_87, _10), vec2(0.001953125, 0.03125) + vec2(_1120 + 0.0625, _1122)); + vec3 _1135 = mix(_1126.xyz, _1132.xyz, vec3((_1112 * 15.0) - _1114)); + vec3 _1391; + if (_100._m0[0u]._m0._m0 > 0) { + vec4 _1143 = texture(sampler2D(_80, _8), _307); + vec4 _1146 = _1143 * _100._m0[0u]._m0._m1; + vec4 _1149 = texture(sampler2D(_89, _10), _307); + float _1151 = dot(_1149.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + float _1153 = clamp(_1146.x, 0.0, 1.0); + float _1155 = _1151 * _1153; + vec3 _1185; + if (_1155 != 0.0) { + float _1159 = _1135.z; + float _1161 = floor(_1159 * 14.99989986419677734375); + float _1167 = (_1161 * 0.0625) + (_1135.x * 0.05859375); + float _1169 = _1135.y * 0.9375; + _1185 = mix(_1135, mix(texture(sampler2D(_83, _10), vec2(0.001953125, 0.03125) + vec2(_1167, _1169)).xyz, texture(sampler2D(_83, _10), vec2(0.001953125, 0.03125) + vec2(_1167 + 0.0625, _1169)).xyz, vec3((_1159 * 15.0) - _1161)), vec3(_1155)); + } else { + _1185 = _1135; + } + float _1187 = clamp(_1146.y, 0.0, 1.0); + float _1189 = _1151 * _1187; + vec3 _1219; + if (_1189 != 0.0) { + float _1195 = floor(_1185.z * 14.99989986419677734375); + float _1201 = (_1195 * 0.0625) + (_1185.x * 0.05859375); + float _1203 = _1185.y * 0.9375; + _1219 = mix(_1185, mix(texture(sampler2D(_84, _10), vec2(0.001953125, 0.03125) + vec2(_1201, _1203)).xyz, texture(sampler2D(_84, _10), vec2(0.001953125, 0.03125) + vec2(_1201 + 0.0625, _1203)).xyz, vec3((_1185.z * 15.0) - _1195)), vec3(_1189)); + } else { + _1219 = _1185; + } + float _1221 = clamp(_1146.z, 0.0, 1.0); + float _1223 = _1151 * _1221; + vec3 _1253; + if (_1223 != 0.0) { + float _1229 = floor(_1219.z * 14.99989986419677734375); + float _1235 = (_1229 * 0.0625) + (_1219.x * 0.05859375); + float _1237 = _1219.y * 0.9375; + _1253 = mix(_1219, mix(texture(sampler2D(_85, _10), vec2(0.001953125, 0.03125) + vec2(_1235, _1237)).xyz, texture(sampler2D(_85, _10), vec2(0.001953125, 0.03125) + vec2(_1235 + 0.0625, _1237)).xyz, vec3((_1219.z * 15.0) - _1229)), vec3(_1223)); + } else { + _1253 = _1219; + } + float _1255 = clamp(_1146.w, 0.0, 1.0); + float _1257 = _1151 * _1255; + vec3 _1287; + if (_1257 != 0.0) { + float _1263 = floor(_1253.z * 14.99989986419677734375); + float _1269 = (_1263 * 0.0625) + (_1253.x * 0.05859375); + float _1271 = _1253.y * 0.9375; + _1287 = mix(_1253, mix(texture(sampler2D(_86, _10), vec2(0.001953125, 0.03125) + vec2(_1269, _1271)).xyz, texture(sampler2D(_86, _10), vec2(0.001953125, 0.03125) + vec2(_1269 + 0.0625, _1271)).xyz, vec3((_1253.z * 15.0) - _1263)), vec3(_1257)); + } else { + _1287 = _1253; + } + float _1323 = floor(_1287.z * 14.99989986419677734375); + float _1329 = (_1323 * 0.0625) + (_1287.x * 0.05859375); + float _1331 = _1287.y * 0.9375; + vec3 _1346 = mix(_1287, mix(texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1329, _1331)).xyz, texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1329 + 0.0625, _1331)).xyz, vec3((_1287.z * 15.0) - _1323)), vec3(clamp(((_318 < _100._m0[0u]._m1[0]._m2) ? clamp((_318 - _100._m0[0u]._m1[0]._m0) * _100._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_318 - _100._m0[0u]._m1[0]._m2) * _100._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _100._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _1358 = _1346.z; + float _1360 = floor(_1358 * 14.99989986419677734375); + float _1366 = (_1360 * 0.0625) + (_1346.x * 0.05859375); + float _1368 = _1346.y * 0.9375; + _1391 = mix(_1346, mix(_1346, mix(texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1366, _1368)).xyz, texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1366 + 0.0625, _1368)).xyz, vec3((_1358 * 15.0) - _1360)), vec3(clamp(((_318 < _100._m0[0u]._m1[1]._m2) ? clamp((_318 - _100._m0[0u]._m1[1]._m0) * _100._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_318 - _100._m0[0u]._m1[1]._m2) * _100._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _100._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_88, _10), _307).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) * (1.0 - clamp(((_1153 + _1187) + _1221) + _1255, 0.0, 1.0)))); + } else { + _1391 = _1135; + } + _1394 = _1391; + } else { + _1394 = _1083; + } + +#if 1 + _1394 = DecodeLUTInput(_1394, _1083, _1108); +#endif + + vec4 _1399 = vec4(_1394, dot(_1394, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1400 = _1399.xyz; + ivec4 _1442 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_60._m0[0u]._m22) & 31), 0u)); + vec3 _1450 = (vec3(texelFetch(_63, _1442.xyz, _1442.w).x) * 2.0) - vec3(1.0); + vec3 _1461; + if (_735) { + _1461 = vec3(ivec3(sign(_1450))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1450))); + } else { + _1461 = _1450; + } + vec3 _1463 = _1400 + CUSTOM_DITHERING * (_1461 * mix(_69._m39.xyz, _69._m40.xyz, pow(clamp((mix(vec3(max(_1394.x, max(_1394.y, _1394.z))), _1400, bvec3(floatBitsToInt(_69._m41.w) != 0)) - _69._m42.xyz) * _69._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_69._m42.w)))); + vec4 _1464 = vec4(_1463.x, _1463.y, _1463.z, _1399.w); + vec4 _1469; + if (!_735) { + _1469 = clamp(_1464, vec4(0.0), vec4(1.0)); + } else { + _1469 = _1464; + } + _6 = _1469; + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + diff --git a/src/games/rdr2vk/tonemap/eagleeye_0xE3E0B5C4.frag.glslx b/src/games/rdr2vk/tonemap/eagleeye_0xE3E0B5C4.frag.glslx new file mode 100644 index 000000000..349aea1d6 --- /dev/null +++ b/src/games/rdr2vk/tonemap/eagleeye_0xE3E0B5C4.frag.glslx @@ -0,0 +1,963 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _12 { + float _m0; +}; + +struct _14 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _13 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _14 _m5; +}; + +struct _16 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _19 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _15 { + _16 _m0[2]; + _17 _m1; + _18 _m2; + _19 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _21 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _20 { + _21 _m0; + _22 _m1; + _23 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _24 { + vec4 _m0[5]; +}; + +struct _25 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _27 { + int _m0; + int _m1; +}; + +struct _28 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _11 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _12 _m41; + _13 _m42; + _15 _m43; + _20 _m44; + _24 _m45; + _25 _m46; + _26 _m47[5]; + vec4 _m48; + _27 _m49; + vec4 _m50; + _28 _m51; +}; + +struct _32 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _33 { + float _m0; +}; + +struct _35 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _34 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _35 _m3; + vec2 _m4; +}; + +struct _37 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _38 { + int _m0; +}; + +struct _39 { + _38 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _36 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _37 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _38 _m16; + _38 _m17; + _39 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _41 { + vec3 _m0; + float _m1; +}; + +struct _42 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _43 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _44 { + float _m0; + _38 _m1; +}; + +struct _45 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _46 { + _38 _m0; + float _m1; + float _m2; +}; + +struct _48 { + int _m0; +}; + +struct _47 { + _38 _m0; + _48 _m1; + _48 _m2; +}; + +struct _49 { + _38 _m0; +}; + +struct _40 { + _41 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _42 _m4; + _43 _m5; + _44 _m6; + _45 _m7; + _46 _m8; + _47 _m9; + _49 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _50 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _51 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _54 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _55 _m19[2]; +}; + +struct _56 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _57 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _58 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _31 { + float _m0[32]; + float _m1[32]; + _32 _m2; + _32 _m3; + _33 _m4; + _34 _m5; + _36 _m6; + _40 _m7; + _50 _m8; + _51 _m9; + float _m10; + vec2 _m11; + _52 _m12; + _53 _m13; + float _m14; + float _m15; + vec4 _m16; + _54 _m17; + _56 _m18; + _57 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _58 _m30; + int _m31; +}; + +struct _92 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _93 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _91 { + _92 _m0; + _93 _m1[11]; +}; + +float _280; + +layout(set = 0, binding = 98, scalar) readonly buffer _10_29 { + _11 _m0[]; +} +_29; + +layout(set = 0, binding = 99, scalar) readonly buffer _30_59 { + _31 _m0[]; +} +_59; + +layout(set = 0, binding = 20, std140) uniform _65_66 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_66; + +layout(set = 1, binding = 16, std140) uniform _67_68 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_68; + +layout(set = 0, binding = 214, std430) readonly buffer _90_94 { + _91 _m0[]; +} +_94; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 0, binding = 121) uniform texture2DArray _62; +layout(set = 0, binding = 140) uniform texture2D _63; +layout(set = 1, binding = 174) uniform texture2D _69; +layout(set = 1, binding = 177) uniform texture2D _70; +layout(set = 1, binding = 185) uniform texture1D _72; +layout(set = 1, binding = 40) uniform sampler _73; +layout(set = 1, binding = 186) uniform texture2D _74; +layout(set = 1, binding = 189) uniform texture2D _75; +layout(set = 1, binding = 194) uniform texture2D _76; +layout(set = 1, binding = 196) uniform texture2D _77; +layout(set = 1, binding = 197) uniform texture2D _78; +layout(set = 1, binding = 198) uniform texture2D _79; +layout(set = 1, binding = 199) uniform texture2D _80; +layout(set = 1, binding = 200) uniform texture2D _81; +layout(set = 1, binding = 201) uniform texture2D _82; +layout(set = 1, binding = 202) uniform texture2D _83; +layout(set = 1, binding = 203) uniform texture2D _84; +layout(set = 1, binding = 204) uniform texture2D _85; +layout(set = 1, binding = 205) uniform texture2D _86; +layout(set = 1, binding = 206) uniform texture2D _87; +layout(set = 1, binding = 207) uniform texture2D _88; +layout(set = 1, binding = 212) uniform samplerBuffer _89; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _290 = texture(sampler2D(_87, _8), _4.xy); + vec2 _291 = _290.xy; + float _302 = _68._m0.z / ((1.0 + _68._m0.w) - textureLod(sampler2D(_69, _8), _291, 0.0).x); + vec4 _306 = texture(sampler2D(_74, _73), _291); + vec3 _320 = vec4(vec4(_306.xyz, 0.0).xyz * _29._m0[0u]._m1.w, _280).xyz; + vec4 _323 = texelFetch(_89, int(0u)); + vec4 _324 = texelFetch(_89, int(1u)); + float _329 = dot(_320 * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _354; + vec3 _355; + if (floatBitsToInt(_68._m61) != 0) { + vec4 _340 = texture(sampler2D(_86, _73), _4.xy); + float _341 = _340.w; + bool _343 = (_341 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _352; + if (_343) { + _352 = _340.xyz; + } else { + _352 = _340.xyz + (_320 * (1.0 - _341)); + } + _354 = _343 ? true : false; + _355 = _352; + } else { + _354 = false; + _355 = _320; + } + vec3 _359 = min(_355 * texelFetch(_63, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _360 = !_354; + float _496; + vec3 _497; + if (_360) { + float _419; + if (floatBitsToInt(_68._m70.x) != 0) { + float _382 = clamp(dot(texture(sampler2D(_70, _9), _291).xyz * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _68._m72.z, _68._m72.w); + float _405 = clamp(((((_68._m70.y * log(_382 + _68._m72.x)) + _68._m70.z) - 10.0) + (_68._m72.y * _382)) + _68._m65.w, _68._m66.x, _68._m66.y); + _419 = pow(2.0, mix(_5, clamp(_405 + ((abs(_405) * _68._m66.z) * float(int(sign(_405)))), _68._m66.x, _68._m66.y), clamp(_68._m70.x, 0.0, 1.0))); + } else { + _419 = _4.z; + } + vec4 _432 = texture(sampler2D(_75, _9), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _68._m16.w) + _68._m16.xy)); + vec3 _442 = max(_359 * vec3(0.5), _359 + vec3((_329 * (_432.w - 0.5)) * _68._m16.z)); + vec3 _495; + if (floatBitsToInt(_68._m51.w) != 0) { + vec2 _471 = ((_4.xy - _68._m50.xy) * mat2(vec2(_68._m52.x, _68._m52.y), vec2(_68._m52.z, _68._m52.w))) * _68._m50.zw; + float _475 = CUSTOM_VIGNETTE * max((dot(_471, _471) - _68._m53.x) * _68._m53.w, 0.0); + bool _476 = _475 < 1.0; + _495 = mix(_442, (_442 * _68._m51.xyz) * _68._m51.w, vec3(_476 ? (_476 ? (1.0 - pow(2.0, (-10.0) * _475)) : 1.0) : (0.9980499744415283203125 + (((_475 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_475 - 2.0)) : 0.0)))); + } else { + _495 = _442; + } + _496 = _419; + _497 = _495; + } else { + _496 = _4.z; + _497 = _359; + } + vec3 _534 = _497 * mix(mix(_68._m54.xyz, _68._m56.xyz, vec3(clamp(clamp(_4.y * _68._m57.y, 0.0, 1.0) + _68._m54.w, 0.0, 1.0))), mix(_68._m56.xyz, _68._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _68._m56.w, 0.0, 1.0) * _68._m57.x, 0.0, 1.0) - _68._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _537 = _66._m3 != 0u; +#if 1 + vec3 _600 = ApplyToneMap(_534, _537, _496, _66._m6, _66._m4, _66._m10, _323.rgb, _324); +#else + vec3 _600; + if (_537) { + vec3 _577 = max(vec3(0.0), _534 * (_496 / _66._m6)); + vec3 _580 = _577 * _323.x; + _600 = (((((_577 * (_580 + vec3(_324.x))) + vec3(_324.y)) / ((_577 * (_580 + vec3(_323.y))) + vec3(_324.z))) - vec3(_324.w)) * ((_66._m4 != 0u) ? _66._m10 : _323.z)) * _66._m6; + } else { + vec3 _543 = max(vec3(0.0), _534 * _496); + vec3 _546 = _543 * _323.x; + _600 = clamp(((((_543 * (_546 + vec3(_324.x))) + vec3(_324.y)) / ((_543 * (_546 + vec3(_323.y))) + vec3(_324.z))) - vec3(_324.w)) * _323.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _648; + if (_360) { + vec3 _647; + if (floatBitsToInt(_68._m47.w) != 0) { + vec2 _633 = ((_4.xy - _68._m46.xy) * mat2(vec2(_68._m48.x, _68._m48.y), vec2(_68._m48.z, _68._m48.w))) * _68._m46.zw; + _647 = mix(_600, _68._m47.xyz, vec3(_68._m47.w * texture(sampler1D(_72, _9), min(1.0, max((dot(_633, _633) - _68._m49.x) * _68._m49.w, 0.0))).w)); + } else { + _647 = _600; + } + _648 = _647; + } else { + _648 = _600; + } + bool _669 = _537 && (!(_66._m2 != 0u)); + +#if 1 + vec3 _671 = EncodeLUTInput(_648, _66._m11, _66._m12, _66._m13, _66._m14, _669); +#else + vec3 _671 = mix(mix((pow(_648, vec3(_66._m12)) * _66._m13) - vec3(_66._m14), _648 * _66._m11, lessThan(_648, vec3(0.003130800090730190277099609375))), _648, bvec3(_669)); +#endif + + vec3 _827; + if (_360 && (floatBitsToInt(_68._m19.x) != 0)) { + vec2 _683 = _4.xy * _68._m17.w; + float _749 = (((((((fract(sin(dot(_683 + vec2(0.070000000298023223876953125 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_683 + vec2(0.10999999940395355224609375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_683 + vec2(0.12999999523162841796875 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_683 + vec2(0.17000000178813934326171875 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_683 + vec2(0.189999997615814208984375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_683 + vec2(0.23000000417232513427734375 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_683 + vec2(0.2899999916553497314453125 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_683 + vec2(0.310000002384185791015625 * _68._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _751 = clamp(_749 + _68._m17.z, 0.0, 1.0); + vec3 _826; + do { + if (!(floatBitsToInt(_68._m18.w) != 0)) { + _826 = vec3(_751); + break; + } + float _774; + if (floatBitsToInt(_68._m18.y) != 0) { + float _769 = dot(_671, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _774 = mix(_751, _751 * 0.5, (_769 * _769) * _769); + } else { + _774 = _751; + } + vec3 _825; + if (floatBitsToInt(_68._m19.z) != 0) { + vec3 _807 = vec3(_774); + vec3 _809 = _807 * 2.0; + _825 = mix(_671, mix(((_671 * 2.0) * (vec3(1.0) - _807)) + (sqrt(_671) * (_809 - vec3(1.0))), (_809 * _671) + ((_671 * _671) * (vec3(1.0) - _809)), lessThan(_807, vec3(0.5))), vec3(_68._m18.x)); + } else { + vec3 _806; + if (floatBitsToInt(_68._m19.w) != 0) { + vec3 _794 = vec3(_774); + _806 = mix(_671, mix(vec3(1.0) - (((vec3(1.0) - _794) * 2.0) * (vec3(1.0) - _671)), (_794 * 2.0) * _671, lessThan(_671, vec3(0.5))), vec3(_68._m18.x)); + } else { + _806 = clamp(max(_671 * 0.02500000037252902984619140625, _671 + vec3((_774 - 0.5) * _68._m18.x)), vec3(0.0), vec3(1.0)); + } + _825 = _806; + } + _826 = _825; + break; + } while (false); + _827 = _826; + } else { + _827 = _671; + } + vec3 _829 = max(_827 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _830 = _829.y; + vec3 _855 = mix(_827, clamp((_68._m81.xyz * (_830 * ((1.33000004291534423828125 * (1.0 + ((_830 + _829.z) / _829.x))) - 1.67999994754791259765625))) * _68._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _329)) * _68._m82.x) + _68._m82.y, 0.0, 1.0))); + vec3 _885; + if (floatBitsToInt(_68._m84.w) != 0) { + _885 = mix(_855, texture(sampler2D(_88, _9), ((((_4.xy - vec2(0.5)) * _68._m84.z) / mix(_68._m85.wx, _68._m85.zy, _4.yx)) - _68._m84.xy) + vec2(0.5)).xyz, vec3(_68._m84.w)); + } else { + _885 = _855; + } + float _910 = 1.0; + vec3 _1196; + if (_360) { +#if 1 + vec3 _911 = CompressLUTInput(_885, _669, _66._m5, _66._m7, _66._m8, _66._m9, _910); +#else + float _904 = max(max(_885.x, max(_885.y, _885.z)), 9.9999997473787516355514526367188e-05); + _910 = (_669 && (!(_66._m5 != 0u))) ? 1.0 : (((_904 > _66._m7) ? ((_904 * _66._m8) + _66._m9) : _904) / _904); + vec3 _911 = _885 * _910; +#endif + float _914 = _911.z; + float _916 = floor(_914 * 14.99989986419677734375); + float _922 = (_916 * 0.0625) + (_911.x * 0.05859375); + float _924 = _911.y * 0.9375; + vec4 _928 = texture(sampler2D(_83, _9), vec2(0.001953125, 0.03125) + vec2(_922, _924)); + vec4 _934 = texture(sampler2D(_83, _9), vec2(0.001953125, 0.03125) + vec2(_922 + 0.0625, _924)); + vec3 _937 = mix(_928.xyz, _934.xyz, vec3((_914 * 15.0) - _916)); + vec3 _1193; + if (_94._m0[0u]._m0._m0 > 0) { + vec4 _945 = texture(sampler2D(_76, _8), _291); + vec4 _948 = _945 * _94._m0[0u]._m0._m1; + vec4 _951 = texture(sampler2D(_85, _9), _291); + float _953 = dot(_951.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + float _955 = clamp(_948.x, 0.0, 1.0); + float _957 = _953 * _955; + vec3 _987; + if (_957 != 0.0) { + float _961 = _937.z; + float _963 = floor(_961 * 14.99989986419677734375); + float _969 = (_963 * 0.0625) + (_937.x * 0.05859375); + float _971 = _937.y * 0.9375; + _987 = mix(_937, mix(texture(sampler2D(_79, _9), vec2(0.001953125, 0.03125) + vec2(_969, _971)).xyz, texture(sampler2D(_79, _9), vec2(0.001953125, 0.03125) + vec2(_969 + 0.0625, _971)).xyz, vec3((_961 * 15.0) - _963)), vec3(_957)); + } else { + _987 = _937; + } + float _989 = clamp(_948.y, 0.0, 1.0); + float _991 = _953 * _989; + vec3 _1021; + if (_991 != 0.0) { + float _997 = floor(_987.z * 14.99989986419677734375); + float _1003 = (_997 * 0.0625) + (_987.x * 0.05859375); + float _1005 = _987.y * 0.9375; + _1021 = mix(_987, mix(texture(sampler2D(_80, _9), vec2(0.001953125, 0.03125) + vec2(_1003, _1005)).xyz, texture(sampler2D(_80, _9), vec2(0.001953125, 0.03125) + vec2(_1003 + 0.0625, _1005)).xyz, vec3((_987.z * 15.0) - _997)), vec3(_991)); + } else { + _1021 = _987; + } + float _1023 = clamp(_948.z, 0.0, 1.0); + float _1025 = _953 * _1023; + vec3 _1055; + if (_1025 != 0.0) { + float _1031 = floor(_1021.z * 14.99989986419677734375); + float _1037 = (_1031 * 0.0625) + (_1021.x * 0.05859375); + float _1039 = _1021.y * 0.9375; + _1055 = mix(_1021, mix(texture(sampler2D(_81, _9), vec2(0.001953125, 0.03125) + vec2(_1037, _1039)).xyz, texture(sampler2D(_81, _9), vec2(0.001953125, 0.03125) + vec2(_1037 + 0.0625, _1039)).xyz, vec3((_1021.z * 15.0) - _1031)), vec3(_1025)); + } else { + _1055 = _1021; + } + float _1057 = clamp(_948.w, 0.0, 1.0); + float _1059 = _953 * _1057; + vec3 _1089; + if (_1059 != 0.0) { + float _1065 = floor(_1055.z * 14.99989986419677734375); + float _1071 = (_1065 * 0.0625) + (_1055.x * 0.05859375); + float _1073 = _1055.y * 0.9375; + _1089 = mix(_1055, mix(texture(sampler2D(_82, _9), vec2(0.001953125, 0.03125) + vec2(_1071, _1073)).xyz, texture(sampler2D(_82, _9), vec2(0.001953125, 0.03125) + vec2(_1071 + 0.0625, _1073)).xyz, vec3((_1055.z * 15.0) - _1065)), vec3(_1059)); + } else { + _1089 = _1055; + } + float _1125 = floor(_1089.z * 14.99989986419677734375); + float _1131 = (_1125 * 0.0625) + (_1089.x * 0.05859375); + float _1133 = _1089.y * 0.9375; + vec3 _1148 = mix(_1089, mix(texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_1131, _1133)).xyz, texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_1131 + 0.0625, _1133)).xyz, vec3((_1089.z * 15.0) - _1125)), vec3(clamp(((_302 < _94._m0[0u]._m1[0]._m2) ? clamp((_302 - _94._m0[0u]._m1[0]._m0) * _94._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_302 - _94._m0[0u]._m1[0]._m2) * _94._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _94._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _1160 = _1148.z; + float _1162 = floor(_1160 * 14.99989986419677734375); + float _1168 = (_1162 * 0.0625) + (_1148.x * 0.05859375); + float _1170 = _1148.y * 0.9375; + _1193 = mix(_1148, mix(_1148, mix(texture(sampler2D(_78, _9), vec2(0.001953125, 0.03125) + vec2(_1168, _1170)).xyz, texture(sampler2D(_78, _9), vec2(0.001953125, 0.03125) + vec2(_1168 + 0.0625, _1170)).xyz, vec3((_1160 * 15.0) - _1162)), vec3(clamp(((_302 < _94._m0[0u]._m1[1]._m2) ? clamp((_302 - _94._m0[0u]._m1[1]._m0) * _94._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_302 - _94._m0[0u]._m1[1]._m2) * _94._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _94._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_84, _9), _291).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)) * (1.0 - clamp(((_955 + _989) + _1023) + _1057, 0.0, 1.0)))); + } else { + _1193 = _937; + } + _1196 = _1193; + } else { + _1196 = _885; + } + +#if 1 + _1196 = DecodeLUTInput(_1196, _885, _910); +#endif + + vec4 _1201 = vec4(_1196, dot(_1196, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1202 = _1201.xyz; + ivec4 _1245 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_59._m0[0u]._m22) & 31), 0u)); + vec3 _1253 = (vec3(texelFetch(_62, _1245.xyz, _1245.w).x) * 2.0) - vec3(1.0); + vec3 _1264; + if (_537) { + _1264 = vec3(ivec3(sign(_1253))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1253))); + } else { + _1264 = _1253; + } + vec3 _1266 = _1202 + CUSTOM_DITHERING * (_1264 * mix(_68._m39.xyz, _68._m40.xyz, pow(clamp((mix(vec3(max(_1196.x, max(_1196.y, _1196.z))), _1202, bvec3(floatBitsToInt(_68._m41.w) != 0)) - _68._m42.xyz) * _68._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_68._m42.w)))); + vec4 _1267 = vec4(_1266.x, _1266.y, _1266.z, _1201.w); + vec4 _1272; + if (!_537) { + _1272 = clamp(_1267, vec4(0.0), vec4(1.0)); + } else { + _1272 = _1267; + } + _6 = _1272; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/filmgrain.glsl b/src/games/rdr2vk/tonemap/filmgrain.glsl new file mode 100644 index 000000000..fe622fc89 --- /dev/null +++ b/src/games/rdr2vk/tonemap/filmgrain.glsl @@ -0,0 +1,68 @@ +#ifndef SRC_GAMES_RDR2VK_TONEMAP_FILMGRAIN_GLSL_ +#define SRC_GAMES_RDR2VK_TONEMAP_FILMGRAIN_GLSL_ + +float GetLuminanceBT2020(vec3 color) { + return dot(color, vec3(0.2627002120, 0.6779980715, 0.0593017165)); +} + +// https://web.archive.org/web/20080211204527/http://lumina.sourceforge.net/Tutorials/Noise.html +float Generate(vec2 uv) { + return fract(sin(dot(uv, vec2(12.9898, 78.233))) * 43758.5453); +} + +float RandomGenerate(vec2 uv) { + return Generate(uv); +} + +// Bartleson +// https://www.imaging.org/common/uploaded%20files/pdfs/Papers/2003/PICS-0-287/8583.pdf +float ComputeFilmGraininess(float density) { + if (density <= 0.0) { + return 0.0; // Because luminance can be negative, pow can be unsafe + } + float bof_d_over_c = 0.880 - (0.736 * density) - (0.003 * pow(density, 7.6)); + return pow(10.0, bof_d_over_c); +} + +vec3 ApplyFilmGrainBT2020(vec3 color_bt2020, vec2 xy, float seed, float strength, float reference_white, bool debug) { + float random_number = Generate(xy + seed); + + // Film grain is based on film density + // Film works in negative, meaning black has no density + // The greater the film density (lighter), more perceived grain + // Simplified, grain scales with Y + // Scaling is not linear + + color_bt2020 = max(vec3(0.0), color_bt2020); + float color_y = GetLuminanceBT2020(color_bt2020); + + float adjusted_color_y = color_y * (1.0 / reference_white); + + // Ideal film density matches 0-3. Skip emulating film stock + // https://www.mr-alvandi.com/technique/measuring-film-speed.html + float density = adjusted_color_y * 3.0; + + float graininess = ComputeFilmGraininess(density); + float random_factor = (random_number * 2.0) - 1.0; + float boost = 1.667; // Boost max to 0.05 + + float y_change = random_factor * graininess * strength * boost; + vec3 output_color = color_bt2020 * (1.0 + y_change); + + if (debug) { + // Output visualization + output_color = vec3(abs(y_change)); + } + + return output_color; +} + +vec3 ApplyFilmGrainBT2020(vec3 color, vec2 xy, float seed, float strength, float reference_white) { + return ApplyFilmGrainBT2020(color, xy, seed, strength, reference_white, false); +} + +vec3 ApplyFilmGrainBT2020(vec3 color, vec2 xy, float seed, float strength) { + return ApplyFilmGrainBT2020(color, xy, seed, strength, 1.0, false); +} + +#endif // SRC_GAMES_INDYGREATCIRCLE_INCLUDE_FILMGRAIN_GLSL_ diff --git a/src/games/rdr2vk/tonemap/pause_0x2B012EDD.frag.glslx b/src/games/rdr2vk/tonemap/pause_0x2B012EDD.frag.glslx new file mode 100644 index 000000000..4c271517b --- /dev/null +++ b/src/games/rdr2vk/tonemap/pause_0x2B012EDD.frag.glslx @@ -0,0 +1,239 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +struct _22 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _21 { + _22 _m0; + _23 _m1[11]; +}; + +layout(set = 0, binding = 20, std140) uniform _9_10 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_10; + +layout(set = 1, binding = 16, std140) uniform _11_12 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_12; + +layout(set = 0, binding = 214, std430) readonly buffer _20_24 { + _21 _m0[]; +} +_24; + +layout(set = 1, binding = 34) uniform sampler _7; +layout(set = 1, binding = 185) uniform texture1D _14; +layout(set = 1, binding = 40) uniform sampler _15; +layout(set = 1, binding = 186) uniform texture2D _16; +layout(set = 1, binding = 196) uniform texture2D _17; +layout(set = 1, binding = 202) uniform texture2D _18; +layout(set = 1, binding = 203) uniform texture2D _19; + +layout(location = 0) in vec4 _4; +layout(location = 0) out vec4 _5; + +void main() { + vec4 _112 = texture(sampler2D(_16, _15), _4.xy); +#if 1 + vec3 _113 = EncodeLUTInput(_112.xyz); +#endif + vec3 _158; + if (floatBitsToInt(_12._m47.w) != 0) { + vec2 _144 = ((_4.xy - _12._m46.xy) * mat2(vec2(_12._m48.x, _12._m48.y), vec2(_12._m48.z, _12._m48.w))) * _12._m46.zw; + _158 = mix(_113, _12._m47.xyz, vec3(_12._m47.w * texture(sampler1D(_14, _7), min(1.0, max((dot(_144, _144) - _12._m49.x) * _12._m49.w, 0.0))).w)); + } else { + _158 = _113; + } + vec4 _316; + if (floatBitsToInt(_12._m19.x) != 0) { + vec2 _171 = _4.xy * _12._m17.w; + float _237 = (((((((fract(sin(dot(_171 + vec2(0.070000000298023223876953125 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_171 + vec2(0.10999999940395355224609375 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_171 + vec2(0.12999999523162841796875 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_171 + vec2(0.17000000178813934326171875 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_171 + vec2(0.189999997615814208984375 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_171 + vec2(0.23000000417232513427734375 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_171 + vec2(0.2899999916553497314453125 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_171 + vec2(0.310000002384185791015625 * _12._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _239 = clamp(_237 + _12._m17.z, 0.0, 1.0); + vec3 _314; + do { + if (!(floatBitsToInt(_12._m18.w) != 0)) { + _314 = vec3(_239); + break; + } + float _262; + if (floatBitsToInt(_12._m18.y) != 0) { + float _257 = dot(_158.xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _262 = mix(_239, _239 * 0.5, (_257 * _257) * _257); + } else { + _262 = _239; + } + vec3 _313; + if (floatBitsToInt(_12._m19.z) != 0) { + vec3 _277 = vec3(_262); + vec3 _279 = _277 * 2.0; + _313 = mix(_158.xyz, mix(((_158.xyz * 2.0) * (vec3(1.0) - _277)) + (sqrt(_158.xyz) * (_279 - vec3(1.0))), (_279 * _158.xyz) + ((_158.xyz * _158.xyz) * (vec3(1.0) - _279)), lessThan(_277, vec3(0.5))), vec3(_12._m18.x)); + } else { + vec3 _312; + if (floatBitsToInt(_12._m19.w) != 0) { + vec3 _300 = vec3(_262); + _312 = mix(_158.xyz, mix(vec3(1.0) - (((vec3(1.0) - _300) * 2.0) * (vec3(1.0) - _158.xyz)), (_300 * 2.0) * _158.xyz, lessThan(_158.xyz, vec3(0.5))), vec3(_12._m18.x)); + } else { + _312 = clamp(max(_158.xyz * 0.02500000037252902984619140625, _158.xyz + vec3((_262 - 0.5) * _12._m18.x)), vec3(0.0), vec3(1.0)); + } + _313 = _312; + } + _314 = _313; + break; + } while (false); + _316 = vec4(_314.x, _314.y, _314.z, _112.w); + } else { + _316 = vec4(_158.x, _158.y, _158.z, _112.w); + } + vec3 lut_input = _316.xyz; + float _338 = 1.0; +#if 1 + vec3 _339 = CompressLUTInputAlt(lut_input, _10._m3, _10._m7, _10._m8, _10._m9, _338); +#else + float _332 = max(max(lut_input.x, max(lut_input.y, lut_input.z)), 9.9999997473787516355514526367188e-05); + _338 = (_10._m3 != 0u) ? (((_332 > _10._m7) ? ((_332 * _10._m8) + _10._m9) : _332) / _332) : 1.0; + vec3 _339 = lut_input * _338; +#endif + float _342 = _339.z; + float _344 = floor(_342 * 14.99989986419677734375); + float _350 = (_344 * 0.0625) + (_339.x * 0.05859375); + float _352 = _339.y * 0.9375; + vec4 _356 = texture(sampler2D(_18, _7), vec2(0.001953125, 0.03125) + vec2(_350, _352)); + vec4 _362 = texture(sampler2D(_18, _7), vec2(0.001953125, 0.03125) + vec2(_350 + 0.0625, _352)); + vec3 _365 = mix(_356.xyz, _362.xyz, vec3((_342 * 15.0) - _344)); + vec4 _406; + if (_24._m0[0u]._m0._m0 > 0) { + float _379 = _365.z; + float _381 = floor(_379 * 14.99989986419677734375); + float _387 = (_381 * 0.0625) + (_365.x * 0.05859375); + float _389 = _365.y * 0.9375; + vec3 _404 = mix(_365.xyz, mix(texture(sampler2D(_17, _7), vec2(0.001953125, 0.03125) + vec2(_387, _389)).xyz, texture(sampler2D(_17, _7), vec2(0.001953125, 0.03125) + vec2(_387 + 0.0625, _389)).xyz, vec3((_379 * 15.0) - _381)), vec3(dot(texture(sampler2D(_19, _7), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + _406 = vec4(_404.x, _404.y, _404.z, _316.w); + } else { + _406 = vec4(_365.x, _365.y, _365.z, _316.w); + } + vec3 _409 = DecodeLUTInput(_406.xyz, lut_input, _338); + _5 = vec4(_409.x, _409.y, _409.z, _406.w); + + _5.rgb = ApplyGradingAndDisplayMap(_5.rgb, _4.xy); +} + diff --git a/src/games/rdr2vk/tonemap/tonemap.glsl b/src/games/rdr2vk/tonemap/tonemap.glsl new file mode 100644 index 000000000..6e8c0802c --- /dev/null +++ b/src/games/rdr2vk/tonemap/tonemap.glsl @@ -0,0 +1,302 @@ +#include "../canvas.glsl" +#include "../common.glsl" +#include "./filmgrain.glsl" +#include "./tonemaprdr2extended.glsl" + +float GetTonemapClampMax() { + return (UNCLAMP_HIGHLIGHTS != 0.f) ? 3.40282346638528859812e+38 : 65504.0; +} + +vec3 InverseReinhardScalablePiecewise(vec3 color, float channel_max, float shoulder) { + float channel_min = 0.0; + float exposure = (channel_max * (channel_min * shoulder + channel_min - shoulder)) + / (shoulder * (shoulder - channel_max)); + + vec3 numerator = -channel_max * (channel_min * color + channel_min - color); + vec3 denominator = exposure * (vec3(channel_max) - color); + vec3 inversed = DivideSafe(numerator, denominator, vec3(65504.0)); + + return mix(color, inversed, step(vec3(shoulder), color)); +} + +// f_p(x) = (p * x) / sqrt(x*x + p*p) +float Neutwo(float x, float peak) { + float p = peak; + float numerator = p * x; + float denominator_squared = fma(x, x, p * p); + return numerator * inversesqrt(denominator_squared); +} + +vec3 Neutwo(vec3 x, float peak) { + float p = peak; + vec3 numerator = p * x; + vec3 denominator_squared = fma(x, x, vec3(p * p)); + return numerator * inversesqrt(denominator_squared); +} + +vec3 Neutwo(vec3 x, vec3 peak) { + vec3 numerator = peak * x; + vec3 denominator_squared = fma(x, x, peak * peak); + return numerator * inversesqrt(denominator_squared); +} + +// f(x) = x / sqrt(x*x + 1) +float Neutwo(float x) { + float numerator = x; + float denominator_squared = fma(x, x, 1.0); + return numerator * inversesqrt(denominator_squared); +} + +// f_ci(x) = (c * p * x) / sqrt(-x*x*(c*c - p*p) + (c*c * p*p)) +vec3 Neutwo_Inverse(vec3 x, float peak, float clip) { + float p = peak; + float c = clip; + float cc = c * c; + float pp = p * p; + vec3 xx = x * x; + + vec3 numerator = (c * p) * x; + vec3 denominator_squared = fma(-xx, vec3(cc - pp), vec3(cc * pp)); + + return numerator * inversesqrt(denominator_squared); +} + +vec3 ApplyAnchoredAdaptationContrast(vec3 color, float contrast, vec3 anchor_in, vec3 anchor_out, float flare) { + vec3 ax = abs(color); + vec3 normalized = ax / anchor_in; + vec3 flare_ratio = DivideSafe(normalized + flare, normalized, vec3(1.0)); + vec3 exponent = contrast * flare_ratio; + + vec3 ax_n = pow(ax, exponent); + vec3 anchor_n = pow(anchor_in, exponent); + vec3 response_target = ax_n / (ax_n + anchor_n); + vec3 response_baseline = ax / (ax + anchor_in); + vec3 gain = DivideSafe(response_target, response_baseline, vec3(0.0)); + + return sign(color) * ax * gain * (anchor_out / anchor_in); +} + +vec3 ApplyToneMap(vec3 _676, bool _679, float _638, float _m6, uint _m4, float _m10, vec3 _488, vec4 _489) { + vec3 untonemapped = _676; + vec3 tonemapped; + if (RENODX_TONE_MAP_TYPE == 0.f) { + vec3 _742; + if (_679) { + vec3 _719 = max(vec3(0.0), _676 * (_638 / _m6)); + vec3 _722 = _719 * _488.x; + _742 = (((((_719 * (_722 + vec3(_489.x))) + vec3(_489.y)) / ((_719 * (_722 + vec3(_488.y))) + vec3(_489.z))) - vec3(_489.w)) * ((_m4 != 0u) ? _m10 : _488.z)) * _m6; + } else { // (x * (A * x + C) + D)/(x * (A * x + B) + E) - F + vec3 _685 = max(vec3(0.0), _676 * _638); + vec3 _688 = _685 * _488.x; + _742 = clamp(((((_685 * (_688 + vec3(_489.x))) + vec3(_489.y)) / ((_685 * (_688 + vec3(_488.y))) + vec3(_489.z))) - vec3(_489.w)) * _488.z, vec3(0.0), vec3(1.0)); + } + tonemapped = _742; + } else if (RENODX_TONE_MAP_TYPE == 1.f || RENODX_TONE_MAP_TYPE == 2.f) { // (x * (A * x + C) + D)/(x * (A * x + B) + E) - F + // Hable/U2-ish form, values found at night in Saint Denis + float A = abs(_488.x); // 0.22, A + float B = abs(_488.y); // 0.3, B + float C = abs(_489.x); // 0.03, C * D? + float D = abs(_489.y); // 0.0, actually E? + float E = abs(_489.z); // 0.06 + float F = abs(_489.w); // 0.0 + float white_precompute = abs(_488.z); // 1.12 + float pivot_point = rdr2_tonemap_FindSecondDerivativeRootMax(A, B, C, D, E); + + untonemapped = max(vec3(0.0), untonemapped * _638); + if (RENODX_TONE_MAP_TYPE == 1.f) { // Enhanced + vec3 bt709_white_lms = renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(1.0)); + untonemapped = renodx_tonemap_psycho22_StockmanLMSFromBT709(untonemapped); + + float anchor_out = rdr2_tonemap_Apply(pivot_point, A, B, C, D, E, F, white_precompute); + float pivot_slope = rdr2_tonemap_Derivative(pivot_point, A, B, C, D, E, F) * white_precompute; + float contrast = 2.0 * pivot_slope * pivot_point / anchor_out - 1.0; + tonemapped = ApplyAnchoredAdaptationContrast(untonemapped / bt709_white_lms, contrast * 1.22f, vec3(pivot_point), vec3(anchor_out), 0.f) * bt709_white_lms; + + vec3 precompression_lms = tonemapped; + float precompression_yf = renodx_color_yf_from_LMS(precompression_lms); + float peak_ratio = RENODX_PEAK_WHITE_NITS / RENODX_DIFFUSE_WHITE_NITS; + vec3 peak_white_lms = renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(peak_ratio)); + vec3 compressed_lms = Neutwo(precompression_lms, peak_white_lms); + + tonemapped = renodx_tonemap_psycho23_ApplySignedOpponentRetentionAndGamutCompressionLMS( + precompression_lms, + compressed_lms, + renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(pivot_point)), + renodx_tonemap_psycho22_StockmanLMSFromBT709(vec3(anchor_out)), + peak_white_lms, + 1.0, + 1.0); + tonemapped *= DivideSafe( + precompression_yf, + renodx_color_yf_from_LMS(tonemapped), + 1.0); + tonemapped = renodx_tonemap_psycho22_BT709FromStockmanLMS(tonemapped); + } else { // Vanilla+ + vec3 base = rdr2_tonemap_Apply(untonemapped, A, B, C, D, E, F, white_precompute); + tonemapped = rdr2_tonemap_ApplyExtended(untonemapped, base, pivot_point, white_precompute, A, B, C, D, E, F); + tonemapped = mix(tonemapped, base, RENODX_TONE_MAP_BLEND_STRENGTH); + + float uncompressed_yf = renodx_color_yf_from_BT709(tonemapped); + + tonemapped = Neutwo(tonemapped, RENODX_PEAK_WHITE_NITS / RENODX_DIFFUSE_WHITE_NITS); + float compressed_yf = renodx_color_yf_from_BT709(tonemapped); + + tonemapped *= DivideSafe(uncompressed_yf, compressed_yf, 1.0); + } + } else { + vec3 _685 = max(vec3(0.0), _676 * _638); + vec3 _688 = _685 * _488.x; + tonemapped = clamp(((((_685 * (_688 + vec3(_489.x))) + vec3(_489.y)) / ((_685 * (_688 + vec3(_488.y))) + vec3(_489.z))) - vec3(_489.w)) * _488.z, vec3(0.0), vec3(1.0)); + } + + return tonemapped; +} + +vec3 EncodeLUTInput(vec3 x, float _m11, float _m12, float _m13, float _m14, bool skip_encoding) { + if (CUSTOM_LUT_ENCODING != 0.f) { // sRGB-like encoding (defaults to 2.2, controlled by the SDR gamma slider) + return EncodeRDR2Gamma(x); + } else { // vanilla (2.2 sRGB-like in SDR, none in HDR) + vec3 encoded = mix( + mix( + (pow(x, vec3(_m12)) * _m13) - vec3(_m14), + x * _m11, + lessThan(x, vec3(0.0031308))), + x, bvec3(skip_encoding)); + + return encoded; + } +} + +vec3 EncodeLUTInput(vec3 x) { + return (CUSTOM_LUT_ENCODING != 0.f) ? EncodeRDR2Gamma(x) : x; +} + +vec3 DecodeLUTInput(vec3 lut_output, vec3 lut_input, float compression_scale) { + if (CUSTOM_LUT_ENCODING != 0.f) { // Custom encoded domain + lut_output = DecodeSRGB(lut_output) / compression_scale; + if (CUSTOM_LUT_STRENGTH != 1.f) { + lut_output = mix(DecodeSRGB(lut_input), lut_output, CUSTOM_LUT_STRENGTH); + } + // if (RENODX_TONE_MAP_TYPE == 1.f) { + // lut_output = DecodeRDR2Gamma(EncodeSRGB(lut_output)); + // } + } else { + lut_output = mix(lut_input, lut_output / compression_scale, CUSTOM_LUT_STRENGTH); + } + return lut_output; +} + +vec3 DecodeLUTInput(vec3 lut_output, vec3 lut_input) { + return DecodeLUTInput(lut_output, lut_input, 1.f); +} + +float ComputeMaxChannelScale(vec3 color) { + float max_channel = max(max(abs(color.r), abs(color.g)), abs(color.b)); + float new_max = Neutwo(max_channel); + float scale = (max_channel != 0.0) ? (new_max / max_channel) : 1.0; + return scale; +} + +float ComputeMaxChannelScale(vec3 color, float peak) { + float max_channel = max(max(abs(color.r), abs(color.g)), abs(color.b)); + float new_max = Neutwo(max_channel, peak); + float scale = (max_channel != 0.0) ? (new_max / max_channel) : 1.0; + return scale; +} + +float CompressLUTInput(vec3 color, bool use_encoding, uint _m5, float _m7, float _m8, float _m9) { + float compression_scale; + if (RENODX_TONE_MAP_TYPE == 0.f) { + float maxch = max(max(color.x, max(color.y, color.z)), 10e-05); + compression_scale = (use_encoding && (!(_m5 != 0u))) ? 1.0 : (((maxch > _m7) ? ((maxch * _m8) + _m9) : maxch) / maxch); + } else if (RENODX_TONE_MAP_TYPE == 1.f || RENODX_TONE_MAP_TYPE == 2.f) { + compression_scale = ComputeMaxChannelScale(color); + } else { + compression_scale = 1.f; + } + + return compression_scale; +} + +vec3 CompressLUTInput(vec3 color, bool use_encoding, uint _m5, float _m7, float _m8, float _m9, out float compression_scale) { + bool use_custom_encoding = CUSTOM_LUT_ENCODING != 0.f; + vec3 compression_input = use_custom_encoding ? DecodeSRGB(color) : color; + + compression_scale = CompressLUTInput(compression_input, use_encoding, _m5, _m7, _m8, _m9); + compression_input *= compression_scale; + + return use_custom_encoding ? EncodeSRGB(compression_input) : compression_input; +} + +vec3 CompressLUTInputAlt(vec3 color, uint _m3, float _m7, float _m8, float _m9, out float compression_scale) { + bool use_custom_encoding = CUSTOM_LUT_ENCODING != 0.f; + vec3 compression_input = use_custom_encoding ? DecodeSRGB(color) : color; + + if (RENODX_TONE_MAP_TYPE == 0.f) { + float maxch = max(max(compression_input.x, max(compression_input.y, compression_input.z)), 10e-05); + compression_scale = (_m3 != 0u) ? (((maxch > _m7) ? ((maxch * _m8) + _m9) : maxch) / maxch) : 1.0; + } else if (RENODX_TONE_MAP_TYPE == 1.f || RENODX_TONE_MAP_TYPE == 2.f) { + compression_scale = ComputeMaxChannelScale(compression_input); + } else { + compression_scale = 1.f; + } + + compression_input *= compression_scale; + + return use_custom_encoding ? EncodeSRGB(compression_input) : compression_input; +} + +vec3 ApplyGradingAndDisplayMap(vec3 ungraded_bt709, vec2 texcoord) { + if (IS_TONEMAPPED == 0.f) { + ungraded_bt709 = GammaSafe(ungraded_bt709, false); + + vec3 ungraded_bt2020 = BT2020FromBT709(ungraded_bt709); + vec3 graded_bt2020; + if (RENODX_TONE_MAP_TYPE != 0.f && RENODX_TONE_MAP_TYPE != 3.f) { + const UserGradingConfig cg_config = { + 1.f, // float exposure; + RENODX_TONE_MAP_HIGHLIGHTS, // float highlights; + 1.f, // float contrast_highlights; + RENODX_TONE_MAP_SHADOWS, // float shadows; + 1.f, // float contrast_shadows; + RENODX_TONE_MAP_CONTRAST, // float contrast; + 0.10f * pow(RENODX_TONE_MAP_FLARE, 10.f), // float flare; + RENODX_TONE_MAP_GAMMA, // float gamma; + RENODX_TONE_MAP_SATURATION, // float saturation; + RENODX_TONE_MAP_DECHROMA, // float dechroma; + -1.f * (RENODX_TONE_MAP_HIGHLIGHT_SATURATION - 1.f), // float highlight_saturation; + 0.f, // float hue_emulation; + 0.f // float purity_emulation; + }; + + float yf = renodx_color_yf_from_BT2020(ungraded_bt2020); + graded_bt2020 = ApplyLuminanceGrading(ungraded_bt2020, yf, cg_config, 0.15f); + graded_bt2020 = ApplyHueAndPurityGrading(graded_bt2020, ungraded_bt2020, yf, cg_config); + graded_bt2020 = max(vec3(0.0), graded_bt2020); + + if (RENODX_TONE_MAP_TYPE == 1.f || RENODX_TONE_MAP_TYPE == 2.f) { + float peak_ratio = RENODX_PEAK_WHITE_NITS / RENODX_DIFFUSE_WHITE_NITS; + graded_bt2020 *= ComputeMaxChannelScale(graded_bt2020, peak_ratio); + } + + } else { + graded_bt2020 = ungraded_bt2020; + } + + if (CUSTOM_GRAIN_STRENGTH > 0.f) { + graded_bt2020 = ApplyFilmGrainBT2020(graded_bt2020, texcoord, CUSTOM_RANDOM, CUSTOM_GRAIN_STRENGTH * 0.03f); + } + + vec3 graded_bt709 = BT709FromBT2020(graded_bt2020); + + if (RENODX_TONE_MAP_TYPE != 0.f) { + graded_bt709 *= vec3(RENODX_DIFFUSE_WHITE_NITS / RENODX_GRAPHICS_WHITE_NITS); + } + + graded_bt709 = GammaSafe(graded_bt709, true); + + return graded_bt709; + } else { + return ungraded_bt709; + } +} diff --git a/src/games/rdr2vk/tonemap/tonemap_0x0C1275BE.frag.glsl b/src/games/rdr2vk/tonemap/tonemap_0x0C1275BE.frag.glsl new file mode 100644 index 000000000..a54890fb5 --- /dev/null +++ b/src/games/rdr2vk/tonemap/tonemap_0x0C1275BE.frag.glsl @@ -0,0 +1,921 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#if defined(GL_EXT_control_flow_attributes) +#extension GL_EXT_control_flow_attributes : require +#define SPIRV_CROSS_FLATTEN [[flatten]] +#define SPIRV_CROSS_BRANCH [[dont_flatten]] +#define SPIRV_CROSS_UNROLL [[unroll]] +#define SPIRV_CROSS_LOOP [[dont_unroll]] +#else +#define SPIRV_CROSS_FLATTEN +#define SPIRV_CROSS_BRANCH +#define SPIRV_CROSS_UNROLL +#define SPIRV_CROSS_LOOP +#endif +#extension GL_EXT_samplerless_texture_functions : require + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _15 _m5; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; +}; + +struct _19 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _20 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _16 { + _17 _m0[2]; + _18 _m1; + _19 _m2; + _20 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; +}; + +struct _24 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _21 { + _22 _m0; + _23 _m1; + _24 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _25 { + vec4 _m0[5]; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _27 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _28 { + int _m0; + int _m1; +}; + +struct _29 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _12 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _13 _m41; + _14 _m42; + _16 _m43; + _21 _m44; + _25 _m45; + _26 _m46; + _27 _m47[5]; + vec4 _m48; + _28 _m49; + vec4 _m50; + _29 _m51; +}; + +struct _33 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _34 { + float _m0; +}; + +struct _36 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _35 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _36 _m3; + vec2 _m4; +}; + +struct _38 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _39 { + int _m0; +}; + +struct _40 { + _39 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _37 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _38 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _39 _m16; + _39 _m17; + _40 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _42 { + vec3 _m0; + float _m1; +}; + +struct _43 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _44 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _45 { + float _m0; + _39 _m1; +}; + +struct _46 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _47 { + _39 _m0; + float _m1; + float _m2; +}; + +struct _49 { + int _m0; +}; + +struct _48 { + _39 _m0; + _49 _m1; + _49 _m2; +}; + +struct _50 { + _39 _m0; +}; + +struct _41 { + _42 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _43 _m4; + _44 _m5; + _45 _m6; + _46 _m7; + _47 _m8; + _48 _m9; + _50 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _51 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _54 { + vec4 _m0; + vec4 _m1; +}; + +struct _56 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _56 _m19[2]; +}; + +struct _57 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _58 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _59 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _32 { + float _m0[32]; + float _m1[32]; + _33 _m2; + _33 _m3; + _34 _m4; + _35 _m5; + _37 _m6; + _41 _m7; + _51 _m8; + _52 _m9; + float _m10; + vec2 _m11; + _53 _m12; + _54 _m13; + float _m14; + float _m15; + vec4 _m16; + _55 _m17; + _57 _m18; + _58 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _59 _m30; + int _m31; +}; + +struct _90 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _91 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _89 { + _90 _m0; + _91 _m1[11]; +}; + +float _267; + +layout(set = 0, binding = 98, scalar) readonly buffer _11_30 { + _12 _m0[]; +} +_30; + +layout(set = 0, binding = 99, scalar) readonly buffer _31_60 { + _32 _m0[]; +} +_60; + +layout(set = 0, binding = 20, std140) uniform _66_67 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_67; + +layout(set = 1, binding = 16, std140) uniform _68_69 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_69; + +layout(set = 0, binding = 214, std430) readonly buffer _88_92 { + _89 _m0[]; +} +_92; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 33) uniform sampler _9; +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 0, binding = 121) uniform texture2DArray _63; +layout(set = 0, binding = 140) uniform texture2D _64; +layout(set = 1, binding = 173) uniform texture2D _70; +layout(set = 1, binding = 174) uniform texture2D _71; +layout(set = 1, binding = 177) uniform texture2D _72; +layout(set = 1, binding = 185) uniform texture1D _74; +layout(set = 1, binding = 40) uniform sampler _75; +layout(set = 1, binding = 186) uniform texture2D _76; +layout(set = 1, binding = 190) uniform texture2D _77; +layout(set = 1, binding = 191) uniform texture2D _78; +layout(set = 1, binding = 196) uniform texture2D _79; +layout(set = 1, binding = 197) uniform texture2D _80; +layout(set = 1, binding = 202) uniform texture2D _81; +layout(set = 1, binding = 203) uniform texture2D _82; +layout(set = 1, binding = 205) uniform texture2D _83; +layout(set = 1, binding = 207) uniform texture2D _84; +layout(set = 1, binding = 209) uniform texture2D _85; +layout(set = 1, binding = 210) uniform texture2D _86; +layout(set = 1, binding = 212) uniform samplerBuffer _87; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + float _282 = 1.0 + _69._m0.w; + float _285 = _69._m0.z / (_282 - textureLod(sampler2D(_71, _8), _4.xy, 0.0).x); + vec4 _289 = texture(sampler2D(_76, _75), _4.xy); + vec4 _314 = textureLod(sampler2D(_86, _8), _4.xy * _69._m80.xy, 0.0) * 1.0; + float _315 = _314.z; + vec4 _472; + SPIRV_CROSS_BRANCH + if ((_315 >= 1.0) && (_314.w < 2.0)) { + float _333 = min(length(textureLod(sampler2D(_85, _8), _4.xy, 0.0).xy * _69._m20.x), _69._m20.z); + float _336 = min(_315, 2.0); + vec2 _337 = (_314.xy / vec2(_315)) * _336; + int _340 = int(min(2.0, 1.0 + _336)); + vec2 _344 = _337 * _69._m63.xy; + float _346 = float(_340) - 0.5; + float _347 = _346 / _336; + vec2 _349 = (-_337) * _69._m63.xy; + vec2 _352 = vec2(uvec2(gl_FragCoord.xy) & uvec2(1u)); + float _366 = ((((_352.x * 2.0) - 1.0) * ((_352.y * 2.0) - 1.0)) * _69._m20.w) * clamp((_336 - 2.0) * 0.5, 0.0, 1.0); + float _367 = 0.5 + _366; + float _368 = 0.5 - _366; + vec4 _370; + _370 = vec4(0.0); + for (int _373 = 0; _373 < _340;) { + float _377 = float(_373); + float _378 = _377 + _367; + vec2 _381 = _4.xy + (_344 * (_378 / _346)); + float _387 = min(length(textureLod(sampler2D(_85, _8), _381, 0.0).xy * _69._m20.x), _69._m20.z); + float _393 = _69._m0.z / (_282 - textureLod(sampler2D(_70, _8), _381, 0.0).x); + float _398 = _333 * _347; + float _415 = _377 + _368; + vec2 _418 = _4.xy + (_349 * (_415 / _346)); + float _424 = min(length(textureLod(sampler2D(_85, _8), _418, 0.0).xy * _69._m20.x), _69._m20.z); + float _429 = _69._m0.z / (_282 - textureLod(sampler2D(_70, _8), _418, 0.0).x); + float _446 = (1.0 - clamp((1.0 - _424) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_429 - _285)), vec2(0.0), vec2(1.0)), clamp(vec2(_398, _424 * _347) - vec2(max(_415 - 1.0, 0.0)), vec2(0.0), vec2(1.0))); + bvec2 _452 = bvec2(_393 > _429, _424 > _387); + float _454 = all(_452) ? _446 : ((1.0 - clamp((1.0 - _387) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_393 - _285)), vec2(0.0), vec2(1.0)), clamp(vec2(_398, _387 * _347) - vec2(max(_378 - 1.0, 0.0)), vec2(0.0), vec2(1.0)))); + float _456 = any(_452) ? _446 : _454; + _370 = (_370 + vec4(textureLod(sampler2D(_77, _9), _418, 0.0).xyz * _456, _456)) + vec4(textureLod(sampler2D(_77, _9), _381, 0.0).xyz * _454, _454); + _373++; + continue; + } + _472 = _370 / vec4(float(2 * _340)); + } else { + _472 = vec4(0.0); + } + vec4 _480 = textureLod(sampler2D(_78, _9), _4.xy, 0.0); + vec3 _485 = _480.xyz + ((_472.xyz + (vec4(vec4(_289.xyz, 0.0).xyz * _30._m0[0u]._m1.w, _267).xyz * (1.0 - _472.w))) * (1.0 - _480.w)); + vec4 _488 = texelFetch(_87, int(0u)); + vec4 _489 = texelFetch(_87, int(1u)); + bool _519; + vec3 _520; + if (floatBitsToInt(_69._m61) != 0) { + vec4 _505 = texture(sampler2D(_83, _75), _4.xy); + float _506 = _505.w; + bool _508 = (_506 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _517; + if (_508) { + _517 = _505.xyz; + } else { + _517 = _505.xyz + (_485 * (1.0 - _506)); + } + _519 = _508 ? true : false; + _520 = _517; + } else { + _519 = false; + _520 = _485; + } + vec3 _524 = min(_520 * texelFetch(_64, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _525 = !_519; + float _638; + vec3 _639; + if (_525) { + float _584; + if (floatBitsToInt(_69._m70.x) != 0) { + float _547 = clamp(dot(texture(sampler2D(_72, _10), _4.xy).xyz * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _69._m72.z, _69._m72.w); + float _570 = clamp(((((_69._m70.y * log(_547 + _69._m72.x)) + _69._m70.z) - 10.0) + (_69._m72.y * _547)) + _69._m65.w, _69._m66.x, _69._m66.y); + _584 = pow(2.0, mix(_5, clamp(_570 + ((abs(_570) * _69._m66.z) * float(int(sign(_570)))), _69._m66.x, _69._m66.y), clamp(_69._m70.x, 0.0, 1.0))); + } else { + _584 = _4.z; + } + vec3 _637; + if (floatBitsToInt(_69._m51.w) != 0) { + vec2 _613 = ((_4.xy - _69._m50.xy) * mat2(vec2(_69._m52.x, _69._m52.y), vec2(_69._m52.z, _69._m52.w))) * _69._m50.zw; + float _617 = CUSTOM_VIGNETTE * max((dot(_613, _613) - _69._m53.x) * _69._m53.w, 0.0); + bool _618 = _617 < 1.0; + _637 = mix(_524, (_524 * _69._m51.xyz) * _69._m51.w, vec3(_618 ? (_618 ? (1.0 - pow(2.0, (-10.0) * _617)) : 1.0) : (0.9980499744415283203125 + (((_617 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_617 - 2.0)) : 0.0)))); + } else { + _637 = _524; + } + _638 = _584; + _639 = _637; + } else { + _638 = _4.z; + _639 = _524; + } + vec3 _676 = _639 * mix(mix(_69._m54.xyz, _69._m56.xyz, vec3(clamp(clamp(_4.y * _69._m57.y, 0.0, 1.0) + _69._m54.w, 0.0, 1.0))), mix(_69._m56.xyz, _69._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _69._m56.w, 0.0, 1.0) * _69._m57.x, 0.0, 1.0) - _69._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _679 = _67._m3 != 0u; +#if 1 + vec3 _742 = ApplyToneMap(_676, _679, _638, _67._m6, _67._m4, _67._m10, _488.rgb, _489); +#else + vec3 _742; + if (_679) { + vec3 _719 = max(vec3(0.0), _676 * (_638 / _67._m6)); + vec3 _722 = _719 * _488.x; + _742 = (((((_719 * (_722 + vec3(_489.x))) + vec3(_489.y)) / ((_719 * (_722 + vec3(_488.y))) + vec3(_489.z))) - vec3(_489.w)) * ((_67._m4 != 0u) ? _67._m10 : _488.z)) * _67._m6; + } else { + vec3 _685 = max(vec3(0.0), _676 * _638); + vec3 _688 = _685 * _488.x; + _742 = clamp(((((_685 * (_688 + vec3(_489.x))) + vec3(_489.y)) / ((_685 * (_688 + vec3(_488.y))) + vec3(_489.z))) - vec3(_489.w)) * _488.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _790; + if (_525) { + vec3 _789; + if (floatBitsToInt(_69._m47.w) != 0) { + vec2 _775 = ((_4.xy - _69._m46.xy) * mat2(vec2(_69._m48.x, _69._m48.y), vec2(_69._m48.z, _69._m48.w))) * _69._m46.zw; + _789 = mix(_742, _69._m47.xyz, vec3(_69._m47.w * texture(sampler1D(_74, _10), min(1.0, max((dot(_775, _775) - _69._m49.x) * _69._m49.w, 0.0))).w)); + } else { + _789 = _742; + } + _790 = _789; + } else { + _790 = _742; + } + bool _811 = _679 && (!(_67._m2 != 0u)); + +#if 1 + vec3 _813 = EncodeLUTInput(_790, _67._m11, _67._m12, _67._m13, _67._m14, _811); +#else + vec3 _813 = mix(mix((pow(_790, vec3(_67._m12)) * _67._m13) - vec3(_67._m14), _790 * _67._m11, lessThan(_790, vec3(0.003130800090730190277099609375))), _790, bvec3(_811)); +#endif + + vec3 _815 = max(_813 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _816 = _815.y; + vec3 _841 = mix(_813, clamp((_69._m81.xyz * (_816 * ((1.33000004291534423828125 * (1.0 + ((_816 + _815.z) / _815.x))) - 1.67999994754791259765625))) * _69._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + dot(_485 * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)))) * _69._m82.x) + _69._m82.y, 0.0, 1.0))); + vec3 _871; + if (floatBitsToInt(_69._m84.w) != 0) { + _871 = mix(_841, texture(sampler2D(_84, _10), ((((_4.xy - vec2(0.5)) * _69._m84.z) / mix(_69._m85.wx, _69._m85.zy, _4.yx)) - _69._m84.xy) + vec2(0.5)).xyz, vec3(_69._m84.w)); + } else { + _871 = _841; + } + float _896 = 1.0; + vec3 _1029; + if (_525) { +#if 1 + vec3 _897 = CompressLUTInput(_871, _811, _67._m5, _67._m7, _67._m8, _67._m9, _896); +#else + float _890 = max(max(_871.x, max(_871.y, _871.z)), 9.9999997473787516355514526367188e-05); + _896 = (_811 && (!(_67._m5 != 0u))) ? 1.0 : (((_890 > _67._m7) ? ((_890 * _67._m8) + _67._m9) : _890) / _890); + vec3 _897 = _871 * _896; +#endif + float _900 = _897.z; + float _902 = floor(_900 * 14.99989986419677734375); + float _908 = (_902 * 0.0625) + (_897.x * 0.05859375); + float _910 = _897.y * 0.9375; + vec4 _914 = texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_908, _910)); + vec4 _920 = texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_908 + 0.0625, _910)); + vec3 _923 = mix(_914.xyz, _920.xyz, vec3((_900 * 15.0) - _902)); + vec3 _1026; + if (_92._m0[0u]._m0._m0 > 0) { + float _957 = _923.z; + float _959 = floor(_957 * 14.99989986419677734375); + float _965 = (_959 * 0.0625) + (_923.x * 0.05859375); + float _967 = _923.y * 0.9375; + vec3 _982 = mix(_923, mix(texture(sampler2D(_79, _10), vec2(0.001953125, 0.03125) + vec2(_965, _967)).xyz, texture(sampler2D(_79, _10), vec2(0.001953125, 0.03125) + vec2(_965 + 0.0625, _967)).xyz, vec3((_957 * 15.0) - _959)), vec3(clamp(((_285 < _92._m0[0u]._m1[0]._m2) ? clamp((_285 - _92._m0[0u]._m1[0]._m0) * _92._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_285 - _92._m0[0u]._m1[0]._m2) * _92._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _92._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _994 = _982.z; + float _996 = floor(_994 * 14.99989986419677734375); + float _1002 = (_996 * 0.0625) + (_982.x * 0.05859375); + float _1004 = _982.y * 0.9375; + _1026 = mix(_982, mix(_982, mix(texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1002, _1004)).xyz, texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1002 + 0.0625, _1004)).xyz, vec3((_994 * 15.0) - _996)), vec3(clamp(((_285 < _92._m0[0u]._m1[1]._m2) ? clamp((_285 - _92._m0[0u]._m1[1]._m0) * _92._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_285 - _92._m0[0u]._m1[1]._m2) * _92._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _92._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_82, _10), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _1026 = _923; + } + _1029 = _1026; + } else { + _1029 = _871; + } + +#if 1 + _1029 = DecodeLUTInput(_1029, _871, _896); +#endif + vec4 _1034 = vec4(_1029, dot(_1029, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1035 = _1034.xyz; + ivec4 _1077 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_60._m0[0u]._m22) & 31), 0u)); + vec3 _1085 = (vec3(texelFetch(_63, _1077.xyz, _1077.w).x) * 2.0) - vec3(1.0); + vec3 _1096; + if (_679) { + _1096 = vec3(ivec3(sign(_1085))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1085))); + } else { + _1096 = _1085; + } + vec3 _1098 = _1035 + CUSTOM_DITHERING * (_1096 * mix(_69._m39.xyz, _69._m40.xyz, pow(clamp((mix(vec3(max(_1029.x, max(_1029.y, _1029.z))), _1035, bvec3(floatBitsToInt(_69._m41.w) != 0)) - _69._m42.xyz) * _69._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_69._m42.w)))); + vec4 _1099 = vec4(_1098.x, _1098.y, _1098.z, _1034.w); + vec4 _1104; + if (!_679) { + _1104 = clamp(_1099, vec4(0.0), vec4(1.0)); + } else { + _1104 = _1099; + } + _6 = _1104; + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + diff --git a/src/games/rdr2vk/tonemap/tonemap_0x4205843B.frag.glsl b/src/games/rdr2vk/tonemap/tonemap_0x4205843B.frag.glsl new file mode 100644 index 000000000..8eef95155 --- /dev/null +++ b/src/games/rdr2vk/tonemap/tonemap_0x4205843B.frag.glsl @@ -0,0 +1,968 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#if defined(GL_EXT_control_flow_attributes) +#extension GL_EXT_control_flow_attributes : require +#define SPIRV_CROSS_FLATTEN [[flatten]] +#define SPIRV_CROSS_BRANCH [[dont_flatten]] +#define SPIRV_CROSS_UNROLL [[unroll]] +#define SPIRV_CROSS_LOOP [[dont_unroll]] +#else +#define SPIRV_CROSS_FLATTEN +#define SPIRV_CROSS_BRANCH +#define SPIRV_CROSS_UNROLL +#define SPIRV_CROSS_LOOP +#endif +#extension GL_EXT_samplerless_texture_functions : require + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _15 _m5; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; +}; + +struct _19 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _20 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _16 { + _17 _m0[2]; + _18 _m1; + _19 _m2; + _20 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; +}; + +struct _24 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _21 { + _22 _m0; + _23 _m1; + _24 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _25 { + vec4 _m0[5]; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _27 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _28 { + int _m0; + int _m1; +}; + +struct _29 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _12 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _13 _m41; + _14 _m42; + _16 _m43; + _21 _m44; + _25 _m45; + _26 _m46; + _27 _m47[5]; + vec4 _m48; + _28 _m49; + vec4 _m50; + _29 _m51; +}; + +struct _33 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _34 { + float _m0; +}; + +struct _36 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _35 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _36 _m3; + vec2 _m4; +}; + +struct _38 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _39 { + int _m0; +}; + +struct _40 { + _39 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _37 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _38 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _39 _m16; + _39 _m17; + _40 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _42 { + vec3 _m0; + float _m1; +}; + +struct _43 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _44 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _45 { + float _m0; + _39 _m1; +}; + +struct _46 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _47 { + _39 _m0; + float _m1; + float _m2; +}; + +struct _49 { + int _m0; +}; + +struct _48 { + _39 _m0; + _49 _m1; + _49 _m2; +}; + +struct _50 { + _39 _m0; +}; + +struct _41 { + _42 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _43 _m4; + _44 _m5; + _45 _m6; + _46 _m7; + _47 _m8; + _48 _m9; + _50 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _51 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _54 { + vec4 _m0; + vec4 _m1; +}; + +struct _56 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _56 _m19[2]; +}; + +struct _57 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _58 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _59 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _32 { + float _m0[32]; + float _m1[32]; + _33 _m2; + _33 _m3; + _34 _m4; + _35 _m5; + _37 _m6; + _41 _m7; + _51 _m8; + _52 _m9; + float _m10; + vec2 _m11; + _53 _m12; + _54 _m13; + float _m14; + float _m15; + vec4 _m16; + _55 _m17; + _57 _m18; + _58 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _59 _m30; + int _m31; +}; + +struct _91 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _92 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _90 { + _91 _m0; + _92 _m1[11]; +}; + +float _289; + +layout(set = 0, binding = 98, scalar) readonly buffer _11_30 { + _12 _m0[]; +} +_30; + +layout(set = 0, binding = 99, scalar) readonly buffer _31_60 { + _32 _m0[]; +} +_60; + +layout(set = 0, binding = 20, std140) uniform _66_67 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_67; + +layout(set = 1, binding = 16, std140) uniform _68_69 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_69; + +layout(set = 0, binding = 214, std430) readonly buffer _89_93 { + _90 _m0[]; +} +_93; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 33) uniform sampler _9; +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 0, binding = 121) uniform texture2DArray _63; +layout(set = 0, binding = 140) uniform texture2D _64; +layout(set = 1, binding = 173) uniform texture2D _70; +layout(set = 1, binding = 174) uniform texture2D _71; +layout(set = 1, binding = 177) uniform texture2D _72; +layout(set = 1, binding = 185) uniform texture1D _74; +layout(set = 1, binding = 40) uniform sampler _75; +layout(set = 1, binding = 186) uniform texture2D _76; +layout(set = 1, binding = 189) uniform texture2D _77; +layout(set = 1, binding = 190) uniform texture2D _78; +layout(set = 1, binding = 191) uniform texture2D _79; +layout(set = 1, binding = 196) uniform texture2D _80; +layout(set = 1, binding = 197) uniform texture2D _81; +layout(set = 1, binding = 202) uniform texture2D _82; +layout(set = 1, binding = 203) uniform texture2D _83; +layout(set = 1, binding = 205) uniform texture2D _84; +layout(set = 1, binding = 207) uniform texture2D _85; +layout(set = 1, binding = 209) uniform texture2D _86; +layout(set = 1, binding = 210) uniform texture2D _87; +layout(set = 1, binding = 212) uniform samplerBuffer _88; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + float _304 = 1.0 + _69._m0.w; + float _307 = _69._m0.z / (_304 - textureLod(sampler2D(_71, _8), _4.xy, 0.0).x); + vec4 _311 = texture(sampler2D(_76, _75), _4.xy); + vec4 _336 = textureLod(sampler2D(_87, _8), _4.xy * _69._m80.xy, 0.0) * 1.0; + float _337 = _336.z; + vec4 _494; + SPIRV_CROSS_BRANCH + if ((_337 >= 1.0) && (_336.w < 2.0)) { + float _355 = min(length(textureLod(sampler2D(_86, _8), _4.xy, 0.0).xy * _69._m20.x), _69._m20.z); + float _358 = min(_337, 2.0); + vec2 _359 = (_336.xy / vec2(_337)) * _358; + int _362 = int(min(2.0, 1.0 + _358)); + vec2 _366 = _359 * _69._m63.xy; + float _368 = float(_362) - 0.5; + float _369 = _368 / _358; + vec2 _371 = (-_359) * _69._m63.xy; + vec2 _374 = vec2(uvec2(gl_FragCoord.xy) & uvec2(1u)); + float _388 = ((((_374.x * 2.0) - 1.0) * ((_374.y * 2.0) - 1.0)) * _69._m20.w) * clamp((_358 - 2.0) * 0.5, 0.0, 1.0); + float _389 = 0.5 + _388; + float _390 = 0.5 - _388; + vec4 _392; + _392 = vec4(0.0); + for (int _395 = 0; _395 < _362;) { + float _399 = float(_395); + float _400 = _399 + _389; + vec2 _403 = _4.xy + (_366 * (_400 / _368)); + float _409 = min(length(textureLod(sampler2D(_86, _8), _403, 0.0).xy * _69._m20.x), _69._m20.z); + float _415 = _69._m0.z / (_304 - textureLod(sampler2D(_70, _8), _403, 0.0).x); + float _420 = _355 * _369; + float _437 = _399 + _390; + vec2 _440 = _4.xy + (_371 * (_437 / _368)); + float _446 = min(length(textureLod(sampler2D(_86, _8), _440, 0.0).xy * _69._m20.x), _69._m20.z); + float _451 = _69._m0.z / (_304 - textureLod(sampler2D(_70, _8), _440, 0.0).x); + float _468 = (1.0 - clamp((1.0 - _446) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_451 - _307)), vec2(0.0), vec2(1.0)), clamp(vec2(_420, _446 * _369) - vec2(max(_437 - 1.0, 0.0)), vec2(0.0), vec2(1.0))); + bvec2 _474 = bvec2(_415 > _451, _446 > _409); + float _476 = all(_474) ? _468 : ((1.0 - clamp((1.0 - _409) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_415 - _307)), vec2(0.0), vec2(1.0)), clamp(vec2(_420, _409 * _369) - vec2(max(_400 - 1.0, 0.0)), vec2(0.0), vec2(1.0)))); + float _478 = any(_474) ? _468 : _476; + _392 = (_392 + vec4(textureLod(sampler2D(_78, _9), _440, 0.0).xyz * _478, _478)) + vec4(textureLod(sampler2D(_78, _9), _403, 0.0).xyz * _476, _476); + _395++; + continue; + } + _494 = _392 / vec4(float(2 * _362)); + } else { + _494 = vec4(0.0); + } + vec4 _502 = textureLod(sampler2D(_79, _9), _4.xy, 0.0); + vec3 _507 = _502.xyz + ((_494.xyz + (vec4(vec4(_311.xyz, 0.0).xyz * _30._m0[0u]._m1.w, _289).xyz * (1.0 - _494.w))) * (1.0 - _502.w)); + vec4 _510 = texelFetch(_88, int(0u)); + vec4 _511 = texelFetch(_88, int(1u)); + float _516 = dot(_507 * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)); + bool _541; + vec3 _542; + if (floatBitsToInt(_69._m61) != 0) { + vec4 _527 = texture(sampler2D(_84, _75), _4.xy); + float _528 = _527.w; + bool _530 = (_528 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _539; + if (_530) { + _539 = _527.xyz; + } else { + _539 = _527.xyz + (_507 * (1.0 - _528)); + } + _541 = _530 ? true : false; + _542 = _539; + } else { + _541 = false; + _542 = _507; + } + vec3 _546 = min(_542 * texelFetch(_64, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _547 = !_541; + float _683; + vec3 _684; + if (_547) { + float _606; + if (floatBitsToInt(_69._m70.x) != 0) { + float _569 = clamp(dot(texture(sampler2D(_72, _10), _4.xy).xyz * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _69._m72.z, _69._m72.w); + float _592 = clamp(((((_69._m70.y * log(_569 + _69._m72.x)) + _69._m70.z) - 10.0) + (_69._m72.y * _569)) + _69._m65.w, _69._m66.x, _69._m66.y); + _606 = pow(2.0, mix(_5, clamp(_592 + ((abs(_592) * _69._m66.z) * float(int(sign(_592)))), _69._m66.x, _69._m66.y), clamp(_69._m70.x, 0.0, 1.0))); + } else { + _606 = _4.z; + } + vec4 _619 = texture(sampler2D(_77, _10), fract(((_4.xy * vec2(1.60000002384185791015625, 0.89999997615814208984375)) * _69._m16.w) + _69._m16.xy)); + vec3 _629 = max(_546 * vec3(0.5), _546 + vec3((_516 * (_619.w - 0.5)) * _69._m16.z)); + vec3 _682; + if (floatBitsToInt(_69._m51.w) != 0) { + vec2 _658 = ((_4.xy - _69._m50.xy) * mat2(vec2(_69._m52.x, _69._m52.y), vec2(_69._m52.z, _69._m52.w))) * _69._m50.zw; + float _662 = CUSTOM_VIGNETTE * max((dot(_658, _658) - _69._m53.x) * _69._m53.w, 0.0); + bool _663 = _662 < 1.0; + _682 = mix(_629, (_629 * _69._m51.xyz) * _69._m51.w, vec3(_663 ? (_663 ? (1.0 - pow(2.0, (-10.0) * _662)) : 1.0) : (0.9980499744415283203125 + (((_662 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_662 - 2.0)) : 0.0)))); + } else { + _682 = _629; + } + _683 = _606; + _684 = _682; + } else { + _683 = _4.z; + _684 = _546; + } + vec3 _721 = _684 * mix(mix(_69._m54.xyz, _69._m56.xyz, vec3(clamp(clamp(_4.y * _69._m57.y, 0.0, 1.0) + _69._m54.w, 0.0, 1.0))), mix(_69._m56.xyz, _69._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _69._m56.w, 0.0, 1.0) * _69._m57.x, 0.0, 1.0) - _69._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _724 = _67._m3 != 0u; +#if 1 + vec3 _787 = ApplyToneMap(_721, _724, _683, _67._m6, _67._m4, _67._m10, _510.rgb, _511); +#else + vec3 _787; + if (_724) { + vec3 _764 = max(vec3(0.0), _721 * (_683 / _67._m6)); + vec3 _767 = _764 * _510.x; + _787 = (((((_764 * (_767 + vec3(_511.x))) + vec3(_511.y)) / ((_764 * (_767 + vec3(_510.y))) + vec3(_511.z))) - vec3(_511.w)) * ((_67._m4 != 0u) ? _67._m10 : _510.z)) * _67._m6; + } else { + vec3 _730 = max(vec3(0.0), _721 * _683); + vec3 _733 = _730 * _510.x; + _787 = clamp(((((_730 * (_733 + vec3(_511.x))) + vec3(_511.y)) / ((_730 * (_733 + vec3(_510.y))) + vec3(_511.z))) - vec3(_511.w)) * _510.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _835; + if (_547) { + vec3 _834; + if (floatBitsToInt(_69._m47.w) != 0) { + vec2 _820 = ((_4.xy - _69._m46.xy) * mat2(vec2(_69._m48.x, _69._m48.y), vec2(_69._m48.z, _69._m48.w))) * _69._m46.zw; + _834 = mix(_787, _69._m47.xyz, vec3(_69._m47.w * texture(sampler1D(_74, _10), min(1.0, max((dot(_820, _820) - _69._m49.x) * _69._m49.w, 0.0))).w)); + } else { + _834 = _787; + } + _835 = _834; + } else { + _835 = _787; + } + bool _856 = _724 && (!(_67._m2 != 0u)); + +#if 1 + vec3 _858 = EncodeLUTInput(_835, _67._m11, _67._m12, _67._m13, _67._m14, _856); +#else + vec3 _858 = mix(mix((pow(_835, vec3(_67._m12)) * _67._m13) - vec3(_67._m14), _835 * _67._m11, lessThan(_835, vec3(0.003130800090730190277099609375))), _835, bvec3(_856)); +#endif + + vec3 _1014; + if (_547 && (floatBitsToInt(_69._m19.x) != 0)) { + vec2 _870 = _4.xy * _69._m17.w; + float _936 = (((((((fract(sin(dot(_870 + vec2(0.070000000298023223876953125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875) + fract(sin(dot(_870 + vec2(0.10999999940395355224609375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_870 + vec2(0.12999999523162841796875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_870 + vec2(0.17000000178813934326171875 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_870 + vec2(0.189999997615814208984375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_870 + vec2(0.23000000417232513427734375 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_870 + vec2(0.2899999916553497314453125 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) + fract(sin(dot(_870 + vec2(0.310000002384185791015625 * _69._m17.x), vec2(12.98980045318603515625, 78.233001708984375))) * 43758.546875)) * 0.125; + float _938 = clamp(_936 + _69._m17.z, 0.0, 1.0); + vec3 _1013; + do { + if (!(floatBitsToInt(_69._m18.w) != 0)) { + _1013 = vec3(_938); + break; + } + float _961; + if (floatBitsToInt(_69._m18.y) != 0) { + float _956 = dot(_858, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)); + _961 = mix(_938, _938 * 0.5, (_956 * _956) * _956); + } else { + _961 = _938; + } + vec3 _1012; + if (floatBitsToInt(_69._m19.z) != 0) { + vec3 _994 = vec3(_961); + vec3 _996 = _994 * 2.0; + _1012 = mix(_858, mix(((_858 * 2.0) * (vec3(1.0) - _994)) + (sqrt(_858) * (_996 - vec3(1.0))), (_996 * _858) + ((_858 * _858) * (vec3(1.0) - _996)), lessThan(_994, vec3(0.5))), vec3(_69._m18.x)); + } else { + vec3 _993; + if (floatBitsToInt(_69._m19.w) != 0) { + vec3 _981 = vec3(_961); + _993 = mix(_858, mix(vec3(1.0) - (((vec3(1.0) - _981) * 2.0) * (vec3(1.0) - _858)), (_981 * 2.0) * _858, lessThan(_858, vec3(0.5))), vec3(_69._m18.x)); + } else { + _993 = clamp(max(_858 * 0.02500000037252902984619140625, _858 + vec3((_961 - 0.5) * _69._m18.x)), vec3(0.0), vec3(1.0)); + } + _1012 = _993; + } + _1013 = _1012; + break; + } while (false); + _1014 = _1013; + } else { + _1014 = _858; + } + vec3 _1016 = max(_1014 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _1017 = _1016.y; + vec3 _1042 = mix(_1014, clamp((_69._m81.xyz * (_1017 * ((1.33000004291534423828125 * (1.0 + ((_1017 + _1016.z) / _1016.x))) - 1.67999994754791259765625))) * _69._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + _516)) * _69._m82.x) + _69._m82.y, 0.0, 1.0))); + vec3 _1072; + if (floatBitsToInt(_69._m84.w) != 0) { + _1072 = mix(_1042, texture(sampler2D(_85, _10), ((((_4.xy - vec2(0.5)) * _69._m84.z) / mix(_69._m85.wx, _69._m85.zy, _4.yx)) - _69._m84.xy) + vec2(0.5)).xyz, vec3(_69._m84.w)); + } else { + _1072 = _1042; + } + float _1097 = 1.0; + vec3 _1230; + if (_547) { +#if 1 + vec3 _1098 = CompressLUTInput(_1072, _856, _67._m5, _67._m7, _67._m8, _67._m9, _1097); +#else + float _1091 = max(max(_1072.x, max(_1072.y, _1072.z)), 9.9999997473787516355514526367188e-05); + _1097 = (_856 && (!(_67._m5 != 0u))) ? 1.0 : (((_1091 > _67._m7) ? ((_1091 * _67._m8) + _67._m9) : _1091) / _1091); + vec3 _1098 = _1072 * _1097; +#endif + float _1101 = _1098.z; + float _1103 = floor(_1101 * 14.99989986419677734375); + float _1109 = (_1103 * 0.0625) + (_1098.x * 0.05859375); + float _1111 = _1098.y * 0.9375; + vec4 _1115 = texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1109, _1111)); + vec4 _1121 = texture(sampler2D(_82, _10), vec2(0.001953125, 0.03125) + vec2(_1109 + 0.0625, _1111)); + vec3 _1124 = mix(_1115.xyz, _1121.xyz, vec3((_1101 * 15.0) - _1103)); + vec3 _1227; + if (_93._m0[0u]._m0._m0 > 0) { + float _1158 = _1124.z; + float _1160 = floor(_1158 * 14.99989986419677734375); + float _1166 = (_1160 * 0.0625) + (_1124.x * 0.05859375); + float _1168 = _1124.y * 0.9375; + vec3 _1183 = mix(_1124, mix(texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1166, _1168)).xyz, texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1166 + 0.0625, _1168)).xyz, vec3((_1158 * 15.0) - _1160)), vec3(clamp(((_307 < _93._m0[0u]._m1[0]._m2) ? clamp((_307 - _93._m0[0u]._m1[0]._m0) * _93._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_307 - _93._m0[0u]._m1[0]._m2) * _93._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _93._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _1195 = _1183.z; + float _1197 = floor(_1195 * 14.99989986419677734375); + float _1203 = (_1197 * 0.0625) + (_1183.x * 0.05859375); + float _1205 = _1183.y * 0.9375; + _1227 = mix(_1183, mix(_1183, mix(texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1203, _1205)).xyz, texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_1203 + 0.0625, _1205)).xyz, vec3((_1195 * 15.0) - _1197)), vec3(clamp(((_307 < _93._m0[0u]._m1[1]._m2) ? clamp((_307 - _93._m0[0u]._m1[1]._m0) * _93._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_307 - _93._m0[0u]._m1[1]._m2) * _93._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _93._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_83, _10), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _1227 = _1124; + } + _1230 = _1227; + } else { + _1230 = _1072; + } + +#if 1 + _1230 = DecodeLUTInput(_1230, _1072, _1097); +#endif + + vec4 _1235 = vec4(_1230, dot(_1230, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1236 = _1235.xyz; + ivec4 _1278 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_60._m0[0u]._m22) & 31), 0u)); + vec3 _1286 = (vec3(texelFetch(_63, _1278.xyz, _1278.w).x) * 2.0) - vec3(1.0); + vec3 _1297; + if (_724) { + _1297 = vec3(ivec3(sign(_1286))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1286))); + } else { + _1297 = _1286; + } + vec3 _1299 = _1236 + CUSTOM_DITHERING * (_1297 * mix(_69._m39.xyz, _69._m40.xyz, pow(clamp((mix(vec3(max(_1230.x, max(_1230.y, _1230.z))), _1236, bvec3(floatBitsToInt(_69._m41.w) != 0)) - _69._m42.xyz) * _69._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_69._m42.w)))); + vec4 _1300 = vec4(_1299.x, _1299.y, _1299.z, _1235.w); + vec4 _1305; + if (!_724) { + _1305 = clamp(_1300, vec4(0.0), vec4(1.0)); + } else { + _1305 = _1300; + } + _6 = _1305; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/tonemap_0x54F0BD84.frag.glsl b/src/games/rdr2vk/tonemap/tonemap_0x54F0BD84.frag.glsl new file mode 100644 index 000000000..eb90fd78e --- /dev/null +++ b/src/games/rdr2vk/tonemap/tonemap_0x54F0BD84.frag.glsl @@ -0,0 +1,928 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#if defined(GL_EXT_control_flow_attributes) +#extension GL_EXT_control_flow_attributes : require +#define SPIRV_CROSS_FLATTEN [[flatten]] +#define SPIRV_CROSS_BRANCH [[dont_flatten]] +#define SPIRV_CROSS_UNROLL [[unroll]] +#define SPIRV_CROSS_LOOP [[dont_unroll]] +#else +#define SPIRV_CROSS_FLATTEN +#define SPIRV_CROSS_BRANCH +#define SPIRV_CROSS_UNROLL +#define SPIRV_CROSS_LOOP +#endif +#extension GL_EXT_samplerless_texture_functions : require + +struct _13 { + float _m0; +}; + +struct _15 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _14 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _15 _m5; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; +}; + +struct _19 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _20 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _16 { + _17 _m0[2]; + _18 _m1; + _19 _m2; + _20 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; +}; + +struct _24 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _21 { + _22 _m0; + _23 _m1; + _24 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _25 { + vec4 _m0[5]; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _27 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _28 { + int _m0; + int _m1; +}; + +struct _29 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _12 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _13 _m41; + _14 _m42; + _16 _m43; + _21 _m44; + _25 _m45; + _26 _m46; + _27 _m47[5]; + vec4 _m48; + _28 _m49; + vec4 _m50; + _29 _m51; +}; + +struct _33 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _34 { + float _m0; +}; + +struct _36 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _35 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _36 _m3; + vec2 _m4; +}; + +struct _38 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _39 { + int _m0; +}; + +struct _40 { + _39 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _37 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _38 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _39 _m16; + _39 _m17; + _40 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _42 { + vec3 _m0; + float _m1; +}; + +struct _43 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _44 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _45 { + float _m0; + _39 _m1; +}; + +struct _46 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _47 { + _39 _m0; + float _m1; + float _m2; +}; + +struct _49 { + int _m0; +}; + +struct _48 { + _39 _m0; + _49 _m1; + _49 _m2; +}; + +struct _50 { + _39 _m0; +}; + +struct _41 { + _42 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _43 _m4; + _44 _m5; + _45 _m6; + _46 _m7; + _47 _m8; + _48 _m9; + _50 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _51 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _54 { + vec4 _m0; + vec4 _m1; +}; + +struct _56 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _56 _m19[2]; +}; + +struct _57 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _58 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _59 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _32 { + float _m0[32]; + float _m1[32]; + _33 _m2; + _33 _m3; + _34 _m4; + _35 _m5; + _37 _m6; + _41 _m7; + _51 _m8; + _52 _m9; + float _m10; + vec2 _m11; + _53 _m12; + _54 _m13; + float _m14; + float _m15; + vec4 _m16; + _55 _m17; + _57 _m18; + _58 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _59 _m30; + int _m31; +}; + +struct _91 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _92 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _90 { + _91 _m0; + _92 _m1[11]; +}; + +float _268; + +layout(set = 0, binding = 98, scalar) readonly buffer _11_30 { + _12 _m0[]; +} +_30; + +layout(set = 0, binding = 99, scalar) readonly buffer _31_60 { + _32 _m0[]; +} +_60; + +layout(set = 0, binding = 20, std140) uniform _66_67 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_67; + +layout(set = 1, binding = 16, std140) uniform _68_69 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_69; + +layout(set = 0, binding = 214, std430) readonly buffer _89_93 { + _90 _m0[]; +} +_93; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 33) uniform sampler _9; +layout(set = 1, binding = 34) uniform sampler _10; +layout(set = 0, binding = 121) uniform texture2DArray _63; +layout(set = 0, binding = 140) uniform texture2D _64; +layout(set = 1, binding = 173) uniform texture2D _70; +layout(set = 1, binding = 174) uniform texture2D _71; +layout(set = 1, binding = 177) uniform texture2D _72; +layout(set = 1, binding = 185) uniform texture1D _74; +layout(set = 1, binding = 40) uniform sampler _75; +layout(set = 1, binding = 186) uniform texture2D _76; +layout(set = 1, binding = 190) uniform texture2D _77; +layout(set = 1, binding = 191) uniform texture2D _78; +layout(set = 1, binding = 196) uniform texture2D _79; +layout(set = 1, binding = 197) uniform texture2D _80; +layout(set = 1, binding = 202) uniform texture2D _81; +layout(set = 1, binding = 203) uniform texture2D _82; +layout(set = 1, binding = 205) uniform texture2D _83; +layout(set = 1, binding = 206) uniform texture2D _84; +layout(set = 1, binding = 207) uniform texture2D _85; +layout(set = 1, binding = 209) uniform texture2D _86; +layout(set = 1, binding = 210) uniform texture2D _87; +layout(set = 1, binding = 212) uniform samplerBuffer _88; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + vec4 _278 = texture(sampler2D(_84, _8), _4.xy); + vec2 _279 = _278.xy; + float _287 = 1.0 + _69._m0.w; + float _290 = _69._m0.z / (_287 - textureLod(sampler2D(_71, _8), _279, 0.0).x); + vec4 _294 = texture(sampler2D(_76, _75), _279); + vec4 _319 = textureLod(sampler2D(_87, _8), _279 * _69._m80.xy, 0.0) * 1.0; + float _320 = _319.z; + vec4 _477; + SPIRV_CROSS_BRANCH + if ((_320 >= 1.0) && (_319.w < 2.0)) { + float _338 = min(length(textureLod(sampler2D(_86, _8), _279, 0.0).xy * _69._m20.x), _69._m20.z); + float _341 = min(_320, 2.0); + vec2 _342 = (_319.xy / vec2(_320)) * _341; + int _345 = int(min(2.0, 1.0 + _341)); + vec2 _349 = _342 * _69._m63.xy; + float _351 = float(_345) - 0.5; + float _352 = _351 / _341; + vec2 _354 = (-_342) * _69._m63.xy; + vec2 _357 = vec2(uvec2(gl_FragCoord.xy) & uvec2(1u)); + float _371 = ((((_357.x * 2.0) - 1.0) * ((_357.y * 2.0) - 1.0)) * _69._m20.w) * clamp((_341 - 2.0) * 0.5, 0.0, 1.0); + float _372 = 0.5 + _371; + float _373 = 0.5 - _371; + vec4 _375; + _375 = vec4(0.0); + for (int _378 = 0; _378 < _345;) { + float _382 = float(_378); + float _383 = _382 + _372; + vec2 _386 = _279 + (_349 * (_383 / _351)); + float _392 = min(length(textureLod(sampler2D(_86, _8), _386, 0.0).xy * _69._m20.x), _69._m20.z); + float _398 = _69._m0.z / (_287 - textureLod(sampler2D(_70, _8), _386, 0.0).x); + float _403 = _338 * _352; + float _420 = _382 + _373; + vec2 _423 = _279 + (_354 * (_420 / _351)); + float _429 = min(length(textureLod(sampler2D(_86, _8), _423, 0.0).xy * _69._m20.x), _69._m20.z); + float _434 = _69._m0.z / (_287 - textureLod(sampler2D(_70, _8), _423, 0.0).x); + float _451 = (1.0 - clamp((1.0 - _429) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_434 - _290)), vec2(0.0), vec2(1.0)), clamp(vec2(_403, _429 * _352) - vec2(max(_420 - 1.0, 0.0)), vec2(0.0), vec2(1.0))); + bvec2 _457 = bvec2(_398 > _434, _429 > _392); + float _459 = all(_457) ? _451 : ((1.0 - clamp((1.0 - _392) * 8.0, 0.0, 1.0)) * dot(clamp(vec2(0.5) + (vec2(1.0, -1.0) * (_398 - _290)), vec2(0.0), vec2(1.0)), clamp(vec2(_403, _392 * _352) - vec2(max(_383 - 1.0, 0.0)), vec2(0.0), vec2(1.0)))); + float _461 = any(_457) ? _451 : _459; + _375 = (_375 + vec4(textureLod(sampler2D(_77, _9), _423, 0.0).xyz * _461, _461)) + vec4(textureLod(sampler2D(_77, _9), _386, 0.0).xyz * _459, _459); + _378++; + continue; + } + _477 = _375 / vec4(float(2 * _345)); + } else { + _477 = vec4(0.0); + } + vec4 _485 = textureLod(sampler2D(_78, _9), _279, 0.0); + vec3 _490 = _485.xyz + ((_477.xyz + (vec4(vec4(_294.xyz, 0.0).xyz * _30._m0[0u]._m1.w, _268).xyz * (1.0 - _477.w))) * (1.0 - _485.w)); + vec4 _493 = texelFetch(_88, int(0u)); + vec4 _494 = texelFetch(_88, int(1u)); + bool _524; + vec3 _525; + if (floatBitsToInt(_69._m61) != 0) { + vec4 _510 = texture(sampler2D(_83, _75), _4.xy); + float _511 = _510.w; + bool _513 = (_511 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _522; + if (_513) { + _522 = _510.xyz; + } else { + _522 = _510.xyz + (_490 * (1.0 - _511)); + } + _524 = _513 ? true : false; + _525 = _522; + } else { + _524 = false; + _525 = _490; + } + vec3 _529 = min(_525 * texelFetch(_64, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _530 = !_524; + float _643; + vec3 _644; + if (_530) { + float _589; + if (floatBitsToInt(_69._m70.x) != 0) { + float _552 = clamp(dot(texture(sampler2D(_72, _10), _279).xyz * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _69._m72.z, _69._m72.w); + float _575 = clamp(((((_69._m70.y * log(_552 + _69._m72.x)) + _69._m70.z) - 10.0) + (_69._m72.y * _552)) + _69._m65.w, _69._m66.x, _69._m66.y); + _589 = pow(2.0, mix(_5, clamp(_575 + ((abs(_575) * _69._m66.z) * float(int(sign(_575)))), _69._m66.x, _69._m66.y), clamp(_69._m70.x, 0.0, 1.0))); + } else { + _589 = _4.z; + } + vec3 _642; + if (floatBitsToInt(_69._m51.w) != 0) { + vec2 _618 = ((_4.xy - _69._m50.xy) * mat2(vec2(_69._m52.x, _69._m52.y), vec2(_69._m52.z, _69._m52.w))) * _69._m50.zw; + float _622 = CUSTOM_VIGNETTE * max((dot(_618, _618) - _69._m53.x) * _69._m53.w, 0.0); + bool _623 = _622 < 1.0; + _642 = mix(_529, (_529 * _69._m51.xyz) * _69._m51.w, vec3(_623 ? (_623 ? (1.0 - pow(2.0, (-10.0) * _622)) : 1.0) : (0.9980499744415283203125 + (((_622 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_622 - 2.0)) : 0.0)))); + } else { + _642 = _529; + } + _643 = _589; + _644 = _642; + } else { + _643 = _4.z; + _644 = _529; + } + vec3 _681 = _644 * mix(mix(_69._m54.xyz, _69._m56.xyz, vec3(clamp(clamp(_4.y * _69._m57.y, 0.0, 1.0) + _69._m54.w, 0.0, 1.0))), mix(_69._m56.xyz, _69._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _69._m56.w, 0.0, 1.0) * _69._m57.x, 0.0, 1.0) - _69._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _684 = _67._m3 != 0u; +#if 1 + vec3 _747 = ApplyToneMap(_681, _684, _643, _67._m6, _67._m4, _67._m10, _493.rgb, _494); +#else + vec3 _747; + if (_684) { + vec3 _724 = max(vec3(0.0), _681 * (_643 / _67._m6)); + vec3 _727 = _724 * _493.x; + _747 = (((((_724 * (_727 + vec3(_494.x))) + vec3(_494.y)) / ((_724 * (_727 + vec3(_493.y))) + vec3(_494.z))) - vec3(_494.w)) * ((_67._m4 != 0u) ? _67._m10 : _493.z)) * _67._m6; + } else { + vec3 _690 = max(vec3(0.0), _681 * _643); + vec3 _693 = _690 * _493.x; + _747 = clamp(((((_690 * (_693 + vec3(_494.x))) + vec3(_494.y)) / ((_690 * (_693 + vec3(_493.y))) + vec3(_494.z))) - vec3(_494.w)) * _493.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _795; + if (_530) { + vec3 _794; + if (floatBitsToInt(_69._m47.w) != 0) { + vec2 _780 = ((_4.xy - _69._m46.xy) * mat2(vec2(_69._m48.x, _69._m48.y), vec2(_69._m48.z, _69._m48.w))) * _69._m46.zw; + _794 = mix(_747, _69._m47.xyz, vec3(_69._m47.w * texture(sampler1D(_74, _10), min(1.0, max((dot(_780, _780) - _69._m49.x) * _69._m49.w, 0.0))).w)); + } else { + _794 = _747; + } + _795 = _794; + } else { + _795 = _747; + } + bool _816 = _684 && (!(_67._m2 != 0u)); + +#if 1 + vec3 _818 = EncodeLUTInput(_795, _67._m11, _67._m12, _67._m13, _67._m14, _816); +#else + vec3 _818 = mix(mix((pow(_795, vec3(_67._m12)) * _67._m13) - vec3(_67._m14), _795 * _67._m11, lessThan(_795, vec3(0.003130800090730190277099609375))), _795, bvec3(_816)); +#endif + + vec3 _820 = max(_818 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), + vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _821 = _820.y; + vec3 _846 = mix(_818, clamp((_69._m81.xyz * (_821 * ((1.33000004291534423828125 * (1.0 + ((_821 + _820.z) / _820.x))) - 1.67999994754791259765625))) * _69._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + dot(_490 * texelFetch(_64, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)))) * _69._m82.x) + _69._m82.y, 0.0, 1.0))); + vec3 _876; + if (floatBitsToInt(_69._m84.w) != 0) { + _876 = mix(_846, texture(sampler2D(_85, _10), ((((_4.xy - vec2(0.5)) * _69._m84.z) / mix(_69._m85.wx, _69._m85.zy, _4.yx)) - _69._m84.xy) + vec2(0.5)).xyz, vec3(_69._m84.w)); + } else { + _876 = _846; + } + float _901 = 1.0; + vec3 _1034; + if (_530) { +#if 1 + vec3 _902 = CompressLUTInput(_876, _816, _67._m5, _67._m7, _67._m8, _67._m9, _901); +#else + float _895 = max(max(_876.x, max(_876.y, _876.z)), 9.9999997473787516355514526367188e-05); + _901 = (_816 && (!(_67._m5 != 0u))) ? 1.0 : (((_895 > _67._m7) ? ((_895 * _67._m8) + _67._m9) : _895) / _895); + vec3 _902 = _876 * _901; +#endif + float _905 = _902.z; + float _907 = floor(_905 * 14.99989986419677734375); + float _913 = (_907 * 0.0625) + (_902.x * 0.05859375); + float _915 = _902.y * 0.9375; + vec4 _919 = texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_913, _915)); + vec4 _925 = texture(sampler2D(_81, _10), vec2(0.001953125, 0.03125) + vec2(_913 + 0.0625, _915)); + vec3 _928 = mix(_919.xyz, _925.xyz, vec3((_905 * 15.0) - _907)); + vec3 _1031; + if (_93._m0[0u]._m0._m0 > 0) { + float _962 = _928.z; + float _964 = floor(_962 * 14.99989986419677734375); + float _970 = (_964 * 0.0625) + (_928.x * 0.05859375); + float _972 = _928.y * 0.9375; + vec3 _987 = mix(_928, mix(texture(sampler2D(_79, _10), vec2(0.001953125, 0.03125) + vec2(_970, _972)).xyz, texture(sampler2D(_79, _10), vec2(0.001953125, 0.03125) + vec2(_970 + 0.0625, _972)).xyz, vec3((_962 * 15.0) - _964)), vec3(clamp(((_290 < _93._m0[0u]._m1[0]._m2) ? clamp((_290 - _93._m0[0u]._m1[0]._m0) * _93._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_290 - _93._m0[0u]._m1[0]._m2) * _93._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _93._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _999 = _987.z; + float _1001 = floor(_999 * 14.99989986419677734375); + float _1007 = (_1001 * 0.0625) + (_987.x * 0.05859375); + float _1009 = _987.y * 0.9375; + _1031 = mix(_987, mix(_987, mix(texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1007, _1009)).xyz, texture(sampler2D(_80, _10), vec2(0.001953125, 0.03125) + vec2(_1007 + 0.0625, _1009)).xyz, vec3((_999 * 15.0) - _1001)), vec3(clamp(((_290 < _93._m0[0u]._m1[1]._m2) ? clamp((_290 - _93._m0[0u]._m1[1]._m0) * _93._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_290 - _93._m0[0u]._m1[1]._m2) * _93._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _93._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_82, _10), _279).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _1031 = _928; + } + _1034 = _1031; + } else { + _1034 = _876; + } + +#if 1 + _1034 = DecodeLUTInput(_1034, _876, _901); +#endif + + vec4 _1039 = vec4(_1034, dot(_1034, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _1040 = _1039.xyz; + ivec4 _1082 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_60._m0[0u]._m22) & 31), 0u)); + vec3 _1090 = (vec3(texelFetch(_63, _1082.xyz, _1082.w).x) * 2.0) - vec3(1.0); + vec3 _1101; + if (_684) { + _1101 = vec3(ivec3(sign(_1090))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_1090))); + } else { + _1101 = _1090; + } + vec3 _1103 = _1040 + CUSTOM_DITHERING * (_1101 * mix(_69._m39.xyz, _69._m40.xyz, pow(clamp((mix(vec3(max(_1034.x, max(_1034.y, _1034.z))), _1040, bvec3(floatBitsToInt(_69._m41.w) != 0)) - _69._m42.xyz) * _69._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_69._m42.w)))); + vec4 _1104 = vec4(_1103.x, _1103.y, _1103.z, _1039.w); + vec4 _1109; + if (!_684) { + _1109 = clamp(_1104, vec4(0.0), vec4(1.0)); + } else { + _1109 = _1104; + } + _6 = _1109; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/tonemap_0x9F191B0B.frag.glsl b/src/games/rdr2vk/tonemap/tonemap_0x9F191B0B.frag.glsl new file mode 100644 index 000000000..5bbe3e959 --- /dev/null +++ b/src/games/rdr2vk/tonemap/tonemap_0x9F191B0B.frag.glsl @@ -0,0 +1,861 @@ +#version 450 + +#extension GL_GOOGLE_include_directive : require +#include "./tonemap.glsl" + +#extension GL_EXT_scalar_block_layout : require +#extension GL_EXT_samplerless_texture_functions : require + +struct _12 { + float _m0; +}; + +struct _14 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _13 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + _14 _m5; +}; + +struct _16 { + vec4 _m0; + vec4 _m1; + mat4 _m2; +}; + +struct _17 { + vec4 _m0; + vec4 _m1; +}; + +struct _18 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; +}; + +struct _19 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; +}; + +struct _15 { + _16 _m0[2]; + _17 _m1; + _18 _m2; + _19 _m3; + vec4 _m4[3]; + vec2 _m5; + vec2 _m6; + vec2 _m7; + float _m8; + vec4 _m9[4]; + vec2 _m10; + vec2 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec4 _m15[4]; + float _m16; + int _m17; + float _m18; + float _m19; +}; + +struct _21 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; +}; + +struct _22 { + float _m0; + float _m1; + float _m2; +}; + +struct _23 { + float _m0; + float _m1; + float _m2; + float _m3; + vec3 _m4; + int _m5; +}; + +struct _20 { + _21 _m0; + _22 _m1; + _23 _m2; + vec2 _m3; + vec2 _m4; + vec4 _m5; + float _m6; + float _m7; + uint _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; +}; + +struct _24 { + vec4 _m0[5]; +}; + +struct _25 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _26 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _27 { + int _m0; + int _m1; +}; + +struct _28 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _11 { + float _m0; + vec4 _m1; + float _m2; + vec4 _m3; + uvec4 _m4; + uvec4 _m5; + vec4 _m6; + int _m7; + int _m8; + int _m9; + vec4 _m10; + vec4 _m11[8]; + uint _m12; + vec3 _m13; + vec3 _m14; + vec2 _m15; + vec2 _m16; + mat3 _m17; + vec3 _m18; + vec3 _m19; + float _m20; + float _m21; + vec3 _m22; + vec3 _m23; + vec3 _m24; + vec3 _m25; + vec4 _m26[13]; + int _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec3 _m31; + vec3 _m32; + vec3 _m33; + vec3 _m34; + vec4 _m35; + float _m36; + float _m37; + float _m38; + float _m39; + mat4 _m40; + _12 _m41; + _13 _m42; + _15 _m43; + _20 _m44; + _24 _m45; + _25 _m46; + _26 _m47[5]; + vec4 _m48; + _27 _m49; + vec4 _m50; + _28 _m51; +}; + +struct _32 { + float _m0; + vec3 _m1; + vec3 _m2; + vec3 _m3; + float _m4; + vec3 _m5; + vec3 _m6; + float _m7; + vec3 _m8; + vec3 _m9; + vec2 _m10; + vec3 _m11; + vec4 _m12; + vec4 _m13[4]; + vec4 _m14; + float _m15; + int _m16; +}; + +struct _33 { + float _m0; +}; + +struct _35 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + uint _m6; + uint _m7; + uvec4 _m8; +}; + +struct _34 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + _35 _m3; + vec2 _m4; +}; + +struct _37 { + float _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _38 { + int _m0; +}; + +struct _39 { + _38 _m0; + float _m1; + float _m2; + float _m3; +}; + +struct _36 { + vec3 _m0; + vec3 _m1; + float _m2; + float _m3; + _37 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + uint _m15; + _38 _m16; + _38 _m17; + _39 _m18; + vec4 _m19; + float _m20; + float _m21; + float _m22; + float _m23; + float _m24; + float _m25; + float _m26; + float _m27; +}; + +struct _41 { + vec3 _m0; + float _m1; +}; + +struct _42 { + vec4 _m0; + vec4 _m1; + vec4 _m2; +}; + +struct _43 { + vec2 _m0; + vec2 _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + vec2 _m8; + float _m9; +}; + +struct _44 { + float _m0; + _38 _m1; +}; + +struct _45 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _46 { + _38 _m0; + float _m1; + float _m2; +}; + +struct _48 { + int _m0; +}; + +struct _47 { + _38 _m0; + _48 _m1; + _48 _m2; +}; + +struct _49 { + _38 _m0; +}; + +struct _40 { + _41 _m0; + vec4 _m1; + mat4 _m2; + mat4 _m3; + _42 _m4; + _43 _m5; + _44 _m6; + _45 _m7; + _46 _m8; + _47 _m9; + _49 _m10; + float _m11; + float _m12; + float _m13; +}; + +struct _50 { + float _m0; + float _m1; + vec2 _m2; + vec2 _m3; + vec2 _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; +}; + +struct _51 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec3 _m3; + vec3 _m4; + vec3 _m5; + vec3 _m6; + vec3 _m7; +}; + +struct _52 { + vec4 _m0; + vec4 _m1; + vec3 _m2; +}; + +struct _53 { + vec4 _m0; + vec4 _m1; +}; + +struct _55 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; +}; + +struct _54 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; + float _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + float _m16; + float _m17; + float _m18; + _55 _m19[2]; +}; + +struct _56 { + vec2 _m0; + vec2 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; + vec2 _m6; +}; + +struct _57 { + vec4 _m0; + vec4 _m1; + vec2 _m2; + float _m3; + float _m4; + float _m5; +}; + +struct _58 { + vec3 _m0; + float _m1; + float _m2; +}; + +struct _31 { + float _m0[32]; + float _m1[32]; + _32 _m2; + _32 _m3; + _33 _m4; + _34 _m5; + _36 _m6; + _40 _m7; + _50 _m8; + _51 _m9; + float _m10; + vec2 _m11; + _52 _m12; + _53 _m13; + float _m14; + float _m15; + vec4 _m16; + _54 _m17; + _56 _m18; + _57 _m19; + vec4 _m20; + float _m21; + uint _m22; + uvec2 _m23; + uvec2 _m24; + uint _m25; + float _m26; + float _m27; + float _m28; + float _m29; + _58 _m30; + int _m31; +}; + +struct _84 { + int _m0; + float _m1; + int _m2[2]; +}; + +struct _85 { + float _m0; + float _m1; + float _m2; + float _m3; + float _m4; +}; + +struct _83 { + _84 _m0; + _85 _m1[11]; +}; + +float _251; + +layout(set = 0, binding = 98, scalar) readonly buffer _10_29 { + _11 _m0[]; +} +_29; + +layout(set = 0, binding = 99, scalar) readonly buffer _30_59 { + _31 _m0[]; +} +_59; + +layout(set = 0, binding = 20, std140) uniform _65_66 { + float _m0; + float _m1; + uint _m2; + uint _m3; + uint _m4; + uint _m5; + float _m6; + float _m7; + float _m8; + float _m9; + float _m10; + float _m11; + float _m12; + float _m13; + float _m14; + float _m15; + uint _m16; + uint _m17; + uint _m18; + uint _m19; +} +_66; + +layout(set = 1, binding = 16, std140) uniform _67_68 { + vec4 _m0; + vec4 _m1; + vec4 _m2; + vec4 _m3; + vec4 _m4; + vec4 _m5; + vec4 _m6; + vec4 _m7; + vec4 _m8; + vec4 _m9; + vec4 _m10; + vec4 _m11; + vec4 _m12; + vec4 _m13; + vec4 _m14; + vec2 _m15; + vec4 _m16; + vec4 _m17; + vec4 _m18; + vec4 _m19; + vec4 _m20; + vec4 _m21; + vec4 _m22; + vec4 _m23; + vec4 _m24; + vec3 _m25; + vec3 _m26; + vec3 _m27; + vec4 _m28; + vec4 _m29; + vec4 _m30; + vec4 _m31; + vec4 _m32; + vec4 _m33; + vec4 _m34; + vec4 _m35; + vec4 _m36; + vec4 _m37; + vec3 _m38; + vec4 _m39; + vec4 _m40; + vec4 _m41; + vec4 _m42; + mat4 _m43; + vec4 _m44; + vec4 _m45; + vec4 _m46; + vec4 _m47; + vec4 _m48; + vec4 _m49; + vec4 _m50; + vec4 _m51; + vec4 _m52; + vec4 _m53; + vec4 _m54; + vec4 _m55; + vec4 _m56; + vec4 _m57; + float _m58; + vec4 _m59; + vec4 _m60; + float _m61; + vec4 _m62; + vec4 _m63; + vec2 _m64; + vec4 _m65; + vec4 _m66; + vec4 _m67; + vec4 _m68; + vec4 _m69; + vec4 _m70; + vec4 _m71; + vec4 _m72; + vec4 _m73; + vec4 _m74; + vec4 _m75; + vec4 _m76; + vec4 _m77; + vec3 _m78; + float _m79; + vec4 _m80; + vec4 _m81; + vec4 _m82; + vec4 _m83; + vec4 _m84; + vec4 _m85; +} +_68; + +layout(set = 0, binding = 214, std430) readonly buffer _82_86 { + _83 _m0[]; +} +_86; + +layout(set = 1, binding = 32) uniform sampler _8; +layout(set = 1, binding = 34) uniform sampler _9; +layout(set = 0, binding = 121) uniform texture2DArray _62; +layout(set = 0, binding = 140) uniform texture2D _63; +layout(set = 1, binding = 174) uniform texture2D _69; +layout(set = 1, binding = 177) uniform texture2D _70; +layout(set = 1, binding = 185) uniform texture1D _72; +layout(set = 1, binding = 40) uniform sampler _73; +layout(set = 1, binding = 186) uniform texture2D _74; +layout(set = 1, binding = 196) uniform texture2D _75; +layout(set = 1, binding = 197) uniform texture2D _76; +layout(set = 1, binding = 202) uniform texture2D _77; +layout(set = 1, binding = 203) uniform texture2D _78; +layout(set = 1, binding = 205) uniform texture2D _79; +layout(set = 1, binding = 207) uniform texture2D _80; +layout(set = 1, binding = 212) uniform samplerBuffer _81; + +layout(location = 0) in vec4 _4; +layout(location = 1) in float _5; +layout(location = 0) out vec4 _6; + +void main() { + float _269 = _68._m0.z / ((1.0 + _68._m0.w) - textureLod(sampler2D(_69, _8), _4.xy, 0.0).x); + vec4 _273 = texture(sampler2D(_74, _73), _4.xy); + vec3 _287 = vec4(vec4(_273.xyz, 0.0).xyz * _29._m0[0u]._m1.w, _251).xyz; + vec4 _290 = texelFetch(_81, int(0u)); + vec4 _291 = texelFetch(_81, int(1u)); + bool _321; + vec3 _322; + if (floatBitsToInt(_68._m61) != 0) { + vec4 _307 = texture(sampler2D(_79, _73), _4.xy); + float _308 = _307.w; + bool _310 = (_308 + 9.9999997473787516355514526367188e-05) >= 1.0; + vec3 _319; + if (_310) { + _319 = _307.xyz; + } else { + _319 = _307.xyz + (_287 * (1.0 - _308)); + } + _321 = _310 ? true : false; + _322 = _319; + } else { + _321 = false; + _322 = _287; + } + vec3 _326 = min(_322 * texelFetch(_63, ivec2(0), 0).x, vec3(GetTonemapClampMax())); + bool _327 = !_321; + float _440; + vec3 _441; + if (_327) { + float _386; + if (floatBitsToInt(_68._m70.x) != 0) { + float _349 = clamp(dot(texture(sampler2D(_70, _9), _4.xy).xyz * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)), _68._m72.z, _68._m72.w); + float _372 = clamp(((((_68._m70.y * log(_349 + _68._m72.x)) + _68._m70.z) - 10.0) + (_68._m72.y * _349)) + _68._m65.w, _68._m66.x, _68._m66.y); + _386 = pow(2.0, mix(_5, clamp(_372 + ((abs(_372) * _68._m66.z) * float(int(sign(_372)))), _68._m66.x, _68._m66.y), clamp(_68._m70.x, 0.0, 1.0))); + } else { + _386 = _4.z; + } + vec3 _439; + if (floatBitsToInt(_68._m51.w) != 0) { + vec2 _415 = ((_4.xy - _68._m50.xy) * mat2(vec2(_68._m52.x, _68._m52.y), vec2(_68._m52.z, _68._m52.w))) * _68._m50.zw; + float _419 = CUSTOM_VIGNETTE * max((dot(_415, _415) - _68._m53.x) * _68._m53.w, 0.0); + bool _420 = _419 < 1.0; + _439 = mix(_326, (_326 * _68._m51.xyz) * _68._m51.w, vec3(_420 ? (_420 ? (1.0 - pow(2.0, (-10.0) * _419)) : 1.0) : (0.9980499744415283203125 + (((_419 - 1.0) > 0.0) ? pow(2.0, 10.0 * (_419 - 2.0)) : 0.0)))); + } else { + _439 = _326; + } + _440 = _386; + _441 = _439; + } else { + _440 = _4.z; + _441 = _326; + } + vec3 _478 = _441 * mix(mix(_68._m54.xyz, _68._m56.xyz, vec3(clamp(clamp(_4.y * _68._m57.y, 0.0, 1.0) + _68._m54.w, 0.0, 1.0))), mix(_68._m56.xyz, _68._m55.xyz, vec3(clamp(clamp(clamp(_4.y - _68._m56.w, 0.0, 1.0) * _68._m57.x, 0.0, 1.0) - _68._m55.w, 0.0, 1.0))), vec3(_4.y)); + bool _481 = _66._m3 != 0u; +#if 1 + vec3 _544 = ApplyToneMap(_478, _481, _440, _66._m6, _66._m4, _66._m10, _290.rgb, _291); +#else + vec3 _544; + if (_481) { + vec3 _521 = max(vec3(0.0), _478 * (_440 / _66._m6)); + vec3 _524 = _521 * _290.x; + _544 = (((((_521 * (_524 + vec3(_291.x))) + vec3(_291.y)) / ((_521 * (_524 + vec3(_290.y))) + vec3(_291.z))) - vec3(_291.w)) * ((_66._m4 != 0u) ? _66._m10 : _290.z)) * _66._m6; + } else { + vec3 _487 = max(vec3(0.0), _478 * _440); + vec3 _490 = _487 * _290.x; + _544 = clamp(((((_487 * (_490 + vec3(_291.x))) + vec3(_291.y)) / ((_487 * (_490 + vec3(_290.y))) + vec3(_291.z))) - vec3(_291.w)) * _290.z, vec3(0.0), vec3(1.0)); + } +#endif + vec3 _592; + if (_327) { + vec3 _591; + if (floatBitsToInt(_68._m47.w) != 0) { + vec2 _577 = ((_4.xy - _68._m46.xy) * mat2(vec2(_68._m48.x, _68._m48.y), vec2(_68._m48.z, _68._m48.w))) * _68._m46.zw; + _591 = mix(_544, _68._m47.xyz, vec3(_68._m47.w * texture(sampler1D(_72, _9), min(1.0, max((dot(_577, _577) - _68._m49.x) * _68._m49.w, 0.0))).w)); + } else { + _591 = _544; + } + _592 = _591; + } else { + _592 = _544; + } + bool _613 = _481 && (!(_66._m2 != 0u)); +#if 1 + vec3 _615 = EncodeLUTInput(_592, _66._m11, _66._m12, _66._m13, _66._m14, _613); +#else + vec3 _615 = mix(mix((pow(_592, vec3(_66._m12)) * _66._m13) - vec3(_66._m14), _592 * _66._m11, lessThan(_592, vec3(0.003130800090730190277099609375))), _592, bvec3(_613)); +#endif + + vec3 _617 = max(_615 * mat3(vec3(0.514900028705596923828125, 0.324400007724761962890625, 0.1606999933719635009765625), vec3(0.265399992465972900390625, 0.67040002346038818359375, 0.06419999897480010986328125), vec3(0.02480000071227550506591796875, 0.1247999966144561767578125, 0.85039997100830078125)), vec3(0.00999999977648258209228515625, 0.0, 0.0)); + float _618 = _617.y; + vec3 _643 = mix(_615, clamp((_68._m81.xyz * (_618 * ((1.33000004291534423828125 * (1.0 + ((_618 + _617.z) / _617.x))) - 1.67999994754791259765625))) * _68._m81.w, vec3(0.0), vec3(1.0)), vec3(clamp(((0.039999999105930328369140625 / (0.039999999105930328369140625 + dot(_287 * texelFetch(_63, ivec2(0), 0).x, vec3(0.300000011920928955078125, 0.589999973773956298828125, 0.10999999940395355224609375)))) * _68._m82.x) + _68._m82.y, 0.0, 1.0))); + vec3 _673; + if (floatBitsToInt(_68._m84.w) != 0) { + _673 = mix(_643, texture(sampler2D(_80, _9), ((((_4.xy - vec2(0.5)) * _68._m84.z) / mix(_68._m85.wx, _68._m85.zy, _4.yx)) - _68._m84.xy) + vec2(0.5)).xyz, vec3(_68._m84.w)); + } else { + _673 = _643; + } + float _698 = 1.0; + vec3 _831; + if (_327) { +#if 1 + vec3 _699 = CompressLUTInput(_673, _613, _66._m5, _66._m7, _66._m8, _66._m9, _698); +#else + float _692 = max(max(_673.x, max(_673.y, _673.z)), 9.9999997473787516355514526367188e-05); + _698 = (_613 && (!(_66._m5 != 0u))) ? 1.0 : (((_692 > _66._m7) ? ((_692 * _66._m8) + _66._m9) : _692) / _692); + vec3 _699 = _673 * _698; +#endif + float _702 = _699.z; + float _704 = floor(_702 * 14.99989986419677734375); + float _710 = (_704 * 0.0625) + (_699.x * 0.05859375); + float _712 = _699.y * 0.9375; + vec4 _716 = texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_710, _712)); + vec4 _722 = texture(sampler2D(_77, _9), vec2(0.001953125, 0.03125) + vec2(_710 + 0.0625, _712)); + vec3 _725 = mix(_716.xyz, _722.xyz, vec3((_702 * 15.0) - _704)); + vec3 _828; + if (_86._m0[0u]._m0._m0 > 0) { + float _759 = _725.z; + float _761 = floor(_759 * 14.99989986419677734375); + float _767 = (_761 * 0.0625) + (_725.x * 0.05859375); + float _769 = _725.y * 0.9375; + vec3 _784 = mix(_725, mix(texture(sampler2D(_75, _9), vec2(0.001953125, 0.03125) + vec2(_767, _769)).xyz, texture(sampler2D(_75, _9), vec2(0.001953125, 0.03125) + vec2(_767 + 0.0625, _769)).xyz, vec3((_759 * 15.0) - _761)), vec3(clamp(((_269 < _86._m0[0u]._m1[0]._m2) ? clamp((_269 - _86._m0[0u]._m1[0]._m0) * _86._m0[0u]._m1[0]._m1, 0.0, 1.0) : (1.0 - clamp((_269 - _86._m0[0u]._m1[0]._m2) * _86._m0[0u]._m1[0]._m3, 0.0, 1.0))) + _86._m0[0u]._m1[0]._m4, 0.0, 1.0))); + float _796 = _784.z; + float _798 = floor(_796 * 14.99989986419677734375); + float _804 = (_798 * 0.0625) + (_784.x * 0.05859375); + float _806 = _784.y * 0.9375; + _828 = mix(_784, mix(_784, mix(texture(sampler2D(_76, _9), vec2(0.001953125, 0.03125) + vec2(_804, _806)).xyz, texture(sampler2D(_76, _9), vec2(0.001953125, 0.03125) + vec2(_804 + 0.0625, _806)).xyz, vec3((_796 * 15.0) - _798)), vec3(clamp(((_269 < _86._m0[0u]._m1[1]._m2) ? clamp((_269 - _86._m0[0u]._m1[1]._m0) * _86._m0[0u]._m1[1]._m1, 0.0, 1.0) : (1.0 - clamp((_269 - _86._m0[0u]._m1[1]._m2) * _86._m0[0u]._m1[1]._m3, 0.0, 1.0))) + _86._m0[0u]._m1[1]._m4, 0.0, 1.0))), vec3(dot(texture(sampler2D(_78, _9), _4.xy).xyz, vec3(0.2125999927520751953125, 0.715200006961822509765625, 0.072200000286102294921875)))); + } else { + _828 = _725; + } + _831 = _828; + } else { + _831 = _673; + } + +#if 1 + _831 = DecodeLUTInput(_831, _673, _698); +#endif + + vec4 _836 = vec4(_831, dot(_831, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625))); + vec3 _837 = _836.xyz; + ivec4 _880 = ivec4(uvec4(uvec2(ivec2(uvec2(gl_FragCoord.xy))) & uvec2(63u), uint(int(_59._m0[0u]._m22) & 31), 0u)); + vec3 _888 = (vec3(texelFetch(_62, _880.xyz, _880.w).x) * 2.0) - vec3(1.0); + vec3 _899; + if (_481) { + _899 = vec3(ivec3(sign(_888))) * (vec3(1.0) - sqrt(vec3(1.0) - abs(_888))); + } else { + _899 = _888; + } + vec3 _901 = _837 + CUSTOM_DITHERING * (_899 * mix(_68._m39.xyz, _68._m40.xyz, pow(clamp((mix(vec3(max(_831.x, max(_831.y, _831.z))), _837, bvec3(floatBitsToInt(_68._m41.w) != 0)) - _68._m42.xyz) * _68._m41.xyz, vec3(0.0), vec3(1.0)), vec3(_68._m42.w)))); + vec4 _902 = vec4(_901.x, _901.y, _901.z, _836.w); + vec4 _907; + if (!_481) { + _907 = clamp(_902, vec4(0.0), vec4(1.0)); + } else { + _907 = _902; + } + _6 = _907; + + + _6.rgb = ApplyGradingAndDisplayMap(_6.rgb, _4.xy); +} + + diff --git a/src/games/rdr2vk/tonemap/tonemaprdr2extended.glsl b/src/games/rdr2vk/tonemap/tonemaprdr2extended.glsl new file mode 100644 index 000000000..2c7e5f49a --- /dev/null +++ b/src/games/rdr2vk/tonemap/tonemaprdr2extended.glsl @@ -0,0 +1,118 @@ +#ifndef RDR2VK_TONEMAP_RDR2EXTENDED_GLSL_ +#define RDR2VK_TONEMAP_RDR2EXTENDED_GLSL_ + +const float PI = 3.14159265358979323846; + +float rdr2_tonemap_SignCbrt(float x) { + return sign(x) * pow(abs(x), 1.0 / 3.0); +} + +float rdr2_tonemap_Derivative(float x, float a, float b, float c, float d, float e, float f) { + float denom = a * x * x + b * x + e; + float numer = a * (b - c) * x * x + 2.0 * a * (e - d) * x + (c * e - b * d); + return numer / (denom * denom); // -f drops out because f is constant +} + +// Solve cubic a3*x^3 + a2*x^2 + a1*x + a0 = 0. +// Returns three real roots if disc <= 0, otherwise one real root duplicated. +vec3 rdr2_tonemap_SolveCubic(float a3, float a2, float a1, float a0) { + // Normalize: x = y - a2/(3a3) + float invA = 1.0 / a3; + float b = a2 * invA; + float c = a1 * invA; + float d = a0 * invA; + + float shift = b / 3.0; + float p = c - (b * b) / 3.0; + float q = (2.0 * b * b * b) / 27.0 - (b * c) / 3.0 + d; + + float halfQ = 0.5 * q; + float thirdP = p / 3.0; + + float disc = halfQ * halfQ + thirdP * thirdP * thirdP; + + if (disc > 0.0) { + // One real root + float s = sqrt(disc); + float u = rdr2_tonemap_SignCbrt(-halfQ + s); + float v = rdr2_tonemap_SignCbrt(-halfQ - s); + float y = u + v; + float x = y - shift; + return vec3(x); + } else { + // Three real roots + float t = 2.0 * sqrt(-thirdP); + float cosArg = (-halfQ) / sqrt(-(thirdP * thirdP * thirdP)); + cosArg = clamp(cosArg, -1.0, 1.0); + + float phi = acos(cosArg) / 3.0; + + float y0 = t * cos(phi); + float y1 = t * cos(phi - 2.0 * PI / 3.0); + float y2 = t * cos(phi - 4.0 * PI / 3.0); + + return vec3( + y0 - shift, + y1 - shift, + y2 - shift); + } +} + +// f(x) = (A x^2 + C x + D) / (A x^2 + B x + E) - F +// f''(x) = 0 => cubic P3(x) = 0 +float rdr2_tonemap_FindSecondDerivativeRootMax(float A, float B, float C, float D, float E) { + float a3 = A * A * (B - C); + float a2 = 3.0 * A * A * (E - D); + float a1 = 3.0 * A * (C * E - B * D); + float a0 = A * D * E - A * E * E - B * B * D + B * C * E; + + vec3 roots = rdr2_tonemap_SolveCubic(a3, a2, a1, a0); + return max(roots.x, max(roots.y, roots.z)); +} + +// Hable/U2-style tonemap used in RDR2 +float rdr2_tonemap_Apply(float x, float A, float B, float C, float D, float E, float F, float white_precompute) { + // (x * (a * x + c) + d)/(x * (a * x + b) + e) - f + float num = x * (A * x + C) + D; + float den = x * (A * x + B) + E; + return white_precompute * ((num / den) - F); +} + +vec3 rdr2_tonemap_Apply(vec3 x, float A, float B, float C, float D, float E, float F, float white_precompute) { + // (x * (a * x + c) + d)/(x * (a * x + b) + e) - f + vec3 num = x * (A * x + C) + D; + vec3 den = x * (A * x + B) + E; + return white_precompute * ((num / den) - F); +} + +float rdr2_tonemap_ApplyExtended( + float x, + float base, + float pivot_point, + float white_precompute, + float A, float B, float C, float D, float E, float F) { + float pivot_x = pivot_point; + float pivot_y = rdr2_tonemap_Apply(pivot_x, A, B, C, D, E, F, white_precompute); + float slope = rdr2_tonemap_Derivative(pivot_x, A, B, C, D, E, F) * white_precompute; + float offset = pivot_y - slope * pivot_x; + + float extended = slope * x + offset; // match slope + return mix(base, extended, step(pivot_x, x)); +} + +vec3 rdr2_tonemap_ApplyExtended( + vec3 x, + vec3 base, + float pivot_point, + float white_precompute, + float A, float B, float C, float D, float E, float F) { + float pivot_x = pivot_point; + float pivot_y = rdr2_tonemap_Apply(pivot_x, A, B, C, D, E, F, white_precompute); + float slope = rdr2_tonemap_Derivative(pivot_x, A, B, C, D, E, F) * white_precompute; + float offset = pivot_y - slope * pivot_x; + + vec3 extended = slope * x + vec3(offset); // match slope + return mix(base, extended, step(pivot_x, x)); +} + +#endif // RDR2VK_TONEMAP_RDR2EXTENDED_GLSL_