diff --git a/src/games/dbzspark/DICE.hlsl b/src/games/dbzspark/DICE.hlsl new file mode 100644 index 00000000..636bc30e --- /dev/null +++ b/src/games/dbzspark/DICE.hlsl @@ -0,0 +1,225 @@ +#include "./shared.h" + +float max3(float a, float b, float c) +{ + return max(a, max(b, c)); +} + +float max3(float3 v) +{ + return max3(v.x, v.y, v.z); +} + +static const float PQ_constant_M1 = 0.1593017578125f; +static const float PQ_constant_M2 = 78.84375f; +static const float PQ_constant_C1 = 0.8359375f; +static const float PQ_constant_C2 = 18.8515625f; +static const float PQ_constant_C3 = 18.6875f; + +// PQ (Perceptual Quantizer - ST.2084) encode/decode used for HDR10 BT.2100. +// Clamp type: +// 0 None +// 1 Remove negative numbers +// 2 Remove numbers beyond 0-1 +// 3 Mirror negative numbers +float3 Linear_to_PQ(float3 LinearColor, int clampType = 0) +{ + float3 LinearColorSign = sign(LinearColor); + if (clampType == 1) + { + LinearColor = max(LinearColor, 0.f); + } + else if (clampType == 2) + { + LinearColor = saturate(LinearColor); + } + else if (clampType == 3) + { + LinearColor = abs(LinearColor); + } + float3 colorPow = pow(LinearColor, PQ_constant_M1); + float3 numerator = PQ_constant_C1 + PQ_constant_C2 * colorPow; + float3 denominator = 1.f + PQ_constant_C3 * colorPow; + float3 pq = pow(numerator / denominator, PQ_constant_M2); + if (clampType == 3) + { + return pq * LinearColorSign; + } + return pq; +} + +float3 PQ_to_Linear(float3 ST2084Color, int clampType = 0) +{ + float3 ST2084ColorSign = sign(ST2084Color); + if (clampType == 1) + { + ST2084Color = max(ST2084Color, 0.f); + } + else if (clampType == 2) + { + ST2084Color = saturate(ST2084Color); + } + else if (clampType == 3) + { + ST2084Color = abs(ST2084Color); + } + float3 colorPow = pow(ST2084Color, 1.f / PQ_constant_M2); + float3 numerator = max(colorPow - PQ_constant_C1, 0.f); + float3 denominator = PQ_constant_C2 - (PQ_constant_C3 * colorPow); + float3 linearColor = pow(numerator / denominator, 1.f / PQ_constant_M1); + if (clampType == 3) + { + return linearColor * ST2084ColorSign; + } + return linearColor; +} + +// Aplies exponential ("Photographic") luminance/luma compression. +// The pow can modulate the curve without changing the values around the edges. +// The max is the max possible range to compress from, to not lose any output range if the input range was limited. +float rangeCompress(float X, float Max = asfloat(0x7F7FFFFF)) +{ + // Branches are for static parameters optimizations + if (Max == renodx::math::FLT_MAX) { + // This does e^X. We expect X to be between 0 and 1. + return 1.f - exp(-X); + } + const float lostRange = exp(-Max); + const float restoreRangeScale = 1.f / (1.f - lostRange); + return (1.f - exp(-X)) * restoreRangeScale; +} + +// Refurbished DICE HDR tonemapper (per channel or luminance). +// Expects "InValue" to be >= "ShoulderStart" and "OutMaxValue" to be > "ShoulderStart". +float luminanceCompress( + float InValue, + float OutMaxValue, + float ShoulderStart = 0.f, + bool considerMaxValue = false, + float InMaxValue = asfloat(0x7F7FFFFF)) +{ + const float compressableValue = InValue - ShoulderStart; + const float compressableRange = InMaxValue - ShoulderStart; + const float compressedRange = OutMaxValue - ShoulderStart; + const float possibleOutValue = ShoulderStart + compressedRange * rangeCompress(compressableValue / compressedRange, considerMaxValue ? (compressableRange / compressedRange) : renodx::math::FLT_MAX); +#if 1 + return possibleOutValue; +#else // Enable this branch if "InValue" can be smaller than "ShoulderStart" + return (InValue <= ShoulderStart) ? InValue : possibleOutValue; +#endif +} + +#define DICE_TYPE_BY_LUMINANCE_RGB 0 +// Doing the DICE compression in PQ (either on luminance or each color channel) produces a curve that is closer to our "perception" and leaves more detail highlights without overly compressing them +#define DICE_TYPE_BY_LUMINANCE_PQ 1 +// Modern HDR displays clip individual rgb channels beyond their "white" peak brightness, +// like, if the peak brightness is 700 nits, any r g b color beyond a value of 700/80 will be clipped (not acknowledged, it won't make a difference). +// Tonemapping by luminance, is generally more perception accurate but can then generate rgb colors "out of range". This setting fixes them up, +// though it's optional as it's working based on assumptions on how current displays work, which might not be true anymore in the future. +// Note that this can create some steep (rough, quickly changing) gradients on very bright colors. +#define DICE_TYPE_BY_LUMINANCE_PQ_CORRECT_CHANNELS_BEYOND_PEAK_WHITE 2 +// This might look more like classic SDR tonemappers and is closer to how modern TVs and Monitors play back colors (usually they clip each individual channel to the peak brightness value, though in their native panel color space, or current SDR/HDR mode color space). +// Overall, this seems to handle bright gradients more smoothly, even if it shifts hues more (and generally desaturating). +#define DICE_TYPE_BY_CHANNEL_PQ 3 + +struct DICESettings +{ + uint Type; + // Determines where the highlights curve (shoulder) starts. + // Values between 0.25 and 0.5 are good with DICE by PQ (any type). + // With linear/rgb DICE this barely makes a difference, zero is a good default but (e.g.) 0.5 would also work. + // This should always be between 0 and 1. + float ShoulderStart; + + // For "Type == DICE_TYPE_BY_LUMINANCE_PQ_CORRECT_CHANNELS_BEYOND_PEAK_WHITE" only: + // The sum of these needs to be <= 1, both within 0 and 1. + // The closer the sum is to 1, the more each color channel will be containted within its peak range. + float DesaturationAmount; + float DarkeningAmount; +}; + +DICESettings DefaultDICESettings() +{ + DICESettings Settings; + Settings.Type = DICE_TYPE_BY_CHANNEL_PQ; + Settings.ShoulderStart = (Settings.Type >= DICE_TYPE_BY_LUMINANCE_RGB) ? (1.f / 4.f) : 0.f; + Settings.DesaturationAmount = 1.0 / 3.0; + Settings.DarkeningAmount = 1.0 / 3.0; + return Settings; +} + +// Tonemapper inspired from DICE. Can work by luminance to maintain hue. +// Takes scRGB colors with a white level (the value of 1 1 1) of 80 nits (sRGB) (to not be confused with paper white). +// Paper white is expected to have already been multiplied in. +float3 DICETonemap( + float3 Color, + float PeakWhite, + const DICESettings Settings) +{ + const float sourceLuminance = renodx::color::y::from::BT709(Color); + + if (Settings.Type != DICE_TYPE_BY_LUMINANCE_RGB) + { + static const float HDR10_MaxWhite = 10000.f / 80.f; + + const float shoulderStartPQ = Linear_to_PQ((Settings.ShoulderStart * PeakWhite) / HDR10_MaxWhite).x; + if (Settings.Type == DICE_TYPE_BY_LUMINANCE_PQ || Settings.Type == DICE_TYPE_BY_LUMINANCE_PQ_CORRECT_CHANNELS_BEYOND_PEAK_WHITE) + { + const float sourceLuminanceNormalized = sourceLuminance / HDR10_MaxWhite; + const float sourceLuminancePQ = Linear_to_PQ(sourceLuminanceNormalized, 1).x; + + if (sourceLuminancePQ > shoulderStartPQ) // Luminance below the shoulder (or below zero) don't need to be adjusted + { + const float peakWhitePQ = Linear_to_PQ(PeakWhite / HDR10_MaxWhite).x; + + const float compressedLuminancePQ = luminanceCompress(sourceLuminancePQ, peakWhitePQ, shoulderStartPQ); + const float compressedLuminanceNormalized = PQ_to_Linear(compressedLuminancePQ).x; + Color *= compressedLuminanceNormalized / sourceLuminanceNormalized; + + if (Settings.Type == DICE_TYPE_BY_LUMINANCE_PQ_CORRECT_CHANNELS_BEYOND_PEAK_WHITE) + { + float3 Color_BT2020 = renodx::color::bt2020::from::BT709(Color); + if (any(Color_BT2020 > PeakWhite)) // Optional "optimization" branch + { + float colorLuminance = renodx::color::y::from::BT2020(Color_BT2020); + float colorLuminanceInExcess = colorLuminance - PeakWhite; + float maxColorInExcess = max3(Color_BT2020) - PeakWhite; // This is guaranteed to be >= "colorLuminanceInExcess" + float brightnessReduction = saturate(renodx::math::SafeDivision(PeakWhite, max3(Color_BT2020), 1)); // Fall back to one in case of division by zero + float desaturateAlpha = saturate(renodx::math::SafeDivision(maxColorInExcess, maxColorInExcess - colorLuminanceInExcess, 0)); // Fall back to zero in case of division by zero + Color_BT2020 = lerp(Color_BT2020, colorLuminance, desaturateAlpha * Settings.DesaturationAmount); + Color_BT2020 = lerp(Color_BT2020, Color_BT2020 * brightnessReduction, Settings.DarkeningAmount); // Also reduce the brightness to partially maintain the hue, at the cost of brightness + Color = renodx::color::bt709::from::BT2020(Color_BT2020); + } + } + } + } + else // DICE_TYPE_BY_CHANNEL_PQ + { + const float peakWhitePQ = Linear_to_PQ(PeakWhite / HDR10_MaxWhite).x; + + // Tonemap in BT.2020 to more closely match the primaries of modern displays + const float3 sourceColorNormalized = renodx::color::bt2020::from::BT709(Color) / HDR10_MaxWhite; + const float3 sourceColorPQ = Linear_to_PQ(sourceColorNormalized, 1); + + for (uint i = 0; i < 3; i++) //TODO LUMA: optimize? will the shader compile already convert this to float3? Or should we already make a version with no branches that works in float3? + { + if (sourceColorPQ[i] > shoulderStartPQ) // Colors below the shoulder (or below zero) don't need to be adjusted + { + const float compressedColorPQ = luminanceCompress(sourceColorPQ[i], peakWhitePQ, shoulderStartPQ); + const float compressedColorNormalized = PQ_to_Linear(compressedColorPQ).x; + Color[i] = renodx::color::bt709::from::BT2020(Color[i] * (compressedColorNormalized / sourceColorNormalized[i])).x; + } + } + } + } + else // DICE_TYPE_BY_LUMINANCE_RGB + { + if (sourceLuminance > Settings.ShoulderStart) // Luminance below the shoulder (or below zero) don't need to be adjusted + { + const float compressedLuminance = luminanceCompress(sourceLuminance, PeakWhite, PeakWhite * Settings.ShoulderStart); + Color *= compressedLuminance / sourceLuminance; + } + } + + return Color; +} diff --git a/src/games/dbzspark/PQcolorcorrect_0xE82792CE.ps_5_1.hlsl b/src/games/dbzspark/PQcolorcorrect_0xE82792CE.ps_5_1.hlsl new file mode 100644 index 00000000..dab8af1f --- /dev/null +++ b/src/games/dbzspark/PQcolorcorrect_0xE82792CE.ps_5_1.hlsl @@ -0,0 +1,72 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 20:10:00 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s0_s : register(s0); + +cbuffer cb0 : register(b0) { + float4 cb0[8]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2; + uint4 bitmask, uiDest; + float4 fDest; + float3 tonemappedPQ, input_srgb, post_srgb, output; + + r0.xyzw = t0.Sample(s0_s, v0.xy).xyzw; + + r0.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r0.xyz); + r1.xyz = cmp(float3(0.0404499993, 0.0404499993, 0.0404499993) < r0.xyz); + r2.xyz = r0.xyz * float3(0.947867274, 0.947867274, 0.947867274) + float3(0.0521326996, 0.0521326996, 0.0521326996); + r2.xyz = log2(r2.xyz); + r2.xyz = float3(2.4000001, 2.4000001, 2.4000001) * r2.xyz; + r2.xyz = exp2(r2.xyz); + r0.xyz = float3(0.0773993805, 0.0773993805, 0.0773993805) * r0.xyz; + r0.xyz = r1.xyz ? r2.xyz : r0.xyz; + r1.x = dot(float3(0.627488017, 0.329267114, 0.0433014743), r0.xyz); + r1.y = dot(float3(0.069108218, 0.9195171, 0.0113595454), r0.xyz); + r1.z = dot(float3(0.0163962338, 0.0880229846, 0.895499706), r0.xyz); + r0.xyz = cb0[7].www * r1.xyz; + r1.xyz = t1.Sample(s0_s, v0.xy).xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r2.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r1.xyz; + r2.xyz = max(float3(0, 0, 0), r2.xyz); + r1.xyz = -r1.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r1.xyz = r2.xyz / r1.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(10000, 10000, 10000) * r1.xyz; + r1.w = cmp(0 < r0.w); + r2.x = cmp(r0.w < 1); + r1.w = r1.w ? r2.x : 0; + if (r1.w != 0) { + r1.w = dot(r1.xyz, float3(0.262699991, 0.677999973, 0.0593000017)); + r1.w = r1.w / cb0[7].z; + r1.w = 1 + r1.w; + r1.w = 1 / r1.w; + r1.w = r1.w * cb0[7].z + -1; + r1.w = r0.w * r1.w + 1; + r1.xyz = r1.xyz * r1.www; + } + r0.w = 1 + -r0.w; + r0.xyz = cb0[7].zzz * r0.xyz; + r0.xyz = r1.xyz * r0.www + r0.xyz; + o0.xyz = float3(0.0125000002, 0.0125000002, 0.0125000002) * r0.xyz; + o0.w = 1; + + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/addon.cpp b/src/games/dbzspark/addon.cpp new file mode 100644 index 00000000..9be1c16b --- /dev/null +++ b/src/games/dbzspark/addon.cpp @@ -0,0 +1,351 @@ +/* + * Copyright (C) 2023 Carlos Lopez + * SPDX-License-Identifier: MIT + */ + +// Empty addon just for running the game in HDR + +#define ImTextureID ImU64 + +#define DEBUG_LEVEL_0 + +#include +#include + +#include "../../mods/shader.hpp" +#include "../../mods/swapchain.hpp" +#include "../../utils/settings.hpp" +#include "./shared.h" + +#include // LUT +#include // LUT +#include // LUT +#include // Final +#include // Output +#include // Output +#include // Output +#include // LUT +#include // LUT +#include // Output + +#include // ColorCorrect +#include // ColorCorrect +#include // ColorCorrect +#include // ColorCorrect + +namespace { + +renodx::mods::shader::CustomShaders custom_shaders = { + CustomShaderEntry(0x2569985B), + CustomShaderEntry(0x31FE4421), + CustomShaderEntry(0x36E3A438), + CustomShaderEntry(0x4156562D), + CustomShaderEntry(0x4F06C1AD), + CustomShaderEntry(0x8C20620E), + CustomShaderEntry(0x9A3DADB2), + CustomShaderEntry(0xC2A711CC), + CustomShaderEntry(0xE2C936EB), + CustomShaderEntry(0xF554DE7A), + + // Color correctors + CustomShaderEntry(0x753DE2A9), + CustomShaderEntry(0x5975CAFA), + CustomShaderEntry(0xAB3F1A02), + CustomShaderEntry(0xD80F99B3), +}; + +ShaderInjectData shader_injection; +const std::string build_date = __DATE__; +const std::string build_time = __TIME__; + +renodx::utils::settings::Settings settings = { + new renodx::utils::settings::Setting{ + .key = "toneMapType", + .binding = &shader_injection.toneMapType, + .value_type = renodx::utils::settings::SettingValueType::INTEGER, + .default_value = 3.f, + .can_reset = false, + .label = "Tone Mapper", + .section = "Tone Mapping", + .tooltip = "Sets the tone mapper type", + .labels = {"Vanilla", "None", "ACES", "RenoDX"}, + }, + new renodx::utils::settings::Setting{ + .key = "toneMapDisplay", + .binding = &shader_injection.toneMapDisplay, + .value_type = renodx::utils::settings::SettingValueType::INTEGER, + .default_value = 1.f, + .can_reset = false, + .label = "Display Tone Mapper", + .section = "Tone Mapping", + .tooltip = "Sets an additional tonemapper run to map to peak", + .labels = {"Off", "DICE", "Reinhard", "Frostbite"}, + }, + new renodx::utils::settings::Setting{ + .key = "toneMapPeakNits", + .binding = &shader_injection.toneMapPeakNits, + .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 = 4000.f, + }, + new renodx::utils::settings::Setting{ + .key = "toneMapGameNits", + .binding = &shader_injection.toneMapGameNits, + .default_value = 80.f, + .label = "Game Brightness", + .section = "Tone Mapping", + .tooltip = "Sets the value of 100% white in nits", + .min = 48.f, + .max = 500.f, + }, + new renodx::utils::settings::Setting{ + .key = "toneMapUINits", + .binding = &shader_injection.toneMapUINits, + .default_value = 120.f, + .label = "UI Brightness", + .section = "Tone Mapping", + .tooltip = "Sets the brightness of UI and HUD elements in nits", + .min = 48.f, + .max = 500.f, + }, + new renodx::utils::settings::Setting{ + .key = "toneMapGammaCorrection", + .binding = &shader_injection.toneMapGammaCorrection, + .value_type = renodx::utils::settings::SettingValueType::BOOLEAN, + .default_value = 1.f, + .can_reset = false, + .label = "Gamma Correction", + .section = "Tone Mapping", + .tooltip = "Emulates a 2.2 EOTF (use with HDR or sRGB)", + }, + new renodx::utils::settings::Setting{ + .key = "toneMapHueCorrection", + .binding = &shader_injection.toneMapHueCorrection, + .default_value = 50.f, + .can_reset = true, + .label = "Hue Correction", + .section = "Tone Mapping", + .tooltip = "Emulates hue shifting from the vanilla tonemapper", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeExposure", + .binding = &shader_injection.colorGradeExposure, + .default_value = 1.f, + .label = "Exposure", + .section = "Color Grading", + .max = 10.f, + .format = "%.2f", + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeHighlights", + .binding = &shader_injection.colorGradeHighlights, + .default_value = 50.f, + .label = "Highlights", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeShadows", + .binding = &shader_injection.colorGradeShadows, + .default_value = 50.f, + .label = "Shadows", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeContrast", + .binding = &shader_injection.colorGradeContrast, + .default_value = 50.f, + .label = "Contrast", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeSaturation", + .binding = &shader_injection.colorGradeSaturation, + .default_value = 50.f, + .label = "Saturation", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.02f; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeLUTStrength", + .binding = &shader_injection.colorGradeLUTStrength, + .default_value = 100.f, + .label = "LUT Strength", + .section = "Color Grading", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .key = "colorGradeBlowout", + .binding = &shader_injection.colorGradeBlowout, + .default_value = 0.f, + .label = "Blowout", + .section = "Color Grading", + .tooltip = "Controls highlight desaturation due to overexposure.", + .max = 100.f, + .is_enabled = []() { return shader_injection.toneMapType > 1; }, + .parse = [](float value) { return value * 0.01f; }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::TEXT, + .label = " - Please enable Native HDR in game!", + .section = "Instructions", + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::TEXT, + .label = "Special thanks to Shortfuse & the folks at HDR Den for their support! Join the HDR Den discord for help!", + .section = "About", + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "HDR Den Discord", + .section = "About", + .group = "button-line-1", + .tint = 0x5865F2, + .on_change = []() { + static const std::string obfuscated_link = std::string("start https://discord.gg/5WZX") + std::string("DpmbpP"); + system(obfuscated_link.c_str()); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "Get more RenoDX mods!", + .section = "About", + .group = "button-line-1", + .tint = 0x5865F2, + .on_change = []() { + system("start https://github.com/clshortfuse/renodx/wiki/Mods"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "ShortFuse's Ko-Fi", + .section = "About", + .group = "button-line-1", + .tint = 0xFF5F5F, + .on_change = []() { + system("start https://ko-fi.com/shortfuse"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "HDR Den's Ko-Fi", + .section = "About", + .group = "button-line-1", + .tint = 0xFF5F5F, + .on_change = []() { + system("start https://ko-fi.com/hdrden"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::TEXT, + .label = "This build was compiled on " + build_date + " at " + build_time + ".", + .section = "About", + }, +}; + +void OnPresetOff() { + renodx::utils::settings::UpdateSetting("toneMapType", 0.f); + renodx::utils::settings::UpdateSetting("toneMapDisplay", 0.f); + renodx::utils::settings::UpdateSetting("toneMapPeakNits", 203.f); + renodx::utils::settings::UpdateSetting("toneMapGameNits", 150.f); + renodx::utils::settings::UpdateSetting("toneMapUINits", 120.f); + renodx::utils::settings::UpdateSetting("toneMapGammaCorrection", 1.f); + renodx::utils::settings::UpdateSetting("toneMapDice", 1.f); + renodx::utils::settings::UpdateSetting("toneMapHueCorrection", 1.f); + renodx::utils::settings::UpdateSetting("colorGradeExposure", 1.f); + renodx::utils::settings::UpdateSetting("colorGradeHighlights", 50.f); + renodx::utils::settings::UpdateSetting("colorGradeShadows", 50.f); + renodx::utils::settings::UpdateSetting("colorGradeContrast", 50.f); + renodx::utils::settings::UpdateSetting("colorGradeSaturation", 50.f); + renodx::utils::settings::UpdateSetting("colorGradeLUTStrength", 100.f); + renodx::utils::settings::UpdateSetting("colorGradeBlowout", 0.f); +} + +} // namespace + +// NOLINTBEGIN(readability-identifier-naming) + +extern "C" __declspec(dllexport) const char* NAME = "RenoDX DBZSPARK"; +extern "C" __declspec(dllexport) const char* DESCRIPTION = "RenoDX DBZSPARK"; + +// NOLINTEND(readability-identifier-naming) + +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; + renodx::mods::shader::on_init_pipeline_layout = [](reshade::api::device* device, auto, auto) { + return device->get_api() == reshade::api::device_api::d3d12; + }; + renodx::mods::shader::force_pipeline_cloning = true; // So the mod works with the toolkit + renodx::mods::shader::expected_constant_buffer_space = 50; + + // RGBA8_unorm + /* renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ + .old_format = reshade::api::format::r8g8b8a8_unorm, + .new_format = reshade::api::format::r16g16b16a16_float, + }); */ + // RGBA8_unorm_srgb + /* renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ + .old_format = reshade::api::format::r8g8b8a8_unorm_srgb, + .new_format = reshade::api::format::r16g16b16a16_float, + }); */ + + // RGB10A2_unorm + /* renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ + .old_format = reshade::api::format::r10g10b10a2_unorm, + .new_format = reshade::api::format::r16g16b16a16_float, + }); + + // R11G11B10_float + renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ + .old_format = reshade::api::format::r11g11b10_float, + .new_format = reshade::api::format::r16g16b16a16_float, + }); + + // BGRA8_unorm + renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ + .old_format = reshade::api::format::b8g8r8a8_unorm, + .new_format = reshade::api::format::r16g16b16a16_float, + }); + + // BGRA8_unorm_srgb + renodx::mods::swapchain::swap_chain_upgrade_targets.push_back({ + .old_format = reshade::api::format::b8g8r8a8_unorm_srgb, + .new_format = reshade::api::format::r16g16b16a16_float, + }); */ + + break; + case DLL_PROCESS_DETACH: + reshade::unregister_addon(h_module); + break; + } + + renodx::utils::settings::Use(fdw_reason, &settings, &OnPresetOff); + + // renodx::mods::swapchain::Use(fdw_reason); + + renodx::mods::shader::Use(fdw_reason, custom_shaders, &shader_injection); + + return TRUE; +} diff --git a/src/games/dbzspark/colorcorrect_0x5975CAFA.ps_5_1.hlsl b/src/games/dbzspark/colorcorrect_0x5975CAFA.ps_5_1.hlsl new file mode 100644 index 00000000..fe768fc1 --- /dev/null +++ b/src/games/dbzspark/colorcorrect_0x5975CAFA.ps_5_1.hlsl @@ -0,0 +1,255 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 20:09:30 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t5 : register(t5); + +Texture2D t4 : register(t4); + +Texture2D t3 : register(t3); + +Texture2D t2 : register(t2); + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s2_s : register(s2); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb2 : register(b2) { + float4 cb2[11]; +} + +cbuffer cb1 : register(b1) { + float4 cb1[136]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[39]; +} + +// 3Dmigoto declarations +#define cmp - + +// Adjusts colors +// THIS IS ALSO CALLED FOR SHOP +// There's also light shafts shader getting called later +void main( + float4 v0 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10; + uint4 bitmask, uiDest; + float4 fDest; + float3 tonemappedPQ, post_srgb; + + r0.xy = asuint(cb0[37].xy); + r0.xy = v0.xy + -r0.xy; + r0.xy = cb0[38].zw * r0.xy; + r0.zw = r0.xy * cb0[5].xy + cb0[4].xy; + r1.xyz = t5.Sample(s2_s, r0.zw).xyz; + + tonemappedPQ = r1.rgb; + + r1.rgb = pqTosRGB(tonemappedPQ, true); + + r0.zw = r0.xy * cb1[129].xy + cb1[128].xy; + r0.zw = cb1[132].zw * r0.zw; + r1.w = t1.SampleLevel(s0_s, r0.zw, 0).x; + r2.xyz = -cb2[3].xyz + r1.xyz; + r2.xyz = r1.www * r2.xyz + cb2[3].xyz; + r2.xyz = r2.xyz + -r1.xyz; + r3.xyz = cb2[4].xxx * r2.xyz; + r2.xyz = cb2[4].xxx * r2.xyz + r1.xyz; + r1.w = t2.SampleLevel(s0_s, r0.zw, 0).x; + r2.w = r1.w * cb1[71].x + cb1[71].y; + r1.w = r1.w * cb1[71].z + -cb1[71].w; + r1.w = 1 / r1.w; + r1.w = r2.w + r1.w; + r4.xy = cb1[132].xy * r0.zw; + r4.xy = cb1[135].xy * r4.xy; + r4.xy = trunc(r4.xy); + r4.xy = (int2)r4.xy; + r4.zw = float2(0, 0); + r2.w = t3.Load(r4.xyz).y; + r2.w = (uint)r2.w; + r0.z = t0.SampleLevel(s0_s, r0.zw, 0).x; + r0.w = r0.z * cb1[71].x + cb1[71].y; + r0.z = r0.z * cb1[71].z + -cb1[71].w; + r0.z = 1 / r0.z; + r0.z = r0.w + r0.z; + r0.w = -cb2[4].z + r2.w; + r0.w = cmp(9.99999975e-06 < abs(r0.w)); + r0.w = r0.w ? -0 : -r0.z; + r0.w = r1.w + r0.w; + r1.w = r1.w + -r0.z; + r2.w = cmp(9.99999975e-06 < abs(cb2[4].w)); + r3.w = cmp(cb2[4].w >= 0); + r0.w = r3.w ? r0.w : r1.w; + r0.w = r2.w ? r0.w : r1.w; + r0.w = saturate(ceil(r0.w)); + r0.w = 1 + -r0.w; + r3.xyz = r0.www * r3.xyz + r1.xyz; + r0.w = cmp(9.99999975e-06 < abs(cb2[5].x)); + r1.w = cmp(cb2[5].x >= 0); + r3.xyz = r1.www ? r3.xyz : r2.xyz; + r2.xyz = r0.www ? r3.xyz : r2.xyz; + r3.xyz = float3(1, 1, 1) + -r1.xyz; + r4.xyz = r3.xyz / r2.xyz; + r4.xyz = float3(1, 1, 1) + -r4.xyz; + r0.w = cmp(cb2[5].y != 1.000000); + if (r0.w != 0) { + r5.xyz = float3(1, 1, 1) + -r2.xyz; + r6.xyz = r1.xyz / r5.xyz; + r0.w = cmp(cb2[5].y == 2.000000); + r4.xyz = r0.www ? r6.xyz : r4.xyz; + if (r0.w == 0) { + r6.xyz = -r2.xyz + r1.xyz; + r0.w = cmp(cb2[5].y == 3.000000); + r4.xyz = r0.www ? abs(r6.xyz) : r4.xyz; + if (r0.w == 0) { + r6.xyz = float3(-0.5, -0.5, -0.5) + r1.xyz; + r7.xyz = float3(-0.5, -0.5, -0.5) + r2.xyz; + r6.xyz = r7.xyz * r6.xyz; + r6.xyz = -r6.xyz * float3(2, 2, 2) + float3(0.5, 0.5, 0.5); + r0.w = cmp(cb2[5].y == 4.000000); + r4.xyz = r0.www ? r6.xyz : r4.xyz; + if (r0.w == 0) { + r6.xyz = r7.xyz + r7.xyz; + r7.xyz = -r7.xyz * float3(2, 2, 2) + float3(1, 1, 1); + r7.xyz = -r3.xyz * r7.xyz + float3(1, 1, 1); + r8.xyz = r2.xyz + r2.xyz; + r9.xyz = r8.xyz * r1.xyz; + r10.xyz = cmp(r2.xyz >= float3(0.5, 0.5, 0.5)); + r7.xyz = r10.xyz ? r7.xyz : r9.xyz; + r0.w = cmp(cb2[5].y == 5.000000); + r4.xyz = r0.www ? abs(r7.xyz) : r4.xyz; + if (r0.w == 0) { + r7.xyz = r2.xyz + r1.xyz; + r9.xyz = float3(-1, -1, -1) + r7.xyz; + r0.w = cmp(cb2[5].y == 6.000000); + r4.xyz = r0.www ? r9.xyz : r4.xyz; + if (r0.w == 0) { + r0.w = cmp(cb2[5].y == 7.000000); + r4.xyz = r0.www ? r7.xyz : r4.xyz; + if (r0.w == 0) { + r7.xyz = float3(-0.125, -0.125, -0.125) + r2.xyz; + r7.xyz = r7.xyz * float3(1.25, 1.25, 1.25) + r1.xyz; + r9.xyz = float3(-0.25, -0.25, -0.25) + r2.xyz; + r9.xyz = r9.xyz * float3(2, 2, 2) + r1.xyz; + r7.xyz = r10.xyz ? r7.xyz : r9.xyz; + r0.w = cmp(cb2[5].y == 8.000000); + r4.xyz = r0.www ? r7.xyz : r4.xyz; + if (r0.w == 0) { + r6.xyz = max(r6.xyz, r1.xyz); + r7.xyz = min(r8.xyz, r1.xyz); + r6.xyz = r10.xyz ? r6.xyz : r7.xyz; + r0.w = cmp(cb2[5].y == 9.000000); + r4.xyz = r0.www ? r6.xyz : r4.xyz; + if (r0.w == 0) { + r6.xyz = -r2.xyz * float3(2, 2, 2) + float3(1, 1, 1); + r6.xyz = -r6.xyz * r3.xyz + float3(1, 1, 1); + r6.xyz = r6.xyz * r1.xyz; + r7.xyz = -r1.xyz * r8.xyz + float3(1, 1, 1); + r7.xyz = -r3.xyz * r7.xyz + float3(1, 1, 1); + r6.xyz = r10.xyz ? r6.xyz : r7.xyz; + r0.w = cmp(cb2[5].y == 10.000000); + r4.xyz = r0.www ? r6.xyz : r4.xyz; + if (r0.w == 0) { + r6.xyz = r5.xyz * r3.xyz; + r3.xyz = -r3.xyz * r5.xyz + float3(1, 1, 1); + r0.w = cmp(cb2[5].y == 11.000000); + r4.xyz = r0.www ? r3.xyz : r4.xyz; + if (r0.w == 0) { + r3.xyz = max(r2.xyz, r1.xyz); + r0.w = cmp(cb2[5].y == 12.000000); + r4.xyz = r0.www ? r3.xyz : r4.xyz; + if (r0.w == 0) { + r3.xyz = min(r2.xyz, r1.xyz); + r0.w = cmp(cb2[5].y == 13.000000); + r4.xyz = r0.www ? r3.xyz : r4.xyz; + + if (r0.w == 0) { + // Main Menu stops here + r3.xyz = cmp(r1.xyz < float3(0.5, 0.5, 0.5)); + r5.xyz = r2.xyz * r1.xyz; + r7.xyz = r5.xyz + r5.xyz; + r6.xyz = -r6.xyz * float3(2, 2, 2) + float3(1, 1, 1); + r3.xyz = r3.xyz ? r7.xyz : r6.xyz; + + r0.w = cmp(cb2[5].y == 14.000000); + r4.xyz = r0.www ? r3.xyz : r4.xyz; + // r4.rgb = float3(1, 0, 0.5); + + if (r0.w == 0) { + r0.w = cmp(cb2[5].y == 15.000000); + r4.xyz = r0.www ? r5.xyz : r4.xyz; + + if (r0.w == 0) { + r0.w = cmp(cb2[5].y != 16.000000); + + if (r0.w != 0) { + r3.xyzw = cmp(cb2[5].yyyy == float4(17, 18, 19, 20)); + r0.w = (int)r3.y | (int)r3.x; + r5.xyz = r0.www ? float3(0, 0, 0) : r4.xyz; + r0.w = (int)r3.z | (int)r0.w; + r6.xyz = r0.www ? float3(0, 0, 0) : r4.xyz; + r0.w = (int)r3.w | (int)r0.w; + r7.xyz = r0.www ? float3(0, 0, 0) : r4.xyz; + r2.xyz = r3.www ? r7.xyz : r2.xyz; + r2.xyz = r3.zzz ? r6.xyz : r2.xyz; + r2.xyz = r3.yyy ? r5.xyz : r2.xyz; + r4.xyz = r3.xxx ? float3(0, 0, 0) : r2.xyz; + + } else { + r4.xyz = float3(0, 0, 0); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + // r4 here has invalid colors + r2.xyz = r4.xyz + -r1.xyz; + r2.xyz = cb2[5].zzz * r2.xyz; + r0.xy = r0.xy * cb2[7].xy + float2(0.5, 0.5); + r0.xy = -cb2[7].zw + r0.xy; + r0.x = t4.Sample(s1_s, r0.xy).x; + r0.xyw = r0.xxx * r2.xyz; + r0.z = cb2[8].z * r0.z; + r1.w = cmp(0 >= r0.z); + r0.z = log2(r0.z); + r0.z = cb2[8].w * r0.z; + r0.z = exp2(r0.z); + r0.z = min(1, r0.z); + r0.z = r1.w ? 0 : r0.z; + r1.w = 1 + -r0.z; + r2.x = cmp(9.99999975e-06 < abs(cb2[9].x)); + r2.y = cmp(cb2[9].x >= 0); + r1.w = r2.y ? r1.w : r0.z; + r0.z = r2.x ? r1.w : r0.z; + r0.xyz = r0.zzz * r0.xyw + r1.xyz; + r1.xyz = cb2[10].xyz + -r0.xyz; + r0.xyz = cb2[9].yyy * r1.xyz + r0.xyz; + o0.xyz = max(float3(0, 0, 0), r0.xyz); + post_srgb = o0.rgb; + o0.w = 0; + + o0.rgb = upgradeSRGBtoPQ(tonemappedPQ, post_srgb); + // o0.rgb = tonemappedPQ; + + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/colorcorrect_0x753DE2A9.ps_5_1.hlsl b/src/games/dbzspark/colorcorrect_0x753DE2A9.ps_5_1.hlsl new file mode 100644 index 00000000..54672b0f --- /dev/null +++ b/src/games/dbzspark/colorcorrect_0x753DE2A9.ps_5_1.hlsl @@ -0,0 +1,67 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 20:09:35 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t0 : register(t0); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[7]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[39]; +} + +// 3Dmigoto declarations +#define cmp - + +// Increases brightness +void main( + float4 v0 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1; + uint4 bitmask, uiDest; + float4 fDest; + float3 tonemappedPQ, post_srgb, output; + + r0.xy = asuint(cb0[37].xy); + r0.xy = v0.xy + -r0.xy; + r0.zw = r0.xy * cb0[38].zw + cb1[1].zw; + r0.xy = cb0[38].zw * r0.xy; + r0.xy = r0.xy * cb0[5].xy + cb0[4].xy; + r0.zw = float2(-0.5, -0.5) + r0.zw; + r0.z = dot(r0.zw, cb1[4].xy); + r0.z = 0.5 + r0.z; + r0.w = 1 + -r0.z; + r0.z = r0.z * r0.w + cb1[4].z; + r0.w = log2(r0.z); + r0.z = cmp(0 >= r0.z); + r0.w = cb1[4].w * r0.w; + r0.w = exp2(r0.w); + r0.w = min(1, r0.w); + r0.z = r0.z ? 0 : r0.w; + r1.xyz = t0.Sample(s0_s, r0.xy).xyz; + r0.xyw = t0.Sample(s1_s, r0.xy).xyz; + + // Both are game render so we srgb both + tonemappedPQ = r1.xyz; + r0.xyw = pqTosRGB(r0.xyw); + r1.xyz = pqTosRGB(r1.xyz); + + r1.xyz = r1.xyz * r0.zzz + -r0.xyw; + r0.xyz = cb1[5].xxx * r1.xyz + r0.xyw; + r1.xyz = cb1[6].xyz + -r0.xyz; + r0.xyz = cb1[5].yyy * r1.xyz + r0.xyz; + o0.xyz = max(float3(0, 0, 0), r0.xyz); + post_srgb = o0.rgb; + o0.w = 0; + + o0.rgb = upgradeSRGBtoPQ(tonemappedPQ, post_srgb); + // o0.rgb = tonemappedPQ; + + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/colorcorrect_0xAB3F1A02.ps_5_1.hlsl b/src/games/dbzspark/colorcorrect_0xAB3F1A02.ps_5_1.hlsl new file mode 100644 index 00000000..16d12bbe --- /dev/null +++ b/src/games/dbzspark/colorcorrect_0xAB3F1A02.ps_5_1.hlsl @@ -0,0 +1,58 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 20:09:46 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t0 : register(t0); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[4]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[39]; +} + +// 3Dmigoto declarations +#define cmp - + +// Increasess brightness and messes up colors +// THIS IS FOR SHOP, it expects aces SDR output +void main( + float4 v0 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1; + uint4 bitmask, uiDest; + float4 fDest; + float3 tonemappedPQ, post_srgb; + + r0.xy = asuint(cb0[37].xy); + r0.xy = v0.xy + -r0.xy; + r0.xy = cb0[38].zw * r0.xy; + r0.xy = r0.xy * cb0[5].xy + cb0[4].xy; + r0.xyz = t0.Sample(s0_s, r0.xy).xyz; + + tonemappedPQ = r0.xyz; + r0.rgb = pqTosRGB(tonemappedPQ); + + r1.xyz = cb1[2].xxx + -cb1[2].yzw; + r1.xyz = r0.xyz * r1.xyz + cb1[2].yzw; + + r1.xyz = max(float3(0, 0, 0), r1.xyz); + r1.xyz = min(float3(100, 100, 100), r1.xyz); + + r1.xyz = r1.xyz + -r0.xyz; + r0.xyz = r1.xyz * float3(0.5, 0.5, 0.5) + r0.xyz; + + r1.xyz = cb1[3].yzw + -r0.xyz; + r0.xyz = cb1[3].xxx * r1.xyz + r0.xyz; + o0.xyz = max(float3(0, 0, 0), r0.xyz); + + post_srgb = o0.rgb; + + o0.rgb = upgradeSRGBtoPQ(tonemappedPQ, post_srgb); + // o0.rgb = tonemappedPQ; + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/colorcorrect_0xD80F99B3.ps_5_1.hlsl b/src/games/dbzspark/colorcorrect_0xD80F99B3.ps_5_1.hlsl new file mode 100644 index 00000000..0349dd78 --- /dev/null +++ b/src/games/dbzspark/colorcorrect_0xD80F99B3.ps_5_1.hlsl @@ -0,0 +1,240 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 20:09:56 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t4 : register(t4); + +Texture2D t3 : register(t3); + +Texture2D t2 : register(t2); + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s3_s : register(s3); + +SamplerState s2_s : register(s2); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb2 : register(b2) { + float4 cb2[8]; +} + +cbuffer cb1 : register(b1) { + float4 cb1[136]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[39]; +} + +// 3Dmigoto declarations +#define cmp - + +// Adjusts colors +void main( + float4 v0 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11; + uint4 bitmask, uiDest; + float4 fDest; + float3 tonemappedPQ, post_srgb, output; + + r0.xy = asuint(cb0[37].xy); + r0.xy = v0.xy + -r0.xy; + r0.xy = cb0[38].zw * r0.xy; + r0.zw = r0.xy * cb0[5].xy + cb0[4].xy; + r1.xyz = t4.Sample(s3_s, r0.zw).xyz; + r2.xyz = t4.Sample(s2_s, r0.zw).xyz; + + tonemappedPQ = r1.rgb; + r1.rgb = pqTosRGB(r1.rgb); + r2.rgb = pqTosRGB(r2.rgb); + + r3.xyz = cb2[1].xyz * r2.xyz; + r0.zw = r0.xy * cb1[129].xy + cb1[128].xy; + r0.zw = cb1[132].zw * r0.zw; + r1.w = t1.SampleLevel(s0_s, r0.zw, 0).x; + r2.w = r1.w * cb1[71].x + cb1[71].y; + r1.w = r1.w * cb1[71].z + -cb1[71].w; + r1.w = 1 / r1.w; + r1.w = r2.w + r1.w; + r4.xy = cb1[132].xy * r0.zw; + r4.xy = cb1[135].xy * r4.xy; + r4.xy = trunc(r4.xy); + r4.xy = (int2)r4.xy; + r4.zw = float2(0, 0); + r2.w = t2.Load(r4.xyz).y; + r2.w = (uint)r2.w; + r0.z = t0.SampleLevel(s0_s, r0.zw, 0).x; + r0.w = r0.z * cb1[71].x + cb1[71].y; + r0.z = r0.z * cb1[71].z + -cb1[71].w; + r0.z = 1 / r0.z; + r0.z = r0.w + r0.z; + r0.w = -cb2[2].x + r2.w; + r0.w = cmp(9.99999975e-06 < abs(r0.w)); + r0.w = r0.w ? -0 : -r0.z; + r0.w = r1.w + r0.w; + r1.w = r1.w + -r0.z; + r4.xy = cmp(float2(9.99999975e-06, 9.99999975e-06) < abs(cb2[2].yz)); + r4.zw = cmp(cb2[2].yz >= float2(0, 0)); + r0.w = r4.z ? r0.w : r1.w; + r0.w = r4.x ? r0.w : r1.w; + r0.w = saturate(ceil(r0.w)); + r0.w = 1 + -r0.w; + r5.xyz = cb2[1].xyz * r2.xyz + -r2.xyz; + r5.xyz = r0.www * r5.xyz + r2.xyz; + r4.xzw = r4.www ? r5.xyz : r3.xyz; + r3.xyz = r4.yyy ? r4.xzw : r3.xyz; + r4.xyz = float3(1, 1, 1) + -r2.xyz; + r5.xyz = r4.xyz / r3.xyz; + r5.xyz = float3(1, 1, 1) + -r5.xyz; + r0.w = cmp(cb2[2].w != 1.000000); + if (r0.w != 0) { + r6.xyz = float3(1, 1, 1) + -r3.xyz; + r7.xyz = r2.xyz / r6.xyz; + r0.w = cmp(cb2[2].w == 2.000000); + r5.xyz = r0.www ? r7.xyz : r5.xyz; + if (r0.w == 0) { + r7.xyz = -r3.xyz + r2.xyz; + r0.w = cmp(cb2[2].w == 3.000000); + r5.xyz = r0.www ? abs(r7.xyz) : r5.xyz; + if (r0.w == 0) { + r7.xyz = float3(-0.5, -0.5, -0.5) + r2.xyz; + r8.xyz = float3(-0.5, -0.5, -0.5) + r3.xyz; + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = -r7.xyz * float3(2, 2, 2) + float3(0.5, 0.5, 0.5); + r0.w = cmp(cb2[2].w == 4.000000); + r5.xyz = r0.www ? r7.xyz : r5.xyz; + if (r0.w == 0) { + r7.xyz = r8.xyz + r8.xyz; + r8.xyz = -r8.xyz * float3(2, 2, 2) + float3(1, 1, 1); + r8.xyz = -r4.xyz * r8.xyz + float3(1, 1, 1); + r9.xyz = r3.xyz + r3.xyz; + r10.xyz = r9.xyz * r2.xyz; + r11.xyz = cmp(r3.xyz >= float3(0.5, 0.5, 0.5)); + r8.xyz = r11.xyz ? r8.xyz : r10.xyz; + r0.w = cmp(cb2[2].w == 5.000000); + r5.xyz = r0.www ? abs(r8.xyz) : r5.xyz; + if (r0.w == 0) { + r8.xyz = r3.xyz + r2.xyz; + r10.xyz = float3(-1, -1, -1) + r8.xyz; + r0.w = cmp(cb2[2].w == 6.000000); + r5.xyz = r0.www ? r10.xyz : r5.xyz; + if (r0.w == 0) { + r0.w = cmp(cb2[2].w == 7.000000); + r5.xyz = r0.www ? r8.xyz : r5.xyz; + if (r0.w == 0) { + r8.xyz = float3(-0.125, -0.125, -0.125) + r3.xyz; + r8.xyz = r8.xyz * float3(1.25, 1.25, 1.25) + r2.xyz; + r10.xyz = float3(-0.25, -0.25, -0.25) + r3.xyz; + r10.xyz = r10.xyz * float3(2, 2, 2) + r2.xyz; + r8.xyz = r11.xyz ? r8.xyz : r10.xyz; + r0.w = cmp(cb2[2].w == 8.000000); + r5.xyz = r0.www ? r8.xyz : r5.xyz; + if (r0.w == 0) { + r7.xyz = max(r7.xyz, r2.xyz); + r8.xyz = min(r9.xyz, r2.xyz); + r7.xyz = r11.xyz ? r7.xyz : r8.xyz; + r0.w = cmp(cb2[2].w == 9.000000); + r5.xyz = r0.www ? r7.xyz : r5.xyz; + if (r0.w == 0) { + r7.xyz = -r3.xyz * float3(2, 2, 2) + float3(1, 1, 1); + r7.xyz = -r7.xyz * r4.xyz + float3(1, 1, 1); + r7.xyz = r7.xyz * r2.xyz; + r8.xyz = -r2.xyz * r9.xyz + float3(1, 1, 1); + r8.xyz = -r4.xyz * r8.xyz + float3(1, 1, 1); + r7.xyz = r11.xyz ? r7.xyz : r8.xyz; + r0.w = cmp(cb2[2].w == 10.000000); + r5.xyz = r0.www ? r7.xyz : r5.xyz; + if (r0.w == 0) { + r7.xyz = r6.xyz * r4.xyz; + r4.xyz = -r4.xyz * r6.xyz + float3(1, 1, 1); + r0.w = cmp(cb2[2].w == 11.000000); + r5.xyz = r0.www ? r4.xyz : r5.xyz; + if (r0.w == 0) { + r4.xyz = max(r3.xyz, r2.xyz); + r0.w = cmp(cb2[2].w == 12.000000); + r5.xyz = r0.www ? r4.xyz : r5.xyz; + if (r0.w == 0) { + r4.xyz = min(r3.xyz, r2.xyz); + r0.w = cmp(cb2[2].w == 13.000000); + r5.xyz = r0.www ? r4.xyz : r5.xyz; + if (r0.w == 0) { + r4.xyz = cmp(r2.xyz < float3(0.5, 0.5, 0.5)); + r6.xyz = r3.xyz * r2.xyz; + r8.xyz = r6.xyz + r6.xyz; + r7.xyz = -r7.xyz * float3(2, 2, 2) + float3(1, 1, 1); + r4.xyz = r4.xyz ? r8.xyz : r7.xyz; + r0.w = cmp(cb2[2].w == 14.000000); + r5.xyz = r0.www ? r4.xyz : r5.xyz; + if (r0.w == 0) { + r0.w = cmp(cb2[2].w == 15.000000); + r5.xyz = r0.www ? r6.xyz : r5.xyz; + if (r0.w == 0) { + r0.w = cmp(cb2[2].w != 16.000000); + if (r0.w != 0) { + r4.xyzw = cmp(cb2[2].wwww == float4(17, 18, 19, 20)); + r0.w = (int)r4.y | (int)r4.x; + r6.xyz = r0.www ? float3(0, 0, 0) : r5.xyz; + r0.w = (int)r4.z | (int)r0.w; + r7.xyz = r0.www ? float3(0, 0, 0) : r5.xyz; + r0.w = (int)r4.w | (int)r0.w; + r8.xyz = r0.www ? float3(0, 0, 0) : r5.xyz; + r3.xyz = r4.www ? r8.xyz : r3.xyz; + r3.xyz = r4.zzz ? r7.xyz : r3.xyz; + r3.xyz = r4.yyy ? r6.xyz : r3.xyz; + r5.xyz = r4.xxx ? float3(0, 0, 0) : r3.xyz; + } else { + r5.xyz = float3(0, 0, 0); + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + r3.xyz = r5.xyz + -r2.xyz; + r3.xyz = cb2[3].xxx * r3.xyz; + r0.xy = r0.xy * cb2[4].zw + float2(0.5, 0.5); + r0.xy = -cb2[5].xy + r0.xy; + r0.x = t3.Sample(s1_s, r0.xy).x; + r0.xyw = r0.xxx * r3.xyz; + r0.z = cb2[6].x * r0.z; + r1.w = cmp(0 >= r0.z); + r0.z = log2(r0.z); + r0.z = cb2[6].y * r0.z; + r0.z = exp2(r0.z); + r0.z = min(1, r0.z); + r0.z = r1.w ? 0 : r0.z; + r1.w = 1 + -r0.z; + r2.w = cmp(9.99999975e-06 < abs(cb2[6].z)); + r3.x = cmp(cb2[6].z >= 0); + r1.w = r3.x ? r1.w : r0.z; + r0.z = r2.w ? r1.w : r0.z; + r0.xyz = r0.zzz * r0.xyw + r2.xyz; + r0.xyz = r0.xyz + -r1.xyz; + r0.xyz = cb2[6].www * r0.xyz + r1.xyz; + r1.xyz = cb2[7].yzw + -r0.xyz; + r0.xyz = cb2[7].xxx * r1.xyz + r0.xyz; + o0.xyz = max(float3(0, 0, 0), r0.xyz); + post_srgb = o0.rgb; + o0.w = 0; + + o0.rgb = upgradeSRGBtoPQ(tonemappedPQ, post_srgb); + // o0.rgb = tonemappedPQ; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/final00_0x4156562D.ps_5_1.hlsl b/src/games/dbzspark/final00_0x4156562D.ps_5_1.hlsl new file mode 100644 index 00000000..dc86af09 --- /dev/null +++ b/src/games/dbzspark/final00_0x4156562D.ps_5_1.hlsl @@ -0,0 +1,165 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:09 2024 +#include "./DICE.hlsl" +#include "./shared.h" + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb0 : register(b0) { + float4 cb0[8]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2; + uint4 bitmask, uiDest; + float4 fDest; + + r0.xyzw = t0.Sample(s0_s, v0.xy).xyzw; // UI bt2020 + + r0.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r0.xyz); + r1.xyz = cmp(float3(0.0404499993, 0.0404499993, 0.0404499993) < r0.xyz); + r2.xyz = r0.xyz * float3(0.947867274, 0.947867274, 0.947867274) + float3(0.0521326996, 0.0521326996, 0.0521326996); + r2.xyz = log2(r2.xyz); + r2.xyz = float3(2.4000001, 2.4000001, 2.4000001) * r2.xyz; + r2.xyz = exp2(r2.xyz); + r0.xyz = float3(0.0773993805, 0.0773993805, 0.0773993805) * r0.xyz; + r0.xyz = r1.xyz ? r2.xyz : r0.xyz; + r1.x = dot(float3(0.627488017, 0.329267114, 0.0433014743), r0.xyz); + r1.y = dot(float3(0.069108218, 0.9195171, 0.0113595454), r0.xyz); + r1.z = dot(float3(0.0163962338, 0.0880229846, 0.895499706), r0.xyz); + r0.xyz = cb0[7].www * r1.xyz; + + // We don't need WCG UI + r0.rgb = renodx::color::bt709::from::BT2020(r0.rgb); + if (injectedData.toneMapType > 1.f) { + r0.rgb = max(0, r0.rgb); + } + if (injectedData.toneMapGammaCorrection == 1.f) { + r0.rgb = renodx::color::correct::GammaSafe(r0.rgb); + } + r0.rgb = renodx::color::bt2020::from::BT709(r0.rgb); + r0.rgb *= injectedData.toneMapUINits / 203.f; // Value found so it matches tonemapUINits + + r1.xyz = t1.Sample(s1_s, v0.xy).xyz; // Game in PQ + if (injectedData.toneMapType > 1.f) { + r1.rgb = renodx::color::pq::Decode(r1.rgb, 80.f); + + r1.rgb = renodx::color::bt709::from::BT2020(r1.rgb); + r1.rgb = renodx::color::grade::UserColorGrading( + r1.rgb, + injectedData.colorGradeExposure, + injectedData.colorGradeHighlights, + injectedData.colorGradeShadows, + injectedData.colorGradeContrast, + 1.f); // We'll do saturation post tonemap + + const float dicePaperWhite = injectedData.toneMapGameNits / 80.f; + const float dicePeakWhite = injectedData.toneMapPeakNits / 80.f; + const float highlightsShoulderStart = 0.3; // Random value honestly + const float frostReinPeak = injectedData.toneMapPeakNits / injectedData.toneMapGameNits; + + // Tonemap adjustments from color correctors + if (injectedData.toneMapDisplay == 1.f) { + DICESettings config = DefaultDICESettings(); + config.Type = 1; + config.ShoulderStart = highlightsShoulderStart; + + r1.rgb = DICETonemap(r1.rgb * dicePaperWhite, dicePeakWhite, config) / dicePaperWhite; + } else if (injectedData.toneMapDisplay == 2.f) { + r1.rgb = renodx::tonemap::frostbite::BT709(r1.rgb, frostReinPeak); + } else if (injectedData.toneMapDisplay == 3.f) { + r1.rgb = renodx::tonemap::ReinhardScalable(r1.rgb, frostReinPeak); + } + + r1.rgb = renodx::color::grade::UserColorGrading( + r1.rgb, + 1.f, + 1.f, + 1.f, + 1.f, + injectedData.colorGradeSaturation); + + if (injectedData.toneMapGammaCorrection == 1.f) { + r1.rgb = renodx::color::correct::GammaSafe(r1.rgb); + } + + r1.rgb = renodx::color::bt2020::from::BT709(r1.rgb); + r1.rgb = max(0, r1.rgb); + r1.rgb = renodx::color::pq::Encode(r1.rgb, 80.f); + } + + r1.rgb = renodx::color::pq::Decode(r1.rgb, 1.f); // We need it to merge with UI + + /* // pow(in_color, 1.f / M2) + r1.xyz = log2(r1.xyz); + r1.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r1.xyz; + r1.xyz = exp2(r1.xyz); + // max(e_m12 - C1, 0) + r2.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r1.xyz; + r2.xyz = max(float3(0, 0, 0), r2.xyz); + // (C2 - C3 * e_m12) + r1.xyz = -r1.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + // r2 is max(e_m12 - C1, 0) + // r1 is (C2 - C3 * e_m12) + r1.xyz = r2.xyz / r1.xyz; + // pow(result, 1.f / M1) + r1.xyz = log2(r1.xyz); + r1.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r1.xyz; // 1.f / M1 + r1.xyz = exp2(r1.xyz); + // out_color * (10000.f / scaling) + r1.xyz = float3(10000, 10000, 10000) * r1.xyz; // No scaling used, notice it's full 10k + // We use 1.f so it Decodes using the full 10k */ + + r1.w = cmp(0 < r0.w); + r2.x = cmp(r0.w < 1); + r1.w = r1.w ? r2.x : 0; + if (r1.w != 0) { + r1.w = dot(r1.xyz, float3(0.262699991, 0.677999973, 0.0593000017)); + r1.w = r1.w / cb0[7].z; + r1.w = 1 + r1.w; + r1.w = 1 / r1.w; + r1.w = r1.w * cb0[7].z + -1; + r1.w = r0.w * r1.w + 1; + r1.xyz = r1.xyz * r1.www; + } + r0.w = 1 + -r0.w; + r0.xyz = cb0[7].zzz * r0.xyz; + r0.xyz = r1.xyz * r0.www + r0.xyz; // Blending UI with game + + /* // 0.00009999999975 ~= 0.00001 * Bt2020 color + // This is basically (scaling / 10000.f) where scaling is 1.f + r0.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r0.xyz; + // pow(color, M1) + r0.xyz = log2(r0.xyz); + r0.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r0.xyz; + r0.xyz = exp2(r0.xyz); + // (C1 + C2 * y_m1) + r1.xyz = r0.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + // (1.f + C3 * y_m1) + r0.xyz = r0.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + // ((C1 + C2 * y_m1) / (1.f + C3 * y_m1)) + // r1 = (C1 + C2 * y_m1) + // r0 = (1.f + C3 * y_m1) + r0.xyz = rcp(r0.xyz); + r0.xyz = r1.xyz * r0.xyz; + // pow(result, M2) + r0.xyz = log2(r0.xyz); + r0.xyz = float3(78.84375, 78.84375, 78.84375) * r0.xyz; + o0.xyz = exp2(r0.xyz); */ + + o0.rgb = renodx::color::pq::Encode(r0.rgb, 1.f); + o0.w = 1; + + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/lutbuilder_0x2569985B.ps_5_1.hlsl b/src/games/dbzspark/lutbuilder_0x2569985B.ps_5_1.hlsl new file mode 100644 index 00000000..b4498d3c --- /dev/null +++ b/src/games/dbzspark/lutbuilder_0x2569985B.ps_5_1.hlsl @@ -0,0 +1,1395 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:08 2024 + +#include "./shared.h" +#include "./tonemapper.hlsl" + +cbuffer cb1 : register(b1) { + float4 cb1[21]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[42]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + uint v2 : SV_RenderTargetArrayIndex0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14; + uint4 bitmask, uiDest; + float4 fDest; + + r0.xy = float2(-0.015625, -0.015625) + v0.xy; + r0.xy = float2(1.03225803, 1.03225803) * r0.xy; + r0.z = (uint)v2.x; + r1.z = 0.0322580636 * r0.z; + r2.xyzw = cmp(int4(1, 2, 3, 4) == asint(cb0[41].xxxx)); + r3.xyz = r2.www ? float3(1, 0, 0) : float3(1.70505154, -0.621790707, -0.0832583979); + r4.xyz = r2.www ? float3(0, 1, 0) : float3(-0.130257145, 1.14080286, -0.0105485283); + r5.xyz = r2.www ? float3(0, 0, 1) : float3(-0.0240032747, -0.128968775, 1.15297174); + r3.xyz = r2.zzz ? float3(0.695452213, 0.140678704, 0.163869068) : r3.xyz; + r4.xyz = r2.zzz ? float3(0.0447945632, 0.859671116, 0.0955343172) : r4.xyz; + r5.xyz = r2.zzz ? float3(-0.00552588282, 0.00402521016, 1.00150073) : r5.xyz; + r3.xyz = r2.yyy ? float3(1.02579927, -0.0200525094, -0.00577136781) : r3.xyz; + r4.xyz = r2.yyy ? float3(-0.00223502493, 1.00458264, -0.00235231337) : r4.xyz; + r2.yzw = r2.yyy ? float3(-0.00501400325, -0.0252933875, 1.03044021) : r5.xyz; + r3.xyz = r2.xxx ? float3(1.37915885, -0.308850735, -0.0703467429) : r3.xyz; + r4.xyz = r2.xxx ? float3(-0.0693352968, 1.08229232, -0.0129620517) : r4.xyz; + r2.xyz = r2.xxx ? float3(-0.00215925858, -0.0454653986, 1.04775953) : r2.yzw; + r0.z = cmp(asuint(cb0[40].w) >= 3); + r5.xy = log2(r0.xy); + r5.z = log2(r1.z); + r0.xyw = float3(0.0126833133, 0.0126833133, 0.0126833133) * r5.xyz; + r0.xyw = exp2(r0.xyw); + r5.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r0.xyw; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyw = -r0.xyw * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r0.xyw = r5.xyz / r0.xyw; + r0.xyw = log2(r0.xyw); + r0.xyw = float3(6.27739477, 6.27739477, 6.27739477) * r0.xyw; + r0.xyw = exp2(r0.xyw); + r0.xyw = float3(100, 100, 100) * r0.xyw; + r1.xy = v0.xy * float2(1.03225803, 1.03225803) + float2(-0.0161290318, -0.0161290318); + r1.xyz = float3(-0.434017599, -0.434017599, -0.434017599) + r1.xyz; + r1.xyz = float3(14, 14, 14) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(0.180000007, 0.180000007, 0.180000007) + float3(-0.00266771927, -0.00266771927, -0.00266771927); + r0.xyz = r0.zzz ? r0.xyw : r1.xyz; + r1.x = dot(cb1[8].xyz, r0.xyz); + r1.y = dot(cb1[9].xyz, r0.xyz); + r1.z = dot(cb1[10].xyz, r0.xyz); + r0.x = dot(r1.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r0.yzw = r1.xyz / r0.xxx; + r0.yzw = float3(-1, -1, -1) + r0.yzw; + r0.y = dot(r0.yzw, r0.yzw); + r0.y = -4 * r0.y; + r0.y = exp2(r0.y); + r0.x = r0.x * r0.x; + r0.x = cb0[36].z * r0.x; + r0.x = -4 * r0.x; + r0.x = exp2(r0.x); + r0.xy = float2(1, 1) + -r0.xy; + r0.x = r0.y * r0.x; + r5.x = dot(float3(1.37041271, -0.329291314, -0.0636827648), r1.xyz); + r5.y = dot(float3(-0.0834341869, 1.09709096, -0.0108615728), r1.xyz); + r5.z = dot(float3(-0.0257932581, -0.0986256376, 1.20369434), r1.xyz); + r0.yzw = r5.xyz + -r1.xyz; + r0.xyz = r0.xxx * r0.yzw + r1.xyz; + r0.w = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r1.xyzw = cb0[20].xyzw * cb0[15].xyzw; + r5.xyzw = cb0[21].xyzw * cb0[16].xyzw; + r6.xyzw = cb0[22].xyzw * cb0[17].xyzw; + r7.xyzw = cb0[23].xyzw * cb0[18].xyzw; + r8.xyzw = cb0[24].xyzw + cb0[19].xyzw; + r1.xyz = r1.xyz * r1.www; + r0.xyz = r0.xyz + -r0.www; + r1.xyz = r1.xyz * r0.xyz + r0.www; + r1.xyz = max(float3(0, 0, 0), r1.xyz); + r1.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r1.xyz; + r5.xyz = r5.xyz * r5.www; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r1.xyz; + r5.xyz = r6.xyz * r6.www; + r5.xyz = float3(1, 1, 1) / r5.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r5.xyz = r7.xyz * r7.www; + r6.xyz = r8.xyz + r8.www; + r1.xyz = r1.xyz * r5.xyz + r6.xyz; + r1.w = 1 / cb0[35].z; + r1.w = saturate(r1.w * r0.w); + r2.w = r1.w * -2 + 3; + r1.w = r1.w * r1.w; + r1.w = -r2.w * r1.w + 1; + r5.xyzw = cb0[30].xyzw * cb0[15].xyzw; + r6.xyzw = cb0[31].xyzw * cb0[16].xyzw; + r7.xyzw = cb0[32].xyzw * cb0[17].xyzw; + r8.xyzw = cb0[33].xyzw * cb0[18].xyzw; + r9.xyzw = cb0[34].xyzw + cb0[19].xyzw; + r5.xyz = r5.xyz * r5.www; + r5.xyz = r5.xyz * r0.xyz + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r5.xyz; + r6.xyz = r6.xyz * r6.www; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r5.xyz; + r6.xyz = r7.xyz * r7.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r6.xyz = r8.xyz * r8.www; + r7.xyz = r9.xyz + r9.www; + r5.xyz = r5.xyz * r6.xyz + r7.xyz; + r2.w = cb0[36].x + -cb0[35].w; + r3.w = -cb0[35].w + r0.w; + r2.w = 1 / r2.w; + r2.w = saturate(r3.w * r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r4.w = r3.w * r2.w; + r6.xyzw = cb0[25].xyzw * cb0[15].xyzw; + r7.xyzw = cb0[26].xyzw * cb0[16].xyzw; + r8.xyzw = cb0[27].xyzw * cb0[17].xyzw; + r9.xyzw = cb0[28].xyzw * cb0[18].xyzw; + r10.xyzw = cb0[29].xyzw + cb0[19].xyzw; + r6.xyz = r6.xyz * r6.www; + r0.xyz = r6.xyz * r0.xyz + r0.www; + r0.xyz = max(float3(0, 0, 0), r0.xyz); + r0.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r0.xyz; + r6.xyz = r7.xyz * r7.www; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r0.xyz; + r6.xyz = r8.xyz * r8.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r6.xyz = r9.xyz * r9.www; + r7.xyz = r10.xyz + r10.www; + r0.xyz = r0.xyz * r6.xyz + r7.xyz; + r0.w = 1 + -r1.w; + r0.w = -r3.w * r2.w + r0.w; + r0.xyz = r0.xyz * r0.www; + r0.xyz = r1.xyz * r1.www + r0.xyz; + r0.xyz = r5.xyz * r4.www + r0.xyz; + + // End of Color Correct + float3 ap1_graded_color = r0.rgb; + float3 ap1_aces_colored = ap1_graded_color; + + // uint output_type = cb0[40].w; + + float3 sdr_color; + float3 hdr_color; + float3 sdr_ap1_color; + + float FilmBlackClip = cb0[37].w; + float FilmToe = cb0[37].y; + float FilmWhiteClip = cb0[38].x; + float FilmShoulder = cb0[37].z; + + // Blue correct -- r0 is still ap1, r1 is sRGB + r1.x = dot(float3(0.938639402, 1.02359565e-10, 0.0613606237), r0.xyz); + r1.y = dot(float3(8.36008554e-11, 0.830794156, 0.169205874), r0.xyz); + r1.z = dot(float3(2.13187367e-12, -5.63307213e-12, 1), r0.xyz); + r1.xyz = r1.xyz + -r0.xyz; + r1.xyz = cb0[36].yyy * r1.xyz + r0.xyz; + + ap1_graded_color = r1.xyz; + + // start of film tonemap + // AP1 => AP0 + + r5.y = dot(float3(0.695452213, 0.140678704, 0.163869068), r1.xyz); + r5.z = dot(float3(0.0447945632, 0.859671116, 0.0955343172), r1.xyz); + r5.w = dot(float3(-0.00552588236, 0.00402521016, 1.00150073), r1.xyz); + r0.w = min(r5.y, r5.z); + r0.w = min(r0.w, r5.w); + r1.w = max(r5.y, r5.z); + r1.w = max(r1.w, r5.w); + r6.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r6.x + -r0.w; + r0.w = r0.w / r6.y; + r6.xyz = r5.wzy + -r5.zyw; + r6.xy = r6.xy * r5.wz; + r1.w = r6.x + r6.y; + r1.w = r5.y * r6.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r5.w + r5.z; + r2.w = r2.w + r5.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.x = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.x + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r6.yzw = r5.yzw * r1.www; + r7.xy = cmp(r6.zw == r6.yz); + r2.w = r7.y ? r7.x : 0; + r3.w = r5.z * r1.w + -r6.w; + r3.w = 1.73205078 * r3.w; + r4.w = r6.y * 2 + -r6.z; + r4.w = -r5.w * r1.w + r4.w; + r5.x = min(abs(r4.w), abs(r3.w)); + r5.z = max(abs(r4.w), abs(r3.w)); + r5.z = 1 / r5.z; + r5.x = r5.x * r5.z; + r5.z = r5.x * r5.x; + r5.w = r5.z * 0.0208350997 + -0.0851330012; + r5.w = r5.z * r5.w + 0.180141002; + r5.w = r5.z * r5.w + -0.330299497; + r5.z = r5.z * r5.w + 0.999866009; + r5.w = r5.x * r5.z; + r7.x = cmp(abs(r4.w) < abs(r3.w)); + r5.w = r5.w * -2 + 1.57079637; + r5.w = r7.x ? r5.w : 0; + r5.x = r5.x * r5.z + r5.w; + r5.z = cmp(r4.w < -r4.w); + r5.z = r5.z ? -3.141593 : 0; + r5.x = r5.x + r5.z; + r5.z = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r5.z < -r5.z); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.x : r5.x; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + // aces::hueweight (with smoothstep) + r2.w = r3.w ? r4.w : r2.w; + r2.w = 0.0148148146 * r2.w; + r2.w = 1 + -abs(r2.w); + r2.w = max(0, r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r2.w = r3.w * r2.w; + r2.w = r2.w * r2.w; + r0.w = r2.w * r0.w; + r1.w = -r5.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r6.x = r0.w * 0.180000007 + r6.y; + // AP0 => AP1 + r5.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r6.xzw); + r5.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r6.xzw); + r5.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r6.xzw); + r5.xyz = max(float3(0, 0, 0), r5.xyz); + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; // End of ACES:RRT + + ap1_aces_colored = r5.xyz; + + // If statement with first dual tonemap would go here + + if (injectedData.toneMapType != 0.f) { + renodx::tonemap::Config config = getCommonConfig(); + + float3 config_color = renodx::color::bt709::from::AP1(ap1_graded_color); + + renodx::tonemap::config::DualToneMap dual_tone_map = renodx::tonemap::config::ApplyToneMaps(config_color, config); + hdr_color = dual_tone_map.color_hdr; + sdr_color = dual_tone_map.color_sdr; + sdr_ap1_color = renodx::color::ap1::from::BT709(sdr_color); + } else { + // Film Toe > 0.8 + r6.xy = cb0[37].ww + float2(1, 0.180000007); + r0.w = -cb0[37].y + r6.x; + r1.w = cb0[38].x + 1; + r2.w = -cb0[37].z + r1.w; + r3.w = cmp(0.800000012 < cb0[37].y); + r6.xz = -cb0[37].yy + float2(0.819999993, 1); + r6.xz = r6.xz / cb0[37].xx; + r4.w = -0.744727492 + r6.x; + r5.w = r6.y / r0.w; + r6.x = -1 + r5.w; + r6.x = 1 + -r6.x; + r5.w = r5.w / r6.x; + r5.w = log2(r5.w); + r5.w = 0.346573591 * r5.w; + r6.x = r0.w / cb0[37].x; + r5.w = -r5.w * r6.x + -0.744727492; + r3.w = r3.w ? r4.w : r5.w; + r4.w = r6.z + -r3.w; + r5.w = cb0[37].z / cb0[37].x; + r5.w = r5.w + -r4.w; + r5.xyz = log2(r5.xyz); + r6.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r5.xyz; + r7.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + r4.www; + r7.xyz = cb0[37].xxx * r7.xyz; + r4.w = r0.w + r0.w; + r6.w = cb0[37].x * -2; + r0.w = r6.w / r0.w; + r8.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r3.www; + r9.xyz = r8.xyz * r0.www; + r9.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r9.xyz; + r9.xyz = exp2(r9.xyz); + r9.xyz = float3(1, 1, 1) + r9.xyz; + r9.xyz = r4.www / r9.xyz; + r9.xyz = -cb0[37].www + r9.xyz; + r0.w = r2.w + r2.w; + r4.w = cb0[37].x + cb0[37].x; + r2.w = r4.w / r2.w; + r5.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r5.www; + r5.xyz = r5.xyz * r2.www; + r5.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(1, 1, 1) + r5.xyz; + r5.xyz = r0.www / r5.xyz; + r5.xyz = -r5.xyz + r1.www; + r10.xyz = cmp(r6.xyz < r3.www); + r9.xyz = r10.xyz ? r9.xyz : r7.xyz; + r6.xyz = cmp(r5.www < r6.xyz); + r5.xyz = r6.xyz ? r5.xyz : r7.xyz; + r0.w = r5.w + -r3.w; + r6.xyz = saturate(r8.xyz / r0.www); + r0.w = cmp(r5.w < r3.w); + r7.xyz = float3(1, 1, 1) + -r6.xyz; + r6.xyz = r0.www ? r7.xyz : r6.xyz; + r7.xyz = -r6.xyz * float3(2, 2, 2) + float3(3, 3, 3); + r6.xyz = r6.xyz * r6.xyz; + r6.xyz = r6.xyz * r7.xyz; + r5.xyz = r5.xyz + -r9.xyz; + r5.xyz = r6.xyz * r5.xyz + r9.xyz; + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.930000007, 0.930000007, 0.930000007) + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + sdr_ap1_color = r5.xyz; + } // The } from the dualtonemap if statement would go here + + r5.xyz = sdr_ap1_color; + + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].www * r5.xyz + r1.xyz; + + // BlueBlueCorrectInv + r5.x = dot(float3(1.06537485, 1.44678506e-06, -0.0653710067), r1.xyz); + r5.y = dot(float3(-3.45525592e-07, 1.20366347, -0.203667715), r1.xyz); + r5.z = dot(float3(1.9865448e-08, 2.12079581e-08, 0.999999583), r1.xyz); + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].yyy * r5.xyz + r1.xyz; + r5.x = dot(cb1[12].xyz, r1.xyz); + r5.y = dot(cb1[13].xyz, r1.xyz); + r5.z = dot(cb1[14].xyz, r1.xyz); + r1.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = r1.xyz * r1.xyz; + r1.xyz = cb0[39].yyy * r1.xyz; + r1.xyz = cb0[39].xxx * r5.xyz + r1.xyz; + r1.xyz = cb0[39].zzz + r1.xyz; + r5.xyz = cb0[14].xyz * r1.xyz; + r1.xyz = -r1.xyz * cb0[14].xyz + cb0[13].xyz; + r1.xyz = cb0[13].www * r1.xyz + r5.xyz; + r5.xyz = max(float3(0, 0, 0), r1.xyz); + r5.xyz = log2(r5.xyz); + r5.xyz = cb0[40].yyy * r5.xyz; + r5.xyz = exp2(r5.xyz); + + float3 film_graded_color = r5.rgb; + + // Add upgrade tonemap here + if (injectedData.toneMapType != 0.f) { + float3 final_color = saturate(film_graded_color); + + if (injectedData.toneMapType != 1.f) { + final_color = renodx::tonemap::UpgradeToneMap(hdr_color, sdr_color, final_color, 1.f); + } else { + final_color = hdr_color; + } + + final_color = renodx::color::bt2020::from::BT709(final_color); + float encodeRate = injectedData.toneMapType > 1.f ? injectedData.toneMapGameNits : 100.f; + final_color = renodx::color::pq::Encode(final_color, encodeRate); + + o0.rgba = float4(final_color, 0); + return; + } + + if (cb0[40].w == 0) { // cb[40].w = output device + r6.x = dot(cb1[8].xyz, r5.xyz); + r6.y = dot(cb1[9].xyz, r5.xyz); + r6.z = dot(cb1[10].xyz, r5.xyz); + r7.x = dot(r3.xyz, r6.xyz); + r7.y = dot(r4.xyz, r6.xyz); + r7.z = dot(r2.xyz, r6.xyz); + r6.xyz = cb1[20].xxx ? r5.xyz : r7.xyz; + r7.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r6.xyz; + r8.xyz = cmp(r6.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r6.xyz = r6.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r6.xyz = r8.xyz ? r6.xyz : r7.xyz; + } else { + r0.w = cmp(1 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r5.xyz); + r7.y = dot(cb1[9].xyz, r5.xyz); + r7.z = dot(cb1[10].xyz, r5.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r8.xyz); + r8.xyz = float3(4.5, 4.5, 4.5) * r7.xyz; + r7.xyz = max(float3(0.0179999992, 0.0179999992, 0.0179999992), r7.xyz); + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.449999988, 0.449999988, 0.449999988) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r7.xyz = r7.xyz * float3(1.09899998, 1.09899998, 1.09899998) + float3(-0.0989999995, -0.0989999995, -0.0989999995); + r6.xyz = min(r8.xyz, r7.xyz); + } else { + r7.x = dot(cb1[12].xyz, r0.xyz); + r7.y = dot(cb1[13].xyz, r0.xyz); + r7.z = dot(cb1[14].xyz, r0.xyz); + r0.xyz = cb0[14].xyz * r7.xyz; + r7.xyz = -r7.xyz * cb0[14].xyz + cb0[13].xyz; + r0.xyz = cb0[13].www * r7.xyz + r0.xyz; + r7.xy = cmp(int2(3, 5) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(5 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(4, 6) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(6 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r0.w = cmp(7 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r0.xyz); + r7.y = dot(cb1[9].xyz, r0.xyz); + r7.z = dot(cb1[10].xyz, r0.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r8.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(8, 9) == asint(cb0[40].ww)); + r8.x = dot(cb1[8].xyz, r1.xyz); + r8.y = dot(cb1[9].xyz, r1.xyz); + r8.z = dot(cb1[10].xyz, r1.xyz); + r1.x = dot(r3.xyz, r8.xyz); + r1.y = dot(r4.xyz, r8.xyz); + r1.z = dot(r2.xyz, r8.xyz); + r8.x = dot(cb1[8].xyz, r5.xyz); + r8.y = dot(cb1[9].xyz, r5.xyz); + r8.z = dot(cb1[10].xyz, r5.xyz); + r0.w = dot(r3.xyz, r8.xyz); + r1.w = dot(r4.xyz, r8.xyz); + r2.x = dot(r2.xyz, r8.xyz); + r3.x = log2(r0.w); + r3.y = log2(r1.w); + r3.z = log2(r2.x); + r2.xyz = cb0[40].zzz * r3.xyz; + r2.xyz = exp2(r2.xyz); + r1.xyz = r7.yyy ? r1.xyz : r2.xyz; + r6.xyz = r7.xxx ? r0.xyz : r1.xyz; + } + } + } + } + } + o0.xyz = float3(0.952381015, 0.952381015, 0.952381015) * r6.xyz; + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/lutbuilder_0x31FE4421.ps_5_1.hlsl b/src/games/dbzspark/lutbuilder_0x31FE4421.ps_5_1.hlsl new file mode 100644 index 00000000..c4389ffb --- /dev/null +++ b/src/games/dbzspark/lutbuilder_0x31FE4421.ps_5_1.hlsl @@ -0,0 +1,1537 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:17 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t0 : register(t0); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[21]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[42]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + uint v2 : SV_RenderTargetArrayIndex0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14; + uint4 bitmask, uiDest; + float4 fDest; + + r0.xy = float2(-0.015625, -0.015625) + v0.xy; + r0.xy = float2(1.03225803, 1.03225803) * r0.xy; + r0.z = (uint)v2.x; + r1.z = 0.0322580636 * r0.z; + r2.xyzw = cmp(int4(1, 2, 3, 4) == asint(cb0[41].xxxx)); + r3.xyz = r2.www ? float3(1, 0, 0) : float3(1.70505154, -0.621790707, -0.0832583979); + r4.xyz = r2.www ? float3(0, 1, 0) : float3(-0.130257145, 1.14080286, -0.0105485283); + r5.xyz = r2.www ? float3(0, 0, 1) : float3(-0.0240032747, -0.128968775, 1.15297174); + r3.xyz = r2.zzz ? float3(0.695452213, 0.140678704, 0.163869068) : r3.xyz; + r4.xyz = r2.zzz ? float3(0.0447945632, 0.859671116, 0.0955343172) : r4.xyz; + r5.xyz = r2.zzz ? float3(-0.00552588282, 0.00402521016, 1.00150073) : r5.xyz; + r3.xyz = r2.yyy ? float3(1.02579927, -0.0200525094, -0.00577136781) : r3.xyz; + r4.xyz = r2.yyy ? float3(-0.00223502493, 1.00458264, -0.00235231337) : r4.xyz; + r2.yzw = r2.yyy ? float3(-0.00501400325, -0.0252933875, 1.03044021) : r5.xyz; + r3.xyz = r2.xxx ? float3(1.37915885, -0.308850735, -0.0703467429) : r3.xyz; + r4.xyz = r2.xxx ? float3(-0.0693352968, 1.08229232, -0.0129620517) : r4.xyz; + r2.xyz = r2.xxx ? float3(-0.00215925858, -0.0454653986, 1.04775953) : r2.yzw; + r0.z = cmp(asuint(cb0[40].w) >= 3); + r5.xy = log2(r0.xy); + r5.z = log2(r1.z); + r0.xyw = float3(0.0126833133, 0.0126833133, 0.0126833133) * r5.xyz; + r0.xyw = exp2(r0.xyw); + r5.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r0.xyw; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyw = -r0.xyw * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r0.xyw = r5.xyz / r0.xyw; + r0.xyw = log2(r0.xyw); + r0.xyw = float3(6.27739477, 6.27739477, 6.27739477) * r0.xyw; + r0.xyw = exp2(r0.xyw); + r0.xyw = float3(100, 100, 100) * r0.xyw; + r1.xy = v0.xy * float2(1.03225803, 1.03225803) + float2(-0.0161290318, -0.0161290318); + r1.xyz = float3(-0.434017599, -0.434017599, -0.434017599) + r1.xyz; + r1.xyz = float3(14, 14, 14) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(0.180000007, 0.180000007, 0.180000007) + float3(-0.00266771927, -0.00266771927, -0.00266771927); + r0.xyz = r0.zzz ? r0.xyw : r1.xyz; + r0.w = cb0[35].x * 1.00055635; + r0.w = 1 / r0.w; + r1.x = cmp(6996.10791 >= cb0[35].x); + r1.yz = -r0.ww * float2(4.60700006e+09, 2.0064e+09) + float2(2967800, 1901800); + r1.yz = r1.yz * r0.ww + float2(99.1100006, 247.479996); + r1.yz = r1.yz * r0.ww + float2(0.244063005, 0.237039998); + r1.x = r1.x ? r1.y : r1.z; + r0.w = r1.x * r1.x; + r1.z = 2.86999989 * r1.x; + r0.w = r0.w * -3 + r1.z; + r1.y = -0.275000006 + r0.w; + r5.xyz = cb0[35].xxx * float3(0.000154118257, 0.00084242021, 4.22806261e-05) + float3(0.860117733, 1, 0.317398727); + r0.w = cb0[35].x * cb0[35].x; + r5.xyz = r0.www * float3(1.28641219e-07, 7.08145137e-07, 4.20481676e-08) + r5.xyz; + r1.z = r5.x / r5.y; + r5.xyw = -cb0[35].xxx * float3(2.8974182e-05, 1916156.25, 705674) + float3(1, -1.13758118e+09, 1.97471539e+09); + r1.w = r0.w * 1.61456057e-07 + r5.x; + r1.w = r5.z / r1.w; + r2.w = 3 * r1.z; + r3.w = r1.z + r1.z; + r3.w = -r1.w * 8 + r3.w; + r3.w = 4 + r3.w; + r6.x = r2.w / r3.w; + r2.w = r1.w + r1.w; + r6.y = r2.w / r3.w; + r2.w = cmp(cb0[35].x < 4000); + r1.xy = r2.ww ? r6.xy : r1.xy; + r5.xy = -r0.ww * float2(1.53176999, 308.606995) + r5.yw; + r2.w = cb0[35].x * 1189.62 + r0.w; + r2.w = 1412139.88 + r2.w; + r2.w = r2.w * r2.w; + r7.x = r5.x / r2.w; + r0.w = -cb0[35].x * 179.455994 + r0.w; + r0.w = 6193636 + r0.w; + r0.w = r0.w * r0.w; + r7.y = r5.y / r0.w; + r0.w = dot(r7.xy, r7.xy); + r0.w = rsqrt(r0.w); + r5.xy = r7.xy * r0.ww; + r0.w = cb0[35].y * r5.y; + r0.w = r0.w * 0.0500000007 + r1.z; + r1.z = cb0[35].y * -r5.x; + r1.z = r1.z * 0.0500000007 + r1.w; + r1.w = 3 * r0.w; + r0.w = r0.w + r0.w; + r0.w = -r1.z * 8 + r0.w; + r0.w = 4 + r0.w; + r1.z = r1.z + r1.z; + r5.xy = r1.wz / r0.ww; + r1.zw = r5.xy + -r6.xy; + r1.xy = r1.xy + r1.zw; + r1.zw = float2(0.312700003, 0.328999996); + r1.xyzw = cb0[38].zzzz ? r1.xyzw : r1.zwxy; + r5.xy = max(float2(1.00000001e-10, 1.00000001e-10), r1.yw); + r5.zw = float2(1, 1) + -r1.xz; + r1.yw = r5.zw + -r1.yw; + r6.xy = r1.xz / r5.xy; + r1.xy = r1.yw / r5.xy; + r6.z = 1; + r6.w = r1.x; + r0.w = dot(float3(0.895099998, 0.266400009, -0.161400005), r6.xzw); + r1.x = dot(float3(-0.750199974, 1.71350002, 0.0366999991), r6.xzw); + r2.w = dot(float3(0.0388999991, -0.0684999973, 1.02960002), r6.xzw); + r1.zw = r6.yz; + r3.w = dot(float3(-0.161400005, 0.895099998, 0.266400009), r1.yzw); + r4.w = dot(float3(0.0366999991, -0.750199974, 1.71350002), r1.yzw); + r1.y = dot(float3(1.02960002, 0.0388999991, -0.0684999973), r1.yzw); + r0.w = r3.w / r0.w; + r1.x = r4.w / r1.x; + r1.y = r1.y / r2.w; + r5.xyz = float3(0.895099998, 0.266400009, -0.161400005) * r0.www; + r1.xzw = float3(-0.750199974, 1.71350002, 0.0366999991) * r1.xxx; + r6.xyz = float3(0.0388999991, -0.0684999973, 1.02960002) * r1.yyy; + r7.x = r5.x; + r7.y = r1.x; + r7.z = r6.x; + r0.w = dot(float3(0.986992896, -0.1470543, 0.159962699), r7.xyz); + r8.x = r5.y; + r8.y = r1.z; + r8.z = r6.y; + r1.x = dot(float3(0.986992896, -0.1470543, 0.159962699), r8.xyz); + r6.x = r5.z; + r6.y = r1.w; + r1.y = dot(float3(0.986992896, -0.1470543, 0.159962699), r6.xyz); + r1.z = dot(float3(0.432305306, 0.518360317, 0.0492912009), r7.xyz); + r1.w = dot(float3(0.432305306, 0.518360317, 0.0492912009), r8.xyz); + r2.w = dot(float3(0.432305306, 0.518360317, 0.0492912009), r6.xyz); + r3.w = dot(float3(-0.0085287001, 0.040042799, 0.968486726), r7.xyz); + r4.w = dot(float3(-0.0085287001, 0.040042799, 0.968486726), r8.xyz); + r5.x = dot(float3(-0.0085287001, 0.040042799, 0.968486726), r6.xyz); + r5.yzw = cb1[1].xyz * r1.xxx; + r5.yzw = r0.www * cb1[0].xyz + r5.yzw; + r5.yzw = r1.yyy * cb1[2].xyz + r5.yzw; + r1.xyw = cb1[1].xyz * r1.www; + r1.xyz = r1.zzz * cb1[0].xyz + r1.xyw; + r1.xyz = r2.www * cb1[2].xyz + r1.xyz; + r6.xyz = cb1[1].xyz * r4.www; + r6.xyz = r3.www * cb1[0].xyz + r6.xyz; + r6.xyz = r5.xxx * cb1[2].xyz + r6.xyz; + r7.xyz = cb1[4].yyy * r1.xyz; + r7.xyz = cb1[4].xxx * r5.yzw + r7.xyz; + r7.xyz = cb1[4].zzz * r6.xyz + r7.xyz; + r8.xyz = cb1[5].yyy * r1.xyz; + r8.xyz = cb1[5].xxx * r5.yzw + r8.xyz; + r8.xyz = cb1[5].zzz * r6.xyz + r8.xyz; + r1.xyz = cb1[6].yyy * r1.xyz; + r1.xyz = cb1[6].xxx * r5.yzw + r1.xyz; + r1.xyz = cb1[6].zzz * r6.xyz + r1.xyz; + r5.x = dot(r7.xyz, r0.xyz); + r5.y = dot(r8.xyz, r0.xyz); + r5.z = dot(r1.xyz, r0.xyz); + r0.x = dot(cb1[8].xyz, r5.xyz); + r0.y = dot(cb1[9].xyz, r5.xyz); + r0.z = dot(cb1[10].xyz, r5.xyz); + r0.w = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r1.xyz = r0.xyz / r0.www; + r1.xyz = float3(-1, -1, -1) + r1.xyz; + r1.x = dot(r1.xyz, r1.xyz); + r1.x = -4 * r1.x; + r1.x = exp2(r1.x); + r1.x = 1 + -r1.x; + r0.w = r0.w * r0.w; + r0.w = cb0[36].z * r0.w; + r0.w = -4 * r0.w; + r0.w = exp2(r0.w); + r0.w = 1 + -r0.w; + r0.w = r1.x * r0.w; + r1.x = dot(float3(1.37041271, -0.329291314, -0.0636827648), r0.xyz); + r1.y = dot(float3(-0.0834341869, 1.09709096, -0.0108615728), r0.xyz); + r1.z = dot(float3(-0.0257932581, -0.0986256376, 1.20369434), r0.xyz); + r1.xyz = r1.xyz + -r0.xyz; + r0.xyz = r0.www * r1.xyz + r0.xyz; + r0.w = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r1.xyzw = cb0[20].xyzw * cb0[15].xyzw; + r5.xyzw = cb0[21].xyzw * cb0[16].xyzw; + r6.xyzw = cb0[22].xyzw * cb0[17].xyzw; + r7.xyzw = cb0[23].xyzw * cb0[18].xyzw; + r8.xyzw = cb0[24].xyzw + cb0[19].xyzw; + r1.xyz = r1.xyz * r1.www; + r0.xyz = r0.xyz + -r0.www; + r1.xyz = r1.xyz * r0.xyz + r0.www; + r1.xyz = max(float3(0, 0, 0), r1.xyz); + r1.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r1.xyz; + r5.xyz = r5.xyz * r5.www; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r1.xyz; + r5.xyz = r6.xyz * r6.www; + r5.xyz = float3(1, 1, 1) / r5.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r5.xyz = r7.xyz * r7.www; + r6.xyz = r8.xyz + r8.www; + r1.xyz = r1.xyz * r5.xyz + r6.xyz; + r1.w = 1 / cb0[35].z; + r1.w = saturate(r1.w * r0.w); + r2.w = r1.w * -2 + 3; + r1.w = r1.w * r1.w; + r1.w = -r2.w * r1.w + 1; + r5.xyzw = cb0[30].xyzw * cb0[15].xyzw; + r6.xyzw = cb0[31].xyzw * cb0[16].xyzw; + r7.xyzw = cb0[32].xyzw * cb0[17].xyzw; + r8.xyzw = cb0[33].xyzw * cb0[18].xyzw; + r9.xyzw = cb0[34].xyzw + cb0[19].xyzw; + r5.xyz = r5.xyz * r5.www; + r5.xyz = r5.xyz * r0.xyz + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r5.xyz; + r6.xyz = r6.xyz * r6.www; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r5.xyz; + r6.xyz = r7.xyz * r7.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r6.xyz = r8.xyz * r8.www; + r7.xyz = r9.xyz + r9.www; + r5.xyz = r5.xyz * r6.xyz + r7.xyz; + r2.w = cb0[36].x + -cb0[35].w; + r3.w = -cb0[35].w + r0.w; + r2.w = 1 / r2.w; + r2.w = saturate(r3.w * r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r4.w = r3.w * r2.w; + r6.xyzw = cb0[25].xyzw * cb0[15].xyzw; + r7.xyzw = cb0[26].xyzw * cb0[16].xyzw; + r8.xyzw = cb0[27].xyzw * cb0[17].xyzw; + r9.xyzw = cb0[28].xyzw * cb0[18].xyzw; + r10.xyzw = cb0[29].xyzw + cb0[19].xyzw; + r6.xyz = r6.xyz * r6.www; + r0.xyz = r6.xyz * r0.xyz + r0.www; + r0.xyz = max(float3(0, 0, 0), r0.xyz); + r0.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r0.xyz; + r6.xyz = r7.xyz * r7.www; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r0.xyz; + r6.xyz = r8.xyz * r8.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r6.xyz = r9.xyz * r9.www; + r7.xyz = r10.xyz + r10.www; + r0.xyz = r0.xyz * r6.xyz + r7.xyz; + r0.w = 1 + -r1.w; + r0.w = -r3.w * r2.w + r0.w; + r0.xyz = r0.xyz * r0.www; + r0.xyz = r1.xyz * r1.www + r0.xyz; + r0.xyz = r5.xyz * r4.www + r0.xyz; + + // End of Color Correct + float3 ap1_graded_color = r0.rgb; + float3 ap1_aces_colored = ap1_graded_color; + + // uint output_type = cb0[40].w; + + float3 sdr_color; + float3 hdr_color; + float3 sdr_ap1_color; + + float FilmBlackClip = cb0[37].w; + float FilmToe = cb0[37].y; + float FilmWhiteClip = cb0[38].x; + float FilmShoulder = cb0[37].z; + + // Blue correct -- r0 is still ap1, r1 is sRGB + r1.x = dot(float3(0.938639402, 1.02359565e-10, 0.0613606237), r0.xyz); + r1.y = dot(float3(8.36008554e-11, 0.830794156, 0.169205874), r0.xyz); + r1.z = dot(float3(2.13187367e-12, -5.63307213e-12, 1), r0.xyz); + r1.xyz = r1.xyz + -r0.xyz; + r1.xyz = cb0[36].yyy * r1.xyz + r0.xyz; + + ap1_graded_color = r1.xyz; + + // start of film tonemap + // AP1 => AP0 + + r5.y = dot(float3(0.695452213, 0.140678704, 0.163869068), r1.xyz); + r5.z = dot(float3(0.0447945632, 0.859671116, 0.0955343172), r1.xyz); + r5.w = dot(float3(-0.00552588236, 0.00402521016, 1.00150073), r1.xyz); + r0.w = min(r5.y, r5.z); + r0.w = min(r0.w, r5.w); + r1.w = max(r5.y, r5.z); + r1.w = max(r1.w, r5.w); + r6.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r6.x + -r0.w; + r0.w = r0.w / r6.y; + r6.xyz = r5.wzy + -r5.zyw; + r6.xy = r6.xy * r5.wz; + r1.w = r6.x + r6.y; + r1.w = r5.y * r6.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r5.w + r5.z; + r2.w = r2.w + r5.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.x = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.x + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r6.yzw = r5.yzw * r1.www; + r7.xy = cmp(r6.zw == r6.yz); + r2.w = r7.y ? r7.x : 0; + r3.w = r5.z * r1.w + -r6.w; + r3.w = 1.73205078 * r3.w; + r4.w = r6.y * 2 + -r6.z; + r4.w = -r5.w * r1.w + r4.w; + r5.x = min(abs(r4.w), abs(r3.w)); + r5.z = max(abs(r4.w), abs(r3.w)); + r5.z = 1 / r5.z; + r5.x = r5.x * r5.z; + r5.z = r5.x * r5.x; + r5.w = r5.z * 0.0208350997 + -0.0851330012; + r5.w = r5.z * r5.w + 0.180141002; + r5.w = r5.z * r5.w + -0.330299497; + r5.z = r5.z * r5.w + 0.999866009; + r5.w = r5.x * r5.z; + r7.x = cmp(abs(r4.w) < abs(r3.w)); + r5.w = r5.w * -2 + 1.57079637; + r5.w = r7.x ? r5.w : 0; + r5.x = r5.x * r5.z + r5.w; + r5.z = cmp(r4.w < -r4.w); + r5.z = r5.z ? -3.141593 : 0; + r5.x = r5.x + r5.z; + r5.z = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r5.z < -r5.z); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.x : r5.x; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + // aces::hueweight (with smoothstep) + r2.w = r3.w ? r4.w : r2.w; + r2.w = 0.0148148146 * r2.w; + r2.w = 1 + -abs(r2.w); + r2.w = max(0, r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r2.w = r3.w * r2.w; + r2.w = r2.w * r2.w; + r0.w = r2.w * r0.w; + r1.w = -r5.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r6.x = r0.w * 0.180000007 + r6.y; + // AP0 => AP1 + r5.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r6.xzw); + r5.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r6.xzw); + r5.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r6.xzw); + r5.xyz = max(float3(0, 0, 0), r5.xyz); + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; // End of ACES:RRT + + ap1_aces_colored = r5.xyz; + + // If statement with first dual tonemap would go here + + if (injectedData.toneMapType != 0.f) { + renodx::tonemap::Config config = getCommonConfig(); + + float3 config_color = renodx::color::bt709::from::AP1(ap1_graded_color); + + renodx::tonemap::config::DualToneMap dual_tone_map = renodx::tonemap::config::ApplyToneMaps(config_color, config); + hdr_color = dual_tone_map.color_hdr; + sdr_color = dual_tone_map.color_sdr; + sdr_ap1_color = renodx::color::ap1::from::BT709(sdr_color); + } else { + // Film Toe > 0.8 + r6.xy = cb0[37].ww + float2(1, 0.180000007); + r0.w = -cb0[37].y + r6.x; + r1.w = cb0[38].x + 1; + r2.w = -cb0[37].z + r1.w; + r3.w = cmp(0.800000012 < cb0[37].y); + r6.xz = -cb0[37].yy + float2(0.819999993, 1); + r6.xz = r6.xz / cb0[37].xx; + r4.w = -0.744727492 + r6.x; + r5.w = r6.y / r0.w; + r6.x = -1 + r5.w; + r6.x = 1 + -r6.x; + r5.w = r5.w / r6.x; + r5.w = log2(r5.w); + r5.w = 0.346573591 * r5.w; + r6.x = r0.w / cb0[37].x; + r5.w = -r5.w * r6.x + -0.744727492; + r3.w = r3.w ? r4.w : r5.w; + r4.w = r6.z + -r3.w; + r5.w = cb0[37].z / cb0[37].x; + r5.w = r5.w + -r4.w; + r5.xyz = log2(r5.xyz); + r6.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r5.xyz; + r7.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + r4.www; + r7.xyz = cb0[37].xxx * r7.xyz; + r4.w = r0.w + r0.w; + r6.w = cb0[37].x * -2; + r0.w = r6.w / r0.w; + r8.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r3.www; + r9.xyz = r8.xyz * r0.www; + r9.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r9.xyz; + r9.xyz = exp2(r9.xyz); + r9.xyz = float3(1, 1, 1) + r9.xyz; + r9.xyz = r4.www / r9.xyz; + r9.xyz = -cb0[37].www + r9.xyz; + r0.w = r2.w + r2.w; + r4.w = cb0[37].x + cb0[37].x; + r2.w = r4.w / r2.w; + r5.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r5.www; + r5.xyz = r5.xyz * r2.www; + r5.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(1, 1, 1) + r5.xyz; + r5.xyz = r0.www / r5.xyz; + r5.xyz = -r5.xyz + r1.www; + r10.xyz = cmp(r6.xyz < r3.www); + r9.xyz = r10.xyz ? r9.xyz : r7.xyz; + r6.xyz = cmp(r5.www < r6.xyz); + r5.xyz = r6.xyz ? r5.xyz : r7.xyz; + r0.w = r5.w + -r3.w; + r6.xyz = saturate(r8.xyz / r0.www); + r0.w = cmp(r5.w < r3.w); + r7.xyz = float3(1, 1, 1) + -r6.xyz; + r6.xyz = r0.www ? r7.xyz : r6.xyz; + r7.xyz = -r6.xyz * float3(2, 2, 2) + float3(3, 3, 3); + r6.xyz = r6.xyz * r6.xyz; + r6.xyz = r6.xyz * r7.xyz; + r5.xyz = r5.xyz + -r9.xyz; + r5.xyz = r6.xyz * r5.xyz + r9.xyz; + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.930000007, 0.930000007, 0.930000007) + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + sdr_ap1_color = r5.xyz; + } // The } from the dualtonemap if statement would go here + + r5.xyz = sdr_ap1_color; + + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].www * r5.xyz + r1.xyz; + + // BlueBlueCorrectInv + r5.x = dot(float3(1.06537485, 1.44678506e-06, -0.0653710067), r1.xyz); + r5.y = dot(float3(-3.45525592e-07, 1.20366347, -0.203667715), r1.xyz); + r5.z = dot(float3(1.9865448e-08, 2.12079581e-08, 0.999999583), r1.xyz); + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].yyy * r5.xyz + r1.xyz; + r5.x = saturate(dot(cb1[12].xyz, r1.xyz)); + r5.y = saturate(dot(cb1[13].xyz, r1.xyz)); + r5.z = saturate(dot(cb1[14].xyz, r1.xyz)); + r1.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r5.xyz; + r6.xyz = cmp(r5.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r5.xyz = log2(r5.xyz); + r5.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = r5.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r1.xyz = r6.xyz ? r5.xyz : r1.xyz; + r5.yzw = r1.xyz * float3(0.9375, 0.9375, 0.9375) + float3(0.03125, 0.03125, 0.03125); + r0.w = r5.w * 16 + -0.5; + r1.w = floor(r0.w); + r0.w = -r1.w + r0.w; + r1.w = r5.y + r1.w; + r5.x = 0.0625 * r1.w; + r6.xyz = t0.Sample(s0_s, r5.xz).xyz; + r5.xy = float2(0.0625, 0) + r5.xz; + r5.xyz = t0.Sample(s0_s, r5.xy).xyz; + r5.xyz = r5.xyz + -r6.xyz; + r5.xyz = r0.www * r5.xyz + r6.xyz; + r5.xyz = cb0[5].yyy * r5.xyz; + r1.xyz = cb0[5].xxx * r1.xyz + r5.xyz; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r5.xyz = cmp(float3(0.0404499993, 0.0404499993, 0.0404499993) < r1.xyz); + r6.xyz = r1.xyz * float3(0.947867274, 0.947867274, 0.947867274) + float3(0.0521326996, 0.0521326996, 0.0521326996); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(2.4000001, 2.4000001, 2.4000001) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r1.xyz = float3(0.0773993805, 0.0773993805, 0.0773993805) * r1.xyz; + r1.xyz = r5.xyz ? r6.xyz : r1.xyz; + r5.xyz = r1.xyz * r1.xyz; + r1.xyz = cb0[39].yyy * r1.xyz; + r1.xyz = cb0[39].xxx * r5.xyz + r1.xyz; + r1.xyz = cb0[39].zzz + r1.xyz; + r5.xyz = cb0[14].xyz * r1.xyz; + r1.xyz = -r1.xyz * cb0[14].xyz + cb0[13].xyz; + r1.xyz = cb0[13].www * r1.xyz + r5.xyz; + r5.xyz = max(float3(0, 0, 0), r1.xyz); + r5.xyz = log2(r5.xyz); + r5.xyz = cb0[40].yyy * r5.xyz; + r5.xyz = exp2(r5.xyz); + + float3 film_graded_color = r5.rgb; + + // Add upgrade tonemap here + if (injectedData.toneMapType != 0.f) { + float3 final_color = saturate(film_graded_color); + + if (injectedData.toneMapType != 1.f) { + final_color = renodx::tonemap::UpgradeToneMap(hdr_color, sdr_color, final_color, 1.f); + } else { + final_color = hdr_color; + } + + final_color = renodx::color::bt2020::from::BT709(final_color); + float encodeRate = injectedData.toneMapType > 1.f ? injectedData.toneMapGameNits : 100.f; + final_color = renodx::color::pq::Encode(final_color, encodeRate); + + o0.rgba = float4(final_color, 0); + return; + } + + if (cb0[40].w == 0) { // cb[40].w = output device + r6.x = dot(cb1[8].xyz, r5.xyz); + r6.y = dot(cb1[9].xyz, r5.xyz); + r6.z = dot(cb1[10].xyz, r5.xyz); + r7.x = dot(r3.xyz, r6.xyz); + r7.y = dot(r4.xyz, r6.xyz); + r7.z = dot(r2.xyz, r6.xyz); + r6.xyz = cb1[20].xxx ? r5.xyz : r7.xyz; + r7.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r6.xyz; + r8.xyz = cmp(r6.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r6.xyz = r6.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r6.xyz = r8.xyz ? r6.xyz : r7.xyz; + } else { + r0.w = cmp(1 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r5.xyz); + r7.y = dot(cb1[9].xyz, r5.xyz); + r7.z = dot(cb1[10].xyz, r5.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r8.xyz); + r8.xyz = float3(4.5, 4.5, 4.5) * r7.xyz; + r7.xyz = max(float3(0.0179999992, 0.0179999992, 0.0179999992), r7.xyz); + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.449999988, 0.449999988, 0.449999988) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r7.xyz = r7.xyz * float3(1.09899998, 1.09899998, 1.09899998) + float3(-0.0989999995, -0.0989999995, -0.0989999995); + r6.xyz = min(r8.xyz, r7.xyz); + } else { + r7.x = dot(cb1[12].xyz, r0.xyz); + r7.y = dot(cb1[13].xyz, r0.xyz); + r7.z = dot(cb1[14].xyz, r0.xyz); + r0.xyz = cb0[14].xyz * r7.xyz; + r7.xyz = -r7.xyz * cb0[14].xyz + cb0[13].xyz; + r0.xyz = cb0[13].www * r7.xyz + r0.xyz; + r7.xy = cmp(int2(3, 5) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(5 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(4, 6) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(6 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r0.w = cmp(7 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r0.xyz); + r7.y = dot(cb1[9].xyz, r0.xyz); + r7.z = dot(cb1[10].xyz, r0.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r8.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(8, 9) == asint(cb0[40].ww)); + r8.x = dot(cb1[8].xyz, r1.xyz); + r8.y = dot(cb1[9].xyz, r1.xyz); + r8.z = dot(cb1[10].xyz, r1.xyz); + r1.x = dot(r3.xyz, r8.xyz); + r1.y = dot(r4.xyz, r8.xyz); + r1.z = dot(r2.xyz, r8.xyz); + r8.x = dot(cb1[8].xyz, r5.xyz); + r8.y = dot(cb1[9].xyz, r5.xyz); + r8.z = dot(cb1[10].xyz, r5.xyz); + r0.w = dot(r3.xyz, r8.xyz); + r1.w = dot(r4.xyz, r8.xyz); + r2.x = dot(r2.xyz, r8.xyz); + r3.x = log2(r0.w); + r3.y = log2(r1.w); + r3.z = log2(r2.x); + r2.xyz = cb0[40].zzz * r3.xyz; + r2.xyz = exp2(r2.xyz); + r1.xyz = r7.yyy ? r1.xyz : r2.xyz; + r6.xyz = r7.xxx ? r0.xyz : r1.xyz; + } + } + } + } + } + o0.xyz = float3(0.952381015, 0.952381015, 0.952381015) * r6.xyz; + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/lutbuilder_0x36E3A438.ps_5_1.hlsl b/src/games/dbzspark/lutbuilder_0x36E3A438.ps_5_1.hlsl new file mode 100644 index 00000000..b60c4668 --- /dev/null +++ b/src/games/dbzspark/lutbuilder_0x36E3A438.ps_5_1.hlsl @@ -0,0 +1,1435 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:09 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[21]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[42]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + uint v2 : SV_RenderTargetArrayIndex0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14; + uint4 bitmask, uiDest; + float4 fDest; + + r0.xy = float2(-0.015625, -0.015625) + v0.xy; + r0.xy = float2(1.03225803, 1.03225803) * r0.xy; + r0.z = (uint)v2.x; + r1.z = 0.0322580636 * r0.z; + r2.xyzw = cmp(int4(1, 2, 3, 4) == asint(cb0[41].xxxx)); + r3.xyz = r2.www ? float3(1, 0, 0) : float3(1.70505154, -0.621790707, -0.0832583979); + r4.xyz = r2.www ? float3(0, 1, 0) : float3(-0.130257145, 1.14080286, -0.0105485283); + r5.xyz = r2.www ? float3(0, 0, 1) : float3(-0.0240032747, -0.128968775, 1.15297174); + r3.xyz = r2.zzz ? float3(0.695452213, 0.140678704, 0.163869068) : r3.xyz; + r4.xyz = r2.zzz ? float3(0.0447945632, 0.859671116, 0.0955343172) : r4.xyz; + r5.xyz = r2.zzz ? float3(-0.00552588282, 0.00402521016, 1.00150073) : r5.xyz; + r3.xyz = r2.yyy ? float3(1.02579927, -0.0200525094, -0.00577136781) : r3.xyz; + r4.xyz = r2.yyy ? float3(-0.00223502493, 1.00458264, -0.00235231337) : r4.xyz; + r2.yzw = r2.yyy ? float3(-0.00501400325, -0.0252933875, 1.03044021) : r5.xyz; + r3.xyz = r2.xxx ? float3(1.37915885, -0.308850735, -0.0703467429) : r3.xyz; + r4.xyz = r2.xxx ? float3(-0.0693352968, 1.08229232, -0.0129620517) : r4.xyz; + r2.xyz = r2.xxx ? float3(-0.00215925858, -0.0454653986, 1.04775953) : r2.yzw; + r0.z = cmp(asuint(cb0[40].w) >= 3); + r5.xy = log2(r0.xy); + r5.z = log2(r1.z); + r0.xyw = float3(0.0126833133, 0.0126833133, 0.0126833133) * r5.xyz; + r0.xyw = exp2(r0.xyw); + r5.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r0.xyw; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyw = -r0.xyw * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r0.xyw = r5.xyz / r0.xyw; + r0.xyw = log2(r0.xyw); + r0.xyw = float3(6.27739477, 6.27739477, 6.27739477) * r0.xyw; + r0.xyw = exp2(r0.xyw); + r0.xyw = float3(100, 100, 100) * r0.xyw; + r1.xy = v0.xy * float2(1.03225803, 1.03225803) + float2(-0.0161290318, -0.0161290318); + r1.xyz = float3(-0.434017599, -0.434017599, -0.434017599) + r1.xyz; + r1.xyz = float3(14, 14, 14) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(0.180000007, 0.180000007, 0.180000007) + float3(-0.00266771927, -0.00266771927, -0.00266771927); + r0.xyz = r0.zzz ? r0.xyw : r1.xyz; + r1.x = dot(cb1[8].xyz, r0.xyz); + r1.y = dot(cb1[9].xyz, r0.xyz); + r1.z = dot(cb1[10].xyz, r0.xyz); + r0.x = dot(r1.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r0.yzw = r1.xyz / r0.xxx; + r0.yzw = float3(-1, -1, -1) + r0.yzw; + r0.y = dot(r0.yzw, r0.yzw); + r0.y = -4 * r0.y; + r0.y = exp2(r0.y); + r0.x = r0.x * r0.x; + r0.x = cb0[36].z * r0.x; + r0.x = -4 * r0.x; + r0.x = exp2(r0.x); + r0.xy = float2(1, 1) + -r0.xy; + r0.x = r0.y * r0.x; + r5.x = dot(float3(1.37041271, -0.329291314, -0.0636827648), r1.xyz); + r5.y = dot(float3(-0.0834341869, 1.09709096, -0.0108615728), r1.xyz); + r5.z = dot(float3(-0.0257932581, -0.0986256376, 1.20369434), r1.xyz); + r0.yzw = r5.xyz + -r1.xyz; + r0.xyz = r0.xxx * r0.yzw + r1.xyz; + r0.w = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r1.xyzw = cb0[20].xyzw * cb0[15].xyzw; + r5.xyzw = cb0[21].xyzw * cb0[16].xyzw; + r6.xyzw = cb0[22].xyzw * cb0[17].xyzw; + r7.xyzw = cb0[23].xyzw * cb0[18].xyzw; + r8.xyzw = cb0[24].xyzw + cb0[19].xyzw; + r1.xyz = r1.xyz * r1.www; + r0.xyz = r0.xyz + -r0.www; + r1.xyz = r1.xyz * r0.xyz + r0.www; + r1.xyz = max(float3(0, 0, 0), r1.xyz); + r1.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r1.xyz; + r5.xyz = r5.xyz * r5.www; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r1.xyz; + r5.xyz = r6.xyz * r6.www; + r5.xyz = float3(1, 1, 1) / r5.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r5.xyz = r7.xyz * r7.www; + r6.xyz = r8.xyz + r8.www; + r1.xyz = r1.xyz * r5.xyz + r6.xyz; + r1.w = 1 / cb0[35].z; + r1.w = saturate(r1.w * r0.w); + r2.w = r1.w * -2 + 3; + r1.w = r1.w * r1.w; + r1.w = -r2.w * r1.w + 1; + r5.xyzw = cb0[30].xyzw * cb0[15].xyzw; + r6.xyzw = cb0[31].xyzw * cb0[16].xyzw; + r7.xyzw = cb0[32].xyzw * cb0[17].xyzw; + r8.xyzw = cb0[33].xyzw * cb0[18].xyzw; + r9.xyzw = cb0[34].xyzw + cb0[19].xyzw; + r5.xyz = r5.xyz * r5.www; + r5.xyz = r5.xyz * r0.xyz + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r5.xyz; + r6.xyz = r6.xyz * r6.www; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r5.xyz; + r6.xyz = r7.xyz * r7.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r6.xyz = r8.xyz * r8.www; + r7.xyz = r9.xyz + r9.www; + r5.xyz = r5.xyz * r6.xyz + r7.xyz; + r2.w = cb0[36].x + -cb0[35].w; + r3.w = -cb0[35].w + r0.w; + r2.w = 1 / r2.w; + r2.w = saturate(r3.w * r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r4.w = r3.w * r2.w; + r6.xyzw = cb0[25].xyzw * cb0[15].xyzw; + r7.xyzw = cb0[26].xyzw * cb0[16].xyzw; + r8.xyzw = cb0[27].xyzw * cb0[17].xyzw; + r9.xyzw = cb0[28].xyzw * cb0[18].xyzw; + r10.xyzw = cb0[29].xyzw + cb0[19].xyzw; + r6.xyz = r6.xyz * r6.www; + r0.xyz = r6.xyz * r0.xyz + r0.www; + r0.xyz = max(float3(0, 0, 0), r0.xyz); + r0.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r0.xyz; + r6.xyz = r7.xyz * r7.www; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r0.xyz; + r6.xyz = r8.xyz * r8.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r6.xyz = r9.xyz * r9.www; + r7.xyz = r10.xyz + r10.www; + r0.xyz = r0.xyz * r6.xyz + r7.xyz; + r0.w = 1 + -r1.w; + r0.w = -r3.w * r2.w + r0.w; + r0.xyz = r0.xyz * r0.www; + r0.xyz = r1.xyz * r1.www + r0.xyz; + r0.xyz = r5.xyz * r4.www + r0.xyz; + + // End of Color Correct + float3 ap1_graded_color = r0.rgb; + float3 ap1_aces_colored = ap1_graded_color; + + // uint output_type = cb0[40].w; + + float3 sdr_color; + float3 hdr_color; + float3 sdr_ap1_color; + + float FilmBlackClip = cb0[37].w; + float FilmToe = cb0[37].y; + float FilmWhiteClip = cb0[38].x; + float FilmShoulder = cb0[37].z; + + // Blue correct -- r0 is still ap1, r1 is sRGB + r1.x = dot(float3(0.938639402, 1.02359565e-10, 0.0613606237), r0.xyz); + r1.y = dot(float3(8.36008554e-11, 0.830794156, 0.169205874), r0.xyz); + r1.z = dot(float3(2.13187367e-12, -5.63307213e-12, 1), r0.xyz); + r1.xyz = r1.xyz + -r0.xyz; + r1.xyz = cb0[36].yyy * r1.xyz + r0.xyz; + + ap1_graded_color = r1.xyz; + + // start of film tonemap + // AP1 => AP0 + + r5.y = dot(float3(0.695452213, 0.140678704, 0.163869068), r1.xyz); + r5.z = dot(float3(0.0447945632, 0.859671116, 0.0955343172), r1.xyz); + r5.w = dot(float3(-0.00552588236, 0.00402521016, 1.00150073), r1.xyz); + r0.w = min(r5.y, r5.z); + r0.w = min(r0.w, r5.w); + r1.w = max(r5.y, r5.z); + r1.w = max(r1.w, r5.w); + r6.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r6.x + -r0.w; + r0.w = r0.w / r6.y; + r6.xyz = r5.wzy + -r5.zyw; + r6.xy = r6.xy * r5.wz; + r1.w = r6.x + r6.y; + r1.w = r5.y * r6.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r5.w + r5.z; + r2.w = r2.w + r5.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.x = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.x + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r6.yzw = r5.yzw * r1.www; + r7.xy = cmp(r6.zw == r6.yz); + r2.w = r7.y ? r7.x : 0; + r3.w = r5.z * r1.w + -r6.w; + r3.w = 1.73205078 * r3.w; + r4.w = r6.y * 2 + -r6.z; + r4.w = -r5.w * r1.w + r4.w; + r5.x = min(abs(r4.w), abs(r3.w)); + r5.z = max(abs(r4.w), abs(r3.w)); + r5.z = 1 / r5.z; + r5.x = r5.x * r5.z; + r5.z = r5.x * r5.x; + r5.w = r5.z * 0.0208350997 + -0.0851330012; + r5.w = r5.z * r5.w + 0.180141002; + r5.w = r5.z * r5.w + -0.330299497; + r5.z = r5.z * r5.w + 0.999866009; + r5.w = r5.x * r5.z; + r7.x = cmp(abs(r4.w) < abs(r3.w)); + r5.w = r5.w * -2 + 1.57079637; + r5.w = r7.x ? r5.w : 0; + r5.x = r5.x * r5.z + r5.w; + r5.z = cmp(r4.w < -r4.w); + r5.z = r5.z ? -3.141593 : 0; + r5.x = r5.x + r5.z; + r5.z = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r5.z < -r5.z); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.x : r5.x; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + // aces::hueweight (with smoothstep) + r2.w = r3.w ? r4.w : r2.w; + r2.w = 0.0148148146 * r2.w; + r2.w = 1 + -abs(r2.w); + r2.w = max(0, r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r2.w = r3.w * r2.w; + r2.w = r2.w * r2.w; + r0.w = r2.w * r0.w; + r1.w = -r5.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r6.x = r0.w * 0.180000007 + r6.y; + // AP0 => AP1 + r5.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r6.xzw); + r5.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r6.xzw); + r5.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r6.xzw); + r5.xyz = max(float3(0, 0, 0), r5.xyz); + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; // End of ACES:RRT + + ap1_aces_colored = r5.xyz; + + // If statement with first dual tonemap would go here + + if (injectedData.toneMapType != 0.f) { + renodx::tonemap::Config config = getCommonConfig(); + + float3 config_color = renodx::color::bt709::from::AP1(ap1_graded_color); + + renodx::tonemap::config::DualToneMap dual_tone_map = renodx::tonemap::config::ApplyToneMaps(config_color, config); + hdr_color = dual_tone_map.color_hdr; + sdr_color = dual_tone_map.color_sdr; + sdr_ap1_color = renodx::color::ap1::from::BT709(sdr_color); + } else { + // Film Toe > 0.8 + r6.xy = cb0[37].ww + float2(1, 0.180000007); + r0.w = -cb0[37].y + r6.x; + r1.w = cb0[38].x + 1; + r2.w = -cb0[37].z + r1.w; + r3.w = cmp(0.800000012 < cb0[37].y); + r6.xz = -cb0[37].yy + float2(0.819999993, 1); + r6.xz = r6.xz / cb0[37].xx; + r4.w = -0.744727492 + r6.x; + r5.w = r6.y / r0.w; + r6.x = -1 + r5.w; + r6.x = 1 + -r6.x; + r5.w = r5.w / r6.x; + r5.w = log2(r5.w); + r5.w = 0.346573591 * r5.w; + r6.x = r0.w / cb0[37].x; + r5.w = -r5.w * r6.x + -0.744727492; + r3.w = r3.w ? r4.w : r5.w; + r4.w = r6.z + -r3.w; + r5.w = cb0[37].z / cb0[37].x; + r5.w = r5.w + -r4.w; + r5.xyz = log2(r5.xyz); + r6.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r5.xyz; + r7.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + r4.www; + r7.xyz = cb0[37].xxx * r7.xyz; + r4.w = r0.w + r0.w; + r6.w = cb0[37].x * -2; + r0.w = r6.w / r0.w; + r8.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r3.www; + r9.xyz = r8.xyz * r0.www; + r9.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r9.xyz; + r9.xyz = exp2(r9.xyz); + r9.xyz = float3(1, 1, 1) + r9.xyz; + r9.xyz = r4.www / r9.xyz; + r9.xyz = -cb0[37].www + r9.xyz; + r0.w = r2.w + r2.w; + r4.w = cb0[37].x + cb0[37].x; + r2.w = r4.w / r2.w; + r5.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r5.www; + r5.xyz = r5.xyz * r2.www; + r5.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(1, 1, 1) + r5.xyz; + r5.xyz = r0.www / r5.xyz; + r5.xyz = -r5.xyz + r1.www; + r10.xyz = cmp(r6.xyz < r3.www); + r9.xyz = r10.xyz ? r9.xyz : r7.xyz; + r6.xyz = cmp(r5.www < r6.xyz); + r5.xyz = r6.xyz ? r5.xyz : r7.xyz; + r0.w = r5.w + -r3.w; + r6.xyz = saturate(r8.xyz / r0.www); + r0.w = cmp(r5.w < r3.w); + r7.xyz = float3(1, 1, 1) + -r6.xyz; + r6.xyz = r0.www ? r7.xyz : r6.xyz; + r7.xyz = -r6.xyz * float3(2, 2, 2) + float3(3, 3, 3); + r6.xyz = r6.xyz * r6.xyz; + r6.xyz = r6.xyz * r7.xyz; + r5.xyz = r5.xyz + -r9.xyz; + r5.xyz = r6.xyz * r5.xyz + r9.xyz; + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.930000007, 0.930000007, 0.930000007) + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + sdr_ap1_color = r5.xyz; + } // The } from the dualtonemap if statement would go here + + r5.xyz = sdr_ap1_color; + + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].www * r5.xyz + r1.xyz; + + // BlueBlueCorrectInv + r5.x = dot(float3(1.06537485, 1.44678506e-06, -0.0653710067), r1.xyz); + r5.y = dot(float3(-3.45525592e-07, 1.20366347, -0.203667715), r1.xyz); + r5.z = dot(float3(1.9865448e-08, 2.12079581e-08, 0.999999583), r1.xyz); + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].yyy * r5.xyz + r1.xyz; + r5.x = saturate(dot(cb1[12].xyz, r1.xyz)); + r5.y = saturate(dot(cb1[13].xyz, r1.xyz)); + r5.z = saturate(dot(cb1[14].xyz, r1.xyz)); + r1.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r5.xyz; + r6.xyz = cmp(r5.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r5.xyz = log2(r5.xyz); + r5.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = r5.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r1.xyz = r6.xyz ? r5.xyz : r1.xyz; + r5.yzw = r1.xyz * float3(0.9375, 0.9375, 0.9375) + float3(0.03125, 0.03125, 0.03125); + r0.w = r5.w * 16 + -0.5; + r1.w = floor(r0.w); + r0.w = -r1.w + r0.w; + r1.w = r5.y + r1.w; + r5.x = 0.0625 * r1.w; + r6.xyz = t0.Sample(s0_s, r5.xz).xyz; + r5.yw = float2(0.0625, 0) + r5.xz; + r7.xyz = t0.Sample(s0_s, r5.yw).xyz; + r7.xyz = r7.xyz + -r6.xyz; + r6.xyz = r0.www * r7.xyz + r6.xyz; + r6.xyz = cb0[5].yyy * r6.xyz; + r1.xyz = cb0[5].xxx * r1.xyz + r6.xyz; + r6.xyz = t1.Sample(s1_s, r5.xz).xyz; + r5.xyz = t1.Sample(s1_s, r5.yw).xyz; + r5.xyz = r5.xyz + -r6.xyz; + r5.xyz = r0.www * r5.xyz + r6.xyz; + r1.xyz = cb0[5].zzz * r5.xyz + r1.xyz; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r5.xyz = cmp(float3(0.0404499993, 0.0404499993, 0.0404499993) < r1.xyz); + r6.xyz = r1.xyz * float3(0.947867274, 0.947867274, 0.947867274) + float3(0.0521326996, 0.0521326996, 0.0521326996); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(2.4000001, 2.4000001, 2.4000001) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r1.xyz = float3(0.0773993805, 0.0773993805, 0.0773993805) * r1.xyz; + r1.xyz = r5.xyz ? r6.xyz : r1.xyz; + r5.xyz = r1.xyz * r1.xyz; + r1.xyz = cb0[39].yyy * r1.xyz; + r1.xyz = cb0[39].xxx * r5.xyz + r1.xyz; + r1.xyz = cb0[39].zzz + r1.xyz; + r5.xyz = cb0[14].xyz * r1.xyz; + r1.xyz = -r1.xyz * cb0[14].xyz + cb0[13].xyz; + r1.xyz = cb0[13].www * r1.xyz + r5.xyz; + r5.xyz = max(float3(0, 0, 0), r1.xyz); + r5.xyz = log2(r5.xyz); + r5.xyz = cb0[40].yyy * r5.xyz; + r5.xyz = exp2(r5.xyz); + + float3 film_graded_color = r5.rgb; + + // Add upgrade tonemap here + if (injectedData.toneMapType != 0.f) { + float3 final_color = saturate(film_graded_color); + + if (injectedData.toneMapType != 1.f) { + final_color = renodx::tonemap::UpgradeToneMap(hdr_color, sdr_color, final_color, 1.f); + } else { + final_color = hdr_color; + } + + final_color = renodx::color::bt2020::from::BT709(final_color); + float encodeRate = injectedData.toneMapType > 1.f ? injectedData.toneMapGameNits : 100.f; + final_color = renodx::color::pq::Encode(final_color, encodeRate); + + o0.rgba = float4(final_color, 0); + return; + } + + if (cb0[40].w == 0) { // cb[40].w = output device + // SDR path + r6.x = dot(cb1[8].xyz, r5.xyz); + r6.y = dot(cb1[9].xyz, r5.xyz); + r6.z = dot(cb1[10].xyz, r5.xyz); + r7.x = dot(r3.xyz, r6.xyz); + r7.y = dot(r4.xyz, r6.xyz); + r7.z = dot(r2.xyz, r6.xyz); + r6.xyz = cb1[20].xxx ? r5.xyz : r7.xyz; + r7.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r6.xyz; + r8.xyz = cmp(r6.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r6.xyz = r6.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r6.xyz = r8.xyz ? r6.xyz : r7.xyz; + } else { + r0.w = cmp(1 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r5.xyz); + r7.y = dot(cb1[9].xyz, r5.xyz); + r7.z = dot(cb1[10].xyz, r5.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r8.xyz); + r8.xyz = float3(4.5, 4.5, 4.5) * r7.xyz; + r7.xyz = max(float3(0.0179999992, 0.0179999992, 0.0179999992), r7.xyz); + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.449999988, 0.449999988, 0.449999988) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r7.xyz = r7.xyz * float3(1.09899998, 1.09899998, 1.09899998) + float3(-0.0989999995, -0.0989999995, -0.0989999995); + r6.xyz = min(r8.xyz, r7.xyz); + } else { + r7.x = dot(cb1[12].xyz, r0.xyz); + r7.y = dot(cb1[13].xyz, r0.xyz); + r7.z = dot(cb1[14].xyz, r0.xyz); + r0.xyz = cb0[14].xyz * r7.xyz; + r7.xyz = -r7.xyz * cb0[14].xyz + cb0[13].xyz; + r0.xyz = cb0[13].www * r7.xyz + r0.xyz; + r7.xy = cmp(int2(3, 5) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(5 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(4, 6) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(6 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r0.w = cmp(7 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r0.xyz); + r7.y = dot(cb1[9].xyz, r0.xyz); + r7.z = dot(cb1[10].xyz, r0.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r8.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(8, 9) == asint(cb0[40].ww)); + r8.x = dot(cb1[8].xyz, r1.xyz); + r8.y = dot(cb1[9].xyz, r1.xyz); + r8.z = dot(cb1[10].xyz, r1.xyz); + r1.x = dot(r3.xyz, r8.xyz); + r1.y = dot(r4.xyz, r8.xyz); + r1.z = dot(r2.xyz, r8.xyz); + r8.x = dot(cb1[8].xyz, r5.xyz); + r8.y = dot(cb1[9].xyz, r5.xyz); + r8.z = dot(cb1[10].xyz, r5.xyz); + r0.w = dot(r3.xyz, r8.xyz); + r1.w = dot(r4.xyz, r8.xyz); + r2.x = dot(r2.xyz, r8.xyz); + r3.x = log2(r0.w); + r3.y = log2(r1.w); + r3.z = log2(r2.x); + r2.xyz = cb0[40].zzz * r3.xyz; + r2.xyz = exp2(r2.xyz); + r1.xyz = r7.yyy ? r1.xyz : r2.xyz; + r6.xyz = r7.xxx ? r0.xyz : r1.xyz; + } + } + } + } + } + o0.xyz = float3(0.952381015, 0.952381015, 0.952381015) * r6.xyz; + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/lutbuilder_0xC2A711CC.ps_5_1.hlsl b/src/games/dbzspark/lutbuilder_0xC2A711CC.ps_5_1.hlsl new file mode 100644 index 00000000..33291222 --- /dev/null +++ b/src/games/dbzspark/lutbuilder_0xC2A711CC.ps_5_1.hlsl @@ -0,0 +1,1426 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:17 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture2D t0 : register(t0); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[21]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[42]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + uint v2 : SV_RenderTargetArrayIndex0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14; + uint4 bitmask, uiDest; + float4 fDest; + + r0.xy = float2(-0.015625, -0.015625) + v0.xy; + r0.xy = float2(1.03225803, 1.03225803) * r0.xy; + r0.z = (uint)v2.x; + r1.z = 0.0322580636 * r0.z; + r2.xyzw = cmp(int4(1, 2, 3, 4) == asint(cb0[41].xxxx)); + r3.xyz = r2.www ? float3(1, 0, 0) : float3(1.70505154, -0.621790707, -0.0832583979); + r4.xyz = r2.www ? float3(0, 1, 0) : float3(-0.130257145, 1.14080286, -0.0105485283); + r5.xyz = r2.www ? float3(0, 0, 1) : float3(-0.0240032747, -0.128968775, 1.15297174); + r3.xyz = r2.zzz ? float3(0.695452213, 0.140678704, 0.163869068) : r3.xyz; + r4.xyz = r2.zzz ? float3(0.0447945632, 0.859671116, 0.0955343172) : r4.xyz; + r5.xyz = r2.zzz ? float3(-0.00552588282, 0.00402521016, 1.00150073) : r5.xyz; + r3.xyz = r2.yyy ? float3(1.02579927, -0.0200525094, -0.00577136781) : r3.xyz; + r4.xyz = r2.yyy ? float3(-0.00223502493, 1.00458264, -0.00235231337) : r4.xyz; + r2.yzw = r2.yyy ? float3(-0.00501400325, -0.0252933875, 1.03044021) : r5.xyz; + r3.xyz = r2.xxx ? float3(1.37915885, -0.308850735, -0.0703467429) : r3.xyz; + r4.xyz = r2.xxx ? float3(-0.0693352968, 1.08229232, -0.0129620517) : r4.xyz; + r2.xyz = r2.xxx ? float3(-0.00215925858, -0.0454653986, 1.04775953) : r2.yzw; + r0.z = cmp(asuint(cb0[40].w) >= 3); + r5.xy = log2(r0.xy); + r5.z = log2(r1.z); + r0.xyw = float3(0.0126833133, 0.0126833133, 0.0126833133) * r5.xyz; + r0.xyw = exp2(r0.xyw); + r5.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r0.xyw; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyw = -r0.xyw * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r0.xyw = r5.xyz / r0.xyw; + r0.xyw = log2(r0.xyw); + r0.xyw = float3(6.27739477, 6.27739477, 6.27739477) * r0.xyw; + r0.xyw = exp2(r0.xyw); + r0.xyw = float3(100, 100, 100) * r0.xyw; + r1.xy = v0.xy * float2(1.03225803, 1.03225803) + float2(-0.0161290318, -0.0161290318); + r1.xyz = float3(-0.434017599, -0.434017599, -0.434017599) + r1.xyz; + r1.xyz = float3(14, 14, 14) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(0.180000007, 0.180000007, 0.180000007) + float3(-0.00266771927, -0.00266771927, -0.00266771927); + r0.xyz = r0.zzz ? r0.xyw : r1.xyz; + r1.x = dot(cb1[8].xyz, r0.xyz); + r1.y = dot(cb1[9].xyz, r0.xyz); + r1.z = dot(cb1[10].xyz, r0.xyz); + r0.x = dot(r1.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r0.yzw = r1.xyz / r0.xxx; + r0.yzw = float3(-1, -1, -1) + r0.yzw; + r0.y = dot(r0.yzw, r0.yzw); + r0.y = -4 * r0.y; + r0.y = exp2(r0.y); + r0.x = r0.x * r0.x; + r0.x = cb0[36].z * r0.x; + r0.x = -4 * r0.x; + r0.x = exp2(r0.x); + r0.xy = float2(1, 1) + -r0.xy; + r0.x = r0.y * r0.x; + r5.x = dot(float3(1.37041271, -0.329291314, -0.0636827648), r1.xyz); + r5.y = dot(float3(-0.0834341869, 1.09709096, -0.0108615728), r1.xyz); + r5.z = dot(float3(-0.0257932581, -0.0986256376, 1.20369434), r1.xyz); + r0.yzw = r5.xyz + -r1.xyz; + r0.xyz = r0.xxx * r0.yzw + r1.xyz; + r0.w = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r1.xyzw = cb0[20].xyzw * cb0[15].xyzw; + r5.xyzw = cb0[21].xyzw * cb0[16].xyzw; + r6.xyzw = cb0[22].xyzw * cb0[17].xyzw; + r7.xyzw = cb0[23].xyzw * cb0[18].xyzw; + r8.xyzw = cb0[24].xyzw + cb0[19].xyzw; + r1.xyz = r1.xyz * r1.www; + r0.xyz = r0.xyz + -r0.www; + r1.xyz = r1.xyz * r0.xyz + r0.www; + r1.xyz = max(float3(0, 0, 0), r1.xyz); + r1.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r1.xyz; + r5.xyz = r5.xyz * r5.www; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r1.xyz; + r5.xyz = r6.xyz * r6.www; + r5.xyz = float3(1, 1, 1) / r5.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = r5.xyz * r1.xyz; + r1.xyz = exp2(r1.xyz); + r5.xyz = r7.xyz * r7.www; + r6.xyz = r8.xyz + r8.www; + r1.xyz = r1.xyz * r5.xyz + r6.xyz; + r1.w = 1 / cb0[35].z; + r1.w = saturate(r1.w * r0.w); + r2.w = r1.w * -2 + 3; + r1.w = r1.w * r1.w; + r1.w = -r2.w * r1.w + 1; + r5.xyzw = cb0[30].xyzw * cb0[15].xyzw; + r6.xyzw = cb0[31].xyzw * cb0[16].xyzw; + r7.xyzw = cb0[32].xyzw * cb0[17].xyzw; + r8.xyzw = cb0[33].xyzw * cb0[18].xyzw; + r9.xyzw = cb0[34].xyzw + cb0[19].xyzw; + r5.xyz = r5.xyz * r5.www; + r5.xyz = r5.xyz * r0.xyz + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r5.xyz; + r6.xyz = r6.xyz * r6.www; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r5.xyz; + r6.xyz = r7.xyz * r7.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r5.xyz = log2(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = exp2(r5.xyz); + r6.xyz = r8.xyz * r8.www; + r7.xyz = r9.xyz + r9.www; + r5.xyz = r5.xyz * r6.xyz + r7.xyz; + r2.w = cb0[36].x + -cb0[35].w; + r3.w = -cb0[35].w + r0.w; + r2.w = 1 / r2.w; + r2.w = saturate(r3.w * r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r4.w = r3.w * r2.w; + r6.xyzw = cb0[25].xyzw * cb0[15].xyzw; + r7.xyzw = cb0[26].xyzw * cb0[16].xyzw; + r8.xyzw = cb0[27].xyzw * cb0[17].xyzw; + r9.xyzw = cb0[28].xyzw * cb0[18].xyzw; + r10.xyzw = cb0[29].xyzw + cb0[19].xyzw; + r6.xyz = r6.xyz * r6.www; + r0.xyz = r6.xyz * r0.xyz + r0.www; + r0.xyz = max(float3(0, 0, 0), r0.xyz); + r0.xyz = float3(5.55555534, 5.55555534, 5.55555534) * r0.xyz; + r6.xyz = r7.xyz * r7.www; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = float3(0.180000007, 0.180000007, 0.180000007) * r0.xyz; + r6.xyz = r8.xyz * r8.www; + r6.xyz = float3(1, 1, 1) / r6.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = r6.xyz * r0.xyz; + r0.xyz = exp2(r0.xyz); + r6.xyz = r9.xyz * r9.www; + r7.xyz = r10.xyz + r10.www; + r0.xyz = r0.xyz * r6.xyz + r7.xyz; + r0.w = 1 + -r1.w; + r0.w = -r3.w * r2.w + r0.w; + r0.xyz = r0.xyz * r0.www; + r0.xyz = r1.xyz * r1.www + r0.xyz; + r0.xyz = r5.xyz * r4.www + r0.xyz; + + // End of Color Correct + float3 ap1_graded_color = r0.rgb; + float3 ap1_aces_colored = ap1_graded_color; + + // uint output_type = cb0[40].w; + + float3 sdr_color; + float3 hdr_color; + float3 sdr_ap1_color; + + float FilmBlackClip = cb0[37].w; + float FilmToe = cb0[37].y; + float FilmWhiteClip = cb0[38].x; + float FilmShoulder = cb0[37].z; + + // Blue correct -- r0 is still ap1, r1 is sRGB + r1.x = dot(float3(0.938639402, 1.02359565e-10, 0.0613606237), r0.xyz); + r1.y = dot(float3(8.36008554e-11, 0.830794156, 0.169205874), r0.xyz); + r1.z = dot(float3(2.13187367e-12, -5.63307213e-12, 1), r0.xyz); + r1.xyz = r1.xyz + -r0.xyz; + r1.xyz = cb0[36].yyy * r1.xyz + r0.xyz; + + ap1_graded_color = r1.xyz; + + // start of film tonemap + // AP1 => AP0 + + r5.y = dot(float3(0.695452213, 0.140678704, 0.163869068), r1.xyz); + r5.z = dot(float3(0.0447945632, 0.859671116, 0.0955343172), r1.xyz); + r5.w = dot(float3(-0.00552588236, 0.00402521016, 1.00150073), r1.xyz); + r0.w = min(r5.y, r5.z); + r0.w = min(r0.w, r5.w); + r1.w = max(r5.y, r5.z); + r1.w = max(r1.w, r5.w); + r6.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r6.x + -r0.w; + r0.w = r0.w / r6.y; + r6.xyz = r5.wzy + -r5.zyw; + r6.xy = r6.xy * r5.wz; + r1.w = r6.x + r6.y; + r1.w = r5.y * r6.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r5.w + r5.z; + r2.w = r2.w + r5.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.x = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.x + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r6.yzw = r5.yzw * r1.www; + r7.xy = cmp(r6.zw == r6.yz); + r2.w = r7.y ? r7.x : 0; + r3.w = r5.z * r1.w + -r6.w; + r3.w = 1.73205078 * r3.w; + r4.w = r6.y * 2 + -r6.z; + r4.w = -r5.w * r1.w + r4.w; + r5.x = min(abs(r4.w), abs(r3.w)); + r5.z = max(abs(r4.w), abs(r3.w)); + r5.z = 1 / r5.z; + r5.x = r5.x * r5.z; + r5.z = r5.x * r5.x; + r5.w = r5.z * 0.0208350997 + -0.0851330012; + r5.w = r5.z * r5.w + 0.180141002; + r5.w = r5.z * r5.w + -0.330299497; + r5.z = r5.z * r5.w + 0.999866009; + r5.w = r5.x * r5.z; + r7.x = cmp(abs(r4.w) < abs(r3.w)); + r5.w = r5.w * -2 + 1.57079637; + r5.w = r7.x ? r5.w : 0; + r5.x = r5.x * r5.z + r5.w; + r5.z = cmp(r4.w < -r4.w); + r5.z = r5.z ? -3.141593 : 0; + r5.x = r5.x + r5.z; + r5.z = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r5.z < -r5.z); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.x : r5.x; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + // aces::hueweight (with smoothstep) + r2.w = r3.w ? r4.w : r2.w; + r2.w = 0.0148148146 * r2.w; + r2.w = 1 + -abs(r2.w); + r2.w = max(0, r2.w); + r3.w = r2.w * -2 + 3; + r2.w = r2.w * r2.w; + r2.w = r3.w * r2.w; + r2.w = r2.w * r2.w; + r0.w = r2.w * r0.w; + r1.w = -r5.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r6.x = r0.w * 0.180000007 + r6.y; + // AP0 => AP1 + r5.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r6.xzw); + r5.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r6.xzw); + r5.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r6.xzw); + r5.xyz = max(float3(0, 0, 0), r5.xyz); + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; // End of ACES:RRT + + ap1_aces_colored = r5.xyz; + + // If statement with first dual tonemap would go here + + if (injectedData.toneMapType != 0.f) { + renodx::tonemap::Config config = getCommonConfig(); + + float3 config_color = renodx::color::bt709::from::AP1(ap1_graded_color); + + renodx::tonemap::config::DualToneMap dual_tone_map = renodx::tonemap::config::ApplyToneMaps(config_color, config); + hdr_color = dual_tone_map.color_hdr; + sdr_color = dual_tone_map.color_sdr; + sdr_ap1_color = renodx::color::ap1::from::BT709(sdr_color); + } else { + // Film Toe > 0.8 + r6.xy = cb0[37].ww + float2(1, 0.180000007); + r0.w = -cb0[37].y + r6.x; + r1.w = cb0[38].x + 1; + r2.w = -cb0[37].z + r1.w; + r3.w = cmp(0.800000012 < cb0[37].y); + r6.xz = -cb0[37].yy + float2(0.819999993, 1); + r6.xz = r6.xz / cb0[37].xx; + r4.w = -0.744727492 + r6.x; + r5.w = r6.y / r0.w; + r6.x = -1 + r5.w; + r6.x = 1 + -r6.x; + r5.w = r5.w / r6.x; + r5.w = log2(r5.w); + r5.w = 0.346573591 * r5.w; + r6.x = r0.w / cb0[37].x; + r5.w = -r5.w * r6.x + -0.744727492; + r3.w = r3.w ? r4.w : r5.w; + r4.w = r6.z + -r3.w; + r5.w = cb0[37].z / cb0[37].x; + r5.w = r5.w + -r4.w; + r5.xyz = log2(r5.xyz); + r6.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r5.xyz; + r7.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + r4.www; + r7.xyz = cb0[37].xxx * r7.xyz; + r4.w = r0.w + r0.w; + r6.w = cb0[37].x * -2; + r0.w = r6.w / r0.w; + r8.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r3.www; + r9.xyz = r8.xyz * r0.www; + r9.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r9.xyz; + r9.xyz = exp2(r9.xyz); + r9.xyz = float3(1, 1, 1) + r9.xyz; + r9.xyz = r4.www / r9.xyz; + r9.xyz = -cb0[37].www + r9.xyz; + r0.w = r2.w + r2.w; + r4.w = cb0[37].x + cb0[37].x; + r2.w = r4.w / r2.w; + r5.xyz = r5.xyz * float3(0.30103001, 0.30103001, 0.30103001) + -r5.www; + r5.xyz = r5.xyz * r2.www; + r5.xyz = float3(1.44269502, 1.44269502, 1.44269502) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = float3(1, 1, 1) + r5.xyz; + r5.xyz = r0.www / r5.xyz; + r5.xyz = -r5.xyz + r1.www; + r10.xyz = cmp(r6.xyz < r3.www); + r9.xyz = r10.xyz ? r9.xyz : r7.xyz; + r6.xyz = cmp(r5.www < r6.xyz); + r5.xyz = r6.xyz ? r5.xyz : r7.xyz; + r0.w = r5.w + -r3.w; + r6.xyz = saturate(r8.xyz / r0.www); + r0.w = cmp(r5.w < r3.w); + r7.xyz = float3(1, 1, 1) + -r6.xyz; + r6.xyz = r0.www ? r7.xyz : r6.xyz; + r7.xyz = -r6.xyz * float3(2, 2, 2) + float3(3, 3, 3); + r6.xyz = r6.xyz * r6.xyz; + r6.xyz = r6.xyz * r7.xyz; + r5.xyz = r5.xyz + -r9.xyz; + r5.xyz = r6.xyz * r5.xyz + r9.xyz; + // AP1_RGB2Y + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.930000007, 0.930000007, 0.930000007) + r0.www; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + sdr_ap1_color = r5.xyz; + } // The } from the dualtonemap if statement would go here + + r5.xyz = sdr_ap1_color; + + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].www * r5.xyz + r1.xyz; + + // BlueBlueCorrectInv + r5.x = dot(float3(1.06537485, 1.44678506e-06, -0.0653710067), r1.xyz); + r5.y = dot(float3(-3.45525592e-07, 1.20366347, -0.203667715), r1.xyz); + r5.z = dot(float3(1.9865448e-08, 2.12079581e-08, 0.999999583), r1.xyz); + r5.xyz = r5.xyz + -r1.xyz; + r1.xyz = cb0[36].yyy * r5.xyz + r1.xyz; + r5.x = saturate(dot(cb1[12].xyz, r1.xyz)); + r5.y = saturate(dot(cb1[13].xyz, r1.xyz)); + r5.z = saturate(dot(cb1[14].xyz, r1.xyz)); + r1.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r5.xyz; + r6.xyz = cmp(r5.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r5.xyz = log2(r5.xyz); + r5.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r5.xyz = r5.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r1.xyz = r6.xyz ? r5.xyz : r1.xyz; + r5.yzw = r1.xyz * float3(0.9375, 0.9375, 0.9375) + float3(0.03125, 0.03125, 0.03125); + r0.w = r5.w * 16 + -0.5; + r1.w = floor(r0.w); + r0.w = -r1.w + r0.w; + r1.w = r5.y + r1.w; + r5.x = 0.0625 * r1.w; + r6.xyz = t0.Sample(s0_s, r5.xz).xyz; + r5.xy = float2(0.0625, 0) + r5.xz; + r5.xyz = t0.Sample(s0_s, r5.xy).xyz; + r5.xyz = r5.xyz + -r6.xyz; + r5.xyz = r0.www * r5.xyz + r6.xyz; + r5.xyz = cb0[5].yyy * r5.xyz; + r1.xyz = cb0[5].xxx * r1.xyz + r5.xyz; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r5.xyz = cmp(float3(0.0404499993, 0.0404499993, 0.0404499993) < r1.xyz); + r6.xyz = r1.xyz * float3(0.947867274, 0.947867274, 0.947867274) + float3(0.0521326996, 0.0521326996, 0.0521326996); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(2.4000001, 2.4000001, 2.4000001) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r1.xyz = float3(0.0773993805, 0.0773993805, 0.0773993805) * r1.xyz; + r1.xyz = r5.xyz ? r6.xyz : r1.xyz; + r5.xyz = r1.xyz * r1.xyz; + r1.xyz = cb0[39].yyy * r1.xyz; + r1.xyz = cb0[39].xxx * r5.xyz + r1.xyz; + r1.xyz = cb0[39].zzz + r1.xyz; + r5.xyz = cb0[14].xyz * r1.xyz; + r1.xyz = -r1.xyz * cb0[14].xyz + cb0[13].xyz; + r1.xyz = cb0[13].www * r1.xyz + r5.xyz; + r5.xyz = max(float3(0, 0, 0), r1.xyz); + r5.xyz = log2(r5.xyz); + r5.xyz = cb0[40].yyy * r5.xyz; + r5.xyz = exp2(r5.xyz); + + float3 film_graded_color = r5.rgb; + + // Add upgrade tonemap here + if (injectedData.toneMapType != 0.f) { + float3 final_color = saturate(film_graded_color); + + if (injectedData.toneMapType != 1.f) { + final_color = renodx::tonemap::UpgradeToneMap(hdr_color, sdr_color, final_color, 1.f); + } else { + final_color = hdr_color; + } + + final_color = renodx::color::bt2020::from::BT709(final_color); + float encodeRate = injectedData.toneMapType > 1.f ? injectedData.toneMapGameNits : 100.f; + final_color = renodx::color::pq::Encode(final_color, encodeRate); + + o0.rgba = float4(final_color, 0); + return; + } + + if (cb0[40].w == 0) { // cb[40].w = output device + r6.x = dot(cb1[8].xyz, r5.xyz); + r6.y = dot(cb1[9].xyz, r5.xyz); + r6.z = dot(cb1[10].xyz, r5.xyz); + r7.x = dot(r3.xyz, r6.xyz); + r7.y = dot(r4.xyz, r6.xyz); + r7.z = dot(r2.xyz, r6.xyz); + r6.xyz = cb1[20].xxx ? r5.xyz : r7.xyz; + r7.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r6.xyz; + r8.xyz = cmp(r6.xyz >= float3(0.00313066994, 0.00313066994, 0.00313066994)); + r6.xyz = log2(r6.xyz); + r6.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r6.xyz; + r6.xyz = exp2(r6.xyz); + r6.xyz = r6.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r6.xyz = r8.xyz ? r6.xyz : r7.xyz; + } else { + r0.w = cmp(1 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r5.xyz); + r7.y = dot(cb1[9].xyz, r5.xyz); + r7.z = dot(cb1[10].xyz, r5.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r8.xyz); + r8.xyz = float3(4.5, 4.5, 4.5) * r7.xyz; + r7.xyz = max(float3(0.0179999992, 0.0179999992, 0.0179999992), r7.xyz); + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.449999988, 0.449999988, 0.449999988) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r7.xyz = r7.xyz * float3(1.09899998, 1.09899998, 1.09899998) + float3(-0.0989999995, -0.0989999995, -0.0989999995); + r6.xyz = min(r8.xyz, r7.xyz); + } else { + r7.x = dot(cb1[12].xyz, r0.xyz); + r7.y = dot(cb1[13].xyz, r0.xyz); + r7.z = dot(cb1[14].xyz, r0.xyz); + r0.xyz = cb0[14].xyz * r7.xyz; + r7.xyz = -r7.xyz * cb0[14].xyz + cb0[13].xyz; + r0.xyz = cb0[13].www * r7.xyz + r0.xyz; + r7.xy = cmp(int2(3, 5) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(5 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(4, 6) == asint(cb0[40].ww)); + r0.w = (int)r7.y | (int)r7.x; + if (r0.w != 0) { + r7.xyz = cb0[12].zzz * r0.xyz; + r8.y = dot(cb1[16].xyz, r7.xyz); + r8.z = dot(cb1[17].xyz, r7.xyz); + r8.w = dot(cb1[18].xyz, r7.xyz); + r0.w = min(r8.y, r8.z); + r0.w = min(r0.w, r8.w); + r1.w = max(r8.y, r8.z); + r1.w = max(r1.w, r8.w); + r7.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r7.x + -r0.w; + r0.w = r0.w / r7.y; + r7.xyz = r8.wzy + -r8.zyw; + r7.xy = r8.wz * r7.xy; + r1.w = r7.x + r7.y; + r1.w = r8.y * r7.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r8.w + r8.z; + r2.w = r2.w + r8.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.w = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.w + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r7.yzw = r8.yzw * r1.www; + r9.xy = cmp(r7.zw == r7.yz); + r2.w = r9.y ? r9.x : 0; + r3.w = r8.z * r1.w + -r7.w; + r3.w = 1.73205078 * r3.w; + r4.w = r7.y * 2 + -r7.z; + r4.w = -r8.w * r1.w + r4.w; + r5.w = min(abs(r4.w), abs(r3.w)); + r6.w = max(abs(r4.w), abs(r3.w)); + r6.w = 1 / r6.w; + r5.w = r6.w * r5.w; + r6.w = r5.w * r5.w; + r8.x = r6.w * 0.0208350997 + -0.0851330012; + r8.x = r6.w * r8.x + 0.180141002; + r8.x = r6.w * r8.x + -0.330299497; + r6.w = r6.w * r8.x + 0.999866009; + r8.x = r6.w * r5.w; + r8.z = cmp(abs(r4.w) < abs(r3.w)); + r8.x = r8.x * -2 + 1.57079637; + r8.x = r8.z ? r8.x : 0; + r5.w = r5.w * r6.w + r8.x; + r6.w = cmp(r4.w < -r4.w); + r6.w = r6.w ? -3.141593 : 0; + r5.w = r6.w + r5.w; + r6.w = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r6.w < -r6.w); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.w : r5.w; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.w = r3.w * r2.w; + r8.xzw = float3(-0.166666672, -0.5, 0.166666672) * r5.www; + r8.xz = r3.ww * float2(0.5, 0.5) + r8.xz; + r8.xz = r2.ww * float2(-0.5, 0.5) + r8.xz; + r2.w = r5.w * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r9.xyz = cmp((int3)r4.www == int3(3, 2, 1)); + r8.xz = float2(0.166666672, 0.166666672) + r8.xz; + r3.w = r4.w ? 0 : r8.w; + r3.w = r9.z ? r8.z : r3.w; + r2.w = r9.y ? r2.w : r3.w; + r2.w = r9.x ? r8.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r8.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r7.x = r0.w * 0.180000007 + r7.y; + r7.xyz = max(float3(0, 0, 0), r7.xzw); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r8.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r7.xyz); + r8.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r7.xyz); + r8.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r7.xyz); + r7.xyz = max(float3(0, 0, 0), r8.xyz); + r7.xyz = min(float3(65504, 65504, 65504), r7.xyz); + r0.w = dot(r7.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r7.xyz = r7.xyz + -r0.www; + r7.xyz = r7.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r7.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r7.xyz); + r7.xyz = log2(r7.xyz); + r8.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r7.xyz; + r0.w = log2(cb0[8].x); + r0.w = 0.30103001 * r0.w; + r9.xyz = cmp(r0.www >= r8.xyz); + if (r9.x != 0) { + r1.w = log2(cb0[8].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r8.x); + r3.w = log2(cb0[9].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r10.y = -r5.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r9.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xw = r9.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[10].xyzw); + r2.w = r9.x * cb0[12].x + r2.w; + r11.x = r9.w * cb0[12].x + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[10].xyzw); + r2.w = r14.x * cb0[12].x + r2.w; + r11.y = r14.y * cb0[12].x + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[10].xyzw); + r2.w = r14.z * cb0[12].x + r2.w; + r11.z = r14.w * cb0[12].x + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = cmp(r8.x >= r4.w); + r3.w = log2(cb0[8].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r8.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r7.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r10.y = -r4.w + r2.w; + r11.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[11].xyzw); + r2.w = r7.x * cb0[12].y + r2.w; + r11.x = r7.w * cb0[12].y + r2.w; + r12.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r13.wzyx, cb0[11].xyzw); + r2.w = r14.x * cb0[12].y + r2.w; + r11.y = r14.y * cb0[12].y + r2.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r12.wzyx, cb0[11].xyzw); + r2.w = r14.z * cb0[12].y + r2.w; + r11.z = r14.w * cb0[12].y + r2.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r1.w = dot(r10.xyz, r12.xyz); + } else { + r2.w = log2(cb0[8].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r9.y != 0) { + r2.w = log2(cb0[8].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r8.y); + r4.w = log2(cb0[9].x); + r5.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r5.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r6.w = trunc(r3.w); + r10.y = -r6.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[10].xyzw); + r3.w = r7.x * cb0[12].x + r3.w; + r11.x = r7.w * cb0[12].x + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[10].xyzw); + r3.w = r14.x * cb0[12].x + r3.w; + r11.y = r14.y * cb0[12].x + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[10].xyzw); + r3.w = r14.z * cb0[12].x + r3.w; + r11.z = r14.w * cb0[12].x + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = cmp(r8.y >= r5.w); + r4.w = log2(cb0[8].z); + r6.w = 0.30103001 * r4.w; + r6.w = cmp(r8.y < r6.w); + r3.w = r3.w ? r6.w : 0; + if (r3.w != 0) { + r3.w = r7.y * 0.30103001 + -r5.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r10.y = -r5.w + r3.w; + r11.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[11].xyzw); + r3.w = r7.x * cb0[12].y + r3.w; + r11.x = r7.y * cb0[12].y + r3.w; + r12.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r13.xyzw = cmp((int4)r12.yyyy == int4(3, 2, 1, 0)); + r14.xyzw = cmp((int4)r12.xyzw == int4(4, 5, 4, 5)); + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r14.xyzw = r14.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r13.wzyx, cb0[11].xyzw); + r3.w = r14.x * cb0[12].y + r3.w; + r11.y = r14.y * cb0[12].y + r3.w; + r12.xyzw = cmp((int4)r12.wwww == int4(3, 2, 1, 0)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r12.wzyx, cb0[11].xyzw); + r3.w = r14.z * cb0[12].y + r3.w; + r11.z = r14.w * cb0[12].y + r3.w; + r10.x = r10.y * r10.y; + r12.x = dot(r11.xzy, float3(0.5, 0.5, -1)); + r12.y = dot(r11.xy, float2(-1, 1)); + r12.z = dot(r11.xy, float2(0.5, 0.5)); + r10.z = 1; + r2.w = dot(r10.xyz, r12.xyz); + } else { + r3.w = log2(cb0[8].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r9.z != 0) { + r3.w = log2(cb0[8].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r8.z); + r5.w = log2(cb0[9].x); + r6.w = 0.30103001 * r5.w; + r7.x = cmp(r8.z < r6.w); + r4.w = r4.w ? r7.x : 0; + if (r4.w != 0) { + r4.w = r7.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.w * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r9.y = -r5.w + r0.w; + r10.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[10].xyzw); + r0.w = r7.x * cb0[12].x + r0.w; + r10.x = r7.y * cb0[12].x + r0.w; + r11.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r12.xyzw = cmp((int4)r11.yyyy == int4(3, 2, 1, 0)); + r13.xyzw = cmp((int4)r11.xyzw == int4(4, 5, 4, 5)); + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r13.xyzw = r13.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r12.wzyx, cb0[10].xyzw); + r0.w = r13.x * cb0[12].x + r0.w; + r10.y = r13.y * cb0[12].x + r0.w; + r11.xyzw = cmp((int4)r11.wwww == int4(3, 2, 1, 0)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r11.wzyx, cb0[10].xyzw); + r0.w = r13.z * cb0[12].x + r0.w; + r10.z = r13.w * cb0[12].x + r0.w; + r9.x = r9.y * r9.y; + r11.x = dot(r10.xzy, float3(0.5, 0.5, -1)); + r11.y = dot(r10.xy, float2(-1, 1)); + r11.z = dot(r10.xy, float2(0.5, 0.5)); + r9.z = 1; + r3.w = dot(r9.xyz, r11.xyz); + } else { + r0.w = cmp(r8.z >= r6.w); + r4.w = log2(cb0[8].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r8.z < r5.w); + r0.w = r0.w ? r5.w : 0; + if (r0.w != 0) { + r0.w = r7.z * 0.30103001 + -r6.w; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r6.w; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.w = trunc(r0.w); + r7.y = -r5.w + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r9.xy = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xy = r9.xy ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[11].xyzw); + r0.w = r9.x * cb0[12].y + r0.w; + r8.x = r9.y * cb0[12].y + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[11].xyzw); + r0.w = r11.x * cb0[12].y + r0.w; + r8.y = r11.y * cb0[12].y + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[11].xyzw); + r0.w = r11.z * cb0[12].y + r0.w; + r8.z = r11.w * cb0[12].y + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = log2(cb0[8].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[8].y + r1.w; + r3.w = cb0[8].w + -cb0[8].y; + r7.x = r1.w / r3.w; + r1.w = -cb0[8].y + r2.w; + r7.y = r1.w / r3.w; + r0.w = -cb0[8].y + r0.w; + r7.z = r0.w / r3.w; + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz)); + r7.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz)); + r7.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz)); + r8.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r7.xyz); + r8.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r7.xyz); + r8.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r7.xyz); + r7.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r8.xyz); + r7.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r8.xyz); + r7.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r8.xyz); + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = cb0[8].www * r7.xyz; + r7.xyz = max(float3(0, 0, 0), r7.xyz); + r7.xyz = min(float3(65535, 65535, 65535), r7.xyz); + r0.w = cmp(6 != asint(cb0[40].w)); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = r0.www ? r8.xyz : r7.xyz; + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r0.w = cmp(7 == asint(cb0[40].w)); + if (r0.w != 0) { + r7.x = dot(cb1[8].xyz, r0.xyz); + r7.y = dot(cb1[9].xyz, r0.xyz); + r7.z = dot(cb1[10].xyz, r0.xyz); + r8.x = dot(r3.xyz, r7.xyz); + r8.y = dot(r4.xyz, r7.xyz); + r8.z = dot(r2.xyz, r7.xyz); + r7.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r8.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r7.xyz; + r7.xyz = exp2(r7.xyz); + r8.xyz = r7.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r7.xyz = r7.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r7.xyz = rcp(r7.xyz); + r7.xyz = r8.xyz * r7.xyz; + r7.xyz = log2(r7.xyz); + r7.xyz = float3(78.84375, 78.84375, 78.84375) * r7.xyz; + r6.xyz = exp2(r7.xyz); + } else { + r7.xy = cmp(int2(8, 9) == asint(cb0[40].ww)); + r8.x = dot(cb1[8].xyz, r1.xyz); + r8.y = dot(cb1[9].xyz, r1.xyz); + r8.z = dot(cb1[10].xyz, r1.xyz); + r1.x = dot(r3.xyz, r8.xyz); + r1.y = dot(r4.xyz, r8.xyz); + r1.z = dot(r2.xyz, r8.xyz); + r8.x = dot(cb1[8].xyz, r5.xyz); + r8.y = dot(cb1[9].xyz, r5.xyz); + r8.z = dot(cb1[10].xyz, r5.xyz); + r0.w = dot(r3.xyz, r8.xyz); + r1.w = dot(r4.xyz, r8.xyz); + r2.x = dot(r2.xyz, r8.xyz); + r3.x = log2(r0.w); + r3.y = log2(r1.w); + r3.z = log2(r2.x); + r2.xyz = cb0[40].zzz * r3.xyz; + r2.xyz = exp2(r2.xyz); + r1.xyz = r7.yyy ? r1.xyz : r2.xyz; + r6.xyz = r7.xxx ? r0.xyz : r1.xyz; + } + } + } + } + } + + o0.xyz = float3(0.952381015, 0.952381015, 0.952381015) * r6.xyz; + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/lutbuilder_0xE2C936EB.ps_5_1.hlsl b/src/games/dbzspark/lutbuilder_0xE2C936EB.ps_5_1.hlsl new file mode 100644 index 00000000..9143e959 --- /dev/null +++ b/src/games/dbzspark/lutbuilder_0xE2C936EB.ps_5_1.hlsl @@ -0,0 +1,973 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:19 2024 +#include "./shared.h" +#include "./tonemapper.hlsl" + +cbuffer cb0 : register(b0) { + float4 cb0[8]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + float4 v1 : SV_POSITION0, + uint v2 : SV_RenderTargetArrayIndex0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12; + uint4 bitmask, uiDest; + float4 fDest; + + r0.xy = float2(-0.015625, -0.015625) + v0.xy; + r0.xy = float2(1.03225803, 1.03225803) * r0.xy; + r0.z = (uint)v2.x; + r1.z = 0.0322580636 * r0.z; + r2.xyzw = cmp(asint(cb0[2].yyyy) == int4(1, 2, 3, 4)); + r3.xyz = r2.www ? float3(1, 0, 0) : float3(1.70505154, -0.621790707, -0.0832583979); + r4.xyz = r2.www ? float3(0, 1, 0) : float3(-0.130257145, 1.14080286, -0.0105485283); + r5.xyz = r2.www ? float3(0, 0, 1) : float3(-0.0240032747, -0.128968775, 1.15297174); + r3.xyz = r2.zzz ? float3(0.695452213, 0.140678704, 0.163869068) : r3.xyz; + r4.xyz = r2.zzz ? float3(0.0447945632, 0.859671116, 0.0955343172) : r4.xyz; + r5.xyz = r2.zzz ? float3(-0.00552588282, 0.00402521016, 1.00150073) : r5.xyz; + r3.xyz = r2.yyy ? float3(1.02579927, -0.0200525094, -0.00577136781) : r3.xyz; + r4.xyz = r2.yyy ? float3(-0.00223502493, 1.00458264, -0.00235231337) : r4.xyz; + r2.yzw = r2.yyy ? float3(-0.00501400325, -0.0252933875, 1.03044021) : r5.xyz; + r3.xyz = r2.xxx ? float3(1.37915885, -0.308850735, -0.0703467429) : r3.xyz; + r4.xyz = r2.xxx ? float3(-0.0693352968, 1.08229232, -0.0129620517) : r4.xyz; + r2.xyz = r2.xxx ? float3(-0.00215925858, -0.0454653986, 1.04775953) : r2.yzw; + r0.xy = log2(r0.xy); + r0.z = log2(r1.z); + r0.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r5.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r0.xyz; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyz = -r0.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r0.xyz = r5.xyz / r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r0.xyz; + r0.xyz = exp2(r0.xyz); + // r0.xyz = float3(10000, 10000, 10000) * r0.xyz; + r0.rgb = float3(100, 100, 100) * r0.rgb; + + // They stop before converting to AP1 + float3 input_color = r0.rgb; + + // uint output_type = cb0[40].w; + float3 sdr_color; + float3 hdr_color; + float3 sdr_ap1_color; + + r5.xy = cmp(asint(cb0[2].xx) == int2(3, 5)); + r0.w = (int)r5.y | (int)r5.x; + + if (injectedData.toneMapType != 0.f) { + renodx::tonemap::Config config = getCommonConfig(); + + float3 config_color = renodx::color::bt709::from::BT2020(input_color); + + renodx::tonemap::config::DualToneMap dual_tone_map = renodx::tonemap::config::ApplyToneMaps(config_color, config); + hdr_color = dual_tone_map.color_hdr; + sdr_color = dual_tone_map.color_sdr; + + float3 final_color = saturate(input_color); + + if (injectedData.toneMapType != 1.f) { + final_color = renodx::tonemap::UpgradeToneMap(hdr_color, sdr_color, final_color, 1.f); + } else { + final_color = hdr_color; + } + + final_color = renodx::color::bt2020::from::BT709(final_color); + float encodeRate = injectedData.toneMapType > 1.f ? injectedData.toneMapGameNits : 100.f; + final_color = renodx::color::pq::Encode(final_color, encodeRate); + + o0.rgba = float4(final_color, 0); + return; + } + // Nothing to upgrade since ACES SDR adjustments are removed + + if (r0.w != 0) { + r5.y = dot(float3(0.439700812, 0.382978052, 0.1773348), r0.xyz); + r5.z = dot(float3(0.0897923037, 0.813423157, 0.096761629), r0.xyz); + r5.w = dot(float3(0.0175439864, 0.111544058, 0.870704114), r0.xyz); + r0.w = min(r5.y, r5.z); + r0.w = min(r0.w, r5.w); + r1.w = max(r5.y, r5.z); + r1.w = max(r1.w, r5.w); + r6.xy = max(float2(1.00000001e-10, 0.00999999978), r1.ww); + r0.w = max(1.00000001e-10, r0.w); + r0.w = r6.x + -r0.w; + r0.w = r0.w / r6.y; + r6.xyz = r5.wzy + -r5.zyw; + r6.xy = r6.xy * r5.wz; + r1.w = r6.x + r6.y; + r1.w = r5.y * r6.z + r1.w; + r1.w = sqrt(r1.w); + r2.w = r5.w + r5.z; + r2.w = r2.w + r5.y; + r1.w = r1.w * 1.75 + r2.w; + r2.w = 0.333333343 * r1.w; + r3.w = -0.400000006 + r0.w; + r4.w = 2.5 * r3.w; + r4.w = 1 + -abs(r4.w); + r4.w = max(0, r4.w); + r5.x = cmp(0 < r3.w); + r3.w = cmp(r3.w < 0); + r3.w = (int)-r5.x + (int)r3.w; + r3.w = (int)r3.w; + r4.w = -r4.w * r4.w + 1; + r3.w = r3.w * r4.w + 1; + r3.w = 0.0250000004 * r3.w; + r4.w = cmp(0.159999996 >= r1.w); + r1.w = cmp(r1.w >= 0.479999989); + r2.w = 0.0799999982 / r2.w; + r2.w = -0.5 + r2.w; + r2.w = r3.w * r2.w; + r1.w = r1.w ? 0 : r2.w; + r1.w = r4.w ? r3.w : r1.w; + r1.w = 1 + r1.w; + r6.yzw = r5.yzw * r1.www; + r7.xy = cmp(r6.zw == r6.yz); + r2.w = r7.y ? r7.x : 0; + r3.w = r5.z * r1.w + -r6.w; + r3.w = 1.73205078 * r3.w; + r4.w = r6.y * 2 + -r6.z; + r4.w = -r5.w * r1.w + r4.w; + r5.x = min(abs(r4.w), abs(r3.w)); + r5.z = max(abs(r4.w), abs(r3.w)); + r5.z = 1 / r5.z; + r5.x = r5.x * r5.z; + r5.z = r5.x * r5.x; + r5.w = r5.z * 0.0208350997 + -0.0851330012; + r5.w = r5.z * r5.w + 0.180141002; + r5.w = r5.z * r5.w + -0.330299497; + r5.z = r5.z * r5.w + 0.999866009; + r5.w = r5.x * r5.z; + r7.x = cmp(abs(r4.w) < abs(r3.w)); + r5.w = r5.w * -2 + 1.57079637; + r5.w = r7.x ? r5.w : 0; + r5.x = r5.x * r5.z + r5.w; + r5.z = cmp(r4.w < -r4.w); + r5.z = r5.z ? -3.141593 : 0; + r5.x = r5.x + r5.z; + r5.z = min(r4.w, r3.w); + r3.w = max(r4.w, r3.w); + r4.w = cmp(r5.z < -r5.z); + r3.w = cmp(r3.w >= -r3.w); + r3.w = r3.w ? r4.w : 0; + r3.w = r3.w ? -r5.x : r5.x; + r3.w = 57.2957802 * r3.w; + r2.w = r2.w ? 0 : r3.w; + r3.w = cmp(r2.w < 0); + r4.w = 360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r2.w = max(0, r2.w); + r2.w = min(360, r2.w); + r3.w = cmp(180 < r2.w); + r4.w = -360 + r2.w; + r2.w = r3.w ? r4.w : r2.w; + r3.w = cmp(-67.5 < r2.w); + r4.w = cmp(r2.w < 67.5); + r3.w = r3.w ? r4.w : 0; + if (r3.w != 0) { + r2.w = 67.5 + r2.w; + r3.w = 0.0296296291 * r2.w; + r4.w = (int)r3.w; + r3.w = trunc(r3.w); + r2.w = r2.w * 0.0296296291 + -r3.w; + r3.w = r2.w * r2.w; + r5.x = r3.w * r2.w; + r7.xyz = float3(-0.166666672, -0.5, 0.166666672) * r5.xxx; + r5.zw = r3.ww * float2(0.5, 0.5) + r7.xy; + r5.zw = r2.ww * float2(-0.5, 0.5) + r5.zw; + r2.w = r5.x * 0.5 + -r3.w; + r2.w = 0.666666687 + r2.w; + r7.xyw = cmp((int3)r4.www == int3(3, 2, 1)); + r5.xz = float2(0.166666672, 0.166666672) + r5.zw; + r3.w = r4.w ? 0 : r7.z; + r3.w = r7.w ? r5.z : r3.w; + r2.w = r7.y ? r2.w : r3.w; + r2.w = r7.x ? r5.x : r2.w; + } else { + r2.w = 0; + } + r0.w = r2.w * r0.w; + r0.w = 1.5 * r0.w; + r1.w = -r5.y * r1.w + 0.0299999993; + r0.w = r1.w * r0.w; + r6.x = r0.w * 0.180000007 + r6.y; + r5.xyz = max(float3(0, 0, 0), r6.xzw); + r5.xyz = min(float3(65535, 65535, 65535), r5.xyz); + r6.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r5.xyz); + r6.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r5.xyz); + r6.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r5.xyz); + r5.xyz = max(float3(0, 0, 0), r6.xyz); + r5.xyz = min(float3(65504, 65504, 65504), r5.xyz); + r0.w = dot(r5.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r5.xyz = r5.xyz + -r0.www; + r5.xyz = r5.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r5.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r5.xyz); + r5.xyz = log2(r5.xyz); + r6.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r5.xyz; + r0.w = log2(cb0[3].x); + r0.w = 0.30103001 * r0.w; + r7.xyz = cmp(r0.www >= r6.xyz); + if (r7.x != 0) { + r1.w = log2(cb0[3].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r6.x); + r3.w = log2(cb0[4].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r6.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r5.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r8.y = -r5.w + r2.w; + r9.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r7.xw = cmp((int2)r3.ww == int2(4, 5)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xw = r7.xw ? float2(1, 1) : 0; + r2.w = dot(r9.wzyx, cb0[5].xyzw); + r2.w = r7.x * cb0[7].x + r2.w; + r9.x = r7.w * cb0[7].x + r2.w; + r10.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r11.xyzw = cmp((int4)r10.yyyy == int4(3, 2, 1, 0)); + r12.xyzw = cmp((int4)r10.xyzw == int4(4, 5, 4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[5].xyzw); + r2.w = r12.x * cb0[7].x + r2.w; + r9.y = r12.y * cb0[7].x + r2.w; + r10.xyzw = cmp((int4)r10.wwww == int4(3, 2, 1, 0)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r10.wzyx, cb0[5].xyzw); + r2.w = r12.z * cb0[7].x + r2.w; + r9.z = r12.w * cb0[7].x + r2.w; + r8.x = r8.y * r8.y; + r10.x = dot(r9.xzy, float3(0.5, 0.5, -1)); + r10.y = dot(r9.xy, float2(-1, 1)); + r10.z = dot(r9.xy, float2(0.5, 0.5)); + r8.z = 1; + r1.w = dot(r8.xyz, r10.xyz); + } else { + r2.w = cmp(r6.x >= r4.w); + r3.w = log2(cb0[3].z); + r5.w = 0.30103001 * r3.w; + r5.w = cmp(r6.x < r5.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r5.x * 0.30103001 + -r4.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r4.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r4.w = trunc(r2.w); + r8.y = -r4.w + r2.w; + r9.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r5.xw = cmp((int2)r3.ww == int2(4, 5)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xw = r5.xw ? float2(1, 1) : 0; + r2.w = dot(r9.wzyx, cb0[6].xyzw); + r2.w = r5.x * cb0[7].y + r2.w; + r9.x = r5.w * cb0[7].y + r2.w; + r10.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r11.xyzw = cmp((int4)r10.yyyy == int4(3, 2, 1, 0)); + r12.xyzw = cmp((int4)r10.xyzw == int4(4, 5, 4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r11.wzyx, cb0[6].xyzw); + r2.w = r12.x * cb0[7].y + r2.w; + r9.y = r12.y * cb0[7].y + r2.w; + r10.xyzw = cmp((int4)r10.wwww == int4(3, 2, 1, 0)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r10.wzyx, cb0[6].xyzw); + r2.w = r12.z * cb0[7].y + r2.w; + r9.z = r12.w * cb0[7].y + r2.w; + r8.x = r8.y * r8.y; + r10.x = dot(r9.xzy, float3(0.5, 0.5, -1)); + r10.y = dot(r9.xy, float2(-1, 1)); + r10.z = dot(r9.xy, float2(0.5, 0.5)); + r8.z = 1; + r1.w = dot(r8.xyz, r10.xyz); + } else { + r2.w = log2(cb0[3].w); + r1.w = 0.30103001 * r2.w; + } + } + } + r1.w = 3.32192802 * r1.w; + r1.w = exp2(r1.w); + if (r7.y != 0) { + r2.w = log2(cb0[3].y); + r2.w = 0.30103001 * r2.w; + } else { + r3.w = cmp(r0.w < r6.y); + r4.w = log2(cb0[4].x); + r5.x = 0.30103001 * r4.w; + r5.w = cmp(r6.y < r5.x); + r3.w = r3.w ? r5.w : 0; + if (r3.w != 0) { + r3.w = r5.y * 0.30103001 + -r0.w; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r0.w; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.w = trunc(r3.w); + r8.y = -r5.w + r3.w; + r9.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r6.xw = cmp((int2)r4.ww == int2(4, 5)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r6.xw = r6.xw ? float2(1, 1) : 0; + r3.w = dot(r9.wzyx, cb0[5].xyzw); + r3.w = r6.x * cb0[7].x + r3.w; + r9.x = r6.w * cb0[7].x + r3.w; + r10.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r11.xyzw = cmp((int4)r10.yyyy == int4(3, 2, 1, 0)); + r12.xyzw = cmp((int4)r10.xyzw == int4(4, 5, 4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[5].xyzw); + r3.w = r12.x * cb0[7].x + r3.w; + r9.y = r12.y * cb0[7].x + r3.w; + r10.xyzw = cmp((int4)r10.wwww == int4(3, 2, 1, 0)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r10.wzyx, cb0[5].xyzw); + r3.w = r12.z * cb0[7].x + r3.w; + r9.z = r12.w * cb0[7].x + r3.w; + r8.x = r8.y * r8.y; + r10.x = dot(r9.xzy, float3(0.5, 0.5, -1)); + r10.y = dot(r9.xy, float2(-1, 1)); + r10.z = dot(r9.xy, float2(0.5, 0.5)); + r8.z = 1; + r2.w = dot(r8.xyz, r10.xyz); + } else { + r3.w = cmp(r6.y >= r5.x); + r4.w = log2(cb0[3].z); + r5.w = 0.30103001 * r4.w; + r5.w = cmp(r6.y < r5.w); + r3.w = r3.w ? r5.w : 0; + if (r3.w != 0) { + r3.w = r5.y * 0.30103001 + -r5.x; + r3.w = 3 * r3.w; + r4.w = r4.w * 0.30103001 + -r5.x; + r3.w = r3.w / r4.w; + r4.w = (int)r3.w; + r5.x = trunc(r3.w); + r8.y = -r5.x + r3.w; + r9.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r5.xy = cmp((int2)r4.ww == int2(4, 5)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xy = r5.xy ? float2(1, 1) : 0; + r3.w = dot(r9.wzyx, cb0[6].xyzw); + r3.w = r5.x * cb0[7].y + r3.w; + r9.x = r5.y * cb0[7].y + r3.w; + r10.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r11.xyzw = cmp((int4)r10.yyyy == int4(3, 2, 1, 0)); + r12.xyzw = cmp((int4)r10.xyzw == int4(4, 5, 4, 5)); + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r12.xyzw = r12.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r11.wzyx, cb0[6].xyzw); + r3.w = r12.x * cb0[7].y + r3.w; + r9.y = r12.y * cb0[7].y + r3.w; + r10.xyzw = cmp((int4)r10.wwww == int4(3, 2, 1, 0)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r3.w = dot(r10.wzyx, cb0[6].xyzw); + r3.w = r12.z * cb0[7].y + r3.w; + r9.z = r12.w * cb0[7].y + r3.w; + r8.x = r8.y * r8.y; + r10.x = dot(r9.xzy, float3(0.5, 0.5, -1)); + r10.y = dot(r9.xy, float2(-1, 1)); + r10.z = dot(r9.xy, float2(0.5, 0.5)); + r8.z = 1; + r2.w = dot(r8.xyz, r10.xyz); + } else { + r3.w = log2(cb0[3].w); + r2.w = 0.30103001 * r3.w; + } + } + } + r2.w = 3.32192802 * r2.w; + r2.w = exp2(r2.w); + if (r7.z != 0) { + r3.w = log2(cb0[3].y); + r3.w = 0.30103001 * r3.w; + } else { + r4.w = cmp(r0.w < r6.z); + r5.x = log2(cb0[4].x); + r5.y = 0.30103001 * r5.x; + r5.w = cmp(r6.z < r5.y); + r4.w = r4.w ? r5.w : 0; + if (r4.w != 0) { + r4.w = r5.z * 0.30103001 + -r0.w; + r4.w = 3 * r4.w; + r0.w = r5.x * 0.30103001 + -r0.w; + r0.w = r4.w / r0.w; + r4.w = (int)r0.w; + r5.x = trunc(r0.w); + r7.y = -r5.x + r0.w; + r8.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r5.xw = cmp((int2)r4.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xw = r5.xw ? float2(1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[5].xyzw); + r0.w = r5.x * cb0[7].x + r0.w; + r8.x = r5.w * cb0[7].x + r0.w; + r9.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r10.wzyx, cb0[5].xyzw); + r0.w = r11.x * cb0[7].x + r0.w; + r8.y = r11.y * cb0[7].x + r0.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[5].xyzw); + r0.w = r11.z * cb0[7].x + r0.w; + r8.z = r11.w * cb0[7].x + r0.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r3.w = dot(r7.xyz, r9.xyz); + } else { + r0.w = cmp(r6.z >= r5.y); + r4.w = log2(cb0[3].z); + r5.x = 0.30103001 * r4.w; + r5.x = cmp(r6.z < r5.x); + r0.w = r0.w ? r5.x : 0; + if (r0.w != 0) { + r0.w = r5.z * 0.30103001 + -r5.y; + r0.w = 3 * r0.w; + r4.w = r4.w * 0.30103001 + -r5.y; + r0.w = r0.w / r4.w; + r4.w = (int)r0.w; + r5.x = trunc(r0.w); + r5.y = -r5.x + r0.w; + r6.xyzw = cmp((int4)r4.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r4.ww == int2(4, 5)); + r6.xyzw = r6.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.w = dot(r6.wzyx, cb0[6].xyzw); + r0.w = r7.x * cb0[7].y + r0.w; + r6.x = r7.y * cb0[7].y + r0.w; + r7.xyzw = (int4)r4.wwww + int4(1, 1, 2, 2); + r8.xyzw = cmp((int4)r7.yyyy == int4(3, 2, 1, 0)); + r9.xyzw = cmp((int4)r7.xyzw == int4(4, 5, 4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[6].xyzw); + r0.w = r9.x * cb0[7].y + r0.w; + r6.y = r9.y * cb0[7].y + r0.w; + r7.xyzw = cmp((int4)r7.wwww == int4(3, 2, 1, 0)); + r7.xyzw = r7.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r7.wzyx, cb0[6].xyzw); + r0.w = r9.z * cb0[7].y + r0.w; + r6.z = r9.w * cb0[7].y + r0.w; + r5.x = r5.y * r5.y; + r7.x = dot(r6.xzy, float3(0.5, 0.5, -1)); + r7.y = dot(r6.xy, float2(-1, 1)); + r7.z = dot(r6.xy, float2(0.5, 0.5)); + r5.z = 1; + r3.w = dot(r5.xyz, r7.xyz); + } else { + r0.w = log2(cb0[3].w); + r3.w = 0.30103001 * r0.w; + } + } + } + r0.w = 3.32192802 * r3.w; + r0.w = exp2(r0.w); + r1.w = -cb0[3].y + r1.w; + r3.w = cb0[3].w + -cb0[3].y; + r5.x = r1.w / r3.w; + r1.w = -cb0[3].y + r2.w; + r5.y = r1.w / r3.w; + r0.w = -cb0[3].y + r0.w; + r5.z = r0.w / r3.w; + r6.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r5.xyz); + r6.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r5.xyz); + r6.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r5.xyz); + r5.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r6.xyz)); + r5.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r6.xyz)); + r5.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r6.xyz)); + r6.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r5.xyz); + r6.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r5.xyz); + r6.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r5.xyz); + r5.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r6.xyz); + r5.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r6.xyz); + r5.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r6.xyz); + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = cb0[3].www * r5.xyz; + r5.xyz = max(float3(0, 0, 0), r5.xyz); + r5.xyz = min(float3(65535, 65535, 65535), r5.xyz); + r0.w = cmp(asint(cb0[2].x) != 5); + r6.x = dot(r3.xyz, r5.xyz); + r6.y = dot(r4.xyz, r5.xyz); + r6.z = dot(r2.xyz, r5.xyz); + r5.xyz = r0.www ? r6.xyz : r5.xyz; + r5.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r5.xyz; + r5.xyz = log2(r5.xyz); + r5.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r5.xyz; + r5.xyz = exp2(r5.xyz); + r6.xyz = r5.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r5.xyz = r5.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r5.xyz = rcp(r5.xyz); + r5.xyz = r6.xyz * r5.xyz; + r5.xyz = log2(r5.xyz); + r5.xyz = float3(78.84375, 78.84375, 78.84375) * r5.xyz; + r1.xyz = exp2(r5.xyz); + } else { + r5.xy = cmp(asint(cb0[2].xx) == int2(4, 6)); + r0.w = (int)r5.y | (int)r5.x; + if (r0.w != 0) { + r5.y = dot(float3(0.439700812, 0.382978052, 0.1773348), r0.xyz); + r5.z = dot(float3(0.0897923037, 0.813423157, 0.096761629), r0.xyz); + r5.w = dot(float3(0.0175439864, 0.111544058, 0.870704114), r0.xyz); + r0.x = min(r5.y, r5.z); + r0.x = min(r0.x, r5.w); + r0.y = max(r5.y, r5.z); + r0.y = max(r0.y, r5.w); + r0.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 0.00999999978), r0.xyy); + r0.x = r0.y + -r0.x; + r0.x = r0.x / r0.z; + r0.yzw = r5.wzy + -r5.zyw; + r0.yz = r5.wz * r0.yz; + r0.y = r0.y + r0.z; + r0.y = r5.y * r0.w + r0.y; + r0.y = sqrt(r0.y); + r0.z = r5.w + r5.z; + r0.z = r0.z + r5.y; + r0.y = r0.y * 1.75 + r0.z; + r0.w = -0.400000006 + r0.x; + r1.w = 2.5 * r0.w; + r1.w = 1 + -abs(r1.w); + r1.w = max(0, r1.w); + r2.w = cmp(0 < r0.w); + r0.w = cmp(r0.w < 0); + r0.w = (int)-r2.w + (int)r0.w; + r0.w = (int)r0.w; + r1.w = -r1.w * r1.w + 1; + r0.w = r0.w * r1.w + 1; + r0.zw = float2(0.333333343, 0.0250000004) * r0.yw; + r1.w = cmp(0.159999996 >= r0.y); + r0.y = cmp(r0.y >= 0.479999989); + r0.z = 0.0799999982 / r0.z; + r0.z = -0.5 + r0.z; + r0.z = r0.w * r0.z; + r0.y = r0.y ? 0 : r0.z; + r0.y = r1.w ? r0.w : r0.y; + r0.y = 1 + r0.y; + r6.yzw = r5.yzw * r0.yyy; + r0.zw = cmp(r6.zw == r6.yz); + r0.z = r0.w ? r0.z : 0; + r0.w = r5.z * r0.y + -r6.w; + r0.w = 1.73205078 * r0.w; + r1.w = r6.y * 2 + -r6.z; + r1.w = -r5.w * r0.y + r1.w; + r2.w = min(abs(r1.w), abs(r0.w)); + r3.w = max(abs(r1.w), abs(r0.w)); + r3.w = 1 / r3.w; + r2.w = r3.w * r2.w; + r3.w = r2.w * r2.w; + r4.w = r3.w * 0.0208350997 + -0.0851330012; + r4.w = r3.w * r4.w + 0.180141002; + r4.w = r3.w * r4.w + -0.330299497; + r3.w = r3.w * r4.w + 0.999866009; + r4.w = r3.w * r2.w; + r5.x = cmp(abs(r1.w) < abs(r0.w)); + r4.w = r4.w * -2 + 1.57079637; + r4.w = r5.x ? r4.w : 0; + r2.w = r2.w * r3.w + r4.w; + r3.w = cmp(r1.w < -r1.w); + r3.w = r3.w ? -3.141593 : 0; + r2.w = r3.w + r2.w; + r3.w = min(r1.w, r0.w); + r0.w = max(r1.w, r0.w); + r1.w = cmp(r3.w < -r3.w); + r0.w = cmp(r0.w >= -r0.w); + r0.w = r0.w ? r1.w : 0; + r0.w = r0.w ? -r2.w : r2.w; + r0.w = 57.2957802 * r0.w; + r0.z = r0.z ? 0 : r0.w; + r0.w = cmp(r0.z < 0); + r1.w = 360 + r0.z; + r0.z = r0.w ? r1.w : r0.z; + r0.z = max(0, r0.z); + r0.z = min(360, r0.z); + r0.w = cmp(180 < r0.z); + r1.w = -360 + r0.z; + r0.z = r0.w ? r1.w : r0.z; + r0.w = cmp(-67.5 < r0.z); + r1.w = cmp(r0.z < 67.5); + r0.w = r0.w ? r1.w : 0; + if (r0.w != 0) { + r0.z = 67.5 + r0.z; + r0.w = 0.0296296291 * r0.z; + r1.w = (int)r0.w; + r0.w = trunc(r0.w); + r0.z = r0.z * 0.0296296291 + -r0.w; + r0.w = r0.z * r0.z; + r2.w = r0.w * r0.z; + r5.xzw = float3(-0.166666672, -0.5, 0.166666672) * r2.www; + r5.xz = r0.ww * float2(0.5, 0.5) + r5.xz; + r5.xz = r0.zz * float2(-0.5, 0.5) + r5.xz; + r0.z = r2.w * 0.5 + -r0.w; + r0.z = 0.666666687 + r0.z; + r7.xyz = cmp((int3)r1.www == int3(3, 2, 1)); + r5.xz = float2(0.166666672, 0.166666672) + r5.xz; + r0.w = r1.w ? 0 : r5.w; + r0.w = r7.z ? r5.z : r0.w; + r0.z = r7.y ? r0.z : r0.w; + r0.z = r7.x ? r5.x : r0.z; + } else { + r0.z = 0; + } + r0.x = r0.z * r0.x; + r0.x = 1.5 * r0.x; + r0.y = -r5.y * r0.y + 0.0299999993; + r0.x = r0.x * r0.y; + r6.x = r0.x * 0.180000007 + r6.y; + r0.xyz = max(float3(0, 0, 0), r6.xzw); + r0.xyz = min(float3(65535, 65535, 65535), r0.xyz); + r5.x = dot(float3(1.45143926, -0.236510754, -0.214928567), r0.xyz); + r5.y = dot(float3(-0.0765537769, 1.17622972, -0.0996759236), r0.xyz); + r5.z = dot(float3(0.00831614807, -0.00603244966, 0.997716308), r0.xyz); + r0.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyz = min(float3(65504, 65504, 65504), r0.xyz); + r0.w = dot(r0.xyz, float3(0.272228718, 0.674081743, 0.0536895171)); + r0.xyz = r0.xyz + -r0.www; + r0.xyz = r0.xyz * float3(0.959999979, 0.959999979, 0.959999979) + r0.www; + r0.xyz = max(float3(1.00000001e-10, 1.00000001e-10, 1.00000001e-10), r0.xyz); + r0.xyz = log2(r0.xyz); + r5.xyz = float3(0.30103001, 0.30103001, 0.30103001) * r0.xyz; + r0.w = log2(cb0[3].x); + r0.w = 0.30103001 * r0.w; + r6.xyz = cmp(r0.www >= r5.xyz); + if (r6.x != 0) { + r1.w = log2(cb0[3].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r5.x); + r3.w = log2(cb0[4].x); + r4.w = 0.30103001 * r3.w; + r5.w = cmp(r5.x < r4.w); + r2.w = r2.w ? r5.w : 0; + if (r2.w != 0) { + r2.w = r0.x * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.w = trunc(r2.w); + r7.y = -r5.w + r2.w; + r8.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r6.xw = cmp((int2)r3.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r6.xw = r6.xw ? float2(1, 1) : 0; + r2.w = dot(r8.wzyx, cb0[5].xyzw); + r2.w = r6.x * cb0[7].x + r2.w; + r8.x = r6.w * cb0[7].x + r2.w; + r9.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r10.wzyx, cb0[5].xyzw); + r2.w = r11.x * cb0[7].x + r2.w; + r8.y = r11.y * cb0[7].x + r2.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r9.wzyx, cb0[5].xyzw); + r2.w = r11.z * cb0[7].x + r2.w; + r8.z = r11.w * cb0[7].x + r2.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r1.w = dot(r7.xyz, r9.xyz); + } else { + r2.w = cmp(r5.x >= r4.w); + r3.w = log2(cb0[3].z); + r5.w = 0.30103001 * r3.w; + r5.x = cmp(r5.x < r5.w); + r2.w = r2.w ? r5.x : 0; + if (r2.w != 0) { + r0.x = r0.x * 0.30103001 + -r4.w; + r0.x = 3 * r0.x; + r2.w = r3.w * 0.30103001 + -r4.w; + r0.x = r0.x / r2.w; + r2.w = (int)r0.x; + r3.w = trunc(r0.x); + r7.y = -r3.w + r0.x; + r8.xyzw = cmp((int4)r2.wwww == int4(3, 2, 1, 0)); + r5.xw = cmp((int2)r2.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xw = r5.xw ? float2(1, 1) : 0; + r0.x = dot(r8.wzyx, cb0[6].xyzw); + r0.x = r5.x * cb0[7].y + r0.x; + r8.x = r5.w * cb0[7].y + r0.x; + r9.xyzw = (int4)r2.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.x = dot(r10.wzyx, cb0[6].xyzw); + r0.x = r11.x * cb0[7].y + r0.x; + r8.y = r11.y * cb0[7].y + r0.x; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.x = dot(r9.wzyx, cb0[6].xyzw); + r0.x = r11.z * cb0[7].y + r0.x; + r8.z = r11.w * cb0[7].y + r0.x; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r1.w = dot(r7.xyz, r9.xyz); + } else { + r0.x = log2(cb0[3].w); + r1.w = 0.30103001 * r0.x; + } + } + } + r0.x = 3.32192802 * r1.w; + r0.x = exp2(r0.x); + if (r6.y != 0) { + r1.w = log2(cb0[3].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r5.y); + r3.w = log2(cb0[4].x); + r4.w = 0.30103001 * r3.w; + r5.x = cmp(r5.y < r4.w); + r2.w = r2.w ? r5.x : 0; + if (r2.w != 0) { + r2.w = r0.y * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r3.w = r3.w * 0.30103001 + -r0.w; + r2.w = r2.w / r3.w; + r3.w = (int)r2.w; + r5.x = trunc(r2.w); + r7.y = -r5.x + r2.w; + r8.xyzw = cmp((int4)r3.wwww == int4(3, 2, 1, 0)); + r5.xw = cmp((int2)r3.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xw = r5.xw ? float2(1, 1) : 0; + r2.w = dot(r8.wzyx, cb0[5].xyzw); + r2.w = r5.x * cb0[7].x + r2.w; + r8.x = r5.w * cb0[7].x + r2.w; + r9.xyzw = (int4)r3.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r10.wzyx, cb0[5].xyzw); + r2.w = r11.x * cb0[7].x + r2.w; + r8.y = r11.y * cb0[7].x + r2.w; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r2.w = dot(r9.wzyx, cb0[5].xyzw); + r2.w = r11.z * cb0[7].x + r2.w; + r8.z = r11.w * cb0[7].x + r2.w; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r1.w = dot(r7.xyz, r9.xyz); + } else { + r2.w = cmp(r5.y >= r4.w); + r3.w = log2(cb0[3].z); + r5.x = 0.30103001 * r3.w; + r5.x = cmp(r5.y < r5.x); + r2.w = r2.w ? r5.x : 0; + if (r2.w != 0) { + r0.y = r0.y * 0.30103001 + -r4.w; + r0.y = 3 * r0.y; + r2.w = r3.w * 0.30103001 + -r4.w; + r0.y = r0.y / r2.w; + r2.w = (int)r0.y; + r3.w = trunc(r0.y); + r7.y = -r3.w + r0.y; + r8.xyzw = cmp((int4)r2.wwww == int4(3, 2, 1, 0)); + r5.xy = cmp((int2)r2.ww == int2(4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xy = r5.xy ? float2(1, 1) : 0; + r0.y = dot(r8.wzyx, cb0[6].xyzw); + r0.y = r5.x * cb0[7].y + r0.y; + r8.x = r5.y * cb0[7].y + r0.y; + r9.xyzw = (int4)r2.wwww + int4(1, 1, 2, 2); + r10.xyzw = cmp((int4)r9.yyyy == int4(3, 2, 1, 0)); + r11.xyzw = cmp((int4)r9.xyzw == int4(4, 5, 4, 5)); + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r11.xyzw = r11.xyzw ? float4(1, 1, 1, 1) : 0; + r0.y = dot(r10.wzyx, cb0[6].xyzw); + r0.y = r11.x * cb0[7].y + r0.y; + r8.y = r11.y * cb0[7].y + r0.y; + r9.xyzw = cmp((int4)r9.wwww == int4(3, 2, 1, 0)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.y = dot(r9.wzyx, cb0[6].xyzw); + r0.y = r11.z * cb0[7].y + r0.y; + r8.z = r11.w * cb0[7].y + r0.y; + r7.x = r7.y * r7.y; + r9.x = dot(r8.xzy, float3(0.5, 0.5, -1)); + r9.y = dot(r8.xy, float2(-1, 1)); + r9.z = dot(r8.xy, float2(0.5, 0.5)); + r7.z = 1; + r1.w = dot(r7.xyz, r9.xyz); + } else { + r0.y = log2(cb0[3].w); + r1.w = 0.30103001 * r0.y; + } + } + } + r0.y = 3.32192802 * r1.w; + r0.y = exp2(r0.y); + if (r6.z != 0) { + r1.w = log2(cb0[3].y); + r1.w = 0.30103001 * r1.w; + } else { + r2.w = cmp(r0.w < r5.z); + r3.w = log2(cb0[4].x); + r4.w = 0.30103001 * r3.w; + r5.x = cmp(r5.z < r4.w); + r2.w = r2.w ? r5.x : 0; + if (r2.w != 0) { + r2.w = r0.z * 0.30103001 + -r0.w; + r2.w = 3 * r2.w; + r0.w = r3.w * 0.30103001 + -r0.w; + r0.w = r2.w / r0.w; + r2.w = (int)r0.w; + r3.w = trunc(r0.w); + r6.y = -r3.w + r0.w; + r7.xyzw = cmp((int4)r2.wwww == int4(3, 2, 1, 0)); + r5.xy = cmp((int2)r2.ww == int2(4, 5)); + r7.xyzw = r7.xyzw ? float4(1, 1, 1, 1) : 0; + r5.xy = r5.xy ? float2(1, 1) : 0; + r0.w = dot(r7.wzyx, cb0[5].xyzw); + r0.w = r5.x * cb0[7].x + r0.w; + r7.x = r5.y * cb0[7].x + r0.w; + r8.xyzw = (int4)r2.wwww + int4(1, 1, 2, 2); + r9.xyzw = cmp((int4)r8.yyyy == int4(3, 2, 1, 0)); + r10.xyzw = cmp((int4)r8.xyzw == int4(4, 5, 4, 5)); + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r10.xyzw = r10.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r9.wzyx, cb0[5].xyzw); + r0.w = r10.x * cb0[7].x + r0.w; + r7.y = r10.y * cb0[7].x + r0.w; + r8.xyzw = cmp((int4)r8.wwww == int4(3, 2, 1, 0)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r0.w = dot(r8.wzyx, cb0[5].xyzw); + r0.w = r10.z * cb0[7].x + r0.w; + r7.z = r10.w * cb0[7].x + r0.w; + r6.x = r6.y * r6.y; + r8.x = dot(r7.xzy, float3(0.5, 0.5, -1)); + r8.y = dot(r7.xy, float2(-1, 1)); + r8.z = dot(r7.xy, float2(0.5, 0.5)); + r6.z = 1; + r1.w = dot(r6.xyz, r8.xyz); + } else { + r0.w = cmp(r5.z >= r4.w); + r2.w = log2(cb0[3].z); + r3.w = 0.30103001 * r2.w; + r3.w = cmp(r5.z < r3.w); + r0.w = r0.w ? r3.w : 0; + if (r0.w != 0) { + r0.z = r0.z * 0.30103001 + -r4.w; + r0.z = 3 * r0.z; + r0.w = r2.w * 0.30103001 + -r4.w; + r0.z = r0.z / r0.w; + r0.w = (int)r0.z; + r2.w = trunc(r0.z); + r5.y = -r2.w + r0.z; + r6.xyzw = cmp((int4)r0.wwww == int4(3, 2, 1, 0)); + r7.xy = cmp((int2)r0.ww == int2(4, 5)); + r6.xyzw = r6.xyzw ? float4(1, 1, 1, 1) : 0; + r7.xy = r7.xy ? float2(1, 1) : 0; + r0.z = dot(r6.wzyx, cb0[6].xyzw); + r0.z = r7.x * cb0[7].y + r0.z; + r6.x = r7.y * cb0[7].y + r0.z; + r7.xyzw = (int4)r0.wwww + int4(1, 1, 2, 2); + r8.xyzw = cmp((int4)r7.yyyy == int4(3, 2, 1, 0)); + r9.xyzw = cmp((int4)r7.xyzw == int4(4, 5, 4, 5)); + r8.xyzw = r8.xyzw ? float4(1, 1, 1, 1) : 0; + r9.xyzw = r9.xyzw ? float4(1, 1, 1, 1) : 0; + r0.z = dot(r8.wzyx, cb0[6].xyzw); + r0.z = r9.x * cb0[7].y + r0.z; + r6.y = r9.y * cb0[7].y + r0.z; + r7.xyzw = cmp((int4)r7.wwww == int4(3, 2, 1, 0)); + r7.xyzw = r7.xyzw ? float4(1, 1, 1, 1) : 0; + r0.z = dot(r7.wzyx, cb0[6].xyzw); + r0.z = r9.z * cb0[7].y + r0.z; + r6.z = r9.w * cb0[7].y + r0.z; + r5.x = r5.y * r5.y; + r7.x = dot(r6.xzy, float3(0.5, 0.5, -1)); + r7.y = dot(r6.xy, float2(-1, 1)); + r7.z = dot(r6.xy, float2(0.5, 0.5)); + r5.z = 1; + r1.w = dot(r5.xyz, r7.xyz); + } else { + r0.z = log2(cb0[3].w); + r1.w = 0.30103001 * r0.z; + } + } + } + r0.z = 3.32192802 * r1.w; + r0.z = exp2(r0.z); + r0.x = -cb0[3].y + r0.x; + r0.w = cb0[3].w + -cb0[3].y; + r5.x = r0.x / r0.w; + r0.x = -cb0[3].y + r0.y; + r5.y = r0.x / r0.w; + r0.x = -cb0[3].y + r0.z; + r5.z = r0.x / r0.w; + r0.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r5.xyz); + r0.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r5.xyz); + r0.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r5.xyz); + r5.x = saturate(dot(float3(1.6410234, -0.324803293, -0.236424699), r0.xyz)); + r5.y = saturate(dot(float3(-0.663662851, 1.61533165, 0.0167563483), r0.xyz)); + r5.z = saturate(dot(float3(0.0117218941, -0.00828444213, 0.988394856), r0.xyz)); + r0.x = dot(float3(0.662454188, 0.134004205, 0.156187683), r5.xyz); + r0.y = dot(float3(0.272228718, 0.674081743, 0.0536895171), r5.xyz); + r0.z = dot(float3(-0.00557464967, 0.0040607336, 1.01033914), r5.xyz); + r5.x = dot(float3(1.6410234, -0.324803293, -0.236424699), r0.xyz); + r5.y = dot(float3(-0.663662851, 1.61533165, 0.0167563483), r0.xyz); + r5.z = dot(float3(0.0117218941, -0.00828444213, 0.988394856), r0.xyz); + r0.xyz = max(float3(0, 0, 0), r5.xyz); + r0.xyz = cb0[3].www * r0.xyz; + r0.xyz = max(float3(0, 0, 0), r0.xyz); + r0.xyz = min(float3(65535, 65535, 65535), r0.xyz); + r0.w = cmp(asint(cb0[2].x) != 6); + r3.x = dot(r3.xyz, r0.xyz); + r3.y = dot(r4.xyz, r0.xyz); + r3.z = dot(r2.xyz, r0.xyz); + r0.xyz = r0.www ? r3.xyz : r0.xyz; + r0.xyz = float3(9.99999975e-05, 9.99999975e-05, 9.99999975e-05) * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r2.xyz = r0.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r0.xyz = r0.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r0.xyz = rcp(r0.xyz); + r0.xyz = r2.xyz * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(78.84375, 78.84375, 78.84375) * r0.xyz; + r1.xyz = exp2(r0.xyz); + } else { + r1.xy = v0.xy * float2(1.03225803, 1.03225803) + float2(-0.0161290318, -0.0161290318); + } + } + o0.xyz = float3(0.952381015, 0.952381015, 0.952381015) * r1.xyz; + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/output01_0x4F06C1AD.ps_5_1.hlsl b/src/games/dbzspark/output01_0x4F06C1AD.ps_5_1.hlsl new file mode 100644 index 00000000..dfe222d5 --- /dev/null +++ b/src/games/dbzspark/output01_0x4F06C1AD.ps_5_1.hlsl @@ -0,0 +1,126 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 16:48:29 2024 + +#include "./shared.h" +#include "./tonemapper.hlsl" + +Texture3D t4 : register(t4); + +Texture2D t3 : register(t3); + +struct t2_t { + float val[4]; +}; +StructuredBuffer t2 : register(t2); + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s3_s : register(s3); + +SamplerState s2_s : register(s2); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[137]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[47]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + linear noperspective float2 w0 : TEXCOORD3, + linear noperspective float4 v1 : TEXCOORD1, + linear noperspective float4 v2 : TEXCOORD2, + float2 v3 : TEXCOORD4, + float4 v4 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3; + uint4 bitmask, uiDest; + float4 fDest; + float3 untonemapped, post_lut; + + r0.xy = max(cb0[15].xy, v0.xy); + r0.xy = min(cb0[15].zw, r0.xy); + r0.xyz = t0.Sample(s0_s, r0.xy).xyz; + r0.xyz = cb1[136].www * r0.xyz; + r0.xyz = cb0[40].xyz * r0.xyz; + r1.x = t2[0].val[0 / 4]; + r1.y = t2[0].val[0 / 4 + 1]; + r1.z = t2[0].val[0 / 4 + 2]; + r2.xy = v0.xy * cb0[32].xy + cb0[32].zw; + r2.xy = max(cb0[33].xy, r2.xy); + r2.xy = min(cb0[33].zw, r2.xy); + r2.xyz = t1.Sample(s1_s, r2.xy).xyz; + r2.xyz = cb1[136].www * r2.xyz; + r3.xy = w0.xy * cb0[44].zw + cb0[44].xy; + r3.xy = r3.xy * float2(0.5, -0.5) + float2(0.5, 0.5); + r3.xyz = t3.Sample(s2_s, r3.xy).xyz; + r3.xyz = r3.xyz * cb0[41].xyz + float3(1, 1, 1); + r2.xyz = r3.xyz * r2.xyz; + r0.xyz = r0.xyz * r1.xyz + r2.xyz; + r0.xyz = v1.xxx * r0.xyz; + r1.xy = cb0[43].xx * v1.zw; + r0.w = dot(r1.xy, r1.xy); + r0.w = 1 + r0.w; + r0.w = rcp(r0.w); + r0.w = r0.w * r0.w; + untonemapped = r0.xyz; + + if (injectedData.toneMapType != 0.f) { + float3 lut_input = untonemapped; // Already PQ + post_lut = renodx::lut::Sample(t4, s3_s, lut_input, 32.f); + } else { + // They forgot to decode PQ? + r0.xyz = r0.xyz * r0.www + float3(0.00266771927, 0.00266771927, 0.00266771927); + r0.xyz = log2(r0.xyz); + r0.xyz = saturate(r0.xyz * float3(0.0714285746, 0.0714285746, 0.0714285746) + float3(0.610726953, 0.610726953, 0.610726953)); + + r0.xyz = r0.xyz * float3(0.96875, 0.96875, 0.96875) + float3(0.015625, 0.015625, 0.015625); + r0.xyz = t4.Sample(s3_s, r0.xyz).xyz; + } + + r0.w = v2.w * 543.309998 + v2.z; + r0.w = sin(r0.w); + r0.w = 493013 * r0.w; + r0.w = frac(r0.w); + r0.w = r0.w * 0.00390625 + -0.001953125; + r0.xyz = r0.xyz * float3(1.04999995, 1.04999995, 1.04999995) + r0.www; + if (cb0[46].z != 0) { + r1.xyz = log2(r0.xyz); + r1.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r2.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r1.xyz; + r2.xyz = max(float3(0, 0, 0), r2.xyz); + r1.xyz = -r1.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r1.xyz = r2.xyz / r1.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(10000, 10000, 10000) * r1.xyz; + r1.xyz = r1.xyz / cb0[46].yyy; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r2.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r1.xyz; + r1.xyz = max(float3(0.00313066994, 0.00313066994, 0.00313066994), r1.xyz); + r1.xyz = log2(r1.xyz); + r1.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r0.xyz = min(r2.xyz, r1.xyz); + } + if (injectedData.toneMapType != 0.f) { + o0.xyz = post_lut; + } else { + o0.xyz = r0.xyz; + } + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/output01_0x8C20620E.ps_5_1.hlsl b/src/games/dbzspark/output01_0x8C20620E.ps_5_1.hlsl new file mode 100644 index 00000000..8d89962f --- /dev/null +++ b/src/games/dbzspark/output01_0x8C20620E.ps_5_1.hlsl @@ -0,0 +1,133 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:14 2024 +#include "./shared.h" + +Texture3D t4 : register(t4); + +Texture2D t3 : register(t3); + +struct t2_t { + float val[4]; +}; +StructuredBuffer t2 : register(t2); + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s3_s : register(s3); + +SamplerState s2_s : register(s2); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[137]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[47]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + linear noperspective float2 w0 : TEXCOORD3, + linear noperspective float4 v1 : TEXCOORD1, + linear noperspective float4 v2 : TEXCOORD2, + float2 v3 : TEXCOORD4, + float4 v4 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3; + uint4 bitmask, uiDest; + float4 fDest; + float3 untonemapped, post_lut; + + r0.xy = max(cb0[15].xy, v0.xy); + r0.xy = min(cb0[15].zw, r0.xy); + r0.xyz = t0.Sample(s0_s, r0.xy).xyz; + r0.xyz = cb1[136].www * r0.xyz; + r0.xyz = cb0[40].xyz * r0.xyz; + r1.x = t2[0].val[0 / 4]; + r1.y = t2[0].val[0 / 4 + 1]; + r1.z = t2[0].val[0 / 4 + 2]; + r2.xy = v0.xy * cb0[32].xy + cb0[32].zw; + r2.xy = max(cb0[33].xy, r2.xy); + r2.xy = min(cb0[33].zw, r2.xy); + r2.xyz = t1.Sample(s1_s, r2.xy).xyz; + r2.xyz = cb1[136].www * r2.xyz; + r3.xy = w0.xy * cb0[44].zw + cb0[44].xy; + r3.xy = r3.xy * float2(0.5, -0.5) + float2(0.5, 0.5); + r3.xyz = t3.Sample(s2_s, r3.xy).xyz; + r3.xyz = r3.xyz * cb0[41].xyz + float3(1, 1, 1); + r2.xyz = r3.xyz * r2.xyz; + r0.xyz = r0.xyz * r1.xyz + r2.xyz; + r0.xyz = v1.xxx * r0.xyz; + r1.xy = cb0[43].xx * v1.zw; + r0.w = dot(r1.xy, r1.xy); + r0.w = 1 + r0.w; + r0.w = rcp(r0.w); + r0.w = r0.w * r0.w; + untonemapped = r0.xyz; + + if (injectedData.toneMapType != 0.f) { + float3 lut_input = renodx::color::pq::Encode(untonemapped, 100.f); + post_lut = renodx::lut::Sample(t4, s3_s, lut_input, 32.f); + } else { + r0.xyz = r0.xyz * r0.www; + r0.xyz = float3(0.00999999978, 0.00999999978, 0.00999999978) * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r1.xyz = r0.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r0.xyz = r0.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r0.xyz = rcp(r0.xyz); + r0.xyz = r1.xyz * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(78.84375, 78.84375, 78.84375) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = r0.xyz * float3(0.96875, 0.96875, 0.96875) + float3(0.015625, 0.015625, 0.015625); + r0.xyz = t4.Sample(s3_s, r0.xyz).xyz; + } + + r0.w = v2.w * 543.309998 + v2.z; + r0.w = sin(r0.w); + r0.w = 493013 * r0.w; + r0.w = frac(r0.w); + r0.w = r0.w * 0.00390625 + -0.001953125; + r0.xyz = r0.xyz * float3(1.25, 1.25, 1.25) + r0.www; + + // Unused + if (cb0[46].z != 0) { + r1.xyz = log2(r0.xyz); + r1.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r2.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r1.xyz; + r2.xyz = max(float3(0, 0, 0), r2.xyz); + r1.xyz = -r1.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r1.xyz = r2.xyz / r1.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(10000, 10000, 10000) * r1.xyz; + r1.xyz = r1.xyz / cb0[46].yyy; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r2.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r1.xyz; + r1.xyz = max(float3(0.00313066994, 0.00313066994, 0.00313066994), r1.xyz); + r1.xyz = log2(r1.xyz); + r1.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r0.xyz = min(r2.xyz, r1.xyz); + } + if (injectedData.toneMapType != 0.f) { + o0.xyz = post_lut; + } else { + o0.xyz = r0.xyz; + } + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/output01_0x9A3DADB2.ps_5_1.hlsl b/src/games/dbzspark/output01_0x9A3DADB2.ps_5_1.hlsl new file mode 100644 index 00000000..1b1bfa60 --- /dev/null +++ b/src/games/dbzspark/output01_0x9A3DADB2.ps_5_1.hlsl @@ -0,0 +1,146 @@ +// ---- Created with 3Dmigoto v1.3.16 on Fri Oct 18 16:48:44 2024 +#include "./shared.h" + +Texture3D t4 : register(t4); + +Texture2D t3 : register(t3); + +struct t2_t { + float val[4]; +}; +StructuredBuffer t2 : register(t2); + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s3_s : register(s3); + +SamplerState s2_s : register(s2); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[137]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[47]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + linear noperspective float2 w0 : TEXCOORD3, + linear noperspective float4 v1 : TEXCOORD1, + linear noperspective float4 v2 : TEXCOORD2, + float2 v3 : TEXCOORD4, + float4 v4 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3; + uint4 bitmask, uiDest; + float4 fDest; + float3 untonemapped, post_lut; + + r0.xy = w0.xy * cb0[44].zw + cb0[44].xy; + r1.xyzw = cmp(float4(0, 0, 0, 0) < r0.xyxy); + r2.xyzw = cmp(r0.xyxy < float4(0, 0, 0, 0)); + r1.xyzw = (int4)-r1.xyzw + (int4)r2.xyzw; + r1.xyzw = (int4)r1.xyzw; + r2.xyzw = saturate(-cb0[42].zzzz + abs(r0.xyxy)); + r1.xyzw = r2.xyzw * r1.xyzw; + r1.xyzw = -r1.xyzw * cb0[42].xxyy + r0.xyxy; + r1.xyzw = r1.xyzw * cb0[45].zwzw + cb0[45].xyxy; + r1.xyzw = r1.xyzw * cb0[10].xyxy + cb0[10].zwzw; + r1.xyzw = cb0[9].zwzw * r1.xyzw; + r1.xyzw = max(cb0[15].xyxy, r1.xyzw); + r1.xyzw = min(cb0[15].zwzw, r1.xyzw); + r2.x = t0.Sample(s0_s, r1.xy).x; + r2.y = t0.Sample(s0_s, r1.zw).y; + r0.zw = max(cb0[15].xy, v0.xy); + r0.zw = min(cb0[15].zw, r0.zw); + r2.z = t0.Sample(s0_s, r0.zw).z; + r1.xyz = cb1[136].www * r2.xyz; + r1.xyz = cb0[40].xyz * r1.xyz; + r2.x = t2[0].val[0 / 4]; + r2.y = t2[0].val[0 / 4 + 1]; + r2.z = t2[0].val[0 / 4 + 2]; + r0.zw = v0.xy * cb0[32].xy + cb0[32].zw; + r0.zw = max(cb0[33].xy, r0.zw); + r0.zw = min(cb0[33].zw, r0.zw); + r3.xyz = t1.Sample(s1_s, r0.zw).xyz; + r3.xyz = cb1[136].www * r3.xyz; + r0.xy = r0.xy * float2(0.5, -0.5) + float2(0.5, 0.5); + r0.xyz = t3.Sample(s2_s, r0.xy).xyz; + r0.xyz = r0.xyz * cb0[41].xyz + float3(1, 1, 1); + r0.xyz = r3.xyz * r0.xyz; + r0.xyz = r1.xyz * r2.xyz + r0.xyz; + r0.xyz = v1.xxx * r0.xyz; + r1.xy = cb0[43].xx * v1.zw; + r0.w = dot(r1.xy, r1.xy); + r0.w = 1 + r0.w; + r0.w = rcp(r0.w); + r0.w = r0.w * r0.w; + untonemapped = r0.xyz; + + if (injectedData.toneMapType != 0.f) { + float3 lut_input = renodx::color::pq::Encode(untonemapped, 100.f); + post_lut = renodx::lut::Sample(t4, s3_s, lut_input, 32.f); + } else { + r0.xyz = r0.xyz * r0.www; + r0.xyz = float3(0.00999999978, 0.00999999978, 0.00999999978) * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r1.xyz = r0.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r0.xyz = r0.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r0.xyz = rcp(r0.xyz); + r0.xyz = r1.xyz * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(78.84375, 78.84375, 78.84375) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = r0.xyz * float3(0.96875, 0.96875, 0.96875) + float3(0.015625, 0.015625, 0.015625); + r0.xyz = t4.Sample(s3_s, r0.xyz).xyz; + } + + r0.w = v2.w * 543.309998 + v2.z; + r0.w = sin(r0.w); + r0.w = 493013 * r0.w; + r0.w = frac(r0.w); + r0.w = r0.w * 0.00390625 + -0.001953125; + r0.xyz = r0.xyz * float3(1.25, 1.25, 1.25) + r0.www; + if (cb0[46].z != 0) { + r1.xyz = log2(r0.xyz); + r1.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r2.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r1.xyz; + r2.xyz = max(float3(0, 0, 0), r2.xyz); + r1.xyz = -r1.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r1.xyz = r2.xyz / r1.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(10000, 10000, 10000) * r1.xyz; + r1.xyz = r1.xyz / cb0[46].yyy; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r2.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r1.xyz; + r1.xyz = max(float3(0.00313066994, 0.00313066994, 0.00313066994), r1.xyz); + r1.xyz = log2(r1.xyz); + r1.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r0.xyz = min(r2.xyz, r1.xyz); + } + if (injectedData.toneMapType != 0.f) { + o0.xyz = post_lut; + } else { + o0.xyz = r0.xyz; + } + + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/output01_0xF554DE7A.ps_5_1.hlsl b/src/games/dbzspark/output01_0xF554DE7A.ps_5_1.hlsl new file mode 100644 index 00000000..370c2b1c --- /dev/null +++ b/src/games/dbzspark/output01_0xF554DE7A.ps_5_1.hlsl @@ -0,0 +1,126 @@ +// ---- Created with 3Dmigoto v1.3.16 on Thu Oct 17 13:24:14 2024 +#include "./shared.h" + +Texture3D t4 : register(t4); + +Texture2D t3 : register(t3); + +struct t2_t { + float val[4]; +}; +StructuredBuffer t2 : register(t2); + +Texture2D t1 : register(t1); + +Texture2D t0 : register(t0); + +SamplerState s3_s : register(s3); + +SamplerState s2_s : register(s2); + +SamplerState s1_s : register(s1); + +SamplerState s0_s : register(s0); + +cbuffer cb1 : register(b1) { + float4 cb1[137]; +} + +cbuffer cb0 : register(b0) { + float4 cb0[47]; +} + +// 3Dmigoto declarations +#define cmp - + +void main( + linear noperspective float2 v0 : TEXCOORD0, + linear noperspective float2 w0 : TEXCOORD3, + linear noperspective float4 v1 : TEXCOORD1, + linear noperspective float4 v2 : TEXCOORD2, + float2 v3 : TEXCOORD4, + float4 v4 : SV_POSITION0, + out float4 o0 : SV_Target0) { + float4 r0, r1, r2, r3; + uint4 bitmask, uiDest; + float4 fDest; + float3 untonemapped, post_lut; + + r0.xy = max(cb0[15].xy, v0.xy); + r0.xy = min(cb0[15].zw, r0.xy); + r0.xyz = t0.Sample(s0_s, r0.xy).xyz; + r0.xyz = cb1[136].www * r0.xyz; + r0.xyz = cb0[40].xyz * r0.xyz; + r1.x = t2[0].val[0 / 4]; + r1.y = t2[0].val[0 / 4 + 1]; + r1.z = t2[0].val[0 / 4 + 2]; + r2.xy = v0.xy * cb0[32].xy + cb0[32].zw; + r2.xy = max(cb0[33].xy, r2.xy); + r2.xy = min(cb0[33].zw, r2.xy); + r2.xyz = t1.Sample(s1_s, r2.xy).xyz; + r2.xyz = cb1[136].www * r2.xyz; + r3.xy = w0.xy * cb0[44].zw + cb0[44].xy; + r3.xy = r3.xy * float2(0.5, -0.5) + float2(0.5, 0.5); + r3.xyz = t3.Sample(s2_s, r3.xy).xyz; + r3.xyz = r3.xyz * cb0[41].xyz + float3(1, 1, 1); + r2.xyz = r3.xyz * r2.xyz; + r0.xyz = r0.xyz * r1.xyz + r2.xyz; + r0.xyz = v1.xxx * r0.xyz; + untonemapped = r0.xyz; + + if (injectedData.toneMapType != 0.f) { + float3 lut_input = renodx::color::pq::Encode(untonemapped, 100.f); + post_lut = renodx::lut::Sample(t4, s3_s, lut_input, 32.f); + } else { + r0.xyz = float3(0.00999999978, 0.00999999978, 0.00999999978) * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(0.159301758, 0.159301758, 0.159301758) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r1.xyz = r0.xyz * float3(18.8515625, 18.8515625, 18.8515625) + float3(0.8359375, 0.8359375, 0.8359375); + r0.xyz = r0.xyz * float3(18.6875, 18.6875, 18.6875) + float3(1, 1, 1); + r0.xyz = rcp(r0.xyz); + r0.xyz = r1.xyz * r0.xyz; + r0.xyz = log2(r0.xyz); + r0.xyz = float3(78.84375, 78.84375, 78.84375) * r0.xyz; + r0.xyz = exp2(r0.xyz); + r0.xyz = r0.xyz * float3(0.96875, 0.96875, 0.96875) + float3(0.015625, 0.015625, 0.015625); + r0.xyz = t4.Sample(s3_s, r0.xyz).xyz; + } + + r0.w = v2.w * 543.309998 + v2.z; + r0.w = sin(r0.w); + r0.w = 493013 * r0.w; + r0.w = frac(r0.w); + r0.w = r0.w * 0.00390625 + -0.001953125; + r0.xyz = r0.xyz * float3(1.25, 1.25, 1.25) + r0.www; + if (cb0[46].z != 0) { + r1.xyz = log2(r0.xyz); + r1.xyz = float3(0.0126833133, 0.0126833133, 0.0126833133) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r2.xyz = float3(-0.8359375, -0.8359375, -0.8359375) + r1.xyz; + r2.xyz = max(float3(0, 0, 0), r2.xyz); + r1.xyz = -r1.xyz * float3(18.6875, 18.6875, 18.6875) + float3(18.8515625, 18.8515625, 18.8515625); + r1.xyz = r2.xyz / r1.xyz; + r1.xyz = log2(r1.xyz); + r1.xyz = float3(6.27739477, 6.27739477, 6.27739477) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = float3(10000, 10000, 10000) * r1.xyz; + r1.xyz = r1.xyz / cb0[46].yyy; + r1.xyz = max(float3(6.10351999e-05, 6.10351999e-05, 6.10351999e-05), r1.xyz); + r2.xyz = float3(12.9200001, 12.9200001, 12.9200001) * r1.xyz; + r1.xyz = max(float3(0.00313066994, 0.00313066994, 0.00313066994), r1.xyz); + r1.xyz = log2(r1.xyz); + r1.xyz = float3(0.416666657, 0.416666657, 0.416666657) * r1.xyz; + r1.xyz = exp2(r1.xyz); + r1.xyz = r1.xyz * float3(1.05499995, 1.05499995, 1.05499995) + float3(-0.0549999997, -0.0549999997, -0.0549999997); + r0.xyz = min(r2.xyz, r1.xyz); + } + if (injectedData.toneMapType != 0.f) { + o0.xyz = post_lut; + } else { + o0.xyz = r0.xyz; + } + + o0.w = 0; + return; +} \ No newline at end of file diff --git a/src/games/dbzspark/shared.h b/src/games/dbzspark/shared.h new file mode 100644 index 00000000..ba4c076d --- /dev/null +++ b/src/games/dbzspark/shared.h @@ -0,0 +1,33 @@ +#ifndef SRC_DBZSPARK_SHARED_H_ +#define SRC_DBZSPARK_SHARED_H_ + +#ifndef __cplusplus +#include "../../shaders/renodx.hlsl" +#endif + +// Must be 32bit aligned +// Should be 4x32 +struct ShaderInjectData { + float toneMapType; + float toneMapDisplay; + float toneMapPeakNits; + float toneMapGameNits; + float toneMapUINits; + float toneMapGammaCorrection; + float toneMapHueCorrection; + float colorGradeExposure; + float colorGradeHighlights; + float colorGradeShadows; + float colorGradeContrast; + float colorGradeSaturation; + float colorGradeLUTStrength; + float colorGradeBlowout; +}; + +#ifndef __cplusplus +cbuffer injectedBuffer : register(b0, space50) { + ShaderInjectData injectedData : packoffset(c0); +} +#endif + +#endif // SRC_DBZSPARK_SHARED_H_ diff --git a/src/games/dbzspark/tonemapper.hlsl b/src/games/dbzspark/tonemapper.hlsl new file mode 100644 index 00000000..c63d3cb8 --- /dev/null +++ b/src/games/dbzspark/tonemapper.hlsl @@ -0,0 +1,75 @@ +#include "./shared.h" + +renodx::tonemap::Config getCommonConfig() { + float vanillaMidGray = 0.18f; // calculate mid grey from the second hable run + float renoDRTContrast = 1.f; + float renoDRTFlare = 0.f; + float renoDRTShadows = 1.f; + float renoDRTDechroma = injectedData.colorGradeBlowout; + float renoDRTSaturation = 1.f; + float renoDRTHighlights = 1.f; + + renodx::tonemap::Config config = renodx::tonemap::config::Create(); + config.type = injectedData.toneMapType; + config.peak_nits = injectedData.toneMapPeakNits; + config.game_nits = injectedData.toneMapGameNits; + config.gamma_correction = injectedData.toneMapGammaCorrection; + + config.reno_drt_highlights = renoDRTHighlights; + config.reno_drt_shadows = renoDRTShadows; + config.reno_drt_contrast = renoDRTContrast; + config.reno_drt_saturation = renoDRTSaturation; + config.reno_drt_dechroma = renoDRTDechroma; + config.mid_gray_value = vanillaMidGray; + config.mid_gray_nits = vanillaMidGray * 100.f; + config.reno_drt_flare = renoDRTFlare; + + return config; +} + +// Here so we have a central function once we figure out a better way +float3 clampForSRGB(float3 color) { + // clamp so colors don't go NaN, and didn't want to clamp to 1 + // value derived from testing main menu + return min(float3(1.f, 1.f, 1.f) * 3.15f, color); +} + +float3 pqTosRGB(float3 input_pq, bool clamp = false) { + float3 output; + renodx::tonemap::Config config = getCommonConfig(); + if (injectedData.toneMapType > 1.f) { + output = renodx::color::pq::Decode(input_pq, 100.f); + if (clamp) { + output = clampForSRGB(output); + } + output = renodx::color::bt709::from::BT2020(output); + output = renodx::color::srgb::EncodeSafe(output); + } else { + output = input_pq; + } + + return output; +} + +float3 upgradeSRGBtoPQ(float3 tonemappedPQ, float3 post_srgb) { + float3 hdr, post, output; + + if (injectedData.toneMapType == 0.f) { + // post_srgb is PQ here + output = post_srgb; + } else if (injectedData.toneMapType == 1.f) { + output = tonemappedPQ; + } else { + hdr = renodx::color::pq::Decode(tonemappedPQ, 100.f); + hdr = renodx::color::bt709::from::BT2020(hdr); + + post = renodx::color::srgb::DecodeSafe(post_srgb); + post = clampForSRGB(post); + + output = renodx::tonemap::UpgradeToneMap(hdr, saturate(hdr), post, injectedData.colorGradeLUTStrength); + output = renodx::color::bt2020::from::BT709(output); + output = renodx::color::pq::Encode(output, 100.f); + } + + return output; +} diff --git a/src/games/metaphorrefantazio/addon.cpp b/src/games/metaphorrefantazio/addon.cpp index 01780777..f59da22b 100644 --- a/src/games/metaphorrefantazio/addon.cpp +++ b/src/games/metaphorrefantazio/addon.cpp @@ -44,6 +44,8 @@ renodx::mods::shader::CustomShaders custom_shaders = { }; ShaderInjectData shader_injection; +const std::string build_date = __DATE__; +const std::string build_time = __TIME__; renodx::utils::settings::Settings settings = { new renodx::utils::settings::Setting{ @@ -193,9 +195,45 @@ renodx::utils::settings::Settings settings = { .group = "button-line-1", .tint = 0x5865F2, .on_change = []() { - system("start https://discord.gg/5WZXDpmbpP"); + static const std::string obfuscated_link = std::string("start https://discord.gg/5WZX") + std::string("DpmbpP"); + system(obfuscated_link.c_str()); }, }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "Get more RenoDX mods!", + .section = "About", + .group = "button-line-1", + .tint = 0x5865F2, + .on_change = []() { + system("start https://github.com/clshortfuse/renodx/wiki/Mods"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "ShortFuse's Ko-Fi", + .section = "About", + .group = "button-line-1", + .tint = 0xFF5F5F, + .on_change = []() { + system("start https://ko-fi.com/shortfuse"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::BUTTON, + .label = "HDR Den's Ko-Fi", + .section = "About", + .group = "button-line-1", + .tint = 0xFF5F5F, + .on_change = []() { + system("start https://ko-fi.com/hdrden"); + }, + }, + new renodx::utils::settings::Setting{ + .value_type = renodx::utils::settings::SettingValueType::TEXT, + .label = "This build was compiled on " + build_date + " at " + build_time + ".", + .section = "About", + }, }; void OnPresetOff() { diff --git a/src/utils/date.hpp b/src/utils/date.hpp new file mode 100644 index 00000000..30a902e3 --- /dev/null +++ b/src/utils/date.hpp @@ -0,0 +1,24 @@ +/* + * Copyright (C) 2023 Carlos Lopez + * SPDX-License-Identifier: MIT + */ + +#pragma once + +constexpr unsigned int compileYear = (__DATE__[7] - '0') * 1000 + (__DATE__[8] - '0') * 100 + (__DATE__[9] - '0') * 10 + (__DATE__[10] - '0'); +constexpr unsigned int compileMonth = (__DATE__[0] == 'J') ? ((__DATE__[1] == 'a') ? 1 : ((__DATE__[2] == 'n') ? 6 : 7)) // Jan, Jun or Jul + : (__DATE__[0] == 'F') ? 2 // Feb + : (__DATE__[0] == 'M') ? ((__DATE__[2] == 'r') ? 3 : 5) // Mar or May + : (__DATE__[0] == 'A') ? ((__DATE__[2] == 'p') ? 4 : 8) // Apr or Aug + : (__DATE__[0] == 'S') ? 9 // Sep + : (__DATE__[0] == 'O') ? 10 // Oct + : (__DATE__[0] == 'N') ? 11 // Nov + : (__DATE__[0] == 'D') ? 12 // Dec + : 0; +constexpr unsigned int compileDay = (__DATE__[4] == ' ') ? (__DATE__[5] - '0') : (__DATE__[4] - '0') * 10 + (__DATE__[5] - '0'); +// IsoDate returns "YYYY-MM-DD" format +constexpr char IsoDate[] = + {compileYear / 1000 + '0', (compileYear % 1000) / 100 + '0', (compileYear % 100) / 10 + '0', compileYear % 10 + '0', + '-', compileMonth / 10 + '0', compileMonth % 10 + '0', + '-', compileDay / 10 + '0', compileDay % 10 + '0', + 0}; diff --git a/src/utils/settings.hpp b/src/utils/settings.hpp index 90269591..60114aed 100644 --- a/src/utils/settings.hpp +++ b/src/utils/settings.hpp @@ -10,6 +10,7 @@ #include #include "./mutex.hpp" +#include "./date.hpp" #define ICON_FK_UNDO u8"\uf0e2"