diff --git a/src/devkit/addon.cpp b/src/devkit/addon.cpp index 856fa8c2..52a7900f 100644 --- a/src/devkit/addon.cpp +++ b/src/devkit/addon.cpp @@ -114,8 +114,8 @@ struct PipelineBindDetails { }; struct DrawDetails { - std::map srv_binds; - std::map uav_binds; + std::map, ResourceViewDetails> srv_binds; + std::map, ResourceViewDetails> uav_binds; std::vector pipeline_binds; enum class DrawMethods { PRESENT, @@ -177,38 +177,35 @@ struct __declspec(uuid("0190ec1a-2e19-74a6-ad41-4df0d4d8caed")) DeviceData { return iterator->second; } - ResourceViewDetails& GetResourceViewDetails(reshade::api::resource_view resource_view, reshade::api::device* device) { + ResourceViewDetails GetResourceViewDetails(reshade::api::resource_view resource_view, reshade::api::device* device) { + ResourceViewDetails details; if (auto pair = resource_view_details.find(resource_view.handle); pair != resource_view_details.end()) { - return pair->second; - } + details = pair->second; + auto device_api = device->get_api(); + if (device_api == reshade::api::device_api::d3d11) { + auto resource_view_tag = renodx::utils::trace::GetDebugName(device_api, resource_view); + if (resource_view_tag.has_value()) { + details.resource_view_tag = resource_view_tag.value(); + } - ResourceViewDetails details = { - .resource_view = resource_view, - .resource_view_desc = device->get_resource_view_desc(resource_view), - .resource = device->get_resource_from_view(resource_view), - }; - auto device_api = device->get_api(); - if (device_api == reshade::api::device_api::d3d11) { - auto resource_view_tag = renodx::utils::trace::GetDebugName(device->get_api(), resource_view); - if (resource_view_tag.has_value()) { - details.resource_view_tag = resource_view_tag.value(); + if (details.resource_desc.type != reshade::api::resource_type::unknown) { + auto resource_tag = renodx::utils::trace::GetDebugName(device_api, details.resource); + if (resource_tag.has_value()) { + details.resource_tag = resource_tag.value(); + } + } } - } - if (details.resource.handle != 0u) { - details.resource_desc = device->get_resource_desc(details.resource); - details.is_swapchain = renodx::utils::swapchain::IsBackBuffer(device, details.resource); - auto resource_tag = renodx::utils::trace::GetDebugName(device->get_api(), details.resource); - if (resource_tag.has_value()) { - details.resource_tag = resource_tag.value(); - } - } + details.UpdateSwapchainModState(device); - details.UpdateSwapchainModState(device); + } else { + details = { + .resource_view = resource_view, + }; + } - auto [iterator, is_new] = resource_view_details.emplace(resource_view.handle, details); - return iterator->second; + return details; } }; @@ -421,9 +418,7 @@ void OnPushDescriptors( auto log_resource_view = [&](uint32_t index, reshade::api::resource_view view, - std::map& destination) { - if (view.handle == 0) return; - + std::map, ResourceViewDetails>& destination) { auto pair = device_data.pipeline_layout_params.find(layout.handle); if (pair == device_data.pipeline_layout_params.end()) { reshade::log::message(reshade::log::level::error, "Could not find handle."); @@ -432,7 +427,8 @@ void OnPushDescriptors( } auto layout_params = pair->second; auto param = layout_params[layout_param]; - auto starting_index = -1; + uint32_t dx_register_index; + uint32_t dx_register_space; switch (param.type) { case reshade::api::pipeline_layout_param_type::descriptor_table: { if (param.descriptor_table.count != 1) { @@ -440,18 +436,31 @@ void OnPushDescriptors( // add warning return; } - starting_index = param.descriptor_table.ranges[0].dx_register_index; + dx_register_index = param.descriptor_table.ranges[0].dx_register_index; + dx_register_space = param.descriptor_table.ranges[0].dx_register_space; break; } case reshade::api::pipeline_layout_param_type::push_descriptors: - starting_index = param.push_descriptors.dx_register_index; + dx_register_index = param.push_descriptors.dx_register_index; + dx_register_space = param.push_descriptors.dx_register_space; break; default: reshade::log::message(reshade::log::level::error, "Not descriptor table."); return; } - auto srv_index = update.binding + index + starting_index; - destination[srv_index] = (device_data.GetResourceViewDetails(view, device)); + + auto slot = std::pair(dx_register_index + update.binding + index, dx_register_space); + + if (view.handle == 0u) { + destination.erase(slot); + } else { + auto detail_item = (device_data.GetResourceViewDetails(view, device)); + if (detail_item.resource_desc.type == reshade::api::resource_type::unknown) { + destination.erase(slot); + } else { + destination[slot] = detail_item; + } + } }; for (uint32_t i = 0; i < update.count; i++) { @@ -490,6 +499,7 @@ void OnBindDescriptorTables( uint32_t count, const reshade::api::descriptor_table* tables) { if (!is_snapshotting) return; + reshade::log::message(reshade::log::level::debug, "start"); auto& data = cmd_list->get_private_data(); auto& details = data.GetCurrentDrawDetails(); @@ -502,8 +512,14 @@ void OnBindDescriptorTables( auto& descriptor_data = device->get_private_data(); for (uint32_t i = 0; i < count; ++i) { - const auto& info = layout_data.pipeline_layout_data[layout.handle]; - const auto& param = info.params.at(first + i); + auto layout_index = first + i; + + auto layout_data_pair = layout_data.pipeline_layout_data.find(layout.handle); + if (layout_data_pair == layout_data.pipeline_layout_data.end()) continue; + + const auto& info = layout_data_pair->second; + if (layout_index > info.params.size()) continue; + const auto& param = info.params.at(layout_index); for (uint32_t k = 0; k < param.descriptor_table.count; ++k) { const auto& range = param.descriptor_table.ranges[k]; @@ -511,9 +527,14 @@ void OnBindDescriptorTables( // Skip unbounded ranges if (range.count == UINT32_MAX) continue; - if (range.type != reshade::api::descriptor_type::shader_resource_view - && range.type != reshade::api::descriptor_type::sampler_with_resource_view) { - continue; + switch (range.type) { + case reshade::api::descriptor_type::shader_resource_view: + case reshade::api::descriptor_type::sampler_with_resource_view: + case reshade::api::descriptor_type::buffer_shader_resource_view: + case reshade::api::descriptor_type::unordered_access_view: + break; + default: + continue; } uint32_t base_offset = 0; @@ -523,7 +544,9 @@ void OnBindDescriptorTables( const std::shared_lock descriptor_lock(descriptor_data.mutex); for (uint32_t j = 0; j < range.count; ++j) { - const auto& heap_data = descriptor_data.heaps[heap.handle]; + auto heap_pair = descriptor_data.heaps.find(heap.handle); + if (heap_pair == descriptor_data.heaps.end()) continue; + const auto& heap_data = heap_pair->second; auto offset = base_offset + j; if (offset >= heap_data.size()) continue; const auto& [descriptor_type, descriptor_data] = heap_data[offset]; @@ -548,13 +571,32 @@ void OnBindDescriptorTables( default: break; } - if (resource_view.handle == 0u) continue; - uint32_t texture_index = range.dx_register_index + j; + + auto slot = std::pair(range.dx_register_index + j, range.dx_register_space); + const std::unique_lock lock(device_data.mutex); if (is_uav) { - details.uav_binds[texture_index] = (device_data.GetResourceViewDetails(resource_view, device)); + if (resource_view.handle == 0u) { + details.uav_binds.erase(slot); + } else { + auto detail_item = (device_data.GetResourceViewDetails(resource_view, device)); + if (detail_item.resource_desc.type == reshade::api::resource_type::unknown) { + details.uav_binds.erase(slot); + } else { + details.uav_binds[slot] = detail_item; + } + } } else { - details.srv_binds[texture_index] = (device_data.GetResourceViewDetails(resource_view, device)); + if (resource_view.handle == 0u) { + details.srv_binds.erase(slot); + } else { + auto detail_item = (device_data.GetResourceViewDetails(resource_view, device)); + if (detail_item.resource_desc.type == reshade::api::resource_type::unknown) { + details.srv_binds.erase(slot); + } else { + details.srv_binds[slot] = detail_item; + } + } } } } @@ -566,16 +608,18 @@ bool OnDraw(reshade::api::command_list* cmd_list, DrawDetails::DrawMethods draw_ auto* device = cmd_list->get_device(); auto& device_data = device->get_private_data(); - std::unique_lock lock(device_data.mutex); - auto& state = renodx::utils::shader::GetCurrentState(cmd_list); - for (auto& [stage, hash] : state.current_shaders_hashes) { - if (auto pair = device_data.shader_details.find(hash); - pair != device_data.shader_details.end()) { - auto details = pair->second; - if (details.bypass_draw) { - bypass_draw = true; - break; + { + auto& state = renodx::utils::shader::GetCurrentState(cmd_list); + std::shared_lock lock(device_data.mutex); + for (auto& [stage, hash] : state.current_shaders_hashes) { + if (auto pair = device_data.shader_details.find(hash); + pair != device_data.shader_details.end()) { + auto details = pair->second; + if (details.bypass_draw) { + bypass_draw = true; + break; + } } } } @@ -586,6 +630,7 @@ bool OnDraw(reshade::api::command_list* cmd_list, DrawDetails::DrawMethods draw_ draw_details.draw_method = draw_method; draw_details.render_targets.clear(); + std::unique_lock lock(device_data.mutex); uint32_t rtv_index = 0u; for (auto render_target : renodx::utils::swapchain::GetRenderTargets(cmd_list)) { if (render_target.handle != 0u) { @@ -634,6 +679,40 @@ bool OnDrawOrDispatchIndirect( return OnDraw(cmd_list, DrawDetails::DrawMethods::DRAW_INDEXED_OR_INDIRECT); } +void OnInitResourceView( + reshade::api::device* device, + reshade::api::resource resource, + reshade::api::resource_usage usage_type, + const reshade::api::resource_view_desc& desc, + reshade::api::resource_view view) { + auto& data = device->get_private_data(); + const std::unique_lock lock(data.mutex); + data.resource_view_details.erase(view.handle); + ResourceViewDetails details = { + .resource_view = view, + .resource_view_desc = desc, + .resource = resource, + }; + + auto resource_view_tag = renodx::utils::trace::GetDebugName(device->get_api(), view); + if (resource_view_tag.has_value()) { + details.resource_view_tag = resource_view_tag.value(); + } + + if (resource.handle != 0u) { + details.resource_desc = device->get_resource_desc(details.resource); + details.is_swapchain = renodx::utils::swapchain::IsBackBuffer(device, details.resource); + } + + data.resource_view_details[view.handle] = details; +} + +void OnDestroyResourceView(reshade::api::device* device, reshade::api::resource_view view) { + auto& data = device->get_private_data(); + const std::unique_lock lock(data.mutex); + data.resource_view_details.erase(view.handle); +} + void DeactivateShader(reshade::api::device* device, uint32_t shader_hash) { renodx::utils::shader::RemoveRuntimeReplacements(device, {shader_hash}); } @@ -886,14 +965,19 @@ void RenderCapturePane(reshade::api::device* device, DeviceData& data) { } } - for (auto& [srv_index, resource_view_details] : draw_details.srv_binds) { + for (auto& [slot, resource_view_details] : draw_details.srv_binds) { ++row_index; bool rtv_node_open = false; if (draw_node_open) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::PushID(row_index); - rtv_node_open = ImGui::TreeNodeEx("", tree_node_flags | ImGuiTreeNodeFlags_DefaultOpen, "SRV%d", srv_index); + + rtv_node_open = ImGui::TreeNodeEx( + "", + tree_node_flags | ImGuiTreeNodeFlags_DefaultOpen, + (slot.second == 0) ? "SRV%d" : "SRV%d,space%d", slot.first, slot.second); + ImGui::PopID(); ImGui::TableNextColumn(); @@ -967,14 +1051,19 @@ void RenderCapturePane(reshade::api::device* device, DeviceData& data) { } } - for (auto& [uav_index, resource_view_details] : draw_details.uav_binds) { + for (auto& [slot, resource_view_details] : draw_details.uav_binds) { ++row_index; bool rtv_node_open = false; if (draw_node_open) { ImGui::TableNextRow(); ImGui::TableNextColumn(); ImGui::PushID(row_index); - rtv_node_open = ImGui::TreeNodeEx("", tree_node_flags | ImGuiTreeNodeFlags_DefaultOpen, "UAV%d", uav_index); + + rtv_node_open = ImGui::TreeNodeEx( + "", + tree_node_flags | ImGuiTreeNodeFlags_DefaultOpen, + (slot.second == 0) ? "UAV%d" : "UAV%d,space%d", slot.first, slot.second); + ImGui::PopID(); ImGui::TableNextColumn(); @@ -1611,8 +1700,6 @@ void OnPresent( const reshade::api::rect* dest_rect, uint32_t dirty_rect_count, const reshade::api::rect* dirty_rects) { - auto* device = swapchain->get_device(); - if (setting_shader_defines_changed) { renodx::utils::shader::compiler::watcher::SetShaderDefines(setting_shader_defines); renodx::utils::shader::compiler::watcher::RequestCompile(); @@ -1672,6 +1759,8 @@ BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) { reshade::register_event(OnDrawOrDispatchIndirect); reshade::register_event(OnDispatch); reshade::register_event(OnPresent); + reshade::register_event(OnInitResourceView); + reshade::register_event(OnDestroyResourceView); reshade::register_overlay("RenoDX DevKit", OnRegisterOverlay); @@ -1697,6 +1786,8 @@ BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) { reshade::unregister_event(OnDrawOrDispatchIndirect); reshade::unregister_event(OnDispatch); reshade::unregister_event(OnPresent); + reshade::unregister_event(OnInitResourceView); + reshade::unregister_event(OnDestroyResourceView); reshade::unregister_overlay("RenoDX DevKit", OnRegisterOverlay); diff --git a/src/games/cp2077/addon.cpp b/src/games/cp2077/addon.cpp index 227afbd9..3b5435dc 100644 --- a/src/games/cp2077/addon.cpp +++ b/src/games/cp2077/addon.cpp @@ -77,7 +77,7 @@ ShaderInjectData shader_injection; auto last_is_hdr = false; float ComputeReferenceWhite(float peak_nits) { - return std::clamp(roundf(powf(10.f, 0.03460730900256f + (0.757737096673107f * log10f(peak_nits)))), 100.f, 203.f); + return std::clamp(roundf(powf(10.f, 0.03460730900256f + (0.757737096673107f * log10f(peak_nits)))), 100.f, 300.f); } renodx::utils::settings::Settings settings = { @@ -440,8 +440,6 @@ void OnPresetOff() { renodx::utils::settings::UpdateSetting("processingLUTCorrection", 0.f); renodx::utils::settings::UpdateSetting("processingLUTOrder", 1.f); renodx::utils::settings::UpdateSetting("processingInternalSampling", 0.f); - renodx::utils::settings::UpdateSetting("processingGlobalGain", 50.f); - renodx::utils::settings::UpdateSetting("processingGlobalLift", 50.f); } void OnInitSwapchain(reshade::api::swapchain* swapchain) { @@ -475,7 +473,9 @@ 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::expected_constant_buffer_index = 14; reshade::register_event(OnInitSwapchain); diff --git a/src/games/cp2077/colormath.hlsl b/src/games/cp2077/colormath.hlsl index a2733546..76ba6573 100644 --- a/src/games/cp2077/colormath.hlsl +++ b/src/games/cp2077/colormath.hlsl @@ -41,9 +41,6 @@ float3 applyUserBrightness(float3 inputColor, float userBrightness = 1.f) { float3 convertColor(float3 inputColor, ConvertColorParams params) { float3 outputColor = inputColor; - if (injectedData.toneMapGammaCorrection == 2.f) { - outputColor = renodx::color::correct::GammaSafe(outputColor); - } switch (params.outputTypeEnum) { case OUTPUT_TYPE_SRGB8: { outputColor = max(0, outputColor); // clamp to BT709 diff --git a/src/games/cp2077/output_0xCBFFC2A3.ps_6_0.hlsl b/src/games/cp2077/output_0xCBFFC2A3.ps_6_0.hlsl index 10ee31e3..cdf4aa82 100644 --- a/src/games/cp2077/output_0xCBFFC2A3.ps_6_0.hlsl +++ b/src/games/cp2077/output_0xCBFFC2A3.ps_6_0.hlsl @@ -99,18 +99,24 @@ float4 main(PSSceneIn input) : SV_TARGET { const float4 inputColor = textureRender.Load(int3(uint2(uint(gl_FragCoord.x), uint(gl_FragCoord.y)), 0u)); ConvertColorParams params = { - pixConsts.outputTypeEnum, - pixConsts.paperWhiteScaling, - pixConsts.blackFloorAdjust, - pixConsts.gammaCorrection, - pixConsts.pqSaturation, - float3x3( - pixConsts.pqMatrix[0].x, pixConsts.pqMatrix[0].y, pixConsts.pqMatrix[0].z, - pixConsts.pqMatrix[1].x, pixConsts.pqMatrix[1].y, pixConsts.pqMatrix[1].z, - pixConsts.pqMatrix[2].x, pixConsts.pqMatrix[2].y, pixConsts.pqMatrix[2].z), - float3(TEXCOORD.x, TEXCOORD.y, shaderConsts.const00.x)}; + pixConsts.outputTypeEnum, + pixConsts.paperWhiteScaling, + pixConsts.blackFloorAdjust, + pixConsts.gammaCorrection, + pixConsts.pqSaturation, + float3x3( + pixConsts.pqMatrix[0].x, pixConsts.pqMatrix[0].y, pixConsts.pqMatrix[0].z, + pixConsts.pqMatrix[1].x, pixConsts.pqMatrix[1].y, pixConsts.pqMatrix[1].z, + pixConsts.pqMatrix[2].x, pixConsts.pqMatrix[2].y, pixConsts.pqMatrix[2].z), + float3(TEXCOORD.x, TEXCOORD.y, shaderConsts.const00.x) + }; - float3 outputColor = convertColor(inputColor.rgb, params); + float3 outputColor = inputColor.rgb; + if (injectedData.toneMapGammaCorrection == 2.f) { + outputColor = renodx::color::correct::GammaSafe(inputColor.rgb); + } + outputColor = convertColor(outputColor.rgb, params); + #if 0 // if (TEXCOORD.x > 0.75f) { // if (TEXCOORD.y < 0.1f) outputColor.rgb = (100.f / 80.f) * shaderConsts.const00.x; diff --git a/src/games/re2remake/ConvertRec2020PS_0xAF0777E5.ps_6_5.hlsl b/src/games/re2remake/ConvertRec2020PS_0xAF0777E5.ps_6_5.hlsl new file mode 100644 index 00000000..748a1636 --- /dev/null +++ b/src/games/re2remake/ConvertRec2020PS_0xAF0777E5.ps_6_5.hlsl @@ -0,0 +1,61 @@ +// cbuffer HDRMapping +// { + +// struct HDRMapping +// { + +// float whitePaperNits; ; Offset: 0 +// float configImageAlphaScale; ; Offset: 4 +// float displayMaxNits; ; Offset: 8 +// float displayMinNits; ; Offset: 12 +// float4 displayMaxNitsRect; ; Offset: 16 +// float4 standardMaxNitsRect; ; Offset: 32 +// float4 mdrOutRangeRect; ; Offset: 48 +// uint drawMode; ; Offset: 64 +// float gammaForHDR; ; Offset: 68 +// float2 configDrawRectSize; ; Offset: 72 + +// } HDRMapping; ; Offset: 0 Size: 80 + +// } + +#include "./DICE.hlsl" +#include "./shared.h" + +Texture2D tLinearImage : register(t0); + +cbuffer HDRMapping : register(b0) { + float whitePaperNits : packoffset(c000.x); + float displayMaxNits : packoffset(c000.z); + float HDRMapping_000w : packoffset(c000.w); + uint HDRMapping_004x : packoffset(c004.x); + float HDRMapping_004y : packoffset(c004.y); +}; + +SamplerState PointBorder : register(s2, space32); + +float4 main(noperspective float4 SV_Position: SV_Position, + linear float2 TEXCOORD: TEXCOORD) + : SV_Target { + float4 bt709Color = tLinearImage.SampleLevel(PointBorder, TEXCOORD.xy, 0.0f); + +#if 0 // Gamma Correction + bt709Color.rgb = renodx::color::correct::GammaSafe(bt709Color.rgb); +#endif + +#if 1 + DICESettings config = DefaultDICESettings(); + config.Type = 3; + config.ShoulderStart = 0.5f; + const float dicePaperWhite = whitePaperNits / renodx::color::srgb::REFERENCE_WHITE; + const float dicePeakWhite = max(displayMaxNits, whitePaperNits) / renodx::color::srgb::REFERENCE_WHITE; + bt709Color.rgb = DICETonemap(bt709Color.rgb * dicePaperWhite, dicePeakWhite, config) / dicePaperWhite; +#endif + + float3 bt2020Color = + renodx::color::bt2020::from::BT709(bt709Color.rgb); + + float3 pqColor = renodx::color::pq::Encode(bt2020Color, whitePaperNits); + + return float4(pqColor, 1.0); +} diff --git a/src/games/re2remake/DICE.hlsl b/src/games/re2remake/DICE.hlsl new file mode 100644 index 00000000..5e165abd --- /dev/null +++ b/src/games/re2remake/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 contained 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; +} \ No newline at end of file diff --git a/src/games/re2remake/HDRPostProcess_WithTonemap_0x314A98A7.ps_6_5.hlsl b/src/games/re2remake/HDRPostProcess_WithTonemap_0x314A98A7.ps_6_5.hlsl new file mode 100644 index 00000000..9d929903 --- /dev/null +++ b/src/games/re2remake/HDRPostProcess_WithTonemap_0x314A98A7.ps_6_5.hlsl @@ -0,0 +1,2502 @@ +#include "./shared.h" +#include "./LUTBlackCorrection.hlsl" + +// Buffer Definitions: + +// cbuffer SceneInfo +// { + +// struct dx.alignment.legacy.SceneInfo +// { + +// row_major float4x4 viewProjMat; ; Offset: 0 +// row_major float3x4 transposeViewMat; ; Offset: 64 +// row_major float3x4 transposeViewInvMat; ; Offset: 112 +// float4 projElement[2]; ; Offset: 160 +// float4 projInvElements[2]; ; Offset: 192 +// row_major float4x4 viewProjInvMat; ; Offset: 224 +// row_major float4x4 prevViewProjMat; ; Offset: 288 +// float3 ZToLinear; ; Offset: 352 +// float subdivisionLevel; ; Offset: 364 +// float2 screenSize; ; Offset: 368 +// float2 screenInverseSize; ; Offset: 376 +// float2 cullingHelper; ; Offset: 384 +// float cameraNearPlane; ; Offset: 392 +// float cameraFarPlane; ; Offset: 396 +// float4 viewFrustum[6]; ; Offset: 400 +// float4 clipplane; ; Offset: 496 +// float2 vrsVelocityThreshold; ; Offset: 512 +// uint renderOutputId; ; Offset: 520 +// uint SceneInfo_Reserve; ; Offset: 524 + +// } SceneInfo; ; Offset: 0 Size: 528 + +// } + +// cbuffer CameraKerare +// { + +// struct CameraKerare +// { + +// float kerare_scale; ; Offset: 0 +// float kerare_offset; ; Offset: 4 +// float kerare_brightness; ; Offset: 8 + +// } CameraKerare; ; Offset: 0 Size: 12 + +// } + +// cbuffer TonemapParam +// { + +// struct TonemapParam +// { + +// float contrast; ; Offset: 0 +// float linearBegin; ; Offset: 4 +// float linearLength; ; Offset: 8 +// float toe; ; Offset: 12 +// float maxNit; ; Offset: 16 +// float linearStart; ; Offset: 20 +// float displayMaxNitSubContrastFactor; ; Offset: 24 +// float contrastFactor; ; Offset: 28 +// float mulLinearStartContrastFactor; ; Offset: 32 +// float invLinearBegin; ; Offset: 36 +// float madLinearStartContrastFactor; ; Offset: 40 + +// } TonemapParam; ; Offset: 0 Size: 44 + +// } + +// cbuffer LensDistortionParam +// { + +// struct LensDistortionParam +// { + +// float fDistortionCoef; ; Offset: 0 +// float fRefraction; ; Offset: 4 +// uint aberrationEnable; ; Offset: 8 +// uint distortionType; ; Offset: 12 +// float fCorrectCoef; ; Offset: 16 +// uint reserve1; ; Offset: 20 +// uint reserve2; ; Offset: 24 +// uint reserve3; ; Offset: 28 + +// } LensDistortionParam; ; Offset: 0 Size: 32 + +// } + +// cbuffer PaniniProjectionParam +// { + +// struct PaniniProjectionParam +// { + +// float4 fOptimizedParam; ; Offset: 0 + +// } PaniniProjectionParam; ; Offset: 0 Size: 16 + +// } + +// cbuffer RadialBlurRenderParam +// { + +// struct RadialBlurRenderParam +// { + +// float4 cbRadialColor; ; Offset: 0 +// float2 cbRadialScreenPos; ; Offset: 16 +// float2 cbRadialMaskSmoothstep; ; Offset: 24 +// float2 cbRadialMaskRate; ; Offset: 32 +// float cbRadialBlurPower; ; Offset: 40 +// float cbRadialSharpRange; ; Offset: 44 +// uint cbRadialBlurFlags; ; Offset: 48 +// float cbRadialReserve0; ; Offset: 52 +// float cbRadialReserve1; ; Offset: 56 +// float cbRadialReserve2; ; Offset: 60 + +// } RadialBlurRenderParam; ; Offset: 0 Size: 64 + +// } + +// cbuffer FilmGrainParam +// { + +// struct FilmGrainParam +// { + +// float2 fNoisePower; ; Offset: 0 +// float2 fNoiseUVOffset; ; Offset: 8 +// float fNoiseDensity; ; Offset: 16 +// float fNoiseContrast; ; Offset: 20 +// float fBlendRate; ; Offset: 24 +// float fReverseNoiseSize; ; Offset: 28 + +// } FilmGrainParam; ; Offset: 0 Size: 32 + +// } + +// cbuffer ColorCorrectTexture +// { + +// struct dx.alignment.legacy.ColorCorrectTexture +// { + +// float fTextureSize; ; Offset: 0 +// float fTextureBlendRate; ; Offset: 4 +// float fTextureBlendRate2; ; Offset: 8 +// float fTextureInverseSize; ; Offset: 12 +// row_major float4x4 fColorMatrix; ; Offset: 16 + +// } ColorCorrectTexture; ; Offset: 0 Size: 80 + +// } + +// cbuffer ColorDeficientTable +// { + +// struct ColorDeficientTable +// { + +// float4 cvdR; ; Offset: 0 +// float4 cvdG; ; Offset: 16 +// float4 cvdB; ; Offset: 32 + +// } ColorDeficientTable; ; Offset: 0 Size: 48 + +// } + +// cbuffer ImagePlaneParam +// { + +// struct ImagePlaneParam +// { + +// float4 ColorParam; ; Offset: 0 +// float Levels_Rate; ; Offset: 16 +// float Levels_Range; ; Offset: 20 +// uint Blend_Type; ; Offset: 24 + +// } ImagePlaneParam; ; Offset: 0 Size: 28 + +// } + +// cbuffer CBControl +// { + +// struct CBControl +// { + +// uint cPassEnabled; ; Offset: 0 + +// } CBControl; ; Offset: 0 Size: 4 + +// } + +// Resource bind info for ComputeResultSRV +// { + +// struct struct.RadialBlurComputeResult +// { + +// float computeAlpha; ; Offset: 0 + +// } $Element; ; Offset: 0 Size: 4 + +// } + + +// Resource Bindings: + +// Name Type Format Dim ID HLSL Bind Count +// ------------------------------ ---------- ------- ----------- ------- -------------- ------ +// SceneInfo cbuffer NA NA CB0 cb0 1 +// CameraKerare cbuffer NA NA CB1 cb1 1 +// TonemapParam cbuffer NA NA CB2 cb2 1 +// LensDistortionParam cbuffer NA NA CB3 cb3 1 +// PaniniProjectionParam cbuffer NA NA CB4 cb4 1 +// RadialBlurRenderParam cbuffer NA NA CB5 cb5 1 +// FilmGrainParam cbuffer NA NA CB6 cb6 1 +// ColorCorrectTexture cbuffer NA NA CB7 cb7 1 +// ColorDeficientTable cbuffer NA NA CB8 cb8 1 +// ImagePlaneParam cbuffer NA NA CB9 cb9 1 +// CBControl cbuffer NA NA CB10 cb10 1 +// BilinearClamp sampler NA NA S0 s5,space32 1 +// BilinearBorder sampler NA NA S1 s6,space32 1 +// TrilinearClamp sampler NA NA S2 s9,space32 1 +// RE_POSTPROCESS_Color texture f32 2d T0 t0 1 +// ComputeResultSRV texture struct r/o T1 t1 1 +// tTextureMap0 texture f32 3d T2 t2 1 +// tTextureMap1 texture f32 3d T3 t3 1 +// tTextureMap2 texture f32 3d T4 t4 1 +// ImagePlameBase texture f32 2d T5 t5 1 +// ImagePlameAlpha texture f32 2d T6 t6 1 + + +Texture2D RE_POSTPROCESS_Color : register(t0); + +struct _ComputeResultSRV { + float data[1]; +}; +StructuredBuffer<_ComputeResultSRV> ComputeResultSRV : register(t1); + +Texture3D tTextureMap0 : register(t2); + +Texture3D tTextureMap1 : register(t3); + +Texture3D tTextureMap2 : register(t4); + +Texture2D ImagePlameBase : register(t5); + +Texture2D ImagePlameAlpha : register(t6); + +cbuffer SceneInfo : register(b0) { + float SceneInfo_023x : packoffset(c023.x); + float SceneInfo_023y : packoffset(c023.y); + float SceneInfo_023z : packoffset(c023.z); + float SceneInfo_023w : packoffset(c023.w); +}; + +cbuffer CameraKerare : register(b1) { + float CameraKerare_000x : packoffset(c000.x); + float CameraKerare_000y : packoffset(c000.y); + float CameraKerare_000z : packoffset(c000.z); +}; + +// struct TonemapParam +// { +// float contrast; ; Offset: 0 +// float linearBegin; ; Offset: 4 +// float linearLength; ; Offset: 8 +// float toe; ; Offset: 12 +// float maxNit; ; Offset: 16 +// float linearStart; ; Offset: 20 +// float displayMaxNitSubContrastFactor; ; Offset: 24 +// float contrastFactor; ; Offset: 28 +// float mulLinearStartContrastFactor; ; Offset: 32 +// float invLinearBegin; ; Offset: 36 +// float madLinearStartContrastFactor; ; Offset: 40 +// } TonemapParam; ; Offset: 0 Size: 44 +cbuffer TonemapParam : register(b2) { + float TonemapParam_000x : packoffset(c000.x); + float TonemapParam_000y : packoffset(c000.y); + float TonemapParam_000w : packoffset(c000.w); + float maxNit : packoffset(c001.x); // float TonemapParam_001x + float linearStart : packoffset(c001.y); // TonemapParam_001y + float TonemapParam_001z : packoffset(c001.z); + float TonemapParam_001w : packoffset(c001.w); + float TonemapParam_002x : packoffset(c002.x); + float TonemapParam_002y : packoffset(c002.y); + float TonemapParam_002z : packoffset(c002.z); +}; + +cbuffer LensDistortionParam : register(b3) { + float LensDistortionParam_000x : packoffset(c000.x); + float LensDistortionParam_000y : packoffset(c000.y); + uint LensDistortionParam_000z : packoffset(c000.z); + uint LensDistortionParam_000w : packoffset(c000.w); + float LensDistortionParam_001x : packoffset(c001.x); +}; + +cbuffer PaniniProjectionParam : register(b4) { + float PaniniProjectionParam_000x : packoffset(c000.x); + float PaniniProjectionParam_000y : packoffset(c000.y); + float PaniniProjectionParam_000z : packoffset(c000.z); + float PaniniProjectionParam_000w : packoffset(c000.w); +}; + +cbuffer RadialBlurRenderParam : register(b5) { + float RadialBlurRenderParam_000x : packoffset(c000.x); + float RadialBlurRenderParam_000y : packoffset(c000.y); + float RadialBlurRenderParam_000z : packoffset(c000.z); + float RadialBlurRenderParam_000w : packoffset(c000.w); + float RadialBlurRenderParam_001x : packoffset(c001.x); + float RadialBlurRenderParam_001y : packoffset(c001.y); + float RadialBlurRenderParam_001z : packoffset(c001.z); + float RadialBlurRenderParam_001w : packoffset(c001.w); + float RadialBlurRenderParam_002x : packoffset(c002.x); + float RadialBlurRenderParam_002y : packoffset(c002.y); + float RadialBlurRenderParam_002z : packoffset(c002.z); + float RadialBlurRenderParam_002w : packoffset(c002.w); + uint RadialBlurRenderParam_003x : packoffset(c003.x); +}; + +cbuffer FilmGrainParam : register(b6) { + float FilmGrainParam_000x : packoffset(c000.x); + float FilmGrainParam_000y : packoffset(c000.y); + float FilmGrainParam_000z : packoffset(c000.z); + float FilmGrainParam_000w : packoffset(c000.w); + float FilmGrainParam_001x : packoffset(c001.x); + float FilmGrainParam_001y : packoffset(c001.y); + float FilmGrainParam_001z : packoffset(c001.z); + float FilmGrainParam_001w : packoffset(c001.w); +}; + +cbuffer ColorCorrectTexture : register(b7) { + float ColorCorrectTexture_000y : packoffset(c000.y); + float ColorCorrectTexture_000z : packoffset(c000.z); + float ColorCorrectTexture_000w : packoffset(c000.w); + float ColorCorrectTexture_001x : packoffset(c001.x); + float ColorCorrectTexture_001y : packoffset(c001.y); + float ColorCorrectTexture_001z : packoffset(c001.z); + float ColorCorrectTexture_002x : packoffset(c002.x); + float ColorCorrectTexture_002y : packoffset(c002.y); + float ColorCorrectTexture_002z : packoffset(c002.z); + float ColorCorrectTexture_003x : packoffset(c003.x); + float ColorCorrectTexture_003y : packoffset(c003.y); + float ColorCorrectTexture_003z : packoffset(c003.z); + float ColorCorrectTexture_004x : packoffset(c004.x); + float ColorCorrectTexture_004y : packoffset(c004.y); + float ColorCorrectTexture_004z : packoffset(c004.z); +}; + +cbuffer ColorDeficientTable : register(b8) { + float ColorDeficientTable_000x : packoffset(c000.x); + float ColorDeficientTable_000y : packoffset(c000.y); + float ColorDeficientTable_000z : packoffset(c000.z); + float ColorDeficientTable_001x : packoffset(c001.x); + float ColorDeficientTable_001y : packoffset(c001.y); + float ColorDeficientTable_001z : packoffset(c001.z); + float ColorDeficientTable_002x : packoffset(c002.x); + float ColorDeficientTable_002y : packoffset(c002.y); + float ColorDeficientTable_002z : packoffset(c002.z); +}; + +cbuffer ImagePlaneParam : register(b9) { + float ImagePlaneParam_000x : packoffset(c000.x); + float ImagePlaneParam_000y : packoffset(c000.y); + float ImagePlaneParam_000z : packoffset(c000.z); + float ImagePlaneParam_000w : packoffset(c000.w); + float ImagePlaneParam_001x : packoffset(c001.x); + float ImagePlaneParam_001y : packoffset(c001.y); +}; + +cbuffer CBControl : register(b10) { + uint CBControl_000x : packoffset(c000.x); +}; + +SamplerState BilinearClamp : register(s5, space32); + +SamplerState BilinearBorder : register(s6, space32); + +SamplerState TrilinearClamp : register(s9, space32); + +float4 main( + noperspective float4 SV_Position: SV_Position, + linear float4 Kerare: Kerare, + linear float Exposure: Exposure +) : SV_Target { + float TonemapParam_001x = 125; + float TonemapParam_001y = 125; + + + // custom code + // declare lut config for use with lut black correction + renodx::lut::Config lut_config = renodx::lut::config::Create( + TrilinearClamp, + 1.f, + 1.f, + renodx::lut::config::type::SRGB, + renodx::lut::config::type::LINEAR, + 1 / ColorCorrectTexture_000w); + + float4 SV_Target; + // texture _1 = ImagePlameAlpha; + // texture _2 = ImagePlameBase; + // texture _3 = tTextureMap2; + // texture _4 = tTextureMap1; + // texture _5 = tTextureMap0; + // texture _6 = ComputeResultSRV; + // texture _7 = RE_POSTPROCESS_Color; + // SamplerState _8 = TrilinearClamp; + // SamplerState _9 = BilinearBorder; + // SamplerState _10 = BilinearClamp; + // cbuffer _11 = CBControl; + // cbuffer _12 = ImagePlaneParam; + // cbuffer _13 = ColorDeficientTable; + // cbuffer _14 = ColorCorrectTexture; + // cbuffer _15 = FilmGrainParam; + // cbuffer _16 = RadialBlurRenderParam; + // cbuffer _17 = PaniniProjectionParam; + // cbuffer _18 = LensDistortionParam; + // cbuffer _19 = TonemapParam; + // cbuffer _20 = CameraKerare; + // cbuffer _21 = SceneInfo; + float _22 = Exposure; + float _23 = Kerare.x; + float _24 = Kerare.y; + float _25 = Kerare.z; + float _26 = Kerare.w; + float _27 = SV_Position.x; + float _28 = SV_Position.y; + uint _30 = CBControl_000x; + int _31 = _30 & 1; + bool _32 = (_31 != 0); + uint _34 = LensDistortionParam_000w; + bool _35 = (_34 == 0); + bool _36 = _32 && _35; + bool _37 = (_34 == 1); + bool _38 = _32 && _37; + float _40 = CameraKerare_000z; + float _41 = _23 / _26; + float _42 = _24 / _26; + float _43 = _25 / _26; + float _44 = dot(float3(_41, _42, _43), float3(_41, _42, _43)); + float _45 = rsqrt(_44); + float _46 = _45 * _43; + float _47 = abs(_46); + float _48 = CameraKerare_000x; + float _49 = _48 * _47; + float _50 = CameraKerare_000y; + float _51 = _49 + _50; + float _52 = saturate(_51); + float _53 = 1.0f - _52; + float _54 = _47 * _47; + float _55 = _54 * _54; + float _56 = _55 * _53; + float _57 = _56 + _40; + float _58 = saturate(_57); + float _59 = _58 * _22; + float _61 = TonemapParam_000y; + float _63 = TonemapParam_002y; + float _65 = TonemapParam_001y; + float _66 = TonemapParam_000w; + float _67 = TonemapParam_000x; + float _68 = TonemapParam_002z; + float _69 = TonemapParam_001x; + float _70 = TonemapParam_001z; + float _71 = TonemapParam_001w; + float _72 = TonemapParam_002x; + float _491; + float _492; + float _493; + float _494; + float _495; + float _496; + float _497; + float _498; + float _499; + float _1462; + float _1463; + float _1464; + float _1490; + float _1491; + float _1492; + float _1503; + float _1504; + float _1505; + float _1547; + float _1563; + float _1579; + float _1604; + float _1605; + float _1606; + float _1638; + float _1639; + float _1640; + float _1652; + float _1663; + float _1674; + float _1713; + float _1724; + float _1735; + float _1760; + float _1771; + float _1782; + float _1797; + float _1798; + float _1799; + float _1817; + float _1818; + float _1819; + float _1854; + float _1855; + float _1856; + float _1925; + float _1926; + float _1927; + if (_36) { + float _75 = LensDistortionParam_000x; + float _76 = LensDistortionParam_000y; + uint _77 = LensDistortionParam_000z; + float _79 = LensDistortionParam_001x; + float _81 = SceneInfo_023z; + float _82 = SceneInfo_023w; + float _83 = _81 * _27; + float _84 = _82 * _28; + float _85 = _83 + -0.5f; + float _86 = _84 + -0.5f; + float _87 = dot(float2(_85, _86), float2(_85, _86)); + float _88 = _87 * _75; + float _89 = _88 + 1.0f; + float _90 = _89 * _79; + float _91 = _90 * _85; + float _92 = _90 * _86; + float _93 = _91 + 0.5f; + float _94 = _92 + 0.5f; + bool _95 = (_77 == 0); + float4 _96 = RE_POSTPROCESS_Color.Sample(BilinearClamp, float2(_93, _94)); + float _97 = _96.x; + float _98 = _97 * _59; + float _99 = _63 * _98; + bool _100 = (_98 >= _61); + float _101 = _99 * _99; + float _102 = _99 * 2.0f; + float _103 = 3.0f - _102; + float _104 = _101 * _103; + float _105 = 1.0f - _104; + float _106 = _100 ? 0.0f : _105; + bool _107 = (_98 < _65); + float _108 = _107 ? 0.0f : 1.0f; + float _109 = 1.0f - _108; + float _110 = _109 - _106; + float _111 = log2(_99); + float _112 = _111 * _66; + float _113 = exp2(_112); + float _114 = _67 * _98; + float _115 = _114 + _68; + float _116 = _115 * _110; + float _117 = _71 * _98; + float _118 = _117 + _72; + float _119 = exp2(_118); + float _120 = _119 * _70; + float _121 = _69 - _120; + float _122 = _121 * _108; + if (_95) { + float _124 = _96.y; + float _125 = _96.z; + float _126 = _124 * _59; + float _127 = _125 * _59; + float _128 = _63 * _126; + bool _129 = (_126 >= _61); + float _130 = _128 * _128; + float _131 = _128 * 2.0f; + float _132 = 3.0f - _131; + float _133 = _130 * _132; + float _134 = _63 * _127; + bool _135 = (_127 >= _61); + float _136 = _134 * _134; + float _137 = _134 * 2.0f; + float _138 = 3.0f - _137; + float _139 = _136 * _138; + float _140 = 1.0f - _133; + float _141 = _129 ? 0.0f : _140; + float _142 = 1.0f - _139; + float _143 = _135 ? 0.0f : _142; + bool _144 = (_126 < _65); + bool _145 = (_127 < _65); + float _146 = _144 ? 0.0f : 1.0f; + float _147 = _145 ? 0.0f : 1.0f; + float _148 = 1.0f - _146; + float _149 = _148 - _141; + float _150 = 1.0f - _147; + float _151 = _150 - _143; + float _152 = log2(_128); + float _153 = log2(_134); + float _154 = _152 * _66; + float _155 = _153 * _66; + float _156 = exp2(_154); + float _157 = exp2(_155); + float _158 = _113 * _106; + float _159 = _158 * _61; + float _160 = _156 * _141; + float _161 = _160 * _61; + float _162 = _157 * _143; + float _163 = _162 * _61; + float _164 = _67 * _126; + float _165 = _67 * _127; + float _166 = _164 + _68; + float _167 = _165 + _68; + float _168 = _166 * _149; + float _169 = _167 * _151; + float _170 = _116 + _159; + float _171 = _168 + _161; + float _172 = _169 + _163; + float _173 = _71 * _126; + float _174 = _71 * _127; + float _175 = _173 + _72; + float _176 = _174 + _72; + float _177 = exp2(_175); + float _178 = exp2(_176); + float _179 = _177 * _70; + float _180 = _178 * _70; + float _181 = _69 - _179; + float _182 = _69 - _180; + float _183 = _181 * _146; + float _184 = _182 * _147; + float _185 = _170 + _122; + float _186 = _171 + _183; + float _187 = _172 + _184; + _491 = _185; + _492 = _186; + _493 = _187; + _494 = _75; + _495 = 0.0f; + _496 = 0.0f; + _497 = 0.0f; + _498 = 0.0f; + _499 = _79; + } else { + float _189 = _87 + _76; + float _190 = _189 * _75; + float _191 = _190 + 1.0f; + float _192 = _85 * _79; + float _193 = _192 * _191; + float _194 = _86 * _79; + float _195 = _194 * _191; + float _196 = _193 + 0.5f; + float _197 = _195 + 0.5f; + float _198 = _189 + _76; + float _199 = _198 * _75; + float _200 = _199 + 1.0f; + float _201 = _192 * _200; + float _202 = _194 * _200; + float _203 = _201 + 0.5f; + float _204 = _202 + 0.5f; + float _205 = _61 * _113; + float _206 = _205 * _106; + float _207 = _116 + _206; + float _208 = _207 + _122; + float4 _209 = RE_POSTPROCESS_Color.Sample(BilinearClamp, float2(_196, _197)); + float _210 = _209.y; + float _211 = _210 * _59; + float _212 = _63 * _211; + bool _213 = (_211 >= _61); + float _214 = _212 * _212; + float _215 = _212 * 2.0f; + float _216 = 3.0f - _215; + float _217 = _214 * _216; + float _218 = 1.0f - _217; + float _219 = _213 ? 0.0f : _218; + bool _220 = (_211 < _65); + float _221 = _220 ? 0.0f : 1.0f; + float _222 = 1.0f - _221; + float _223 = _222 - _219; + float _224 = log2(_212); + float _225 = _224 * _66; + float _226 = exp2(_225); + float _227 = _61 * _226; + float _228 = _227 * _219; + float _229 = _67 * _211; + float _230 = _229 + _68; + float _231 = _230 * _223; + float _232 = _231 + _228; + float _233 = _71 * _211; + float _234 = _233 + _72; + float _235 = exp2(_234); + float _236 = _235 * _70; + float _237 = _69 - _236; + float _238 = _237 * _221; + float _239 = _232 + _238; + float4 _240 = RE_POSTPROCESS_Color.Sample(BilinearClamp, float2(_203, _204)); + float _241 = _240.z; + float _242 = _241 * _59; + float _243 = _63 * _242; + bool _244 = (_242 >= _61); + float _245 = _243 * _243; + float _246 = _243 * 2.0f; + float _247 = 3.0f - _246; + float _248 = _245 * _247; + float _249 = 1.0f - _248; + float _250 = _244 ? 0.0f : _249; + bool _251 = (_242 < _65); + float _252 = _251 ? 0.0f : 1.0f; + float _253 = 1.0f - _252; + float _254 = _253 - _250; + float _255 = log2(_243); + float _256 = _255 * _66; + float _257 = exp2(_256); + float _258 = _61 * _257; + float _259 = _258 * _250; + float _260 = _67 * _242; + float _261 = _260 + _68; + float _262 = _261 * _254; + float _263 = _262 + _259; + float _264 = _71 * _242; + float _265 = _264 + _72; + float _266 = exp2(_265); + float _267 = _266 * _70; + float _268 = _69 - _267; + float _269 = _268 * _252; + float _270 = _263 + _269; + _491 = _208; + _492 = _239; + _493 = _270; + _494 = _75; + _495 = 0.0f; + _496 = 0.0f; + _497 = 0.0f; + _498 = 0.0f; + _499 = _79; + } + } else { + if (_38) { + float _274 = PaniniProjectionParam_000x; + float _275 = PaniniProjectionParam_000y; + float _276 = PaniniProjectionParam_000z; + float _277 = PaniniProjectionParam_000w; + float _279 = SceneInfo_023z; + float _280 = SceneInfo_023w; + float _281 = _27 * 2.0f; + float _282 = _281 * _279; + float _283 = _28 * 2.0f; + float _284 = _283 * _280; + float _285 = _282 + -1.0f; + float _286 = _284 + -1.0f; + float _287 = _285 * _285; + float _288 = _287 + 1.0f; + float _289 = sqrt(_288); + float _290 = 1.0f / _289; + float _291 = _290 + _274; + float _292 = _289 * _276; + float _293 = _292 * _291; + float _294 = _290 + -1.0f; + float _295 = _294 * _275; + float _296 = _295 + 1.0f; + float _297 = _277 * 0.5f; + float _298 = _297 * _285; + float _299 = _298 * _293; + float _300 = _297 * _286; + float _301 = _300 * _296; + float _302 = _301 * _293; + float _303 = _299 + 0.5f; + float _304 = _302 + 0.5f; + float4 _305 = RE_POSTPROCESS_Color.Sample(BilinearBorder, float2(_303, _304)); + float _306 = _305.x; + float _307 = _305.y; + float _308 = _305.z; + float _309 = _306 * _59; + float _310 = _307 * _59; + float _311 = _308 * _59; + float _312 = _63 * _309; + bool _313 = (_309 >= _61); + float _314 = _312 * _312; + float _315 = _312 * 2.0f; + float _316 = 3.0f - _315; + float _317 = _314 * _316; + float _318 = _63 * _310; + bool _319 = (_310 >= _61); + float _320 = _318 * _318; + float _321 = _318 * 2.0f; + float _322 = 3.0f - _321; + float _323 = _320 * _322; + float _324 = _63 * _311; + bool _325 = (_311 >= _61); + float _326 = _324 * _324; + float _327 = _324 * 2.0f; + float _328 = 3.0f - _327; + float _329 = _326 * _328; + float _330 = 1.0f - _317; + float _331 = _313 ? 0.0f : _330; + float _332 = 1.0f - _323; + float _333 = _319 ? 0.0f : _332; + float _334 = 1.0f - _329; + float _335 = _325 ? 0.0f : _334; + bool _336 = (_309 < _65); + bool _337 = (_310 < _65); + bool _338 = (_311 < _65); + float _339 = _336 ? 0.0f : 1.0f; + float _340 = _337 ? 0.0f : 1.0f; + float _341 = _338 ? 0.0f : 1.0f; + float _342 = 1.0f - _339; + float _343 = _342 - _331; + float _344 = 1.0f - _340; + float _345 = _344 - _333; + float _346 = 1.0f - _341; + float _347 = _346 - _335; + float _348 = log2(_312); + float _349 = log2(_318); + float _350 = log2(_324); + float _351 = _348 * _66; + float _352 = _349 * _66; + float _353 = _350 * _66; + float _354 = exp2(_351); + float _355 = exp2(_352); + float _356 = exp2(_353); + float _357 = _354 * _331; + float _358 = _357 * _61; + float _359 = _355 * _333; + float _360 = _359 * _61; + float _361 = _356 * _335; + float _362 = _361 * _61; + float _363 = _67 * _309; + float _364 = _67 * _310; + float _365 = _67 * _311; + float _366 = _363 + _68; + float _367 = _364 + _68; + float _368 = _365 + _68; + float _369 = _366 * _343; + float _370 = _367 * _345; + float _371 = _368 * _347; + float _372 = _369 + _358; + float _373 = _370 + _360; + float _374 = _371 + _362; + float _375 = _71 * _309; + float _376 = _71 * _310; + float _377 = _71 * _311; + float _378 = _375 + _72; + float _379 = _376 + _72; + float _380 = _377 + _72; + float _381 = exp2(_378); + float _382 = exp2(_379); + float _383 = exp2(_380); + float _384 = _381 * _70; + float _385 = _382 * _70; + float _386 = _383 * _70; + float _387 = _69 - _384; + float _388 = _69 - _385; + float _389 = _69 - _386; + float _390 = _387 * _339; + float _391 = _388 * _340; + float _392 = _389 * _341; + float _393 = _372 + _390; + float _394 = _373 + _391; + float _395 = _374 + _392; + _491 = _393; + _492 = _394; + _493 = _395; + _494 = 0.0f; + _495 = _274; + _496 = _275; + _497 = _276; + _498 = _277; + _499 = 1.0f; + } else { + uint _397 = uint(_27); + uint _398 = uint(_28); + float4 _399 = RE_POSTPROCESS_Color.Load(int3(_397, _398, 0)); + float _400 = _399.x; + float _401 = _399.y; + float _402 = _399.z; + float _403 = _400 * _59; + float _404 = _401 * _59; + float _405 = _402 * _59; + float _406 = _63 * _403; + bool _407 = (_403 >= _61); + float _408 = _406 * _406; + float _409 = _406 * 2.0f; + float _410 = 3.0f - _409; + float _411 = _408 * _410; + float _412 = _63 * _404; + bool _413 = (_404 >= _61); + float _414 = _412 * _412; + float _415 = _412 * 2.0f; + float _416 = 3.0f - _415; + float _417 = _414 * _416; + float _418 = _63 * _405; + bool _419 = (_405 >= _61); + float _420 = _418 * _418; + float _421 = _418 * 2.0f; + float _422 = 3.0f - _421; + float _423 = _420 * _422; + float _424 = 1.0f - _411; + float _425 = _407 ? 0.0f : _424; + float _426 = 1.0f - _417; + float _427 = _413 ? 0.0f : _426; + float _428 = 1.0f - _423; + float _429 = _419 ? 0.0f : _428; + bool _430 = (_403 < _65); + bool _431 = (_404 < _65); + bool _432 = (_405 < _65); + float _433 = _430 ? 0.0f : 1.0f; + float _434 = _431 ? 0.0f : 1.0f; + float _435 = _432 ? 0.0f : 1.0f; + float _436 = 1.0f - _433; + float _437 = _436 - _425; + float _438 = 1.0f - _434; + float _439 = _438 - _427; + float _440 = 1.0f - _435; + float _441 = _440 - _429; + float _442 = log2(_406); + float _443 = log2(_412); + float _444 = log2(_418); + float _445 = _442 * _66; + float _446 = _443 * _66; + float _447 = _444 * _66; + float _448 = exp2(_445); + float _449 = exp2(_446); + float _450 = exp2(_447); + float _451 = _448 * _425; + float _452 = _451 * _61; + float _453 = _449 * _427; + float _454 = _453 * _61; + float _455 = _450 * _429; + float _456 = _455 * _61; + float _457 = _67 * _403; + float _458 = _67 * _404; + float _459 = _67 * _405; + float _460 = _457 + _68; + float _461 = _458 + _68; + float _462 = _459 + _68; + float _463 = _460 * _437; + float _464 = _461 * _439; + float _465 = _462 * _441; + float _466 = _463 + _452; + float _467 = _464 + _454; + float _468 = _465 + _456; + float _469 = _71 * _403; + float _470 = _71 * _404; + float _471 = _71 * _405; + float _472 = _469 + _72; + float _473 = _470 + _72; + float _474 = _471 + _72; + float _475 = exp2(_472); + float _476 = exp2(_473); + float _477 = exp2(_474); + float _478 = _475 * _70; + float _479 = _476 * _70; + float _480 = _477 * _70; + float _481 = _69 - _478; + float _482 = _69 - _479; + float _483 = _69 - _480; + float _484 = _481 * _433; + float _485 = _482 * _434; + float _486 = _483 * _435; + float _487 = _466 + _484; + float _488 = _467 + _485; + float _489 = _468 + _486; + _491 = _487; + _492 = _488; + _493 = _489; + _494 = 0.0f; + _495 = 0.0f; + _496 = 0.0f; + _497 = 0.0f; + _498 = 0.0f; + _499 = 1.0f; + } + } + int _500 = _30 & 32; + bool _501 = (_500 == 0); + _1503 = _491; + _1504 = _492; + _1505 = _493; + if (!_501) { + float _504 = RadialBlurRenderParam_000x; + float _505 = RadialBlurRenderParam_000y; + float _506 = RadialBlurRenderParam_000z; + float _507 = RadialBlurRenderParam_000w; + float _509 = RadialBlurRenderParam_001x; + float _510 = RadialBlurRenderParam_001y; + float _511 = RadialBlurRenderParam_001z; + float _512 = RadialBlurRenderParam_001w; + float _514 = RadialBlurRenderParam_002x; + float _515 = RadialBlurRenderParam_002y; + float _516 = RadialBlurRenderParam_002z; + uint _518 = RadialBlurRenderParam_003x; + int _519 = _518 & 2; + bool _520 = (_519 != 0); + float _521 = float(_520); + float _522 = 1.0f - _521; + float4 _523 = ComputeResultSRV[0].data[0 / 4]; + float _524 = _523.x; + float _525 = _524 * _521; + float _526 = _522 + _525; + float _527 = _526 * _507; + bool _528 = (_527 == 0.0f); + _1503 = _491; + _1504 = _492; + _1505 = _493; + if (!_528) { + float _530 = _58 * _22; + float _531 = RadialBlurRenderParam_002w; + float _533 = SceneInfo_023z; + float _534 = SceneInfo_023w; + float _535 = _533 * _27; + float _536 = _534 * _28; + float _537 = -0.5f - _509; + float _538 = _537 + _535; + float _539 = -0.5f - _510; + float _540 = _539 + _536; + bool _541 = (_538 < 0.0f); + float _542 = 1.0f - _535; + float _543 = _541 ? _542 : _535; + bool _544 = (_540 < 0.0f); + float _545 = 1.0f - _536; + float _546 = _544 ? _545 : _536; + int _547 = _518 & 1; + bool _548 = (_547 != 0); + float _549 = dot(float2(_538, _540), float2(_538, _540)); + float _550 = rsqrt(_549); + float _551 = _550 * _531; + float _552 = _551 * _538; + float _553 = _551 * _540; + float _554 = abs(_552); + float _555 = abs(_553); + uint _556 = uint(_554); + uint _557 = uint(_555); + uint _558 = _557 + _556; + uint _559 = _558 ^ 61; + uint _560 = _558 >> 16; + uint _561 = _559 ^ _560; + uint _562 = _561 * 9; + uint _563 = _562 >> 4; + uint _564 = _563 ^ _562; + uint _565 = _564 * 668265261; + uint _566 = _565 >> 15; + uint _567 = _566 ^ _565; + float _568 = float(_567); + float _569 = _568 * 2.3283064365386963e-10f; + float _570 = _548 ? _569 : 1.0f; + float _571 = _538 * _538; + float _572 = _540 * _540; + float _573 = _571 + _572; + float _574 = sqrt(_573); + float _575 = max(1.0f, _574); + float _576 = 1.0f / _575; + float _577 = _516 * -0.0011111111380159855f; + float _578 = _577 * _543; + float _579 = _578 * _570; + float _580 = _579 * _576; + float _581 = _577 * _546; + float _582 = _581 * _570; + float _583 = _582 * _576; + float _584 = _580 + 1.0f; + float _585 = _583 + 1.0f; + float _586 = _584 * _538; + float _587 = _585 * _540; + float _588 = _516 * -0.002222222276031971f; + float _589 = _588 * _543; + float _590 = _589 * _570; + float _591 = _590 * _576; + float _592 = _588 * _546; + float _593 = _592 * _570; + float _594 = _593 * _576; + float _595 = _591 + 1.0f; + float _596 = _594 + 1.0f; + float _597 = _595 * _538; + float _598 = _596 * _540; + float _599 = _516 * -0.0033333334140479565f; + float _600 = _599 * _543; + float _601 = _600 * _570; + float _602 = _601 * _576; + float _603 = _599 * _546; + float _604 = _603 * _570; + float _605 = _604 * _576; + float _606 = _602 + 1.0f; + float _607 = _605 + 1.0f; + float _608 = _606 * _538; + float _609 = _607 * _540; + float _610 = _516 * -0.004444444552063942f; + float _611 = _610 * _543; + float _612 = _611 * _570; + float _613 = _612 * _576; + float _614 = _610 * _546; + float _615 = _614 * _570; + float _616 = _615 * _576; + float _617 = _613 + 1.0f; + float _618 = _616 + 1.0f; + float _619 = _617 * _538; + float _620 = _618 * _540; + float _621 = _516 * -0.0055555556900799274f; + float _622 = _621 * _543; + float _623 = _622 * _570; + float _624 = _623 * _576; + float _625 = _621 * _546; + float _626 = _625 * _570; + float _627 = _626 * _576; + float _628 = _624 + 1.0f; + float _629 = _627 + 1.0f; + float _630 = _628 * _538; + float _631 = _629 * _540; + float _632 = _516 * -0.006666666828095913f; + float _633 = _632 * _543; + float _634 = _633 * _570; + float _635 = _634 * _576; + float _636 = _632 * _546; + float _637 = _636 * _570; + float _638 = _637 * _576; + float _639 = _635 + 1.0f; + float _640 = _638 + 1.0f; + float _641 = _639 * _538; + float _642 = _640 * _540; + float _643 = _516 * -0.007777777966111898f; + float _644 = _643 * _543; + float _645 = _644 * _570; + float _646 = _645 * _576; + float _647 = _643 * _546; + float _648 = _647 * _570; + float _649 = _648 * _576; + float _650 = _646 + 1.0f; + float _651 = _649 + 1.0f; + float _652 = _650 * _538; + float _653 = _651 * _540; + float _654 = _516 * -0.008888889104127884f; + float _655 = _654 * _543; + float _656 = _655 * _570; + float _657 = _656 * _576; + float _658 = _654 * _546; + float _659 = _658 * _570; + float _660 = _659 * _576; + float _661 = _657 + 1.0f; + float _662 = _660 + 1.0f; + float _663 = _661 * _538; + float _664 = _662 * _540; + float _665 = _516 * -0.009999999776482582f; + float _666 = _665 * _543; + float _667 = _666 * _570; + float _668 = _667 * _576; + float _669 = _665 * _546; + float _670 = _669 * _570; + float _671 = _670 * _576; + float _672 = _668 + 1.0f; + float _673 = _671 + 1.0f; + float _674 = _672 * _538; + float _675 = _673 * _540; + float _676 = _530 * 0.10000000149011612f; + float _677 = _676 * _504; + float _678 = _676 * _505; + float _679 = _676 * _506; + float _681 = TonemapParam_000y; + float _683 = TonemapParam_002y; + float _685 = TonemapParam_001y; + float _686 = TonemapParam_000w; + float _687 = TonemapParam_000x; + float _688 = TonemapParam_002z; + float _689 = TonemapParam_001x; + float _690 = TonemapParam_001z; + float _691 = TonemapParam_001w; + float _692 = TonemapParam_002x; + float _693 = _491 * 0.10000000149011612f; + float _694 = _693 * _504; + float _695 = _492 * 0.10000000149011612f; + float _696 = _695 * _505; + float _697 = _493 * 0.10000000149011612f; + float _698 = _697 * _506; + do { + if (_36) { + float _700 = _586 + _509; + float _701 = _587 + _510; + float _702 = dot(float2(_700, _701), float2(_700, _701)); + float _703 = _702 * _494; + float _704 = _703 + 1.0f; + float _705 = _704 * _499; + float _706 = _705 * _700; + float _707 = _705 * _701; + float _708 = _706 + 0.5f; + float _709 = _707 + 0.5f; + float4 _710 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_708, _709), 0.0f); + float _711 = _710.x; + float _712 = _710.y; + float _713 = _710.z; + float _714 = _597 + _509; + float _715 = _598 + _510; + float _716 = dot(float2(_714, _715), float2(_714, _715)); + float _717 = _716 * _494; + float _718 = _717 + 1.0f; + float _719 = _714 * _499; + float _720 = _719 * _718; + float _721 = _715 * _499; + float _722 = _721 * _718; + float _723 = _720 + 0.5f; + float _724 = _722 + 0.5f; + float4 _725 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_723, _724), 0.0f); + float _726 = _725.x; + float _727 = _725.y; + float _728 = _725.z; + float _729 = _726 + _711; + float _730 = _727 + _712; + float _731 = _728 + _713; + float _732 = _608 + _509; + float _733 = _609 + _510; + float _734 = dot(float2(_732, _733), float2(_732, _733)); + float _735 = _734 * _494; + float _736 = _735 + 1.0f; + float _737 = _732 * _499; + float _738 = _737 * _736; + float _739 = _733 * _499; + float _740 = _739 * _736; + float _741 = _738 + 0.5f; + float _742 = _740 + 0.5f; + float4 _743 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_741, _742), 0.0f); + float _744 = _743.x; + float _745 = _743.y; + float _746 = _743.z; + float _747 = _729 + _744; + float _748 = _730 + _745; + float _749 = _731 + _746; + float _750 = _619 + _509; + float _751 = _620 + _510; + float _752 = dot(float2(_750, _751), float2(_750, _751)); + float _753 = _752 * _494; + float _754 = _753 + 1.0f; + float _755 = _750 * _499; + float _756 = _755 * _754; + float _757 = _751 * _499; + float _758 = _757 * _754; + float _759 = _756 + 0.5f; + float _760 = _758 + 0.5f; + float4 _761 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_759, _760), 0.0f); + float _762 = _761.x; + float _763 = _761.y; + float _764 = _761.z; + float _765 = _747 + _762; + float _766 = _748 + _763; + float _767 = _749 + _764; + float _768 = _630 + _509; + float _769 = _631 + _510; + float _770 = dot(float2(_768, _769), float2(_768, _769)); + float _771 = _770 * _494; + float _772 = _771 + 1.0f; + float _773 = _768 * _499; + float _774 = _773 * _772; + float _775 = _769 * _499; + float _776 = _775 * _772; + float _777 = _774 + 0.5f; + float _778 = _776 + 0.5f; + float4 _779 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_777, _778), 0.0f); + float _780 = _779.x; + float _781 = _779.y; + float _782 = _779.z; + float _783 = _765 + _780; + float _784 = _766 + _781; + float _785 = _767 + _782; + float _786 = _641 + _509; + float _787 = _642 + _510; + float _788 = dot(float2(_786, _787), float2(_786, _787)); + float _789 = _788 * _494; + float _790 = _789 + 1.0f; + float _791 = _786 * _499; + float _792 = _791 * _790; + float _793 = _787 * _499; + float _794 = _793 * _790; + float _795 = _792 + 0.5f; + float _796 = _794 + 0.5f; + float4 _797 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_795, _796), 0.0f); + float _798 = _797.x; + float _799 = _797.y; + float _800 = _797.z; + float _801 = _783 + _798; + float _802 = _784 + _799; + float _803 = _785 + _800; + float _804 = _652 + _509; + float _805 = _653 + _510; + float _806 = dot(float2(_804, _805), float2(_804, _805)); + float _807 = _806 * _494; + float _808 = _807 + 1.0f; + float _809 = _804 * _499; + float _810 = _809 * _808; + float _811 = _805 * _499; + float _812 = _811 * _808; + float _813 = _810 + 0.5f; + float _814 = _812 + 0.5f; + float4 _815 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_813, _814), 0.0f); + float _816 = _815.x; + float _817 = _815.y; + float _818 = _815.z; + float _819 = _801 + _816; + float _820 = _802 + _817; + float _821 = _803 + _818; + float _822 = _663 + _509; + float _823 = _664 + _510; + float _824 = dot(float2(_822, _823), float2(_822, _823)); + float _825 = _824 * _494; + float _826 = _825 + 1.0f; + float _827 = _822 * _499; + float _828 = _827 * _826; + float _829 = _823 * _499; + float _830 = _829 * _826; + float _831 = _828 + 0.5f; + float _832 = _830 + 0.5f; + float4 _833 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_831, _832), 0.0f); + float _834 = _833.x; + float _835 = _833.y; + float _836 = _833.z; + float _837 = _819 + _834; + float _838 = _820 + _835; + float _839 = _821 + _836; + float _840 = _674 + _509; + float _841 = _675 + _510; + float _842 = dot(float2(_840, _841), float2(_840, _841)); + float _843 = _842 * _494; + float _844 = _843 + 1.0f; + float _845 = _840 * _499; + float _846 = _845 * _844; + float _847 = _841 * _499; + float _848 = _847 * _844; + float _849 = _846 + 0.5f; + float _850 = _848 + 0.5f; + float4 _851 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_849, _850), 0.0f); + float _852 = _851.x; + float _853 = _851.y; + float _854 = _851.z; + float _855 = _837 + _852; + float _856 = _838 + _853; + float _857 = _839 + _854; + float _858 = _677 * _855; + float _859 = _678 * _856; + float _860 = _679 * _857; + float _861 = _858 * _683; + bool _862 = (_858 >= _681); + float _863 = _861 * _861; + float _864 = _861 * 2.0f; + float _865 = 3.0f - _864; + float _866 = _863 * _865; + float _867 = _859 * _683; + bool _868 = (_859 >= _681); + float _869 = _867 * _867; + float _870 = _867 * 2.0f; + float _871 = 3.0f - _870; + float _872 = _869 * _871; + float _873 = _860 * _683; + bool _874 = (_860 >= _681); + float _875 = _873 * _873; + float _876 = _873 * 2.0f; + float _877 = 3.0f - _876; + float _878 = _875 * _877; + float _879 = 1.0f - _866; + float _880 = _862 ? 0.0f : _879; + float _881 = 1.0f - _872; + float _882 = _868 ? 0.0f : _881; + float _883 = 1.0f - _878; + float _884 = _874 ? 0.0f : _883; + bool _885 = (_858 < _685); + bool _886 = (_859 < _685); + bool _887 = (_860 < _685); + float _888 = _885 ? 0.0f : 1.0f; + float _889 = _886 ? 0.0f : 1.0f; + float _890 = _887 ? 0.0f : 1.0f; + float _891 = 1.0f - _888; + float _892 = _891 - _880; + float _893 = 1.0f - _889; + float _894 = _893 - _882; + float _895 = 1.0f - _890; + float _896 = _895 - _884; + float _897 = log2(_861); + float _898 = log2(_867); + float _899 = log2(_873); + float _900 = _897 * _686; + float _901 = _898 * _686; + float _902 = _899 * _686; + float _903 = exp2(_900); + float _904 = exp2(_901); + float _905 = exp2(_902); + float _906 = _880 * _903; + float _907 = _906 * _681; + float _908 = _904 * _882; + float _909 = _908 * _681; + float _910 = _905 * _884; + float _911 = _910 * _681; + float _912 = _687 * _858; + float _913 = _687 * _859; + float _914 = _687 * _860; + float _915 = _912 + _688; + float _916 = _913 + _688; + float _917 = _914 + _688; + float _918 = _915 * _892; + float _919 = _916 * _894; + float _920 = _917 * _896; + float _921 = _691 * _858; + float _922 = _691 * _859; + float _923 = _691 * _860; + float _924 = _921 + _692; + float _925 = _922 + _692; + float _926 = _923 + _692; + float _927 = exp2(_924); + float _928 = exp2(_925); + float _929 = exp2(_926); + float _930 = _927 * _690; + float _931 = _928 * _690; + float _932 = _929 * _690; + float _933 = _689 - _930; + float _934 = _689 - _931; + float _935 = _689 - _932; + float _936 = _933 * _888; + float _937 = _934 * _889; + float _938 = _935 * _890; + float _939 = _907 + _694; + float _940 = _939 + _918; + float _941 = _940 + _936; + float _942 = _909 + _696; + float _943 = _942 + _919; + float _944 = _943 + _937; + float _945 = _911 + _698; + float _946 = _945 + _920; + float _947 = _946 + _938; + _1462 = _941; + _1463 = _944; + _1464 = _947; + } else { + float _949 = _509 + 0.5f; + float _950 = _949 + _586; + float _951 = _510 + 0.5f; + float _952 = _951 + _587; + float _953 = _949 + _597; + float _954 = _951 + _598; + float _955 = _949 + _608; + float _956 = _951 + _609; + float _957 = _949 + _619; + float _958 = _951 + _620; + float _959 = _949 + _630; + float _960 = _951 + _631; + float _961 = _949 + _641; + float _962 = _951 + _642; + float _963 = _949 + _652; + float _964 = _951 + _653; + float _965 = _949 + _663; + float _966 = _951 + _664; + float _967 = _949 + _674; + float _968 = _951 + _675; + if (_38) { + float _970 = _950 * 2.0f; + float _971 = _952 * 2.0f; + float _972 = _970 + -1.0f; + float _973 = _971 + -1.0f; + float _974 = _972 * _972; + float _975 = _974 + 1.0f; + float _976 = sqrt(_975); + float _977 = 1.0f / _976; + float _978 = _977 + _495; + float _979 = _976 * _497; + float _980 = _979 * _978; + float _981 = _977 + -1.0f; + float _982 = _981 * _496; + float _983 = _982 + 1.0f; + float _984 = _498 * 0.5f; + float _985 = _984 * _980; + float _986 = _985 * _972; + float _987 = _984 * _983; + float _988 = _987 * _980; + float _989 = _988 * _973; + float _990 = _986 + 0.5f; + float _991 = _989 + 0.5f; + float4 _992 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_990, _991), 0.0f); + float _993 = _992.x; + float _994 = _992.y; + float _995 = _992.z; + float _996 = _953 * 2.0f; + float _997 = _954 * 2.0f; + float _998 = _996 + -1.0f; + float _999 = _997 + -1.0f; + float _1000 = _998 * _998; + float _1001 = _1000 + 1.0f; + float _1002 = sqrt(_1001); + float _1003 = 1.0f / _1002; + float _1004 = _1003 + _495; + float _1005 = _1002 * _497; + float _1006 = _1005 * _1004; + float _1007 = _1003 + -1.0f; + float _1008 = _1007 * _496; + float _1009 = _1008 + 1.0f; + float _1010 = _984 * _998; + float _1011 = _1010 * _1006; + float _1012 = _984 * _999; + float _1013 = _1012 * _1009; + float _1014 = _1013 * _1006; + float _1015 = _1011 + 0.5f; + float _1016 = _1014 + 0.5f; + float4 _1017 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1015, _1016), 0.0f); + float _1018 = _1017.x; + float _1019 = _1017.y; + float _1020 = _1017.z; + float _1021 = _1018 + _993; + float _1022 = _1019 + _994; + float _1023 = _1020 + _995; + float _1024 = _955 * 2.0f; + float _1025 = _956 * 2.0f; + float _1026 = _1024 + -1.0f; + float _1027 = _1025 + -1.0f; + float _1028 = _1026 * _1026; + float _1029 = _1028 + 1.0f; + float _1030 = sqrt(_1029); + float _1031 = 1.0f / _1030; + float _1032 = _1031 + _495; + float _1033 = _1030 * _497; + float _1034 = _1033 * _1032; + float _1035 = _1031 + -1.0f; + float _1036 = _1035 * _496; + float _1037 = _1036 + 1.0f; + float _1038 = _984 * _1026; + float _1039 = _1038 * _1034; + float _1040 = _984 * _1027; + float _1041 = _1040 * _1037; + float _1042 = _1041 * _1034; + float _1043 = _1039 + 0.5f; + float _1044 = _1042 + 0.5f; + float4 _1045 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1043, _1044), 0.0f); + float _1046 = _1045.x; + float _1047 = _1045.y; + float _1048 = _1045.z; + float _1049 = _1021 + _1046; + float _1050 = _1022 + _1047; + float _1051 = _1023 + _1048; + float _1052 = _957 * 2.0f; + float _1053 = _958 * 2.0f; + float _1054 = _1052 + -1.0f; + float _1055 = _1053 + -1.0f; + float _1056 = _1054 * _1054; + float _1057 = _1056 + 1.0f; + float _1058 = sqrt(_1057); + float _1059 = 1.0f / _1058; + float _1060 = _1059 + _495; + float _1061 = _1058 * _497; + float _1062 = _1061 * _1060; + float _1063 = _1059 + -1.0f; + float _1064 = _1063 * _496; + float _1065 = _1064 + 1.0f; + float _1066 = _984 * _1054; + float _1067 = _1066 * _1062; + float _1068 = _984 * _1055; + float _1069 = _1068 * _1065; + float _1070 = _1069 * _1062; + float _1071 = _1067 + 0.5f; + float _1072 = _1070 + 0.5f; + float4 _1073 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1071, _1072), 0.0f); + float _1074 = _1073.x; + float _1075 = _1073.y; + float _1076 = _1073.z; + float _1077 = _1049 + _1074; + float _1078 = _1050 + _1075; + float _1079 = _1051 + _1076; + float _1080 = _959 * 2.0f; + float _1081 = _960 * 2.0f; + float _1082 = _1080 + -1.0f; + float _1083 = _1081 + -1.0f; + float _1084 = _1082 * _1082; + float _1085 = _1084 + 1.0f; + float _1086 = sqrt(_1085); + float _1087 = 1.0f / _1086; + float _1088 = _1087 + _495; + float _1089 = _1086 * _497; + float _1090 = _1089 * _1088; + float _1091 = _1087 + -1.0f; + float _1092 = _1091 * _496; + float _1093 = _1092 + 1.0f; + float _1094 = _984 * _1082; + float _1095 = _1094 * _1090; + float _1096 = _984 * _1083; + float _1097 = _1096 * _1093; + float _1098 = _1097 * _1090; + float _1099 = _1095 + 0.5f; + float _1100 = _1098 + 0.5f; + float4 _1101 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1099, _1100), 0.0f); + float _1102 = _1101.x; + float _1103 = _1101.y; + float _1104 = _1101.z; + float _1105 = _1077 + _1102; + float _1106 = _1078 + _1103; + float _1107 = _1079 + _1104; + float _1108 = _961 * 2.0f; + float _1109 = _962 * 2.0f; + float _1110 = _1108 + -1.0f; + float _1111 = _1109 + -1.0f; + float _1112 = _1110 * _1110; + float _1113 = _1112 + 1.0f; + float _1114 = sqrt(_1113); + float _1115 = 1.0f / _1114; + float _1116 = _1115 + _495; + float _1117 = _1114 * _497; + float _1118 = _1117 * _1116; + float _1119 = _1115 + -1.0f; + float _1120 = _1119 * _496; + float _1121 = _1120 + 1.0f; + float _1122 = _984 * _1110; + float _1123 = _1122 * _1118; + float _1124 = _984 * _1111; + float _1125 = _1124 * _1121; + float _1126 = _1125 * _1118; + float _1127 = _1123 + 0.5f; + float _1128 = _1126 + 0.5f; + float4 _1129 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1127, _1128), 0.0f); + float _1130 = _1129.x; + float _1131 = _1129.y; + float _1132 = _1129.z; + float _1133 = _1105 + _1130; + float _1134 = _1106 + _1131; + float _1135 = _1107 + _1132; + float _1136 = _963 * 2.0f; + float _1137 = _964 * 2.0f; + float _1138 = _1136 + -1.0f; + float _1139 = _1137 + -1.0f; + float _1140 = _1138 * _1138; + float _1141 = _1140 + 1.0f; + float _1142 = sqrt(_1141); + float _1143 = 1.0f / _1142; + float _1144 = _1143 + _495; + float _1145 = _1142 * _497; + float _1146 = _1145 * _1144; + float _1147 = _1143 + -1.0f; + float _1148 = _1147 * _496; + float _1149 = _1148 + 1.0f; + float _1150 = _984 * _1138; + float _1151 = _1150 * _1146; + float _1152 = _984 * _1139; + float _1153 = _1152 * _1149; + float _1154 = _1153 * _1146; + float _1155 = _1151 + 0.5f; + float _1156 = _1154 + 0.5f; + float4 _1157 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1155, _1156), 0.0f); + float _1158 = _1157.x; + float _1159 = _1157.y; + float _1160 = _1157.z; + float _1161 = _1133 + _1158; + float _1162 = _1134 + _1159; + float _1163 = _1135 + _1160; + float _1164 = _965 * 2.0f; + float _1165 = _966 * 2.0f; + float _1166 = _1164 + -1.0f; + float _1167 = _1165 + -1.0f; + float _1168 = _1166 * _1166; + float _1169 = _1168 + 1.0f; + float _1170 = sqrt(_1169); + float _1171 = 1.0f / _1170; + float _1172 = _1171 + _495; + float _1173 = _1170 * _497; + float _1174 = _1173 * _1172; + float _1175 = _1171 + -1.0f; + float _1176 = _1175 * _496; + float _1177 = _1176 + 1.0f; + float _1178 = _984 * _1166; + float _1179 = _1178 * _1174; + float _1180 = _984 * _1167; + float _1181 = _1180 * _1177; + float _1182 = _1181 * _1174; + float _1183 = _1179 + 0.5f; + float _1184 = _1182 + 0.5f; + float4 _1185 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1183, _1184), 0.0f); + float _1186 = _1185.x; + float _1187 = _1185.y; + float _1188 = _1185.z; + float _1189 = _1161 + _1186; + float _1190 = _1162 + _1187; + float _1191 = _1163 + _1188; + float _1192 = _967 * 2.0f; + float _1193 = _968 * 2.0f; + float _1194 = _1192 + -1.0f; + float _1195 = _1193 + -1.0f; + float _1196 = _1194 * _1194; + float _1197 = _1196 + 1.0f; + float _1198 = sqrt(_1197); + float _1199 = 1.0f / _1198; + float _1200 = _1199 + _495; + float _1201 = _1198 * _497; + float _1202 = _1201 * _1200; + float _1203 = _1199 + -1.0f; + float _1204 = _1203 * _496; + float _1205 = _1204 + 1.0f; + float _1206 = _984 * _1194; + float _1207 = _1206 * _1202; + float _1208 = _984 * _1195; + float _1209 = _1208 * _1205; + float _1210 = _1209 * _1202; + float _1211 = _1207 + 0.5f; + float _1212 = _1210 + 0.5f; + float4 _1213 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1211, _1212), 0.0f); + float _1214 = _1213.x; + float _1215 = _1213.y; + float _1216 = _1213.z; + float _1217 = _1189 + _1214; + float _1218 = _1190 + _1215; + float _1219 = _1191 + _1216; + float _1220 = _677 * _1217; + float _1221 = _678 * _1218; + float _1222 = _679 * _1219; + float _1223 = _1220 * _683; + bool _1224 = (_1220 >= _681); + float _1225 = _1223 * _1223; + float _1226 = _1223 * 2.0f; + float _1227 = 3.0f - _1226; + float _1228 = _1225 * _1227; + float _1229 = _1221 * _683; + bool _1230 = (_1221 >= _681); + float _1231 = _1229 * _1229; + float _1232 = _1229 * 2.0f; + float _1233 = 3.0f - _1232; + float _1234 = _1231 * _1233; + float _1235 = _1222 * _683; + bool _1236 = (_1222 >= _681); + float _1237 = _1235 * _1235; + float _1238 = _1235 * 2.0f; + float _1239 = 3.0f - _1238; + float _1240 = _1237 * _1239; + float _1241 = 1.0f - _1228; + float _1242 = _1224 ? 0.0f : _1241; + float _1243 = 1.0f - _1234; + float _1244 = _1230 ? 0.0f : _1243; + float _1245 = 1.0f - _1240; + float _1246 = _1236 ? 0.0f : _1245; + bool _1247 = (_1220 < _685); + bool _1248 = (_1221 < _685); + bool _1249 = (_1222 < _685); + float _1250 = _1247 ? 0.0f : 1.0f; + float _1251 = _1248 ? 0.0f : 1.0f; + float _1252 = _1249 ? 0.0f : 1.0f; + float _1253 = 1.0f - _1250; + float _1254 = _1253 - _1242; + float _1255 = 1.0f - _1251; + float _1256 = _1255 - _1244; + float _1257 = 1.0f - _1252; + float _1258 = _1257 - _1246; + float _1259 = log2(_1223); + float _1260 = log2(_1229); + float _1261 = log2(_1235); + float _1262 = _1259 * _686; + float _1263 = _1260 * _686; + float _1264 = _1261 * _686; + float _1265 = exp2(_1262); + float _1266 = exp2(_1263); + float _1267 = exp2(_1264); + float _1268 = _1242 * _1265; + float _1269 = _1268 * _681; + float _1270 = _1266 * _1244; + float _1271 = _1270 * _681; + float _1272 = _1267 * _1246; + float _1273 = _1272 * _681; + float _1274 = _687 * _1220; + float _1275 = _687 * _1221; + float _1276 = _687 * _1222; + float _1277 = _1274 + _688; + float _1278 = _1275 + _688; + float _1279 = _1276 + _688; + float _1280 = _1277 * _1254; + float _1281 = _1278 * _1256; + float _1282 = _1279 * _1258; + float _1283 = _691 * _1220; + float _1284 = _691 * _1221; + float _1285 = _691 * _1222; + float _1286 = _1283 + _692; + float _1287 = _1284 + _692; + float _1288 = _1285 + _692; + float _1289 = exp2(_1286); + float _1290 = exp2(_1287); + float _1291 = exp2(_1288); + float _1292 = _1289 * _690; + float _1293 = _1290 * _690; + float _1294 = _1291 * _690; + float _1295 = _689 - _1292; + float _1296 = _689 - _1293; + float _1297 = _689 - _1294; + float _1298 = _1295 * _1250; + float _1299 = _1296 * _1251; + float _1300 = _1297 * _1252; + float _1301 = _1269 + _694; + float _1302 = _1301 + _1280; + float _1303 = _1302 + _1298; + float _1304 = _1271 + _696; + float _1305 = _1304 + _1281; + float _1306 = _1305 + _1299; + float _1307 = _1273 + _698; + float _1308 = _1307 + _1282; + float _1309 = _1308 + _1300; + _1462 = _1303; + _1463 = _1306; + _1464 = _1309; + } else { + float4 _1311 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_950, _952), 0.0f); + float _1312 = _1311.x; + float _1313 = _1311.y; + float _1314 = _1311.z; + float4 _1315 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_953, _954), 0.0f); + float _1316 = _1315.x; + float _1317 = _1315.y; + float _1318 = _1315.z; + float _1319 = _1316 + _1312; + float _1320 = _1317 + _1313; + float _1321 = _1318 + _1314; + float4 _1322 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_955, _956), 0.0f); + float _1323 = _1322.x; + float _1324 = _1322.y; + float _1325 = _1322.z; + float _1326 = _1319 + _1323; + float _1327 = _1320 + _1324; + float _1328 = _1321 + _1325; + float4 _1329 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_957, _958), 0.0f); + float _1330 = _1329.x; + float _1331 = _1329.y; + float _1332 = _1329.z; + float _1333 = _1326 + _1330; + float _1334 = _1327 + _1331; + float _1335 = _1328 + _1332; + float4 _1336 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_959, _960), 0.0f); + float _1337 = _1336.x; + float _1338 = _1336.y; + float _1339 = _1336.z; + float _1340 = _1333 + _1337; + float _1341 = _1334 + _1338; + float _1342 = _1335 + _1339; + float4 _1343 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_961, _962), 0.0f); + float _1344 = _1343.x; + float _1345 = _1343.y; + float _1346 = _1343.z; + float _1347 = _1340 + _1344; + float _1348 = _1341 + _1345; + float _1349 = _1342 + _1346; + float4 _1350 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_963, _964), 0.0f); + float _1351 = _1350.x; + float _1352 = _1350.y; + float _1353 = _1350.z; + float _1354 = _1347 + _1351; + float _1355 = _1348 + _1352; + float _1356 = _1349 + _1353; + float4 _1357 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_965, _966), 0.0f); + float _1358 = _1357.x; + float _1359 = _1357.y; + float _1360 = _1357.z; + float _1361 = _1354 + _1358; + float _1362 = _1355 + _1359; + float _1363 = _1356 + _1360; + float4 _1364 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_967, _968), 0.0f); + float _1365 = _1364.x; + float _1366 = _1364.y; + float _1367 = _1364.z; + float _1368 = _1361 + _1365; + float _1369 = _1362 + _1366; + float _1370 = _1363 + _1367; + float _1371 = _677 * _1368; + float _1372 = _678 * _1369; + float _1373 = _679 * _1370; + float _1374 = _1371 * _683; + bool _1375 = (_1371 >= _681); + float _1376 = _1374 * _1374; + float _1377 = _1374 * 2.0f; + float _1378 = 3.0f - _1377; + float _1379 = _1376 * _1378; + float _1380 = _1372 * _683; + bool _1381 = (_1372 >= _681); + float _1382 = _1380 * _1380; + float _1383 = _1380 * 2.0f; + float _1384 = 3.0f - _1383; + float _1385 = _1382 * _1384; + float _1386 = _1373 * _683; + bool _1387 = (_1373 >= _681); + float _1388 = _1386 * _1386; + float _1389 = _1386 * 2.0f; + float _1390 = 3.0f - _1389; + float _1391 = _1388 * _1390; + float _1392 = 1.0f - _1379; + float _1393 = _1375 ? 0.0f : _1392; + float _1394 = 1.0f - _1385; + float _1395 = _1381 ? 0.0f : _1394; + float _1396 = 1.0f - _1391; + float _1397 = _1387 ? 0.0f : _1396; + bool _1398 = (_1371 < _685); + bool _1399 = (_1372 < _685); + bool _1400 = (_1373 < _685); + float _1401 = _1398 ? 0.0f : 1.0f; + float _1402 = _1399 ? 0.0f : 1.0f; + float _1403 = _1400 ? 0.0f : 1.0f; + float _1404 = 1.0f - _1401; + float _1405 = _1404 - _1393; + float _1406 = 1.0f - _1402; + float _1407 = _1406 - _1395; + float _1408 = 1.0f - _1403; + float _1409 = _1408 - _1397; + float _1410 = log2(_1374); + float _1411 = log2(_1380); + float _1412 = log2(_1386); + float _1413 = _1410 * _686; + float _1414 = _1411 * _686; + float _1415 = _1412 * _686; + float _1416 = exp2(_1413); + float _1417 = exp2(_1414); + float _1418 = exp2(_1415); + float _1419 = _1393 * _1416; + float _1420 = _1419 * _681; + float _1421 = _1417 * _1395; + float _1422 = _1421 * _681; + float _1423 = _1418 * _1397; + float _1424 = _1423 * _681; + float _1425 = _687 * _1371; + float _1426 = _687 * _1372; + float _1427 = _687 * _1373; + float _1428 = _1425 + _688; + float _1429 = _1426 + _688; + float _1430 = _1427 + _688; + float _1431 = _1428 * _1405; + float _1432 = _1429 * _1407; + float _1433 = _1430 * _1409; + float _1434 = _691 * _1371; + float _1435 = _691 * _1372; + float _1436 = _691 * _1373; + float _1437 = _1434 + _692; + float _1438 = _1435 + _692; + float _1439 = _1436 + _692; + float _1440 = exp2(_1437); + float _1441 = exp2(_1438); + float _1442 = exp2(_1439); + float _1443 = _1440 * _690; + float _1444 = _1441 * _690; + float _1445 = _1442 * _690; + float _1446 = _689 - _1443; + float _1447 = _689 - _1444; + float _1448 = _689 - _1445; + float _1449 = _1446 * _1401; + float _1450 = _1447 * _1402; + float _1451 = _1448 * _1403; + float _1452 = _1420 + _694; + float _1453 = _1452 + _1431; + float _1454 = _1453 + _1449; + float _1455 = _1422 + _696; + float _1456 = _1455 + _1432; + float _1457 = _1456 + _1450; + float _1458 = _1424 + _698; + float _1459 = _1458 + _1433; + float _1460 = _1459 + _1451; + _1462 = _1454; + _1463 = _1457; + _1464 = _1460; + } + } + bool _1465 = (_514 > 0.0f); + _1490 = _1462; + _1491 = _1463; + _1492 = _1464; + do { + if (_1465) { + float _1467 = _538 * _538; + float _1468 = _540 * _540; + float _1469 = _1467 + _1468; + float _1470 = sqrt(_1469); + float _1471 = _1470 * _511; + float _1472 = _1471 + _512; + float _1473 = saturate(_1472); + float _1474 = _1473 * 2.0f; + float _1475 = 3.0f - _1474; + float _1476 = _1473 * _1473; + float _1477 = _1476 * _514; + float _1478 = _1477 * _1475; + float _1479 = _1478 + _515; + float _1480 = _1462 - _491; + float _1481 = _1463 - _492; + float _1482 = _1464 - _493; + float _1483 = _1479 * _1480; + float _1484 = _1479 * _1481; + float _1485 = _1479 * _1482; + float _1486 = _1483 + _491; + float _1487 = _1484 + _492; + float _1488 = _1485 + _493; + _1490 = _1486; + _1491 = _1487; + _1492 = _1488; + } + float _1493 = _1490 - _491; + float _1494 = _1491 - _492; + float _1495 = _1492 - _493; + float _1496 = _1493 * _527; + float _1497 = _1494 * _527; + float _1498 = _1495 * _527; + float _1499 = _1496 + _491; + float _1500 = _1497 + _492; + float _1501 = _1498 + _493; + _1503 = _1499; + _1504 = _1500; + _1505 = _1501; + } while (false); + } while (false); + } + } + int _1506 = _30 & 2; + bool _1507 = (_1506 == 0); + _1604 = _1503; + _1605 = _1504; + _1606 = _1505; + if (!_1507) { + float _1510 = FilmGrainParam_000x; + float _1511 = FilmGrainParam_000y; + float _1512 = FilmGrainParam_000z; + float _1513 = FilmGrainParam_000w; + float _1515 = FilmGrainParam_001x; + float _1516 = FilmGrainParam_001y; + float _1517 = FilmGrainParam_001z; + float _1518 = FilmGrainParam_001w; + float _1520 = SceneInfo_023x; + float _1521 = SceneInfo_023y; + float _1522 = _1520 * _1512; + float _1523 = _1521 * _1513; + float _1524 = _1522 + _27; + float _1525 = _1523 + _28; + float _1526 = _1524 * _1518; + float _1527 = floor(_1526); + float _1528 = _1525 * _1518; + float _1529 = floor(_1528); + float _1530 = dot(float2(_1527, _1529), float2(0.0671105608344078f, 0.005837149918079376f)); + float _1531 = frac(_1530); + float _1532 = _1531 * 52.98291778564453f; + float _1533 = frac(_1532); + bool _1534 = (_1533 < _1515); + _1547 = 0.0f; + do { + if (_1534) { + float _1536 = _1529 * _1527; + uint _1537 = uint(_1536); + uint _1538 = _1537 ^ 12345391; + uint _1539 = _1538 * 3635641; + uint _1540 = _1538 * 232681024; + uint _1541 = _1539 >> 26; + int _1542 = _1541 | _1540; + uint _1543 = _1542 ^ _1539; + float _1544 = float(_1543); + float _1545 = _1544 * 2.3283064365386963e-10f; + _1547 = _1545; + } + float _1548 = _1533 * 757.4846801757812f; + float _1549 = frac(_1548); + bool _1550 = (_1549 < _1515); + _1563 = 0.0f; + do { + if (_1550) { + int _1552 = (int)_1549; + uint _1553 = _1552 ^ 12345391; + uint _1554 = _1553 * 3635641; + uint _1555 = _1553 * 232681024; + uint _1556 = _1554 >> 26; + int _1557 = _1556 | _1555; + uint _1558 = _1557 ^ _1554; + float _1559 = float(_1558); + float _1560 = _1559 * 2.3283064365386963e-10f; + float _1561 = _1560 + -0.5f; + _1563 = _1561; + } + float _1564 = _1549 * 757.4846801757812f; + float _1565 = frac(_1564); + bool _1566 = (_1565 < _1515); + _1579 = 0.0f; + do { + if (_1566) { + int _1568 = (int)_1565; + uint _1569 = _1568 ^ 12345391; + uint _1570 = _1569 * 3635641; + uint _1571 = _1569 * 232681024; + uint _1572 = _1570 >> 26; + int _1573 = _1572 | _1571; + uint _1574 = _1573 ^ _1570; + float _1575 = float(_1574); + float _1576 = _1575 * 2.3283064365386963e-10f; + float _1577 = _1576 + -0.5f; + _1579 = _1577; + } + float _1580 = _1547 * _1510; + float _1581 = _1579 * _1511; + float _1582 = _1563 * _1511; + float _1583 = mad(_1582, 1.4019999504089355f, _1580); + float _1584 = mad(_1581, -0.3440000116825104f, _1580); + float _1585 = mad(_1582, -0.7139999866485596f, _1584); + float _1586 = mad(_1581, 1.7719999551773071f, _1580); + float _1587 = dot(float3(_1503, _1504, _1505), float3(0.29899999499320984f, -0.16899999976158142f, 0.5f)); + float _1588 = saturate(_1587); + float _1589 = 1.0f - _1588; + float _1590 = log2(_1589); + float _1591 = _1590 * _1516; + float _1592 = exp2(_1591); + float _1593 = _1592 * _1517; + float _1594 = _1583 - _1503; + float _1595 = _1585 - _1504; + float _1596 = _1586 - _1505; + float _1597 = _1593 * _1594; + float _1598 = _1593 * _1595; + float _1599 = _1593 * _1596; + float _1600 = _1597 + _1503; + float _1601 = _1598 + _1504; + float _1602 = _1599 + _1505; + _1604 = _1600; + _1605 = _1601; + _1606 = _1602; + } while (false); + } while (false); + } while (false); + } + int _1607 = _30 & 4; + bool _1608 = (_1607 == 0); + _1817 = _1604; + _1818 = _1605; + _1819 = _1606; + if (!_1608) { + float _1611 = ColorCorrectTexture_000y; + float _1612 = ColorCorrectTexture_000z; + float _1613 = ColorCorrectTexture_000w; + float _1615 = ColorCorrectTexture_001x; + float _1616 = ColorCorrectTexture_001y; + float _1617 = ColorCorrectTexture_001z; + float _1619 = ColorCorrectTexture_002x; + float _1620 = ColorCorrectTexture_002y; + float _1621 = ColorCorrectTexture_002z; + float _1623 = ColorCorrectTexture_003x; + float _1624 = ColorCorrectTexture_003y; + float _1625 = ColorCorrectTexture_003z; + float _1627 = ColorCorrectTexture_004x; + float _1628 = ColorCorrectTexture_004y; + float _1629 = ColorCorrectTexture_004z; + float _1630 = max(_1604, _1605); + float _1631 = max(_1630, _1606); + bool _1632 = (_1631 > 1.0f); + _1638 = _1604; + _1639 = _1605; + _1640 = _1606; + do { + if (_1632) { + float _1634 = _1604 / _1631; + float _1635 = _1605 / _1631; + float _1636 = _1606 / _1631; + _1638 = _1634; + _1639 = _1635; + _1640 = _1636; + } + float _1641 = _1613 * 0.5f; + bool _1642 = !(_1638 <= 0.0031308000907301903f); + do { + if (!_1642) { + float _1644 = _1638 * 12.920000076293945f; + _1652 = _1644; + } else { + float _1646 = log2(_1638); + float _1647 = _1646 * 0.4166666567325592f; + float _1648 = exp2(_1647); + float _1649 = _1648 * 1.0549999475479126f; + float _1650 = _1649 + -0.054999999701976776f; + _1652 = _1650; + } + bool _1653 = !(_1639 <= 0.0031308000907301903f); + do { + if (!_1653) { + float _1655 = _1639 * 12.920000076293945f; + _1663 = _1655; + } else { + float _1657 = log2(_1639); + float _1658 = _1657 * 0.4166666567325592f; + float _1659 = exp2(_1658); + float _1660 = _1659 * 1.0549999475479126f; + float _1661 = _1660 + -0.054999999701976776f; + _1663 = _1661; + } + bool _1664 = !(_1640 <= 0.0031308000907301903f); + do { + if (!_1664) { + float _1666 = _1640 * 12.920000076293945f; + _1674 = _1666; + } else { + float _1668 = log2(_1640); + float _1669 = _1668 * 0.4166666567325592f; + float _1670 = exp2(_1669); + float _1671 = _1670 * 1.0549999475479126f; + float _1672 = _1671 + -0.054999999701976776f; + _1674 = _1672; + } + float _1675 = 1.0f - _1613; + float _1676 = _1652 * _1675; + float _1677 = _1663 * _1675; + float _1678 = _1674 * _1675; + float _1679 = _1676 + _1641; + float _1680 = _1677 + _1641; + float _1681 = _1678 + _1641; + +#if 0 + float4 _1682 = tTextureMap0.SampleLevel(TrilinearClamp, float3(_1679, _1680, _1681), 0.0f); +#else + float3 _1682 = LUTBlackCorrection(float3(_1638, _1639, _1640), tTextureMap0, lut_config); +#endif + + float _1683 = _1682.x; + float _1684 = _1682.y; + float _1685 = _1682.z; + bool _1686 = (_1611 > 0.0f); + do { + if (_1686) { +#if 0 + float4 _1688 = tTextureMap1.SampleLevel(TrilinearClamp, float3(_1679, _1680, _1681), 0.0f); + +#else + float3 _1688 = LUTBlackCorrection(float3(_1638, _1639, _1640), tTextureMap1, lut_config); +#endif + + + float _1689 = _1688.x; + float _1690 = _1688.y; + float _1691 = _1688.z; + float _1692 = _1689 - _1683; + float _1693 = _1690 - _1684; + float _1694 = _1691 - _1685; + float _1695 = _1692 * _1611; + float _1696 = _1693 * _1611; + float _1697 = _1694 * _1611; + float _1698 = _1695 + _1683; + float _1699 = _1696 + _1684; + float _1700 = _1697 + _1685; + bool _1701 = (_1612 > 0.0f); + _1797 = _1698; + _1798 = _1699; + _1799 = _1700; + if (_1701) { + bool _1703 = !(_1698 <= 0.0031308000907301903f); + do { + if (!_1703) { + float _1705 = _1698 * 12.920000076293945f; + _1713 = _1705; + } else { + float _1707 = log2(_1698); + float _1708 = _1707 * 0.4166666567325592f; + float _1709 = exp2(_1708); + float _1710 = _1709 * 1.0549999475479126f; + float _1711 = _1710 + -0.054999999701976776f; + _1713 = _1711; + } + bool _1714 = !(_1699 <= 0.0031308000907301903f); + do { + if (!_1714) { + float _1716 = _1699 * 12.920000076293945f; + _1724 = _1716; + } else { + float _1718 = log2(_1699); + float _1719 = _1718 * 0.4166666567325592f; + float _1720 = exp2(_1719); + float _1721 = _1720 * 1.0549999475479126f; + float _1722 = _1721 + -0.054999999701976776f; + _1724 = _1722; + } + bool _1725 = !(_1700 <= 0.0031308000907301903f); + do { + if (!_1725) { + float _1727 = _1700 * 12.920000076293945f; + _1735 = _1727; + } else { + float _1729 = log2(_1700); + float _1730 = _1729 * 0.4166666567325592f; + float _1731 = exp2(_1730); + float _1732 = _1731 * 1.0549999475479126f; + float _1733 = _1732 + -0.054999999701976776f; + _1735 = _1733; + } + // custom code +#if 0 + float4 _1736 = tTextureMap2.SampleLevel(TrilinearClamp, float3(_1713, _1724, _1735), 0.0f); + +#else + float3 _1736 = LUTBlackCorrection(float3(_1797, _1798, _1799), tTextureMap2, lut_config); +#endif + + float _1737 = _1736.x; + float _1738 = _1736.y; + float _1739 = _1736.z; + float _1740 = _1737 - _1698; + float _1741 = _1738 - _1699; + float _1742 = _1739 - _1700; + float _1743 = _1740 * _1612; + float _1744 = _1741 * _1612; + float _1745 = _1742 * _1612; + float _1746 = _1743 + _1698; + float _1747 = _1744 + _1699; + float _1748 = _1745 + _1700; + _1797 = _1746; + _1798 = _1747; + _1799 = _1748; + } while (false); + } while (false); + } while (false); + } + } else { + bool _1750 = !(_1683 <= 0.0031308000907301903f); + do { + if (!_1750) { + float _1752 = _1683 * 12.920000076293945f; + _1760 = _1752; + } else { + float _1754 = log2(_1683); + float _1755 = _1754 * 0.4166666567325592f; + float _1756 = exp2(_1755); + float _1757 = _1756 * 1.0549999475479126f; + float _1758 = _1757 + -0.054999999701976776f; + _1760 = _1758; + } + bool _1761 = !(_1684 <= 0.0031308000907301903f); + do { + if (!_1761) { + float _1763 = _1684 * 12.920000076293945f; + _1771 = _1763; + } else { + float _1765 = log2(_1684); + float _1766 = _1765 * 0.4166666567325592f; + float _1767 = exp2(_1766); + float _1768 = _1767 * 1.0549999475479126f; + float _1769 = _1768 + -0.054999999701976776f; + _1771 = _1769; + } + bool _1772 = !(_1685 <= 0.0031308000907301903f); + do { + if (!_1772) { + float _1774 = _1685 * 12.920000076293945f; + _1782 = _1774; + } else { + float _1776 = log2(_1685); + float _1777 = _1776 * 0.4166666567325592f; + float _1778 = exp2(_1777); + float _1779 = _1778 * 1.0549999475479126f; + float _1780 = _1779 + -0.054999999701976776f; + _1782 = _1780; + } +#if 0 + float4 _1783 = tTextureMap2.SampleLevel(TrilinearClamp, float3(_1760, _1771, _1782), 0.0f); + +#else + float3 _1783 = LUTBlackCorrection(float3(_1683, _1684, _1685), tTextureMap2, lut_config); +#endif + + float _1784 = _1783.x; + float _1785 = _1783.y; + float _1786 = _1783.z; + float _1787 = _1784 - _1683; + float _1788 = _1785 - _1684; + float _1789 = _1786 - _1685; + float _1790 = _1787 * _1612; + float _1791 = _1788 * _1612; + float _1792 = _1789 * _1612; + float _1793 = _1790 + _1683; + float _1794 = _1791 + _1684; + float _1795 = _1792 + _1685; + _1797 = _1793; + _1798 = _1794; + _1799 = _1795; + } while (false); + } while (false); + } while (false); + } + float _1800 = _1797 * _1615; + float _1801 = mad(_1798, _1619, _1800); + float _1802 = mad(_1799, _1623, _1801); + float _1803 = _1802 + _1627; + float _1804 = _1797 * _1616; + float _1805 = mad(_1798, _1620, _1804); + float _1806 = mad(_1799, _1624, _1805); + float _1807 = _1806 + _1628; + float _1808 = _1797 * _1617; + float _1809 = mad(_1798, _1621, _1808); + float _1810 = mad(_1799, _1625, _1809); + float _1811 = _1810 + _1629; + _1817 = _1803; + _1818 = _1807; + _1819 = _1811; + if (_1632) { + float _1813 = _1803 * _1631; + float _1814 = _1807 * _1631; + float _1815 = _1811 * _1631; + _1817 = _1813; + _1818 = _1814; + _1819 = _1815; + } + } while (false); + } while (false); + } while (false); + } while (false); + } while (false); + } + int _1820 = _30 & 8; + bool _1821 = (_1820 == 0); + _1854 = _1817; + _1855 = _1818; + _1856 = _1819; + if (!_1821) { + float _1824 = ColorDeficientTable_000x; + float _1825 = ColorDeficientTable_000y; + float _1826 = ColorDeficientTable_000z; + float _1828 = ColorDeficientTable_001x; + float _1829 = ColorDeficientTable_001y; + float _1830 = ColorDeficientTable_001z; + float _1832 = ColorDeficientTable_002x; + float _1833 = ColorDeficientTable_002y; + float _1834 = ColorDeficientTable_002z; + float _1835 = _1824 * _1817; + float _1836 = _1825 * _1818; + float _1837 = _1835 + _1836; + float _1838 = _1826 * _1819; + float _1839 = _1837 + _1838; + float _1840 = _1828 * _1817; + float _1841 = _1829 * _1818; + float _1842 = _1840 + _1841; + float _1843 = _1830 * _1819; + float _1844 = _1842 + _1843; + float _1845 = _1832 * _1817; + float _1846 = _1833 * _1818; + float _1847 = _1845 + _1846; + float _1848 = _1834 * _1819; + float _1849 = _1847 + _1848; + float _1850 = saturate(_1839); + float _1851 = saturate(_1844); + float _1852 = saturate(_1849); + _1854 = _1850; + _1855 = _1851; + _1856 = _1852; + } + int _1857 = _30 & 16; + bool _1858 = (_1857 == 0); + _1925 = _1854; + _1926 = _1855; + _1927 = _1856; + if (!_1858) { + float _1861 = ImagePlaneParam_000x; + float _1862 = ImagePlaneParam_000y; + float _1863 = ImagePlaneParam_000z; + float _1864 = ImagePlaneParam_000w; + float _1866 = ImagePlaneParam_001x; + float _1867 = ImagePlaneParam_001y; + float _1869 = SceneInfo_023z; + float _1870 = SceneInfo_023w; + float _1871 = _1869 * _27; + float _1872 = _1870 * _28; + float4 _1873 = ImagePlameBase.SampleLevel(BilinearClamp, float2(_1871, _1872), 0.0f); + float _1874 = _1873.x; + float _1875 = _1873.y; + float _1876 = _1873.z; + float _1877 = _1873.w; + float _1878 = _1874 * _1861; + float _1879 = _1875 * _1862; + float _1880 = _1876 * _1863; + float _1881 = _1877 * _1864; + float _1882 = ImagePlameAlpha.SampleLevel(BilinearClamp, float2(_1871, _1872), 0.0f); + float _1883 = _1882.x; + float _1884 = _1883 * _1866; + float _1885 = _1884 + _1867; + float _1886 = saturate(_1885); + float _1887 = _1881 * _1886; + bool _1888 = (_1878 < 0.5f); + bool _1889 = (_1879 < 0.5f); + bool _1890 = (_1880 < 0.5f); + float _1891 = _1854 * 2.0f; + float _1892 = _1891 * _1878; + float _1893 = _1855 * 2.0f; + float _1894 = _1893 * _1879; + float _1895 = _1856 * 2.0f; + float _1896 = _1895 * _1880; + float _1897 = 1.0f - _1878; + float _1898 = 1.0f - _1879; + float _1899 = 1.0f - _1880; + float _1900 = 1.0f - _1854; + float _1901 = 1.0f - _1855; + float _1902 = 1.0f - _1856; + float _1903 = _1900 * 2.0f; + float _1904 = _1903 * _1897; + float _1905 = _1901 * 2.0f; + float _1906 = _1905 * _1898; + float _1907 = _1902 * 2.0f; + float _1908 = _1907 * _1899; + float _1909 = 1.0f - _1904; + float _1910 = 1.0f - _1906; + float _1911 = 1.0f - _1908; + float _1912 = _1888 ? _1892 : _1909; + float _1913 = _1889 ? _1894 : _1910; + float _1914 = _1890 ? _1896 : _1911; + float _1915 = _1912 - _1854; + float _1916 = _1913 - _1855; + float _1917 = _1914 - _1856; + float _1918 = _1915 * _1887; + float _1919 = _1916 * _1887; + float _1920 = _1917 * _1887; + float _1921 = _1918 + _1854; + float _1922 = _1919 + _1855; + float _1923 = _1920 + _1856; + _1925 = _1921; + _1926 = _1922; + _1927 = _1923; + } + SV_Target.x = _1925; + SV_Target.y = _1926; + SV_Target.z = _1927; + SV_Target.w = 0.0f; + +#if 0 // HDR Gamma boost + + SV_Target.rgb = AdjustGammaOnLuminance(SV_Target.rgb, 1.1); + +#endif + + return SV_Target; +} diff --git a/src/games/re2remake/LUTBlackCorrection.hlsl b/src/games/re2remake/LUTBlackCorrection.hlsl new file mode 100644 index 00000000..a0cf336b --- /dev/null +++ b/src/games/re2remake/LUTBlackCorrection.hlsl @@ -0,0 +1,52 @@ +#include "./shared.h" + +// take OkLab hues and saturation from Gamma Correction +float3 HueSatCorrection(float3 incorrect_color, float3 correct_color) { + float3 incorrect_lab = renodx::color::oklab::from::BT709(incorrect_color); + float3 correct_lab = renodx::color::oklab::from::BT709(correct_color); + + float3 corrected_lab = float3(incorrect_lab.x, correct_lab.yz); + float3 corrected_color = renodx::color::bt709::from::OkLab(corrected_lab); + + return corrected_color; +} + +// Gamma adjustment on luminance +// BT.2408: 5.1.3.2 - Mapping with OOTF adjustment +// works well to preserve the appearance of shadows and midtones at 100 cd / m2 +// while scaling the SDR nominal peak white to 203 cd / m2 +// https://www.itu.int/dms_pub/itu-r/opb/rep/R-REP-BT.2408-7-2023-PDF-E.pdf- 5.1.3.2 +float3 AdjustGammaOnLuminance(float3 linearColor, float gammaAdjustmentFactor) { + // Calculate the original luminance + float originalLuminance = renodx::color::y::from::BT709(abs(linearColor)); + + // Adjust luminance only if it is less than or equal to 1 + float adjustedLuminance = originalLuminance > 1.0 ? originalLuminance : renodx::color::gamma::Encode(originalLuminance, 1 / gammaAdjustmentFactor); + + // Recombine the colors with the adjusted luminance + if (originalLuminance == 0) return float3(0, 0, 0); // Prevent division by zero + return linearColor * (adjustedLuminance / originalLuminance); +} + +float3 LUTBlackCorrection(float3 color_input, Texture3D lut_texture, renodx::lut::Config lut_config) { + float3 lutInputColor = renodx::lut::ConvertInput(color_input, lut_config); + float3 lutOutputColor = renodx::lut::SampleColor(lutInputColor, lut_config, lut_texture); + float3 color_output = renodx::lut::LinearOutput(lutOutputColor, lut_config); + if (lut_config.scaling != 0) { + float3 lutBlack = renodx::lut::SampleColor(renodx::lut::ConvertInput(0, lut_config), lut_config, lut_texture); + float3 lutMid = renodx::lut::SampleColor(renodx::lut::ConvertInput(0.18f, lut_config), lut_config, lut_texture); + float3 unclamped = renodx::lut::Unclamp( + renodx::lut::GammaOutput(lutOutputColor, lut_config), + renodx::lut::GammaOutput(lutBlack, lut_config), + renodx::lut::GammaOutput(lutMid, lut_config), + 1.f, // set peak to 1 so it doesn't touch highlights + renodx::lut::GammaInput(color_input, lutInputColor, lut_config)); + float3 recolored = renodx::lut::RecolorUnclamped(color_output, renodx::lut::LinearUnclampedOutput(unclamped, lut_config)); + color_output = lerp(color_output, recolored, lut_config.scaling); + } + color_output = renodx::lut::RestoreSaturationLoss(color_input, color_output, lut_config); + if (lut_config.strength != 1.f) { + color_output = lerp(color_input, color_output, lut_config.strength); + } + return color_output; +} \ No newline at end of file diff --git a/src/games/re2remake/NoVignette_HDRPostProcess_WithTonemap_0x30D8372F.ps_6_5.hlsl b/src/games/re2remake/NoVignette_HDRPostProcess_WithTonemap_0x30D8372F.ps_6_5.hlsl new file mode 100644 index 00000000..298deef3 --- /dev/null +++ b/src/games/re2remake/NoVignette_HDRPostProcess_WithTonemap_0x30D8372F.ps_6_5.hlsl @@ -0,0 +1,2194 @@ +#include "./shared.h" +#include "./LUTBlackCorrection.hlsl" + +Texture2D RE_POSTPROCESS_Color : register(t0); + +struct _ComputeResultSRV { + float data[1]; +}; +StructuredBuffer<_ComputeResultSRV> ComputeResultSRV : register(t1); + +Texture3D tTextureMap0 : register(t2); + +Texture3D tTextureMap1 : register(t3); + +Texture3D tTextureMap2 : register(t4); + +Texture2D ImagePlameBase : register(t5); + +Texture2D ImagePlameAlpha : register(t6); + +cbuffer SceneInfo : register(b0) { + float SceneInfo_023x : packoffset(c023.x); + float SceneInfo_023y : packoffset(c023.y); + float SceneInfo_023z : packoffset(c023.z); + float SceneInfo_023w : packoffset(c023.w); +}; + +cbuffer TonemapParam : register(b1) { + float TonemapParam_000x : packoffset(c000.x); + float TonemapParam_000y : packoffset(c000.y); + float TonemapParam_000w : packoffset(c000.w); + float maxNit : packoffset(c001.x); // float TonemapParam_001x + float linearStart : packoffset(c001.y); // float TonemapParam_001y + float TonemapParam_001z : packoffset(c001.z); + float TonemapParam_001w : packoffset(c001.w); + float TonemapParam_002x : packoffset(c002.x); + float TonemapParam_002y : packoffset(c002.y); + float TonemapParam_002z : packoffset(c002.z); +}; + +cbuffer LensDistortionParam : register(b2) { + float LensDistortionParam_000x : packoffset(c000.x); + float LensDistortionParam_000y : packoffset(c000.y); + uint LensDistortionParam_000z : packoffset(c000.z); + uint LensDistortionParam_000w : packoffset(c000.w); + float LensDistortionParam_001x : packoffset(c001.x); +}; + +cbuffer PaniniProjectionParam : register(b3) { + float PaniniProjectionParam_000x : packoffset(c000.x); + float PaniniProjectionParam_000y : packoffset(c000.y); + float PaniniProjectionParam_000z : packoffset(c000.z); + float PaniniProjectionParam_000w : packoffset(c000.w); +}; + +cbuffer RadialBlurRenderParam : register(b4) { + float RadialBlurRenderParam_000x : packoffset(c000.x); + float RadialBlurRenderParam_000y : packoffset(c000.y); + float RadialBlurRenderParam_000z : packoffset(c000.z); + float RadialBlurRenderParam_000w : packoffset(c000.w); + float RadialBlurRenderParam_001x : packoffset(c001.x); + float RadialBlurRenderParam_001y : packoffset(c001.y); + float RadialBlurRenderParam_001z : packoffset(c001.z); + float RadialBlurRenderParam_001w : packoffset(c001.w); + float RadialBlurRenderParam_002x : packoffset(c002.x); + float RadialBlurRenderParam_002y : packoffset(c002.y); + float RadialBlurRenderParam_002z : packoffset(c002.z); + float RadialBlurRenderParam_002w : packoffset(c002.w); + uint RadialBlurRenderParam_003x : packoffset(c003.x); +}; + +cbuffer FilmGrainParam : register(b5) { + float FilmGrainParam_000x : packoffset(c000.x); + float FilmGrainParam_000y : packoffset(c000.y); + float FilmGrainParam_000z : packoffset(c000.z); + float FilmGrainParam_000w : packoffset(c000.w); + float FilmGrainParam_001x : packoffset(c001.x); + float FilmGrainParam_001y : packoffset(c001.y); + float FilmGrainParam_001z : packoffset(c001.z); + float FilmGrainParam_001w : packoffset(c001.w); +}; + +cbuffer ColorCorrectTexture : register(b6) { + float ColorCorrectTexture_000y : packoffset(c000.y); + float ColorCorrectTexture_000z : packoffset(c000.z); + float ColorCorrectTexture_000w : packoffset(c000.w); + float ColorCorrectTexture_001x : packoffset(c001.x); + float ColorCorrectTexture_001y : packoffset(c001.y); + float ColorCorrectTexture_001z : packoffset(c001.z); + float ColorCorrectTexture_002x : packoffset(c002.x); + float ColorCorrectTexture_002y : packoffset(c002.y); + float ColorCorrectTexture_002z : packoffset(c002.z); + float ColorCorrectTexture_003x : packoffset(c003.x); + float ColorCorrectTexture_003y : packoffset(c003.y); + float ColorCorrectTexture_003z : packoffset(c003.z); + float ColorCorrectTexture_004x : packoffset(c004.x); + float ColorCorrectTexture_004y : packoffset(c004.y); + float ColorCorrectTexture_004z : packoffset(c004.z); +}; + +cbuffer ColorDeficientTable : register(b7) { + float ColorDeficientTable_000x : packoffset(c000.x); + float ColorDeficientTable_000y : packoffset(c000.y); + float ColorDeficientTable_000z : packoffset(c000.z); + float ColorDeficientTable_001x : packoffset(c001.x); + float ColorDeficientTable_001y : packoffset(c001.y); + float ColorDeficientTable_001z : packoffset(c001.z); + float ColorDeficientTable_002x : packoffset(c002.x); + float ColorDeficientTable_002y : packoffset(c002.y); + float ColorDeficientTable_002z : packoffset(c002.z); +}; + +cbuffer ImagePlaneParam : register(b8) { + float ImagePlaneParam_000x : packoffset(c000.x); + float ImagePlaneParam_000y : packoffset(c000.y); + float ImagePlaneParam_000z : packoffset(c000.z); + float ImagePlaneParam_000w : packoffset(c000.w); + float ImagePlaneParam_001x : packoffset(c001.x); + float ImagePlaneParam_001y : packoffset(c001.y); +}; + +cbuffer CBControl : register(b9) { + uint CBControl_000x : packoffset(c000.x); +}; + +SamplerState BilinearClamp : register(s5, space32); + +SamplerState BilinearBorder : register(s6, space32); + +SamplerState TrilinearClamp : register(s9, space32); + +float4 main( + noperspective float4 SV_Position : SV_Position, + linear float4 Kerare : Kerare, + linear float Exposure : Exposure +) : SV_Target { + + // custom code + // set vanilla tonemapper to 10k + float TonemapParam_001x = 125; + float TonemapParam_001y = 125; + + // declare lut config for use with lut black correction + renodx::lut::Config lut_config = renodx::lut::config::Create( + TrilinearClamp, + 1.f, + 1.f, + renodx::lut::config::type::SRGB, + renodx::lut::config::type::LINEAR, + 1 / ColorCorrectTexture_000w); + + + float4 SV_Target; + float _21 = Exposure; + float _22 = SV_Position.x; + float _23 = SV_Position.y; + uint _25 = CBControl_000x; + int _26 = _25 & 1; + bool _27 = (_26 != 0); + uint _29 = LensDistortionParam_000w; + bool _30 = (_29 == 0); + bool _31 = _27 && _30; + bool _32 = (_29 == 1); + bool _33 = _27 && _32; + float _35 = TonemapParam_000y; + float _37 = TonemapParam_002y; + float _39 = TonemapParam_001y; + float _40 = TonemapParam_000w; + float _41 = TonemapParam_000x; + float _42 = TonemapParam_002z; + float _43 = TonemapParam_001x; + float _44 = TonemapParam_001z; + float _45 = TonemapParam_001w; + float _46 = TonemapParam_002x; + float _465; + float _466; + float _467; + float _468; + float _469; + float _470; + float _471; + float _472; + float _473; + float _1435; + float _1436; + float _1437; + float _1463; + float _1464; + float _1465; + float _1476; + float _1477; + float _1478; + float _1520; + float _1536; + float _1552; + float _1577; + float _1578; + float _1579; + float _1611; + float _1612; + float _1613; + float _1625; + float _1636; + float _1647; + float _1686; + float _1697; + float _1708; + float _1733; + float _1744; + float _1755; + float _1770; + float _1771; + float _1772; + float _1790; + float _1791; + float _1792; + float _1827; + float _1828; + float _1829; + float _1898; + float _1899; + float _1900; + if (_31) { + float _49 = LensDistortionParam_000x; + float _50 = LensDistortionParam_000y; + uint _51 = LensDistortionParam_000z; + float _53 = LensDistortionParam_001x; + float _55 = SceneInfo_023z; + float _56 = SceneInfo_023w; + float _57 = _55 * _22; + float _58 = _56 * _23; + float _59 = _57 + -0.5f; + float _60 = _58 + -0.5f; + float _61 = dot(float2(_59, _60), float2(_59, _60)); + float _62 = _61 * _49; + float _63 = _62 + 1.0f; + float _64 = _63 * _53; + float _65 = _64 * _59; + float _66 = _64 * _60; + float _67 = _65 + 0.5f; + float _68 = _66 + 0.5f; + bool _69 = (_51 == 0); + float4 _70 = RE_POSTPROCESS_Color.Sample(BilinearClamp, float2(_67, _68)); + float _71 = _70.x; + float _72 = _71 * _21; + float _73 = _37 * _72; + bool _74 = (_72 >= _35); + float _75 = _73 * _73; + float _76 = _73 * 2.0f; + float _77 = 3.0f - _76; + float _78 = _75 * _77; + float _79 = 1.0f - _78; + float _80 = _74 ? 0.0f : _79; + bool _81 = (_72 < _39); + float _82 = _81 ? 0.0f : 1.0f; + float _83 = 1.0f - _82; + float _84 = _83 - _80; + float _85 = log2(_73); + float _86 = _85 * _40; + float _87 = exp2(_86); + float _88 = _41 * _72; + float _89 = _88 + _42; + float _90 = _89 * _84; + float _91 = _45 * _72; + float _92 = _91 + _46; + float _93 = exp2(_92); + float _94 = _93 * _44; + float _95 = _43 - _94; + float _96 = _95 * _82; + if (_69) { + float _98 = _70.y; + float _99 = _70.z; + float _100 = _98 * _21; + float _101 = _99 * _21; + float _102 = _37 * _100; + bool _103 = (_100 >= _35); + float _104 = _102 * _102; + float _105 = _102 * 2.0f; + float _106 = 3.0f - _105; + float _107 = _104 * _106; + float _108 = _37 * _101; + bool _109 = (_101 >= _35); + float _110 = _108 * _108; + float _111 = _108 * 2.0f; + float _112 = 3.0f - _111; + float _113 = _110 * _112; + float _114 = 1.0f - _107; + float _115 = _103 ? 0.0f : _114; + float _116 = 1.0f - _113; + float _117 = _109 ? 0.0f : _116; + bool _118 = (_100 < _39); + bool _119 = (_101 < _39); + float _120 = _118 ? 0.0f : 1.0f; + float _121 = _119 ? 0.0f : 1.0f; + float _122 = 1.0f - _120; + float _123 = _122 - _115; + float _124 = 1.0f - _121; + float _125 = _124 - _117; + float _126 = log2(_102); + float _127 = log2(_108); + float _128 = _126 * _40; + float _129 = _127 * _40; + float _130 = exp2(_128); + float _131 = exp2(_129); + float _132 = _87 * _80; + float _133 = _132 * _35; + float _134 = _130 * _115; + float _135 = _134 * _35; + float _136 = _131 * _117; + float _137 = _136 * _35; + float _138 = _41 * _100; + float _139 = _41 * _101; + float _140 = _138 + _42; + float _141 = _139 + _42; + float _142 = _140 * _123; + float _143 = _141 * _125; + float _144 = _90 + _133; + float _145 = _142 + _135; + float _146 = _143 + _137; + float _147 = _45 * _100; + float _148 = _45 * _101; + float _149 = _147 + _46; + float _150 = _148 + _46; + float _151 = exp2(_149); + float _152 = exp2(_150); + float _153 = _151 * _44; + float _154 = _152 * _44; + float _155 = _43 - _153; + float _156 = _43 - _154; + float _157 = _155 * _120; + float _158 = _156 * _121; + float _159 = _144 + _96; + float _160 = _145 + _157; + float _161 = _146 + _158; + _465 = _159; + _466 = _160; + _467 = _161; + _468 = _49; + _469 = 0.0f; + _470 = 0.0f; + _471 = 0.0f; + _472 = 0.0f; + _473 = _53; + } else { + float _163 = _61 + _50; + float _164 = _163 * _49; + float _165 = _164 + 1.0f; + float _166 = _59 * _53; + float _167 = _166 * _165; + float _168 = _60 * _53; + float _169 = _168 * _165; + float _170 = _167 + 0.5f; + float _171 = _169 + 0.5f; + float _172 = _163 + _50; + float _173 = _172 * _49; + float _174 = _173 + 1.0f; + float _175 = _166 * _174; + float _176 = _168 * _174; + float _177 = _175 + 0.5f; + float _178 = _176 + 0.5f; + float _179 = _35 * _87; + float _180 = _179 * _80; + float _181 = _90 + _180; + float _182 = _181 + _96; + float4 _183 = RE_POSTPROCESS_Color.Sample(BilinearClamp, float2(_170, _171)); + float _184 = _183.y; + float _185 = _184 * _21; + float _186 = _37 * _185; + bool _187 = (_185 >= _35); + float _188 = _186 * _186; + float _189 = _186 * 2.0f; + float _190 = 3.0f - _189; + float _191 = _188 * _190; + float _192 = 1.0f - _191; + float _193 = _187 ? 0.0f : _192; + bool _194 = (_185 < _39); + float _195 = _194 ? 0.0f : 1.0f; + float _196 = 1.0f - _195; + float _197 = _196 - _193; + float _198 = log2(_186); + float _199 = _198 * _40; + float _200 = exp2(_199); + float _201 = _35 * _200; + float _202 = _201 * _193; + float _203 = _41 * _185; + float _204 = _203 + _42; + float _205 = _204 * _197; + float _206 = _205 + _202; + float _207 = _45 * _185; + float _208 = _207 + _46; + float _209 = exp2(_208); + float _210 = _209 * _44; + float _211 = _43 - _210; + float _212 = _211 * _195; + float _213 = _206 + _212; + float4 _214 = RE_POSTPROCESS_Color.Sample(BilinearClamp, float2(_177, _178)); + float _215 = _214.z; + float _216 = _215 * _21; + float _217 = _37 * _216; + bool _218 = (_216 >= _35); + float _219 = _217 * _217; + float _220 = _217 * 2.0f; + float _221 = 3.0f - _220; + float _222 = _219 * _221; + float _223 = 1.0f - _222; + float _224 = _218 ? 0.0f : _223; + bool _225 = (_216 < _39); + float _226 = _225 ? 0.0f : 1.0f; + float _227 = 1.0f - _226; + float _228 = _227 - _224; + float _229 = log2(_217); + float _230 = _229 * _40; + float _231 = exp2(_230); + float _232 = _35 * _231; + float _233 = _232 * _224; + float _234 = _41 * _216; + float _235 = _234 + _42; + float _236 = _235 * _228; + float _237 = _236 + _233; + float _238 = _45 * _216; + float _239 = _238 + _46; + float _240 = exp2(_239); + float _241 = _240 * _44; + float _242 = _43 - _241; + float _243 = _242 * _226; + float _244 = _237 + _243; + _465 = _182; + _466 = _213; + _467 = _244; + _468 = _49; + _469 = 0.0f; + _470 = 0.0f; + _471 = 0.0f; + _472 = 0.0f; + _473 = _53; + } + } else { + if (_33) { + float _248 = PaniniProjectionParam_000x; + float _249 = PaniniProjectionParam_000y; + float _250 = PaniniProjectionParam_000z; + float _251 = PaniniProjectionParam_000w; + float _253 = SceneInfo_023z; + float _254 = SceneInfo_023w; + float _255 = _22 * 2.0f; + float _256 = _255 * _253; + float _257 = _23 * 2.0f; + float _258 = _257 * _254; + float _259 = _256 + -1.0f; + float _260 = _258 + -1.0f; + float _261 = _259 * _259; + float _262 = _261 + 1.0f; + float _263 = sqrt(_262); + float _264 = 1.0f / _263; + float _265 = _264 + _248; + float _266 = _263 * _250; + float _267 = _266 * _265; + float _268 = _264 + -1.0f; + float _269 = _268 * _249; + float _270 = _269 + 1.0f; + float _271 = _251 * 0.5f; + float _272 = _271 * _259; + float _273 = _272 * _267; + float _274 = _271 * _260; + float _275 = _274 * _270; + float _276 = _275 * _267; + float _277 = _273 + 0.5f; + float _278 = _276 + 0.5f; + float4 _279 = RE_POSTPROCESS_Color.Sample(BilinearBorder, float2(_277, _278)); + float _280 = _279.x; + float _281 = _279.y; + float _282 = _279.z; + float _283 = _280 * _21; + float _284 = _281 * _21; + float _285 = _282 * _21; + float _286 = _37 * _283; + bool _287 = (_283 >= _35); + float _288 = _286 * _286; + float _289 = _286 * 2.0f; + float _290 = 3.0f - _289; + float _291 = _288 * _290; + float _292 = _37 * _284; + bool _293 = (_284 >= _35); + float _294 = _292 * _292; + float _295 = _292 * 2.0f; + float _296 = 3.0f - _295; + float _297 = _294 * _296; + float _298 = _37 * _285; + bool _299 = (_285 >= _35); + float _300 = _298 * _298; + float _301 = _298 * 2.0f; + float _302 = 3.0f - _301; + float _303 = _300 * _302; + float _304 = 1.0f - _291; + float _305 = _287 ? 0.0f : _304; + float _306 = 1.0f - _297; + float _307 = _293 ? 0.0f : _306; + float _308 = 1.0f - _303; + float _309 = _299 ? 0.0f : _308; + bool _310 = (_283 < _39); + bool _311 = (_284 < _39); + bool _312 = (_285 < _39); + float _313 = _310 ? 0.0f : 1.0f; + float _314 = _311 ? 0.0f : 1.0f; + float _315 = _312 ? 0.0f : 1.0f; + float _316 = 1.0f - _313; + float _317 = _316 - _305; + float _318 = 1.0f - _314; + float _319 = _318 - _307; + float _320 = 1.0f - _315; + float _321 = _320 - _309; + float _322 = log2(_286); + float _323 = log2(_292); + float _324 = log2(_298); + float _325 = _322 * _40; + float _326 = _323 * _40; + float _327 = _324 * _40; + float _328 = exp2(_325); + float _329 = exp2(_326); + float _330 = exp2(_327); + float _331 = _328 * _305; + float _332 = _331 * _35; + float _333 = _329 * _307; + float _334 = _333 * _35; + float _335 = _330 * _309; + float _336 = _335 * _35; + float _337 = _41 * _283; + float _338 = _41 * _284; + float _339 = _41 * _285; + float _340 = _337 + _42; + float _341 = _338 + _42; + float _342 = _339 + _42; + float _343 = _340 * _317; + float _344 = _341 * _319; + float _345 = _342 * _321; + float _346 = _343 + _332; + float _347 = _344 + _334; + float _348 = _345 + _336; + float _349 = _45 * _283; + float _350 = _45 * _284; + float _351 = _45 * _285; + float _352 = _349 + _46; + float _353 = _350 + _46; + float _354 = _351 + _46; + float _355 = exp2(_352); + float _356 = exp2(_353); + float _357 = exp2(_354); + float _358 = _355 * _44; + float _359 = _356 * _44; + float _360 = _357 * _44; + float _361 = _43 - _358; + float _362 = _43 - _359; + float _363 = _43 - _360; + float _364 = _361 * _313; + float _365 = _362 * _314; + float _366 = _363 * _315; + float _367 = _346 + _364; + float _368 = _347 + _365; + float _369 = _348 + _366; + _465 = _367; + _466 = _368; + _467 = _369; + _468 = 0.0f; + _469 = _248; + _470 = _249; + _471 = _250; + _472 = _251; + _473 = 1.0f; + } else { + uint _371 = uint(_22); + uint _372 = uint(_23); + float4 _373 = RE_POSTPROCESS_Color.Load(int3(_371, _372, 0)); + float _374 = _373.x; + float _375 = _373.y; + float _376 = _373.z; + float _377 = _374 * _21; + float _378 = _375 * _21; + float _379 = _376 * _21; + float _380 = _37 * _377; + bool _381 = (_377 >= _35); + float _382 = _380 * _380; + float _383 = _380 * 2.0f; + float _384 = 3.0f - _383; + float _385 = _382 * _384; + float _386 = _37 * _378; + bool _387 = (_378 >= _35); + float _388 = _386 * _386; + float _389 = _386 * 2.0f; + float _390 = 3.0f - _389; + float _391 = _388 * _390; + float _392 = _37 * _379; + bool _393 = (_379 >= _35); + float _394 = _392 * _392; + float _395 = _392 * 2.0f; + float _396 = 3.0f - _395; + float _397 = _394 * _396; + float _398 = 1.0f - _385; + float _399 = _381 ? 0.0f : _398; + float _400 = 1.0f - _391; + float _401 = _387 ? 0.0f : _400; + float _402 = 1.0f - _397; + float _403 = _393 ? 0.0f : _402; + bool _404 = (_377 < _39); + bool _405 = (_378 < _39); + bool _406 = (_379 < _39); + float _407 = _404 ? 0.0f : 1.0f; + float _408 = _405 ? 0.0f : 1.0f; + float _409 = _406 ? 0.0f : 1.0f; + float _410 = 1.0f - _407; + float _411 = _410 - _399; + float _412 = 1.0f - _408; + float _413 = _412 - _401; + float _414 = 1.0f - _409; + float _415 = _414 - _403; + float _416 = log2(_380); + float _417 = log2(_386); + float _418 = log2(_392); + float _419 = _416 * _40; + float _420 = _417 * _40; + float _421 = _418 * _40; + float _422 = exp2(_419); + float _423 = exp2(_420); + float _424 = exp2(_421); + float _425 = _422 * _399; + float _426 = _425 * _35; + float _427 = _423 * _401; + float _428 = _427 * _35; + float _429 = _424 * _403; + float _430 = _429 * _35; + float _431 = _41 * _377; + float _432 = _41 * _378; + float _433 = _41 * _379; + float _434 = _431 + _42; + float _435 = _432 + _42; + float _436 = _433 + _42; + float _437 = _434 * _411; + float _438 = _435 * _413; + float _439 = _436 * _415; + float _440 = _437 + _426; + float _441 = _438 + _428; + float _442 = _439 + _430; + float _443 = _45 * _377; + float _444 = _45 * _378; + float _445 = _45 * _379; + float _446 = _443 + _46; + float _447 = _444 + _46; + float _448 = _445 + _46; + float _449 = exp2(_446); + float _450 = exp2(_447); + float _451 = exp2(_448); + float _452 = _449 * _44; + float _453 = _450 * _44; + float _454 = _451 * _44; + float _455 = _43 - _452; + float _456 = _43 - _453; + float _457 = _43 - _454; + float _458 = _455 * _407; + float _459 = _456 * _408; + float _460 = _457 * _409; + float _461 = _440 + _458; + float _462 = _441 + _459; + float _463 = _442 + _460; + _465 = _461; + _466 = _462; + _467 = _463; + _468 = 0.0f; + _469 = 0.0f; + _470 = 0.0f; + _471 = 0.0f; + _472 = 0.0f; + _473 = 1.0f; + } + } + int _474 = _25 & 32; + bool _475 = (_474 == 0); + _1476 = _465; + _1477 = _466; + _1478 = _467; + if (!_475) { + float _478 = RadialBlurRenderParam_000x; + float _479 = RadialBlurRenderParam_000y; + float _480 = RadialBlurRenderParam_000z; + float _481 = RadialBlurRenderParam_000w; + float _483 = RadialBlurRenderParam_001x; + float _484 = RadialBlurRenderParam_001y; + float _485 = RadialBlurRenderParam_001z; + float _486 = RadialBlurRenderParam_001w; + float _488 = RadialBlurRenderParam_002x; + float _489 = RadialBlurRenderParam_002y; + float _490 = RadialBlurRenderParam_002z; + uint _492 = RadialBlurRenderParam_003x; + int _493 = _492 & 2; + bool _494 = (_493 != 0); + float _495 = float(_494); + float _496 = 1.0f - _495; + float4 _497 = ComputeResultSRV[0].data[0 / 4]; + float _498 = _497.x; + float _499 = _498 * _495; + float _500 = _496 + _499; + float _501 = _500 * _481; + bool _502 = (_501 == 0.0f); + _1476 = _465; + _1477 = _466; + _1478 = _467; + if (!_502) { + float _504 = RadialBlurRenderParam_002w; + float _506 = SceneInfo_023z; + float _507 = SceneInfo_023w; + float _508 = _506 * _22; + float _509 = _507 * _23; + float _510 = -0.5f - _483; + float _511 = _510 + _508; + float _512 = -0.5f - _484; + float _513 = _512 + _509; + bool _514 = (_511 < 0.0f); + float _515 = 1.0f - _508; + float _516 = _514 ? _515 : _508; + bool _517 = (_513 < 0.0f); + float _518 = 1.0f - _509; + float _519 = _517 ? _518 : _509; + int _520 = _492 & 1; + bool _521 = (_520 != 0); + float _522 = dot(float2(_511, _513), float2(_511, _513)); + float _523 = rsqrt(_522); + float _524 = _523 * _504; + float _525 = _524 * _511; + float _526 = _524 * _513; + float _527 = abs(_525); + float _528 = abs(_526); + uint _529 = uint(_527); + uint _530 = uint(_528); + uint _531 = _530 + _529; + uint _532 = _531 ^ 61; + uint _533 = _531 >> 16; + uint _534 = _532 ^ _533; + uint _535 = _534 * 9; + uint _536 = _535 >> 4; + uint _537 = _536 ^ _535; + uint _538 = _537 * 668265261; + uint _539 = _538 >> 15; + uint _540 = _539 ^ _538; + float _541 = float(_540); + float _542 = _541 * 2.3283064365386963e-10f; + float _543 = _521 ? _542 : 1.0f; + float _544 = _511 * _511; + float _545 = _513 * _513; + float _546 = _544 + _545; + float _547 = sqrt(_546); + float _548 = max(1.0f, _547); + float _549 = 1.0f / _548; + float _550 = _490 * -0.0011111111380159855f; + float _551 = _550 * _516; + float _552 = _551 * _543; + float _553 = _552 * _549; + float _554 = _550 * _519; + float _555 = _554 * _543; + float _556 = _555 * _549; + float _557 = _553 + 1.0f; + float _558 = _556 + 1.0f; + float _559 = _557 * _511; + float _560 = _558 * _513; + float _561 = _490 * -0.002222222276031971f; + float _562 = _561 * _516; + float _563 = _562 * _543; + float _564 = _563 * _549; + float _565 = _561 * _519; + float _566 = _565 * _543; + float _567 = _566 * _549; + float _568 = _564 + 1.0f; + float _569 = _567 + 1.0f; + float _570 = _568 * _511; + float _571 = _569 * _513; + float _572 = _490 * -0.0033333334140479565f; + float _573 = _572 * _516; + float _574 = _573 * _543; + float _575 = _574 * _549; + float _576 = _572 * _519; + float _577 = _576 * _543; + float _578 = _577 * _549; + float _579 = _575 + 1.0f; + float _580 = _578 + 1.0f; + float _581 = _579 * _511; + float _582 = _580 * _513; + float _583 = _490 * -0.004444444552063942f; + float _584 = _583 * _516; + float _585 = _584 * _543; + float _586 = _585 * _549; + float _587 = _583 * _519; + float _588 = _587 * _543; + float _589 = _588 * _549; + float _590 = _586 + 1.0f; + float _591 = _589 + 1.0f; + float _592 = _590 * _511; + float _593 = _591 * _513; + float _594 = _490 * -0.0055555556900799274f; + float _595 = _594 * _516; + float _596 = _595 * _543; + float _597 = _596 * _549; + float _598 = _594 * _519; + float _599 = _598 * _543; + float _600 = _599 * _549; + float _601 = _597 + 1.0f; + float _602 = _600 + 1.0f; + float _603 = _601 * _511; + float _604 = _602 * _513; + float _605 = _490 * -0.006666666828095913f; + float _606 = _605 * _516; + float _607 = _606 * _543; + float _608 = _607 * _549; + float _609 = _605 * _519; + float _610 = _609 * _543; + float _611 = _610 * _549; + float _612 = _608 + 1.0f; + float _613 = _611 + 1.0f; + float _614 = _612 * _511; + float _615 = _613 * _513; + float _616 = _490 * -0.007777777966111898f; + float _617 = _616 * _516; + float _618 = _617 * _543; + float _619 = _618 * _549; + float _620 = _616 * _519; + float _621 = _620 * _543; + float _622 = _621 * _549; + float _623 = _619 + 1.0f; + float _624 = _622 + 1.0f; + float _625 = _623 * _511; + float _626 = _624 * _513; + float _627 = _490 * -0.008888889104127884f; + float _628 = _627 * _516; + float _629 = _628 * _543; + float _630 = _629 * _549; + float _631 = _627 * _519; + float _632 = _631 * _543; + float _633 = _632 * _549; + float _634 = _630 + 1.0f; + float _635 = _633 + 1.0f; + float _636 = _634 * _511; + float _637 = _635 * _513; + float _638 = _490 * -0.009999999776482582f; + float _639 = _638 * _516; + float _640 = _639 * _543; + float _641 = _640 * _549; + float _642 = _638 * _519; + float _643 = _642 * _543; + float _644 = _643 * _549; + float _645 = _641 + 1.0f; + float _646 = _644 + 1.0f; + float _647 = _645 * _511; + float _648 = _646 * _513; + float _649 = _21 * 0.10000000149011612f; + float _650 = _649 * _478; + float _651 = _649 * _479; + float _652 = _649 * _480; + float _654 = TonemapParam_000y; + float _656 = TonemapParam_002y; + float _658 = TonemapParam_001y; + float _659 = TonemapParam_000w; + float _660 = TonemapParam_000x; + float _661 = TonemapParam_002z; + float _662 = TonemapParam_001x; + float _663 = TonemapParam_001z; + float _664 = TonemapParam_001w; + float _665 = TonemapParam_002x; + float _666 = _465 * 0.10000000149011612f; + float _667 = _666 * _478; + float _668 = _466 * 0.10000000149011612f; + float _669 = _668 * _479; + float _670 = _467 * 0.10000000149011612f; + float _671 = _670 * _480; + do { + if (_31) { + float _673 = _559 + _483; + float _674 = _560 + _484; + float _675 = dot(float2(_673, _674), float2(_673, _674)); + float _676 = _675 * _468; + float _677 = _676 + 1.0f; + float _678 = _677 * _473; + float _679 = _678 * _673; + float _680 = _678 * _674; + float _681 = _679 + 0.5f; + float _682 = _680 + 0.5f; + float4 _683 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_681, _682), 0.0f); + float _684 = _683.x; + float _685 = _683.y; + float _686 = _683.z; + float _687 = _570 + _483; + float _688 = _571 + _484; + float _689 = dot(float2(_687, _688), float2(_687, _688)); + float _690 = _689 * _468; + float _691 = _690 + 1.0f; + float _692 = _687 * _473; + float _693 = _692 * _691; + float _694 = _688 * _473; + float _695 = _694 * _691; + float _696 = _693 + 0.5f; + float _697 = _695 + 0.5f; + float4 _698 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_696, _697), 0.0f); + float _699 = _698.x; + float _700 = _698.y; + float _701 = _698.z; + float _702 = _699 + _684; + float _703 = _700 + _685; + float _704 = _701 + _686; + float _705 = _581 + _483; + float _706 = _582 + _484; + float _707 = dot(float2(_705, _706), float2(_705, _706)); + float _708 = _707 * _468; + float _709 = _708 + 1.0f; + float _710 = _705 * _473; + float _711 = _710 * _709; + float _712 = _706 * _473; + float _713 = _712 * _709; + float _714 = _711 + 0.5f; + float _715 = _713 + 0.5f; + float4 _716 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_714, _715), 0.0f); + float _717 = _716.x; + float _718 = _716.y; + float _719 = _716.z; + float _720 = _702 + _717; + float _721 = _703 + _718; + float _722 = _704 + _719; + float _723 = _592 + _483; + float _724 = _593 + _484; + float _725 = dot(float2(_723, _724), float2(_723, _724)); + float _726 = _725 * _468; + float _727 = _726 + 1.0f; + float _728 = _723 * _473; + float _729 = _728 * _727; + float _730 = _724 * _473; + float _731 = _730 * _727; + float _732 = _729 + 0.5f; + float _733 = _731 + 0.5f; + float4 _734 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_732, _733), 0.0f); + float _735 = _734.x; + float _736 = _734.y; + float _737 = _734.z; + float _738 = _720 + _735; + float _739 = _721 + _736; + float _740 = _722 + _737; + float _741 = _603 + _483; + float _742 = _604 + _484; + float _743 = dot(float2(_741, _742), float2(_741, _742)); + float _744 = _743 * _468; + float _745 = _744 + 1.0f; + float _746 = _741 * _473; + float _747 = _746 * _745; + float _748 = _742 * _473; + float _749 = _748 * _745; + float _750 = _747 + 0.5f; + float _751 = _749 + 0.5f; + float4 _752 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_750, _751), 0.0f); + float _753 = _752.x; + float _754 = _752.y; + float _755 = _752.z; + float _756 = _738 + _753; + float _757 = _739 + _754; + float _758 = _740 + _755; + float _759 = _614 + _483; + float _760 = _615 + _484; + float _761 = dot(float2(_759, _760), float2(_759, _760)); + float _762 = _761 * _468; + float _763 = _762 + 1.0f; + float _764 = _759 * _473; + float _765 = _764 * _763; + float _766 = _760 * _473; + float _767 = _766 * _763; + float _768 = _765 + 0.5f; + float _769 = _767 + 0.5f; + float4 _770 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_768, _769), 0.0f); + float _771 = _770.x; + float _772 = _770.y; + float _773 = _770.z; + float _774 = _756 + _771; + float _775 = _757 + _772; + float _776 = _758 + _773; + float _777 = _625 + _483; + float _778 = _626 + _484; + float _779 = dot(float2(_777, _778), float2(_777, _778)); + float _780 = _779 * _468; + float _781 = _780 + 1.0f; + float _782 = _777 * _473; + float _783 = _782 * _781; + float _784 = _778 * _473; + float _785 = _784 * _781; + float _786 = _783 + 0.5f; + float _787 = _785 + 0.5f; + float4 _788 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_786, _787), 0.0f); + float _789 = _788.x; + float _790 = _788.y; + float _791 = _788.z; + float _792 = _774 + _789; + float _793 = _775 + _790; + float _794 = _776 + _791; + float _795 = _636 + _483; + float _796 = _637 + _484; + float _797 = dot(float2(_795, _796), float2(_795, _796)); + float _798 = _797 * _468; + float _799 = _798 + 1.0f; + float _800 = _795 * _473; + float _801 = _800 * _799; + float _802 = _796 * _473; + float _803 = _802 * _799; + float _804 = _801 + 0.5f; + float _805 = _803 + 0.5f; + float4 _806 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_804, _805), 0.0f); + float _807 = _806.x; + float _808 = _806.y; + float _809 = _806.z; + float _810 = _792 + _807; + float _811 = _793 + _808; + float _812 = _794 + _809; + float _813 = _647 + _483; + float _814 = _648 + _484; + float _815 = dot(float2(_813, _814), float2(_813, _814)); + float _816 = _815 * _468; + float _817 = _816 + 1.0f; + float _818 = _813 * _473; + float _819 = _818 * _817; + float _820 = _814 * _473; + float _821 = _820 * _817; + float _822 = _819 + 0.5f; + float _823 = _821 + 0.5f; + float4 _824 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_822, _823), 0.0f); + float _825 = _824.x; + float _826 = _824.y; + float _827 = _824.z; + float _828 = _810 + _825; + float _829 = _811 + _826; + float _830 = _812 + _827; + float _831 = _650 * _828; + float _832 = _651 * _829; + float _833 = _652 * _830; + float _834 = _831 * _656; + bool _835 = (_831 >= _654); + float _836 = _834 * _834; + float _837 = _834 * 2.0f; + float _838 = 3.0f - _837; + float _839 = _836 * _838; + float _840 = _832 * _656; + bool _841 = (_832 >= _654); + float _842 = _840 * _840; + float _843 = _840 * 2.0f; + float _844 = 3.0f - _843; + float _845 = _842 * _844; + float _846 = _833 * _656; + bool _847 = (_833 >= _654); + float _848 = _846 * _846; + float _849 = _846 * 2.0f; + float _850 = 3.0f - _849; + float _851 = _848 * _850; + float _852 = 1.0f - _839; + float _853 = _835 ? 0.0f : _852; + float _854 = 1.0f - _845; + float _855 = _841 ? 0.0f : _854; + float _856 = 1.0f - _851; + float _857 = _847 ? 0.0f : _856; + bool _858 = (_831 < _658); + bool _859 = (_832 < _658); + bool _860 = (_833 < _658); + float _861 = _858 ? 0.0f : 1.0f; + float _862 = _859 ? 0.0f : 1.0f; + float _863 = _860 ? 0.0f : 1.0f; + float _864 = 1.0f - _861; + float _865 = _864 - _853; + float _866 = 1.0f - _862; + float _867 = _866 - _855; + float _868 = 1.0f - _863; + float _869 = _868 - _857; + float _870 = log2(_834); + float _871 = log2(_840); + float _872 = log2(_846); + float _873 = _870 * _659; + float _874 = _871 * _659; + float _875 = _872 * _659; + float _876 = exp2(_873); + float _877 = exp2(_874); + float _878 = exp2(_875); + float _879 = _853 * _876; + float _880 = _879 * _654; + float _881 = _877 * _855; + float _882 = _881 * _654; + float _883 = _878 * _857; + float _884 = _883 * _654; + float _885 = _660 * _831; + float _886 = _660 * _832; + float _887 = _660 * _833; + float _888 = _885 + _661; + float _889 = _886 + _661; + float _890 = _887 + _661; + float _891 = _888 * _865; + float _892 = _889 * _867; + float _893 = _890 * _869; + float _894 = _664 * _831; + float _895 = _664 * _832; + float _896 = _664 * _833; + float _897 = _894 + _665; + float _898 = _895 + _665; + float _899 = _896 + _665; + float _900 = exp2(_897); + float _901 = exp2(_898); + float _902 = exp2(_899); + float _903 = _900 * _663; + float _904 = _901 * _663; + float _905 = _902 * _663; + float _906 = _662 - _903; + float _907 = _662 - _904; + float _908 = _662 - _905; + float _909 = _906 * _861; + float _910 = _907 * _862; + float _911 = _908 * _863; + float _912 = _880 + _667; + float _913 = _912 + _891; + float _914 = _913 + _909; + float _915 = _882 + _669; + float _916 = _915 + _892; + float _917 = _916 + _910; + float _918 = _884 + _671; + float _919 = _918 + _893; + float _920 = _919 + _911; + _1435 = _914; + _1436 = _917; + _1437 = _920; + } else { + float _922 = _483 + 0.5f; + float _923 = _922 + _559; + float _924 = _484 + 0.5f; + float _925 = _924 + _560; + float _926 = _922 + _570; + float _927 = _924 + _571; + float _928 = _922 + _581; + float _929 = _924 + _582; + float _930 = _922 + _592; + float _931 = _924 + _593; + float _932 = _922 + _603; + float _933 = _924 + _604; + float _934 = _922 + _614; + float _935 = _924 + _615; + float _936 = _922 + _625; + float _937 = _924 + _626; + float _938 = _922 + _636; + float _939 = _924 + _637; + float _940 = _922 + _647; + float _941 = _924 + _648; + if (_33) { + float _943 = _923 * 2.0f; + float _944 = _925 * 2.0f; + float _945 = _943 + -1.0f; + float _946 = _944 + -1.0f; + float _947 = _945 * _945; + float _948 = _947 + 1.0f; + float _949 = sqrt(_948); + float _950 = 1.0f / _949; + float _951 = _950 + _469; + float _952 = _949 * _471; + float _953 = _952 * _951; + float _954 = _950 + -1.0f; + float _955 = _954 * _470; + float _956 = _955 + 1.0f; + float _957 = _472 * 0.5f; + float _958 = _957 * _953; + float _959 = _958 * _945; + float _960 = _957 * _956; + float _961 = _960 * _953; + float _962 = _961 * _946; + float _963 = _959 + 0.5f; + float _964 = _962 + 0.5f; + float4 _965 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_963, _964), 0.0f); + float _966 = _965.x; + float _967 = _965.y; + float _968 = _965.z; + float _969 = _926 * 2.0f; + float _970 = _927 * 2.0f; + float _971 = _969 + -1.0f; + float _972 = _970 + -1.0f; + float _973 = _971 * _971; + float _974 = _973 + 1.0f; + float _975 = sqrt(_974); + float _976 = 1.0f / _975; + float _977 = _976 + _469; + float _978 = _975 * _471; + float _979 = _978 * _977; + float _980 = _976 + -1.0f; + float _981 = _980 * _470; + float _982 = _981 + 1.0f; + float _983 = _957 * _971; + float _984 = _983 * _979; + float _985 = _957 * _972; + float _986 = _985 * _982; + float _987 = _986 * _979; + float _988 = _984 + 0.5f; + float _989 = _987 + 0.5f; + float4 _990 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_988, _989), 0.0f); + float _991 = _990.x; + float _992 = _990.y; + float _993 = _990.z; + float _994 = _991 + _966; + float _995 = _992 + _967; + float _996 = _993 + _968; + float _997 = _928 * 2.0f; + float _998 = _929 * 2.0f; + float _999 = _997 + -1.0f; + float _1000 = _998 + -1.0f; + float _1001 = _999 * _999; + float _1002 = _1001 + 1.0f; + float _1003 = sqrt(_1002); + float _1004 = 1.0f / _1003; + float _1005 = _1004 + _469; + float _1006 = _1003 * _471; + float _1007 = _1006 * _1005; + float _1008 = _1004 + -1.0f; + float _1009 = _1008 * _470; + float _1010 = _1009 + 1.0f; + float _1011 = _957 * _999; + float _1012 = _1011 * _1007; + float _1013 = _957 * _1000; + float _1014 = _1013 * _1010; + float _1015 = _1014 * _1007; + float _1016 = _1012 + 0.5f; + float _1017 = _1015 + 0.5f; + float4 _1018 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1016, _1017), 0.0f); + float _1019 = _1018.x; + float _1020 = _1018.y; + float _1021 = _1018.z; + float _1022 = _994 + _1019; + float _1023 = _995 + _1020; + float _1024 = _996 + _1021; + float _1025 = _930 * 2.0f; + float _1026 = _931 * 2.0f; + float _1027 = _1025 + -1.0f; + float _1028 = _1026 + -1.0f; + float _1029 = _1027 * _1027; + float _1030 = _1029 + 1.0f; + float _1031 = sqrt(_1030); + float _1032 = 1.0f / _1031; + float _1033 = _1032 + _469; + float _1034 = _1031 * _471; + float _1035 = _1034 * _1033; + float _1036 = _1032 + -1.0f; + float _1037 = _1036 * _470; + float _1038 = _1037 + 1.0f; + float _1039 = _957 * _1027; + float _1040 = _1039 * _1035; + float _1041 = _957 * _1028; + float _1042 = _1041 * _1038; + float _1043 = _1042 * _1035; + float _1044 = _1040 + 0.5f; + float _1045 = _1043 + 0.5f; + float4 _1046 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1044, _1045), 0.0f); + float _1047 = _1046.x; + float _1048 = _1046.y; + float _1049 = _1046.z; + float _1050 = _1022 + _1047; + float _1051 = _1023 + _1048; + float _1052 = _1024 + _1049; + float _1053 = _932 * 2.0f; + float _1054 = _933 * 2.0f; + float _1055 = _1053 + -1.0f; + float _1056 = _1054 + -1.0f; + float _1057 = _1055 * _1055; + float _1058 = _1057 + 1.0f; + float _1059 = sqrt(_1058); + float _1060 = 1.0f / _1059; + float _1061 = _1060 + _469; + float _1062 = _1059 * _471; + float _1063 = _1062 * _1061; + float _1064 = _1060 + -1.0f; + float _1065 = _1064 * _470; + float _1066 = _1065 + 1.0f; + float _1067 = _957 * _1055; + float _1068 = _1067 * _1063; + float _1069 = _957 * _1056; + float _1070 = _1069 * _1066; + float _1071 = _1070 * _1063; + float _1072 = _1068 + 0.5f; + float _1073 = _1071 + 0.5f; + float4 _1074 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1072, _1073), 0.0f); + float _1075 = _1074.x; + float _1076 = _1074.y; + float _1077 = _1074.z; + float _1078 = _1050 + _1075; + float _1079 = _1051 + _1076; + float _1080 = _1052 + _1077; + float _1081 = _934 * 2.0f; + float _1082 = _935 * 2.0f; + float _1083 = _1081 + -1.0f; + float _1084 = _1082 + -1.0f; + float _1085 = _1083 * _1083; + float _1086 = _1085 + 1.0f; + float _1087 = sqrt(_1086); + float _1088 = 1.0f / _1087; + float _1089 = _1088 + _469; + float _1090 = _1087 * _471; + float _1091 = _1090 * _1089; + float _1092 = _1088 + -1.0f; + float _1093 = _1092 * _470; + float _1094 = _1093 + 1.0f; + float _1095 = _957 * _1083; + float _1096 = _1095 * _1091; + float _1097 = _957 * _1084; + float _1098 = _1097 * _1094; + float _1099 = _1098 * _1091; + float _1100 = _1096 + 0.5f; + float _1101 = _1099 + 0.5f; + float4 _1102 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1100, _1101), 0.0f); + float _1103 = _1102.x; + float _1104 = _1102.y; + float _1105 = _1102.z; + float _1106 = _1078 + _1103; + float _1107 = _1079 + _1104; + float _1108 = _1080 + _1105; + float _1109 = _936 * 2.0f; + float _1110 = _937 * 2.0f; + float _1111 = _1109 + -1.0f; + float _1112 = _1110 + -1.0f; + float _1113 = _1111 * _1111; + float _1114 = _1113 + 1.0f; + float _1115 = sqrt(_1114); + float _1116 = 1.0f / _1115; + float _1117 = _1116 + _469; + float _1118 = _1115 * _471; + float _1119 = _1118 * _1117; + float _1120 = _1116 + -1.0f; + float _1121 = _1120 * _470; + float _1122 = _1121 + 1.0f; + float _1123 = _957 * _1111; + float _1124 = _1123 * _1119; + float _1125 = _957 * _1112; + float _1126 = _1125 * _1122; + float _1127 = _1126 * _1119; + float _1128 = _1124 + 0.5f; + float _1129 = _1127 + 0.5f; + float4 _1130 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1128, _1129), 0.0f); + float _1131 = _1130.x; + float _1132 = _1130.y; + float _1133 = _1130.z; + float _1134 = _1106 + _1131; + float _1135 = _1107 + _1132; + float _1136 = _1108 + _1133; + float _1137 = _938 * 2.0f; + float _1138 = _939 * 2.0f; + float _1139 = _1137 + -1.0f; + float _1140 = _1138 + -1.0f; + float _1141 = _1139 * _1139; + float _1142 = _1141 + 1.0f; + float _1143 = sqrt(_1142); + float _1144 = 1.0f / _1143; + float _1145 = _1144 + _469; + float _1146 = _1143 * _471; + float _1147 = _1146 * _1145; + float _1148 = _1144 + -1.0f; + float _1149 = _1148 * _470; + float _1150 = _1149 + 1.0f; + float _1151 = _957 * _1139; + float _1152 = _1151 * _1147; + float _1153 = _957 * _1140; + float _1154 = _1153 * _1150; + float _1155 = _1154 * _1147; + float _1156 = _1152 + 0.5f; + float _1157 = _1155 + 0.5f; + float4 _1158 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1156, _1157), 0.0f); + float _1159 = _1158.x; + float _1160 = _1158.y; + float _1161 = _1158.z; + float _1162 = _1134 + _1159; + float _1163 = _1135 + _1160; + float _1164 = _1136 + _1161; + float _1165 = _940 * 2.0f; + float _1166 = _941 * 2.0f; + float _1167 = _1165 + -1.0f; + float _1168 = _1166 + -1.0f; + float _1169 = _1167 * _1167; + float _1170 = _1169 + 1.0f; + float _1171 = sqrt(_1170); + float _1172 = 1.0f / _1171; + float _1173 = _1172 + _469; + float _1174 = _1171 * _471; + float _1175 = _1174 * _1173; + float _1176 = _1172 + -1.0f; + float _1177 = _1176 * _470; + float _1178 = _1177 + 1.0f; + float _1179 = _957 * _1167; + float _1180 = _1179 * _1175; + float _1181 = _957 * _1168; + float _1182 = _1181 * _1178; + float _1183 = _1182 * _1175; + float _1184 = _1180 + 0.5f; + float _1185 = _1183 + 0.5f; + float4 _1186 = RE_POSTPROCESS_Color.SampleLevel(BilinearBorder, float2(_1184, _1185), 0.0f); + float _1187 = _1186.x; + float _1188 = _1186.y; + float _1189 = _1186.z; + float _1190 = _1162 + _1187; + float _1191 = _1163 + _1188; + float _1192 = _1164 + _1189; + float _1193 = _650 * _1190; + float _1194 = _651 * _1191; + float _1195 = _652 * _1192; + float _1196 = _1193 * _656; + bool _1197 = (_1193 >= _654); + float _1198 = _1196 * _1196; + float _1199 = _1196 * 2.0f; + float _1200 = 3.0f - _1199; + float _1201 = _1198 * _1200; + float _1202 = _1194 * _656; + bool _1203 = (_1194 >= _654); + float _1204 = _1202 * _1202; + float _1205 = _1202 * 2.0f; + float _1206 = 3.0f - _1205; + float _1207 = _1204 * _1206; + float _1208 = _1195 * _656; + bool _1209 = (_1195 >= _654); + float _1210 = _1208 * _1208; + float _1211 = _1208 * 2.0f; + float _1212 = 3.0f - _1211; + float _1213 = _1210 * _1212; + float _1214 = 1.0f - _1201; + float _1215 = _1197 ? 0.0f : _1214; + float _1216 = 1.0f - _1207; + float _1217 = _1203 ? 0.0f : _1216; + float _1218 = 1.0f - _1213; + float _1219 = _1209 ? 0.0f : _1218; + bool _1220 = (_1193 < _658); + bool _1221 = (_1194 < _658); + bool _1222 = (_1195 < _658); + float _1223 = _1220 ? 0.0f : 1.0f; + float _1224 = _1221 ? 0.0f : 1.0f; + float _1225 = _1222 ? 0.0f : 1.0f; + float _1226 = 1.0f - _1223; + float _1227 = _1226 - _1215; + float _1228 = 1.0f - _1224; + float _1229 = _1228 - _1217; + float _1230 = 1.0f - _1225; + float _1231 = _1230 - _1219; + float _1232 = log2(_1196); + float _1233 = log2(_1202); + float _1234 = log2(_1208); + float _1235 = _1232 * _659; + float _1236 = _1233 * _659; + float _1237 = _1234 * _659; + float _1238 = exp2(_1235); + float _1239 = exp2(_1236); + float _1240 = exp2(_1237); + float _1241 = _1215 * _1238; + float _1242 = _1241 * _654; + float _1243 = _1239 * _1217; + float _1244 = _1243 * _654; + float _1245 = _1240 * _1219; + float _1246 = _1245 * _654; + float _1247 = _660 * _1193; + float _1248 = _660 * _1194; + float _1249 = _660 * _1195; + float _1250 = _1247 + _661; + float _1251 = _1248 + _661; + float _1252 = _1249 + _661; + float _1253 = _1250 * _1227; + float _1254 = _1251 * _1229; + float _1255 = _1252 * _1231; + float _1256 = _664 * _1193; + float _1257 = _664 * _1194; + float _1258 = _664 * _1195; + float _1259 = _1256 + _665; + float _1260 = _1257 + _665; + float _1261 = _1258 + _665; + float _1262 = exp2(_1259); + float _1263 = exp2(_1260); + float _1264 = exp2(_1261); + float _1265 = _1262 * _663; + float _1266 = _1263 * _663; + float _1267 = _1264 * _663; + float _1268 = _662 - _1265; + float _1269 = _662 - _1266; + float _1270 = _662 - _1267; + float _1271 = _1268 * _1223; + float _1272 = _1269 * _1224; + float _1273 = _1270 * _1225; + float _1274 = _1242 + _667; + float _1275 = _1274 + _1253; + float _1276 = _1275 + _1271; + float _1277 = _1244 + _669; + float _1278 = _1277 + _1254; + float _1279 = _1278 + _1272; + float _1280 = _1246 + _671; + float _1281 = _1280 + _1255; + float _1282 = _1281 + _1273; + _1435 = _1276; + _1436 = _1279; + _1437 = _1282; + } else { + float4 _1284 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_923, _925), 0.0f); + float _1285 = _1284.x; + float _1286 = _1284.y; + float _1287 = _1284.z; + float4 _1288 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_926, _927), 0.0f); + float _1289 = _1288.x; + float _1290 = _1288.y; + float _1291 = _1288.z; + float _1292 = _1289 + _1285; + float _1293 = _1290 + _1286; + float _1294 = _1291 + _1287; + float4 _1295 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_928, _929), 0.0f); + float _1296 = _1295.x; + float _1297 = _1295.y; + float _1298 = _1295.z; + float _1299 = _1292 + _1296; + float _1300 = _1293 + _1297; + float _1301 = _1294 + _1298; + float4 _1302 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_930, _931), 0.0f); + float _1303 = _1302.x; + float _1304 = _1302.y; + float _1305 = _1302.z; + float _1306 = _1299 + _1303; + float _1307 = _1300 + _1304; + float _1308 = _1301 + _1305; + float4 _1309 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_932, _933), 0.0f); + float _1310 = _1309.x; + float _1311 = _1309.y; + float _1312 = _1309.z; + float _1313 = _1306 + _1310; + float _1314 = _1307 + _1311; + float _1315 = _1308 + _1312; + float4 _1316 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_934, _935), 0.0f); + float _1317 = _1316.x; + float _1318 = _1316.y; + float _1319 = _1316.z; + float _1320 = _1313 + _1317; + float _1321 = _1314 + _1318; + float _1322 = _1315 + _1319; + float4 _1323 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_936, _937), 0.0f); + float _1324 = _1323.x; + float _1325 = _1323.y; + float _1326 = _1323.z; + float _1327 = _1320 + _1324; + float _1328 = _1321 + _1325; + float _1329 = _1322 + _1326; + float4 _1330 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_938, _939), 0.0f); + float _1331 = _1330.x; + float _1332 = _1330.y; + float _1333 = _1330.z; + float _1334 = _1327 + _1331; + float _1335 = _1328 + _1332; + float _1336 = _1329 + _1333; + float4 _1337 = RE_POSTPROCESS_Color.SampleLevel(BilinearClamp, float2(_940, _941), 0.0f); + float _1338 = _1337.x; + float _1339 = _1337.y; + float _1340 = _1337.z; + float _1341 = _1334 + _1338; + float _1342 = _1335 + _1339; + float _1343 = _1336 + _1340; + float _1344 = _650 * _1341; + float _1345 = _651 * _1342; + float _1346 = _652 * _1343; + float _1347 = _1344 * _656; + bool _1348 = (_1344 >= _654); + float _1349 = _1347 * _1347; + float _1350 = _1347 * 2.0f; + float _1351 = 3.0f - _1350; + float _1352 = _1349 * _1351; + float _1353 = _1345 * _656; + bool _1354 = (_1345 >= _654); + float _1355 = _1353 * _1353; + float _1356 = _1353 * 2.0f; + float _1357 = 3.0f - _1356; + float _1358 = _1355 * _1357; + float _1359 = _1346 * _656; + bool _1360 = (_1346 >= _654); + float _1361 = _1359 * _1359; + float _1362 = _1359 * 2.0f; + float _1363 = 3.0f - _1362; + float _1364 = _1361 * _1363; + float _1365 = 1.0f - _1352; + float _1366 = _1348 ? 0.0f : _1365; + float _1367 = 1.0f - _1358; + float _1368 = _1354 ? 0.0f : _1367; + float _1369 = 1.0f - _1364; + float _1370 = _1360 ? 0.0f : _1369; + bool _1371 = (_1344 < _658); + bool _1372 = (_1345 < _658); + bool _1373 = (_1346 < _658); + float _1374 = _1371 ? 0.0f : 1.0f; + float _1375 = _1372 ? 0.0f : 1.0f; + float _1376 = _1373 ? 0.0f : 1.0f; + float _1377 = 1.0f - _1374; + float _1378 = _1377 - _1366; + float _1379 = 1.0f - _1375; + float _1380 = _1379 - _1368; + float _1381 = 1.0f - _1376; + float _1382 = _1381 - _1370; + float _1383 = log2(_1347); + float _1384 = log2(_1353); + float _1385 = log2(_1359); + float _1386 = _1383 * _659; + float _1387 = _1384 * _659; + float _1388 = _1385 * _659; + float _1389 = exp2(_1386); + float _1390 = exp2(_1387); + float _1391 = exp2(_1388); + float _1392 = _1366 * _1389; + float _1393 = _1392 * _654; + float _1394 = _1390 * _1368; + float _1395 = _1394 * _654; + float _1396 = _1391 * _1370; + float _1397 = _1396 * _654; + float _1398 = _660 * _1344; + float _1399 = _660 * _1345; + float _1400 = _660 * _1346; + float _1401 = _1398 + _661; + float _1402 = _1399 + _661; + float _1403 = _1400 + _661; + float _1404 = _1401 * _1378; + float _1405 = _1402 * _1380; + float _1406 = _1403 * _1382; + float _1407 = _664 * _1344; + float _1408 = _664 * _1345; + float _1409 = _664 * _1346; + float _1410 = _1407 + _665; + float _1411 = _1408 + _665; + float _1412 = _1409 + _665; + float _1413 = exp2(_1410); + float _1414 = exp2(_1411); + float _1415 = exp2(_1412); + float _1416 = _1413 * _663; + float _1417 = _1414 * _663; + float _1418 = _1415 * _663; + float _1419 = _662 - _1416; + float _1420 = _662 - _1417; + float _1421 = _662 - _1418; + float _1422 = _1419 * _1374; + float _1423 = _1420 * _1375; + float _1424 = _1421 * _1376; + float _1425 = _1393 + _667; + float _1426 = _1425 + _1404; + float _1427 = _1426 + _1422; + float _1428 = _1395 + _669; + float _1429 = _1428 + _1405; + float _1430 = _1429 + _1423; + float _1431 = _1397 + _671; + float _1432 = _1431 + _1406; + float _1433 = _1432 + _1424; + _1435 = _1427; + _1436 = _1430; + _1437 = _1433; + } + } + bool _1438 = (_488 > 0.0f); + _1463 = _1435; + _1464 = _1436; + _1465 = _1437; + do { + if (_1438) { + float _1440 = _511 * _511; + float _1441 = _513 * _513; + float _1442 = _1440 + _1441; + float _1443 = sqrt(_1442); + float _1444 = _1443 * _485; + float _1445 = _1444 + _486; + float _1446 = saturate(_1445); + float _1447 = _1446 * 2.0f; + float _1448 = 3.0f - _1447; + float _1449 = _1446 * _1446; + float _1450 = _1449 * _488; + float _1451 = _1450 * _1448; + float _1452 = _1451 + _489; + float _1453 = _1435 - _465; + float _1454 = _1436 - _466; + float _1455 = _1437 - _467; + float _1456 = _1452 * _1453; + float _1457 = _1452 * _1454; + float _1458 = _1452 * _1455; + float _1459 = _1456 + _465; + float _1460 = _1457 + _466; + float _1461 = _1458 + _467; + _1463 = _1459; + _1464 = _1460; + _1465 = _1461; + } + float _1466 = _1463 - _465; + float _1467 = _1464 - _466; + float _1468 = _1465 - _467; + float _1469 = _1466 * _501; + float _1470 = _1467 * _501; + float _1471 = _1468 * _501; + float _1472 = _1469 + _465; + float _1473 = _1470 + _466; + float _1474 = _1471 + _467; + _1476 = _1472; + _1477 = _1473; + _1478 = _1474; + } while (false); + } while (false); + } + } + int _1479 = _25 & 2; + bool _1480 = (_1479 == 0); + _1577 = _1476; + _1578 = _1477; + _1579 = _1478; + if (!_1480) { + float _1483 = FilmGrainParam_000x; + float _1484 = FilmGrainParam_000y; + float _1485 = FilmGrainParam_000z; + float _1486 = FilmGrainParam_000w; + float _1488 = FilmGrainParam_001x; + float _1489 = FilmGrainParam_001y; + float _1490 = FilmGrainParam_001z; + float _1491 = FilmGrainParam_001w; + float _1493 = SceneInfo_023x; + float _1494 = SceneInfo_023y; + float _1495 = _1493 * _1485; + float _1496 = _1494 * _1486; + float _1497 = _1495 + _22; + float _1498 = _1496 + _23; + float _1499 = _1497 * _1491; + float _1500 = floor(_1499); + float _1501 = _1498 * _1491; + float _1502 = floor(_1501); + float _1503 = dot(float2(_1500, _1502), float2(0.0671105608344078f, 0.005837149918079376f)); + float _1504 = frac(_1503); + float _1505 = _1504 * 52.98291778564453f; + float _1506 = frac(_1505); + bool _1507 = (_1506 < _1488); + _1520 = 0.0f; + do { + if (_1507) { + float _1509 = _1502 * _1500; + uint _1510 = uint(_1509); + uint _1511 = _1510 ^ 12345391; + uint _1512 = _1511 * 3635641; + uint _1513 = _1511 * 232681024; + uint _1514 = _1512 >> 26; + int _1515 = _1514 | _1513; + uint _1516 = _1515 ^ _1512; + float _1517 = float(_1516); + float _1518 = _1517 * 2.3283064365386963e-10f; + _1520 = _1518; + } + float _1521 = _1506 * 757.4846801757812f; + float _1522 = frac(_1521); + bool _1523 = (_1522 < _1488); + _1536 = 0.0f; + do { + if (_1523) { + int _1525 = (int)_1522; + uint _1526 = _1525 ^ 12345391; + uint _1527 = _1526 * 3635641; + uint _1528 = _1526 * 232681024; + uint _1529 = _1527 >> 26; + int _1530 = _1529 | _1528; + uint _1531 = _1530 ^ _1527; + float _1532 = float(_1531); + float _1533 = _1532 * 2.3283064365386963e-10f; + float _1534 = _1533 + -0.5f; + _1536 = _1534; + } + float _1537 = _1522 * 757.4846801757812f; + float _1538 = frac(_1537); + bool _1539 = (_1538 < _1488); + _1552 = 0.0f; + do { + if (_1539) { + int _1541 = (int)_1538; + uint _1542 = _1541 ^ 12345391; + uint _1543 = _1542 * 3635641; + uint _1544 = _1542 * 232681024; + uint _1545 = _1543 >> 26; + int _1546 = _1545 | _1544; + uint _1547 = _1546 ^ _1543; + float _1548 = float(_1547); + float _1549 = _1548 * 2.3283064365386963e-10f; + float _1550 = _1549 + -0.5f; + _1552 = _1550; + } + float _1553 = _1520 * _1483; + float _1554 = _1552 * _1484; + float _1555 = _1536 * _1484; + float _1556 = mad(_1555, 1.4019999504089355f, _1553); + float _1557 = mad(_1554, -0.3440000116825104f, _1553); + float _1558 = mad(_1555, -0.7139999866485596f, _1557); + float _1559 = mad(_1554, 1.7719999551773071f, _1553); + float _1560 = dot(float3(_1476, _1477, _1478), float3(0.29899999499320984f, -0.16899999976158142f, 0.5f)); + float _1561 = saturate(_1560); + float _1562 = 1.0f - _1561; + float _1563 = log2(_1562); + float _1564 = _1563 * _1489; + float _1565 = exp2(_1564); + float _1566 = _1565 * _1490; + float _1567 = _1556 - _1476; + float _1568 = _1558 - _1477; + float _1569 = _1559 - _1478; + float _1570 = _1566 * _1567; + float _1571 = _1566 * _1568; + float _1572 = _1566 * _1569; + float _1573 = _1570 + _1476; + float _1574 = _1571 + _1477; + float _1575 = _1572 + _1478; + _1577 = _1573; + _1578 = _1574; + _1579 = _1575; + } while (false); + } while (false); + } while (false); + } + int _1580 = _25 & 4; + bool _1581 = (_1580 == 0); + _1790 = _1577; + _1791 = _1578; + _1792 = _1579; + if (!_1581) { + float _1584 = ColorCorrectTexture_000y; + float _1585 = ColorCorrectTexture_000z; + float _1586 = ColorCorrectTexture_000w; + float _1588 = ColorCorrectTexture_001x; + float _1589 = ColorCorrectTexture_001y; + float _1590 = ColorCorrectTexture_001z; + float _1592 = ColorCorrectTexture_002x; + float _1593 = ColorCorrectTexture_002y; + float _1594 = ColorCorrectTexture_002z; + float _1596 = ColorCorrectTexture_003x; + float _1597 = ColorCorrectTexture_003y; + float _1598 = ColorCorrectTexture_003z; + float _1600 = ColorCorrectTexture_004x; + float _1601 = ColorCorrectTexture_004y; + float _1602 = ColorCorrectTexture_004z; + float _1603 = max(_1577, _1578); + float _1604 = max(_1603, _1579); + bool _1605 = (_1604 > 1.0f); + _1611 = _1577; + _1612 = _1578; + _1613 = _1579; + do { + if (_1605) { + float _1607 = _1577 / _1604; + float _1608 = _1578 / _1604; + float _1609 = _1579 / _1604; + _1611 = _1607; + _1612 = _1608; + _1613 = _1609; + } + float _1614 = _1586 * 0.5f; + bool _1615 = !(_1611 <= 0.0031308000907301903f); + do { + if (!_1615) { + float _1617 = _1611 * 12.920000076293945f; + _1625 = _1617; + } else { + float _1619 = log2(_1611); + float _1620 = _1619 * 0.4166666567325592f; + float _1621 = exp2(_1620); + float _1622 = _1621 * 1.0549999475479126f; + float _1623 = _1622 + -0.054999999701976776f; + _1625 = _1623; + } + bool _1626 = !(_1612 <= 0.0031308000907301903f); + do { + if (!_1626) { + float _1628 = _1612 * 12.920000076293945f; + _1636 = _1628; + } else { + float _1630 = log2(_1612); + float _1631 = _1630 * 0.4166666567325592f; + float _1632 = exp2(_1631); + float _1633 = _1632 * 1.0549999475479126f; + float _1634 = _1633 + -0.054999999701976776f; + _1636 = _1634; + } + bool _1637 = !(_1613 <= 0.0031308000907301903f); + do { + if (!_1637) { + float _1639 = _1613 * 12.920000076293945f; + _1647 = _1639; + } else { + float _1641 = log2(_1613); + float _1642 = _1641 * 0.4166666567325592f; + float _1643 = exp2(_1642); + float _1644 = _1643 * 1.0549999475479126f; + float _1645 = _1644 + -0.054999999701976776f; + _1647 = _1645; + } + float _1648 = 1.0f - _1586; + float _1649 = _1625 * _1648; + float _1650 = _1636 * _1648; + float _1651 = _1647 * _1648; + float _1652 = _1649 + _1614; + float _1653 = _1650 + _1614; + float _1654 = _1651 + _1614; +#if 0 + float4 _1655 = tTextureMap0.SampleLevel(TrilinearClamp, float3(_1652, _1653, _1654), 0.0f); +#else + float3 _1655 = LUTBlackCorrection(float3(_1611, _1612, _1613), tTextureMap0, lut_config); +#endif + float _1656 = _1655.x; + float _1657 = _1655.y; + float _1658 = _1655.z; + bool _1659 = (_1584 > 0.0f); + do { + if (_1659) { +#if 0 + float4 _1661 = tTextureMap1.SampleLevel(TrilinearClamp, float3(_1652, _1653, _1654), 0.0f); +#else + float3 _1661 = LUTBlackCorrection(float3(_1611, _1612, _1613), tTextureMap1, lut_config); +#endif + float _1662 = _1661.x; + float _1663 = _1661.y; + float _1664 = _1661.z; + float _1665 = _1662 - _1656; + float _1666 = _1663 - _1657; + float _1667 = _1664 - _1658; + float _1668 = _1665 * _1584; + float _1669 = _1666 * _1584; + float _1670 = _1667 * _1584; + float _1671 = _1668 + _1656; + float _1672 = _1669 + _1657; + float _1673 = _1670 + _1658; + bool _1674 = (_1585 > 0.0f); + _1770 = _1671; + _1771 = _1672; + _1772 = _1673; + if (_1674) { + bool _1676 = !(_1671 <= 0.0031308000907301903f); + do { + if (!_1676) { + float _1678 = _1671 * 12.920000076293945f; + _1686 = _1678; + } else { + float _1680 = log2(_1671); + float _1681 = _1680 * 0.4166666567325592f; + float _1682 = exp2(_1681); + float _1683 = _1682 * 1.0549999475479126f; + float _1684 = _1683 + -0.054999999701976776f; + _1686 = _1684; + } + bool _1687 = !(_1672 <= 0.0031308000907301903f); + do { + if (!_1687) { + float _1689 = _1672 * 12.920000076293945f; + _1697 = _1689; + } else { + float _1691 = log2(_1672); + float _1692 = _1691 * 0.4166666567325592f; + float _1693 = exp2(_1692); + float _1694 = _1693 * 1.0549999475479126f; + float _1695 = _1694 + -0.054999999701976776f; + _1697 = _1695; + } + bool _1698 = !(_1673 <= 0.0031308000907301903f); + do { + if (!_1698) { + float _1700 = _1673 * 12.920000076293945f; + _1708 = _1700; + } else { + float _1702 = log2(_1673); + float _1703 = _1702 * 0.4166666567325592f; + float _1704 = exp2(_1703); + float _1705 = _1704 * 1.0549999475479126f; + float _1706 = _1705 + -0.054999999701976776f; + _1708 = _1706; + } +#if 0 + float4 _1709 = tTextureMap2.SampleLevel(TrilinearClamp, float3(_1686, _1697, _1708), 0.0f); +#else + float3 _1709 = LUTBlackCorrection(float3(_1770, _1771, _1772), tTextureMap2, lut_config); +#endif + float _1710 = _1709.x; + float _1711 = _1709.y; + float _1712 = _1709.z; + float _1713 = _1710 - _1671; + float _1714 = _1711 - _1672; + float _1715 = _1712 - _1673; + float _1716 = _1713 * _1585; + float _1717 = _1714 * _1585; + float _1718 = _1715 * _1585; + float _1719 = _1716 + _1671; + float _1720 = _1717 + _1672; + float _1721 = _1718 + _1673; + _1770 = _1719; + _1771 = _1720; + _1772 = _1721; + } while (false); + } while (false); + } while (false); + } + } else { + bool _1723 = !(_1656 <= 0.0031308000907301903f); + do { + if (!_1723) { + float _1725 = _1656 * 12.920000076293945f; + _1733 = _1725; + } else { + float _1727 = log2(_1656); + float _1728 = _1727 * 0.4166666567325592f; + float _1729 = exp2(_1728); + float _1730 = _1729 * 1.0549999475479126f; + float _1731 = _1730 + -0.054999999701976776f; + _1733 = _1731; + } + bool _1734 = !(_1657 <= 0.0031308000907301903f); + do { + if (!_1734) { + float _1736 = _1657 * 12.920000076293945f; + _1744 = _1736; + } else { + float _1738 = log2(_1657); + float _1739 = _1738 * 0.4166666567325592f; + float _1740 = exp2(_1739); + float _1741 = _1740 * 1.0549999475479126f; + float _1742 = _1741 + -0.054999999701976776f; + _1744 = _1742; + } + bool _1745 = !(_1658 <= 0.0031308000907301903f); + do { + if (!_1745) { + float _1747 = _1658 * 12.920000076293945f; + _1755 = _1747; + } else { + float _1749 = log2(_1658); + float _1750 = _1749 * 0.4166666567325592f; + float _1751 = exp2(_1750); + float _1752 = _1751 * 1.0549999475479126f; + float _1753 = _1752 + -0.054999999701976776f; + _1755 = _1753; + } +#if 0 + float4 _1756 = tTextureMap2.SampleLevel(TrilinearClamp, float3(_1733, _1744, _1755), 0.0f); +#else + float3 _1756 = LUTBlackCorrection(float3(_1656, _1657, _1658), tTextureMap2, lut_config); +#endif + float _1757 = _1756.x; + float _1758 = _1756.y; + float _1759 = _1756.z; + float _1760 = _1757 - _1656; + float _1761 = _1758 - _1657; + float _1762 = _1759 - _1658; + float _1763 = _1760 * _1585; + float _1764 = _1761 * _1585; + float _1765 = _1762 * _1585; + float _1766 = _1763 + _1656; + float _1767 = _1764 + _1657; + float _1768 = _1765 + _1658; + _1770 = _1766; + _1771 = _1767; + _1772 = _1768; + } while (false); + } while (false); + } while (false); + } + float _1773 = _1770 * _1588; + float _1774 = mad(_1771, _1592, _1773); + float _1775 = mad(_1772, _1596, _1774); + float _1776 = _1775 + _1600; + float _1777 = _1770 * _1589; + float _1778 = mad(_1771, _1593, _1777); + float _1779 = mad(_1772, _1597, _1778); + float _1780 = _1779 + _1601; + float _1781 = _1770 * _1590; + float _1782 = mad(_1771, _1594, _1781); + float _1783 = mad(_1772, _1598, _1782); + float _1784 = _1783 + _1602; + _1790 = _1776; + _1791 = _1780; + _1792 = _1784; + if (_1605) { + float _1786 = _1776 * _1604; + float _1787 = _1780 * _1604; + float _1788 = _1784 * _1604; + _1790 = _1786; + _1791 = _1787; + _1792 = _1788; + } + } while (false); + } while (false); + } while (false); + } while (false); + } while (false); + } + int _1793 = _25 & 8; + bool _1794 = (_1793 == 0); + _1827 = _1790; + _1828 = _1791; + _1829 = _1792; + if (!_1794) { + float _1797 = ColorDeficientTable_000x; + float _1798 = ColorDeficientTable_000y; + float _1799 = ColorDeficientTable_000z; + float _1801 = ColorDeficientTable_001x; + float _1802 = ColorDeficientTable_001y; + float _1803 = ColorDeficientTable_001z; + float _1805 = ColorDeficientTable_002x; + float _1806 = ColorDeficientTable_002y; + float _1807 = ColorDeficientTable_002z; + float _1808 = _1797 * _1790; + float _1809 = _1798 * _1791; + float _1810 = _1808 + _1809; + float _1811 = _1799 * _1792; + float _1812 = _1810 + _1811; + float _1813 = _1801 * _1790; + float _1814 = _1802 * _1791; + float _1815 = _1813 + _1814; + float _1816 = _1803 * _1792; + float _1817 = _1815 + _1816; + float _1818 = _1805 * _1790; + float _1819 = _1806 * _1791; + float _1820 = _1818 + _1819; + float _1821 = _1807 * _1792; + float _1822 = _1820 + _1821; + float _1823 = saturate(_1812); + float _1824 = saturate(_1817); + float _1825 = saturate(_1822); + _1827 = _1823; + _1828 = _1824; + _1829 = _1825; + } + int _1830 = _25 & 16; + bool _1831 = (_1830 == 0); + _1898 = _1827; + _1899 = _1828; + _1900 = _1829; + if (!_1831) { + float _1834 = ImagePlaneParam_000x; + float _1835 = ImagePlaneParam_000y; + float _1836 = ImagePlaneParam_000z; + float _1837 = ImagePlaneParam_000w; + float _1839 = ImagePlaneParam_001x; + float _1840 = ImagePlaneParam_001y; + float _1842 = SceneInfo_023z; + float _1843 = SceneInfo_023w; + float _1844 = _1842 * _22; + float _1845 = _1843 * _23; + float4 _1846 = ImagePlameBase.SampleLevel(BilinearClamp, float2(_1844, _1845), 0.0f); + float _1847 = _1846.x; + float _1848 = _1846.y; + float _1849 = _1846.z; + float _1850 = _1846.w; + float _1851 = _1847 * _1834; + float _1852 = _1848 * _1835; + float _1853 = _1849 * _1836; + float _1854 = _1850 * _1837; + float _1855 = ImagePlameAlpha.SampleLevel(BilinearClamp, float2(_1844, _1845), 0.0f); + float _1856 = _1855.x; + float _1857 = _1856 * _1839; + float _1858 = _1857 + _1840; + float _1859 = saturate(_1858); + float _1860 = _1854 * _1859; + bool _1861 = (_1851 < 0.5f); + bool _1862 = (_1852 < 0.5f); + bool _1863 = (_1853 < 0.5f); + float _1864 = _1827 * 2.0f; + float _1865 = _1864 * _1851; + float _1866 = _1828 * 2.0f; + float _1867 = _1866 * _1852; + float _1868 = _1829 * 2.0f; + float _1869 = _1868 * _1853; + float _1870 = 1.0f - _1851; + float _1871 = 1.0f - _1852; + float _1872 = 1.0f - _1853; + float _1873 = 1.0f - _1827; + float _1874 = 1.0f - _1828; + float _1875 = 1.0f - _1829; + float _1876 = _1873 * 2.0f; + float _1877 = _1876 * _1870; + float _1878 = _1874 * 2.0f; + float _1879 = _1878 * _1871; + float _1880 = _1875 * 2.0f; + float _1881 = _1880 * _1872; + float _1882 = 1.0f - _1877; + float _1883 = 1.0f - _1879; + float _1884 = 1.0f - _1881; + float _1885 = _1861 ? _1865 : _1882; + float _1886 = _1862 ? _1867 : _1883; + float _1887 = _1863 ? _1869 : _1884; + float _1888 = _1885 - _1827; + float _1889 = _1886 - _1828; + float _1890 = _1887 - _1829; + float _1891 = _1888 * _1860; + float _1892 = _1889 * _1860; + float _1893 = _1890 * _1860; + float _1894 = _1891 + _1827; + float _1895 = _1892 + _1828; + float _1896 = _1893 + _1829; + _1898 = _1894; + _1899 = _1895; + _1900 = _1896; + } + SV_Target.x = _1898; + SV_Target.y = _1899; + SV_Target.z = _1900; + SV_Target.w = 0.0f; + +#if 0 // HDR Gamma boost + + SV_Target.rgb = AdjustGammaOnLuminance(SV_Target.rgb, 1.1); + +#endif + + return SV_Target; +} diff --git a/src/games/re2remake/addon.cpp b/src/games/re2remake/addon.cpp new file mode 100644 index 00000000..963e6507 --- /dev/null +++ b/src/games/re2remake/addon.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2024 Musa Haji + * Copyright (C) 2024 Carlos Lopez + * SPDX-License-Identifier: MIT + */ + +#include // Tonemap + Postfx +#include // Tonemap + Postfx - Vignette off +#include // BT.2020 + PQ Encoding + +#include +#include "../../mods/shader.hpp" + +namespace { + +renodx::mods::shader::CustomShaders custom_shaders = { + CustomShaderEntry(0x314A98A7), // Tonemap + Postfx + CustomShaderEntry(0x30D8372F), // Tonemap + Postfx - Vignette off + CustomShaderEntry(0xAF0777E5), // BT.2020 + PQ Encoding +}; + +} // namespace + +// NOLINTBEGIN(readability-identifier-naming) + +extern "C" __declspec(dllexport) const char* NAME = "RenoDX"; +extern "C" __declspec(dllexport) const char* DESCRIPTION = "RenoDX for Resident Evil 2 Remake"; + +// 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; + break; + case DLL_PROCESS_DETACH: + reshade::unregister_addon(h_module); + break; + } + + renodx::mods::shader::Use(fdw_reason, custom_shaders); + + return TRUE; +} \ No newline at end of file diff --git a/src/games/re2remake/shared.h b/src/games/re2remake/shared.h new file mode 100644 index 00000000..e1faef53 --- /dev/null +++ b/src/games/re2remake/shared.h @@ -0,0 +1,8 @@ +#ifndef SRC_RE2REMAKE_SHARED_H_ +#define SRC_RE2REMAKE_SHARED_H_ + +#ifndef __cplusplus +#include "../../shaders/renodx.hlsl" +#endif + +#endif // SRC_RE2REMAKE_SHARED_H_ \ No newline at end of file diff --git a/src/shaders/color.hlsl b/src/shaders/color.hlsl index fec64c3f..f1cef5a5 100644 --- a/src/shaders/color.hlsl +++ b/src/shaders/color.hlsl @@ -46,20 +46,32 @@ static const float3x3 XYZ_TO_AP1_MAT = float3x3( -0.6636628587f, 1.6153315917f, 0.0167563477f, 0.0117218943f, -0.0082844420f, 0.9883948585f); -static const float3x3 XYZ_TO_LMS_MAT = float3x3( - 0.3592832590121217f, 0.6976051147779502f, -0.0358915932320290f, - -0.1920808463704993f, 1.1004767970374321f, 0.0753748658519118f, - 0.0070797844607479f, 0.0748396662186362f, 0.8433265453898765f); - -static const float3x3 LMS_TO_XYZ_MAT = float3x3( - 2.07018005669561320, -1.32645687610302100, 0.206616006847855170, - 0.36498825003265756, 0.68046736285223520, -0.045421753075853236, - -0.04959554223893212, -0.04942116118675749, 1.187995941732803400); +static const float3x3 XYZ_TO_ICTCP_LMS_MAT = float3x3( + 0.359168797f, 0.697604775f, -0.0357883982f, + -0.192186400f, 1.10039842f, 0.0755404010f, + 0.00695759989f, 0.0749168023f, 0.843357980f); + +static const float3x3 ICTCP_LMS_TO_XYZ_MAT = float3x3( + 2.07036161f, -1.32659053f, 0.206681042f, + 0.364990383f, 0.680468797f, -0.0454616732f, + -0.0495028905f, -0.0495028905f, 1.18806946f); + +static const float3x3 BT709_TO_ICTCP_LMS_MAT = float3x3( + 0.295764088f, 0.623072445f, 0.0811667516f, + 0.156191974f, 0.727251648f, 0.116557933f, + 0.0351022854f, 0.156589955f, 0.808302998f +); + +static const float3x3 ICTCP_LMS_TO_BT709_MAT = float3x3( + 6.17353248f, -5.32089900f, 0.147354885f, + -1.32403194f, 2.56026983f, -0.236238613f, + -0.0115983877f, -0.264921456f, 1.27652633f +); static const float3x3 DISPLAYP3_TO_XYZ_MAT = float3x3( 0.4865709486f, 0.2656676932f, 0.1982172852f, 0.2289745641f, 0.6917385218f, 0.0792869141f, - -0.0000000000f, 0.0451133819f, 1.0439443689f); + 0.0000000000f, 0.0451133819f, 1.0439443689f); static const float3x3 XYZ_TO_DISPLAYP3_MAT = float3x3( 2.4934969119f, -0.9313836179f, -0.4027107845f, @@ -124,6 +136,60 @@ static const float3 BT601_Y = float3(0.299, 0.587, 0.114); // https://www.ilkeratalay.com/colorspacesfaq.php static const float3 BOURGIN_D65_Y = float3(0.222015, 0.706655, 0.071330); +namespace XYZ { +namespace from { +float3 xyY(float3 xyY) { + float3 XYZ; + + XYZ.xz = float2(xyY.x, (1.f - xyY.xy.x - xyY.xy.y)) / xyY.y * xyY[2]; + + XYZ.y = xyY[2]; + + return XYZ; +} + +float3 BT709(float3 bt709) { + return mul(BT709_TO_XYZ_MAT, bt709); +} +} // namespace from +} // namespace XYZ + +namespace xyY { +namespace from { +float3 XYZ(float3 XYZ) { + float xyz = XYZ.x + XYZ.y + XYZ.z; + + float3 xyY; + + xyY.xy = XYZ.xy / xyz; + + xyY[2] = XYZ.y; + + return xyY; +} + +float3 BT709(float3 bt709) { + float3 XYZ = XYZ::from::BT709(bt709); + + return xyY::from::XYZ(XYZ); +} +} // namespace from +} // namespace xyY + +namespace bt709 { +namespace from { +float3 XYZ(float3 XYZ) { + return mul(XYZ_TO_BT709_MAT, XYZ); +} + +float3 xyY(float3 xyY) { + float3 XYZ = XYZ::from::xyY(xyY); + + return bt709::from::XYZ(XYZ); +} +} // namespace from +} // namespace bt709 + namespace bt709 { static const float REFERENCE_WHITE = 100.f; namespace from { @@ -214,15 +280,16 @@ float3 Decode(float3 in_color, float scaling = 10000.f) { namespace ictcp { namespace from { float3 BT709(float3 bt709_color) { - float3 xyz_color = mul(BT709_TO_XYZ_MAT, bt709_color); - float3 lms_color = mul(XYZ_TO_LMS_MAT, xyz_color); + float3 lms_color = mul(BT709_TO_ICTCP_LMS_MAT, bt709_color); - float3x3 mat = float3x3( - 0.5000, 0.5000, 0.0000, - 1.6137, -3.3234, 1.7097, - 4.3780, -4.2455, -0.1325); + //L'M'S' -> ICtCp + float3x3 lms_to_ictcp = { + 0.5f, 0.5f, 0.f, + 1.61370003f, -3.32339620f, 1.70969617f, + 4.37806224f, -4.24553966f, -0.132522642f + }; - return mul(mat, pq::Encode(lms_color, 100.0f)); + return mul(lms_to_ictcp, pq::Encode(lms_color, 100.0f)); } } // namespace from } // namespace ictcp @@ -230,78 +297,111 @@ float3 BT709(float3 bt709_color) { namespace srgb { static const float REFERENCE_WHITE = 80.f; -float Encode(float channel) { - return (channel <= 0.0031308f) - ? (channel * 12.92f) - : (1.055f * pow(channel, 1.f / 2.4f) - 0.055f); -} - -float EncodeSafe(float channel) { - return (channel <= 0.0031308f) - ? (channel * 12.92f) - : (1.055f * renodx::math::PowSafe(channel, 1.f / 2.4f) - 0.055f); -} - -float3 Encode(float3 color) { - return float3( - Encode(color.r), - Encode(color.g), - Encode(color.b)); -} +#if __SHADER_TARGET_MAJOR <= 5 +#define ENCODE(T) \ + T Encode(T c) { \ + return (c <= 0.0031308f) \ + ? (c * 12.92f) \ + : (1.055f * pow(c, 1.f / 2.4f) - 0.055f); \ + } +#else +#define ENCODE(T) \ + T Encode(T c) { \ + return select(c <= 0.0031308f, c * 12.92f, 1.055f * pow(c, 1.f / 2.4f) - 0.055f); \ + } +#endif -float3 EncodeSafe(float3 color) { - return renodx::math::Sign(color) * Encode(abs(color)); -} +ENCODE(float) +ENCODE(float2) +ENCODE(float3) float4 Encode(float4 color) { return float4(Encode(color.rgb), color.a); } -float4 EncodeSafe(float4 color) { - return float4(EncodeSafe(color.rgb), color.a); -} +#if __SHADER_TARGET_MAJOR <= 5 +#define ENCODE_SAFE(T) \ + T EncodeSafe(T c) { \ + return (c <= 0.0031308f) \ + ? (c * 12.92f) \ + : (1.055f * renodx::math::PowSafe(c, 1.f / 2.4f) - 0.055f); \ + } +#else +#define ENCODE_SAFE(T) \ + T EncodeSafe(T c) { \ + return select(c <= 0.0031308f, c * 12.92f, 1.055f * renodx::math::PowSafe(c, 1.f / 2.4f) - 0.055f); \ + } +#endif -float Decode(float channel) { - return (channel <= 0.04045f) - ? (channel / 12.92f) - : pow((channel + 0.055f) / 1.055f, 2.4f); -} +ENCODE_SAFE(float) +ENCODE_SAFE(float2) +ENCODE_SAFE(float3) -float DecodeSafe(float channel) { - return (channel <= 0.04045f) - ? (channel / 12.92f) - : renodx::math::PowSafe((channel + 0.055f) / 1.055f, 2.4f); +float4 EncodeSafe(float4 color) { + return float4(EncodeSafe(color.rgb), color.a); } -float3 Decode(float3 color) { - return float3( - Decode(color.r), - Decode(color.g), - Decode(color.b)); -} +#if __SHADER_TARGET_MAJOR <= 5 +#define DECODE(T) \ + T Decode(T c) { \ + return (c <= 0.04045f) \ + ? (c / 12.92f) \ + : pow((c + 0.055f) / 1.055f, 2.4f); \ + } +#else +#define DECODE(T) \ + T Decode(T c) { \ + return select(c <= 0.04045f, c / 12.92f, pow((c + 0.055f) / 1.055f, 2.4f)); \ + } +#endif -float3 DecodeSafe(float3 color) { - return renodx::math::Sign(color) * Decode(abs(color)); -} +DECODE(float) +DECODE(float2) +DECODE(float3) float4 Decode(float4 color) { return float4(Decode(color.rgb), color.a); } +#if __SHADER_TARGET_MAJOR <= 5 +#define DECODE_SAFE(T) \ + T DecodeSafe(T c) { \ + return (c <= 0.04045f) \ + ? (c / 12.92f) \ + : renodx::math::PowSafe((c + 0.055f) / 1.055f, 2.4f); \ + } +#else +#define DECODE_SAFE(T) \ + T DecodeSafe(T c) { \ + return select(c <= 0.04045f, c / 12.92f, renodx::math::PowSafe((c + 0.055f) / 1.055f, 2.4f)); \ + } +#endif + +DECODE_SAFE(float) +DECODE_SAFE(float2) +DECODE_SAFE(float3) + float4 DecodeSafe(float4 color) { return float4(DecodeSafe(color.rgb), color.a); } +#undef ENCODE +#undef ENCODE_SAFE +#undef DECODE +#undef DECODE_SAFE + } // namespace srgb namespace srgba { float4 Encode(float4 color) { - return float4( - srgb::Encode(color.r), - srgb::Encode(color.g), - srgb::Encode(color.b), - srgb::Encode(color.a)); +#if __SHADER_TARGET_MAJOR <= 5 + return (color <= 0.0031308f) + ? (color * 12.92f) + : (1.055f * pow(color, 1.f / 2.4f) - 0.055f); +#else + return select(color <= 0.0031308f, color * 12.92f, 1.055f * pow(color, 1.f / 2.4f) - 0.055f); +#endif } float4 EncodeSafe(float4 color) { @@ -309,11 +409,13 @@ float4 EncodeSafe(float4 color) { } float4 Decode(float4 color) { - return float4( - srgb::Decode(color.r), - srgb::Decode(color.g), - srgb::Decode(color.b), - srgb::Decode(color.a)); +#if __SHADER_TARGET_MAJOR <= 5 + return (color <= 0.04045f) + ? (color / 12.92f) + : pow((color + 0.055f) / 1.055f, 2.4f); +#else + return select(color <= 0.04045f, color / 12.92f, pow((color + 0.055f) / 1.055f, 2.4f)); +#endif } float4 DecodeSafe(float4 color) { @@ -324,37 +426,46 @@ float4 DecodeSafe(float4 color) { namespace gamma { -float Encode(float color, float gamma = 2.2f) { - return pow(color, 1.f / gamma); -} +#define ENCODE(T) \ + T Encode(T c, float gamma = 2.2f) { \ + return pow(c, 1.f / gamma); \ + } -float3 Encode(float3 color, float gamma = 2.2f) { - return pow(color, 1.f / gamma); -} +ENCODE(float) +ENCODE(float2) +ENCODE(float3) -float EncodeSafe(float color, float gamma = 2.2f) { - return renodx::math::PowSafe(color, 1.f / gamma); -} +#define ENCODE_SAFE(T) \ + T EncodeSafe(T c, float gamma = 2.2f) { \ + return renodx::math::PowSafe(c, 1.f / gamma); \ + } -float3 EncodeSafe(float3 color, float gamma = 2.2f) { - return renodx::math::PowSafe(color, 1.f / gamma); -} +ENCODE_SAFE(float) +ENCODE_SAFE(float2) +ENCODE_SAFE(float3) -float Decode(float color, float gamma = 2.2f) { - return pow(color, gamma); -} +#define DECODE(T) \ + T Decode(T c, float gamma = 2.2f) { \ + return pow(c, gamma); \ + } -float3 Decode(float3 color, float gamma = 2.2f) { - return pow(color, gamma); -} +DECODE(float) +DECODE(float2) +DECODE(float3) -float DecodeSafe(float color, float gamma = 2.2f) { - return renodx::math::PowSafe(color, gamma); -} +#define DECODE_SAFE(T) \ + T DecodeSafe(T c, float gamma = 2.2f) { \ + return renodx::math::PowSafe(c, gamma); \ + } -float3 DecodeSafe(float3 color, float gamma = 2.2f) { - return renodx::math::PowSafe(color, gamma); -} +DECODE_SAFE(float) +DECODE_SAFE(float2) +DECODE_SAFE(float3) + +#undef ENCODE +#undef ENCODE_SAFE +#undef DECODE +#undef DECODE_SAFE } // namespace gamma @@ -371,41 +482,83 @@ struct EncodingParams { float cut; }; -float Encode(float x, EncodingParams params, bool use_cut = true) { - return (!use_cut || (x > params.cut)) - ? (params.c * log10((params.a * x) + params.b) + params.d) - : (params.e * x + params.f); -} - -float3 Encode(float3 color, EncodingParams params, bool use_cut = true) { - return float3(Encode(color.r, params, use_cut), Encode(color.g, params, use_cut), Encode(color.b, params, use_cut)); -} - -float Decode(float t, EncodingParams params, bool use_cut = true) { - return (t > (use_cut ? (params.e * params.cut + params.f) : params.f)) - ? (pow(10.f, (t - params.d) / params.c) - params.b) / params.a - : (t - params.f) / params.e; -} - -float3 Decode(float3 color, EncodingParams params, bool use_cut = true) { - return float3(Decode(color.r, params, use_cut), Decode(color.g, params, use_cut), Decode(color.b, params, use_cut)); -} - -#define GENERATE_ARRI_LOGC_FUNCTIONS \ - float Encode(float x, bool use_cut = true) { \ - return logc::Encode(x, PARAMS, use_cut); \ - } \ - \ - float3 Encode(float3 color, bool use_cut = true) { \ - return logc::Encode(color, PARAMS, use_cut); \ - } \ - \ - float Decode(float t, bool use_cut = true) { \ - return logc::Decode(t, PARAMS, use_cut); \ - } \ - \ - float3 Decode(float3 color, bool use_cut = true) { \ - return logc::Decode(color, PARAMS, use_cut); \ +#define ENCODE_CONDS (c > params.cut) +#define ENCODE_COND_TRUE (params.c * log10((params.a * c) + params.b) + params.d) +#define ENCODE_COND_FALSE (params.e * c + params.f) + +#if __SHADER_TARGET_MAJOR <= 5 +#define ENCODE(T) \ + T Encode(T c, EncodingParams params, bool use_cut = true) { \ + if (!use_cut) { \ + return ENCODE_COND_TRUE; \ + } \ + else { \ + return ENCODE_CONDS \ + ? ENCODE_COND_TRUE \ + : ENCODE_COND_FALSE; \ + } \ + } +#else +#define ENCODE(T) \ + T Encode(T c, EncodingParams params, bool use_cut = true) { \ + if (!use_cut) { \ + return ENCODE_COND_TRUE; \ + } \ + return select(ENCODE_CONDS, ENCODE_COND_TRUE, ENCODE_COND_FALSE); \ + } +#endif + +ENCODE(float) +ENCODE(float2) +ENCODE(float3) + +#define DECODE_CONDS_CUT (c > (params.e * params.cut + params.f)) +#define DECODE_CONDS_NO_CUT (c > params.f) +#define DECODE_COND_TRUE ((pow(10.f, (c - params.d) / params.c) - params.b) / params.a) +#define DECODE_COND_FALSE ((c - params.f) / params.e) + +#if __SHADER_TARGET_MAJOR <= 5 +#define DECODE(T) \ + T Decode(T c, EncodingParams params, bool use_cut = true) { \ + if (use_cut) { \ + return DECODE_CONDS_CUT \ + ? DECODE_COND_TRUE \ + : DECODE_COND_FALSE; \ + } \ + return DECODE_CONDS_NO_CUT \ + ? DECODE_COND_TRUE \ + : DECODE_COND_FALSE; \ + } +#else +#define DECODE(T) \ + T Decode(T c, EncodingParams params, bool use_cut = true) { \ + if (use_cut) { \ + return select(DECODE_CONDS_CUT, DECODE_COND_TRUE, DECODE_COND_FALSE); \ + } \ + return select(DECODE_CONDS_NO_CUT, DECODE_COND_TRUE, DECODE_COND_FALSE); \ + } +#endif + +DECODE(float) +DECODE(float2) +DECODE(float3) + +#undef ENCODE +#undef ENCODE_CONDS +#undef ENCODE_COND_TRUE +#undef ENCODE_COND_FALSE +#undef DECODE +#undef DECODE_CONDS_CUT +#undef DECODE_CONDS_NO_CUT +#undef DECODE_COND_TRUE +#undef DECODE_COND_FALSE + +#define GENERATE_ARRI_LOGC_FUNCTIONS(T) \ + T Encode(T c, bool use_cut = true) { \ + return logc::Encode(c, PARAMS, use_cut); \ + } \ + T Decode(T c, bool use_cut = true) { \ + return logc::Decode(c, PARAMS, use_cut); \ } namespace c800 { @@ -419,7 +572,9 @@ static const EncodingParams PARAMS = { 0.010591f, }; -GENERATE_ARRI_LOGC_FUNCTIONS; +GENERATE_ARRI_LOGC_FUNCTIONS(float) +GENERATE_ARRI_LOGC_FUNCTIONS(float2) +GENERATE_ARRI_LOGC_FUNCTIONS(float3) } // namespace c800 @@ -435,7 +590,9 @@ static const EncodingParams PARAMS = { 0.011361f }; -GENERATE_ARRI_LOGC_FUNCTIONS; +GENERATE_ARRI_LOGC_FUNCTIONS(float) +GENERATE_ARRI_LOGC_FUNCTIONS(float2) +GENERATE_ARRI_LOGC_FUNCTIONS(float3) } // namespace c1000 @@ -483,6 +640,73 @@ float3 OkLCh(float3 oklch) { } // namespace from } // namespace oklab +// Copyright 2022 - Aurélien PIERRE / darktable project +// URL: https://eng.aurelienpierre.com/2022/02/color-saturation-control-for-the-21th-century/ +// The following source code is released under the MIT license +// (https://opensource.org/licenses/MIT) with the following addenda: +// * Any reuse of this code shall include the names of the author and of the project, as well as the source URL, +// * Any implementation of this colour space MUST call it "darktable Uniform Color Space" or +// "darktable UCS" in the end - user interface of the software. +namespace dtucs_uvY { +namespace from { +static const float3x3 xyToUVD = { + -0.783941002840055f, 0.277512987809202f, 0.153836578598858f, + 0.745273540913283f, -0.205375866083878f, -0.165478376301988f, + 0.318707282433486f, 2.16743692732158f, 0.291320554395942f +}; + +static const float2x2 UVStarToUVStarPrime = { + -1.124983854323892f, -0.980483721769325f, + 1.86323315098672f, 1.971853092390862f +}; + +float3 BT709(float3 bt709) { + float3 xyY = xyY::from::BT709(bt709); + + float3 UVD = mul(xyToUVD, float3(xyY.xy, 1.f)); + + float2 UV = UVD.xy /= UVD.z; + + float2 UVStar = float2(1.39656225667f, 1.4513954287f) * UV / (abs(UV) + float2(1.49217352929f, 1.52488637914f)); + + float2 UVStarPrime = mul(UVStarToUVStarPrime, UVStar); + + return float3(UVStarPrime, xyY[2]); +} +} // namespace from +} // namespace dtucs_uvY + +namespace bt709 { +namespace from { +static const float2x2 UVStarPrimeToUVStar = { + -5.037522385190711f, -2.504856328185843f, + 4.760029407436461f, 2.874012963239247f +}; + +static const float3x3 UVToxyD = { + 0.167171472114775f, 0.141299802443708f, -0.00801531300850582f, + -0.150959086409163f, -0.155185060382272f, -0.00843312433578007f, + 0.940254742367256f, 1.f, -0.0256325967652889f +}; + +float3 dtucs_uvY(float3 uvY) { + float2 UVStar = mul(UVStarPrimeToUVStar, uvY.xy); + + float2 UV = float2(-1.49217352929f, -1.52488637914f) * UVStar / (abs(UVStar) - float2(1.39656225667f, 1.4513954287f)); + + float3 xyD = mul(UVToxyD, float3(UV, 1.f)); + + float3 xyY; + + xyY.xy = xyD.xy / xyD.z; + + xyY[2] = uvY[2]; + + return bt709::from::xyY(xyY); +} +} // namespace from +} // namespace bt709 + namespace bt2408 { static const float REFERENCE_WHITE = 203.f; } // namespace bt2408 @@ -510,16 +734,17 @@ float3 OkLCh(float3 oklch) { } float3 ICtCp(float3 col) { - float3x3 mat = float3x3( - 1.0, 0.00860514569398152, 0.11103560447547328, - 1.0, -0.00860514569398152, -0.11103560447547328, - 1.0, 0.56004885956263900, -0.32063747023212210); - col = mul(mat, col); + //ICtCp -> L'M'S' + float3x3 ictcp_to_lms = float3x3( + 1.f, 0.00860647484f, 0.111033529f, + 1.f, -0.00860647484f, -0.111033529f, + 1.f, 0.560046315f, -0.320631951f); + + col = mul(ictcp_to_lms, col); // 1.0f = 100 nits, 100.0f = 10k nits - col = bt2020::from::PQ(col, 100.f); - col = mul(LMS_TO_XYZ_MAT, col); - return mul(XYZ_TO_BT709_MAT, col); + col = pq::Decode(col, 100.f); + return mul(ICTCP_LMS_TO_BT709_MAT, col); } } // namespace from diff --git a/src/shaders/colorcorrect.hlsl b/src/shaders/colorcorrect.hlsl index 6ec80f45..8796e097 100644 --- a/src/shaders/colorcorrect.hlsl +++ b/src/shaders/colorcorrect.hlsl @@ -8,47 +8,41 @@ namespace renodx { namespace color { namespace correct { -float Gamma(float x, bool pow_to_srgb = false) { - if (pow_to_srgb) { - return srgb::Decode(gamma::Encode(x)); +#define GAMMA(T) \ + T Gamma(T c, bool pow_to_srgb = false) { \ + if (pow_to_srgb) { \ + return srgb::Decode(gamma::Encode(c)); \ + } \ + return gamma::Decode(srgb::Encode(c)); \ } - // srgb2pow - return gamma::Decode(srgb::Encode(x)); -} -float GammaSafe(float x, bool pow_to_srgb = false) { - if (pow_to_srgb) { - return renodx::math::Sign(x) * srgb::Decode(gamma::Encode(abs(x))); - } - return renodx::math::Sign(x) * gamma::Decode(srgb::Encode(abs(x))); -} +GAMMA(float) +GAMMA(float2) +GAMMA(float3) -float3 Gamma(float3 color, bool pow_to_srgb = false) { - return float3( - Gamma(color.r, pow_to_srgb), - Gamma(color.g, pow_to_srgb), - Gamma(color.b, pow_to_srgb)); +float4 Gamma(float4 color, bool pow_to_srgb = false) { + return float4(Gamma(color.rgb), color.a); } -float4 Gamma(float4 color, bool pow2srgb = false) { - return float4(Gamma(color.rgb, pow2srgb), color.a); -} +#define GAMMA_SAFE(T) \ + T GammaSafe(T c, bool pow_to_srgb = false) { \ + if (pow_to_srgb) { \ + return renodx::math::Sign(c) * srgb::Decode(gamma::Encode(abs(c))); \ + } \ + return renodx::math::Sign(c) * gamma::Decode(srgb::Encode(abs(c))); \ + } -float3 GammaSafe(float3 color, bool pow2srgb = false) { - float3 signs = renodx::math::Sign(color); - color = abs(color); - color = float3( - Gamma(color.r, pow2srgb), - Gamma(color.g, pow2srgb), - Gamma(color.b, pow2srgb)); - color *= signs; - return color; -} +GAMMA_SAFE(float) +GAMMA_SAFE(float2) +GAMMA_SAFE(float3) -float4 GammaSafe(float4 color, bool pow2srgb = false) { - return float4(GammaSafe(color.rgb, pow2srgb), color.a); +float4 GammaSafe(float4 color, bool pow_to_srgb = false) { + return float4(Gamma(color.rgb), color.a); } +#undef GAMMA +#undef GAMMA_SAFE + float3 HueOKLab(float3 incorrect_color, float3 correct_color, float strength = 1.f) { if (strength == 0.f) return incorrect_color; @@ -93,10 +87,35 @@ float3 HueICtCp(float3 incorrect_color, float3 correct_color, float strength = 1 return color; } +float3 HuedtUCSUV(float3 incorrect_color, float3 correct_color, float strength = 1.f) { + if (strength == 0.f) return incorrect_color; + + float3 correct_perceptual = renodx::color::dtucs_uvY::from::BT709(correct_color); + + float3 incorrect_perceptual = renodx::color::dtucs_uvY::from::BT709(incorrect_color); + + float chrominance_pre_adjust = distance(incorrect_perceptual.xy, 0); + + incorrect_perceptual.xy = lerp(incorrect_perceptual.xy, correct_perceptual.xy, strength); + + float chrominance_post_adjust = distance(incorrect_perceptual.xy, 0); + + if (chrominance_post_adjust != 0.f) { + incorrect_perceptual.xy *= chrominance_pre_adjust / chrominance_post_adjust; + } + + float3 color = renodx::color::bt709::from::dtucs_uvY(incorrect_perceptual); + color = renodx::color::bt709::clamp::AP1(color); + return color; +} + float3 Hue(float3 incorrect_color, float3 correct_color, float strength = 1.f, uint method = 0u) { if (method == 1u) { return HueICtCp(incorrect_color, correct_color, strength); } + else if (method == 2u) { + return HuedtUCSUV(incorrect_color, correct_color, strength); + } return HueOKLab(incorrect_color, correct_color, strength); } diff --git a/src/shaders/math.hlsl b/src/shaders/math.hlsl index 590bee69..ba171d06 100644 --- a/src/shaders/math.hlsl +++ b/src/shaders/math.hlsl @@ -10,15 +10,15 @@ static const float FLT10_MAX = 64512.f; static const float FLT11_MAX = 65024.f; static const float FLT16_MAX = 65504.f; -#if __SHADER_TARGET_MINOR >= 5 -#define SIGN_FUNCTION_GENERATOR(struct) \ - struct Sign(struct x) { \ - return mad(saturate(mad(x, FLT_MAX, 0.5f)), 2.f, -1.f); \ +#if __SHADER_TARGET_MAJOR >= 6 +#define SIGN_FUNCTION_GENERATOR(T) \ + T Sign(T x) { \ + return sign(x); \ } #else -#define SIGN_FUNCTION_GENERATOR(struct) \ - struct Sign(struct x) { \ - return saturate(x * FLT_MAX + 0.5f) * 2.f - 1.f; \ +#define SIGN_FUNCTION_GENERATOR(T) \ + T Sign(T x) { \ + return mad(saturate(mad(x, FLT_MAX, 0.5f)), 2.f, -1.f); \ } #endif diff --git a/src/utils/swapchain.hpp b/src/utils/swapchain.hpp index ffe11fa1..0dd2b89f 100644 --- a/src/utils/swapchain.hpp +++ b/src/utils/swapchain.hpp @@ -43,9 +43,9 @@ struct __declspec(uuid("4721e307-0cf3-4293-b4a5-40d0a4e62544")) DeviceData { struct __declspec(uuid("3cf9a628-8518-4509-84c3-9fbe9a295212")) CommandListData { std::vector current_render_targets; - reshade::api::resource_view current_depth_stencil; + reshade::api::resource_view current_depth_stencil = {0}; bool has_swapchain_render_target_dirty = true; - bool has_swapchain_render_target; + bool has_swapchain_render_target = false; }; static std::shared_mutex mutex; @@ -182,13 +182,13 @@ static bool HasBackBufferRenderTarget(reshade::api::command_list* cmd_list) { const std::shared_lock device_lock(device_data.mutex); bool found_swapchain_rtv = false; - for (uint32_t i = 0; i < count; i++) { - const reshade::api::resource_view rtv = cmd_list_data.current_render_targets[i]; - auto resource = device->get_resource_from_view(rtv); - if ((resource.handle != 0u) && device_data.back_buffers.contains(resource.handle)) { - found_swapchain_rtv = true; - break; - } + for (const auto& rtv : cmd_list_data.current_render_targets) { + if (rtv.handle == 0u) continue; + const auto& resource = device->get_resource_from_view(rtv); + if (resource.handle == 0u) continue; + if (!device_data.back_buffers.contains(resource.handle)) continue; + found_swapchain_rtv = true; + break; } cmd_list_data.has_swapchain_render_target_dirty = false; diff --git a/src/utils/trace.hpp b/src/utils/trace.hpp index 366c2216..6527ed59 100644 --- a/src/utils/trace.hpp +++ b/src/utils/trace.hpp @@ -1012,7 +1012,7 @@ static void OnBindDescriptorTables( uint32_t first, uint32_t count, const reshade::api::descriptor_table* tables) { - if (!trace_running && present_count >= MAX_PRESENT_COUNT) return; + if (!trace_running) return; auto* device = cmd_list->get_device(); auto& layout_data = device->get_private_data(); @@ -1020,10 +1020,11 @@ static void OnBindDescriptorTables( auto& descriptor_data = device->get_private_data(); for (uint32_t i = 0; i < count; ++i) { + auto layout_index = first + i; { std::stringstream s; s << "bind_descriptor_table(" << reinterpret_cast(layout.handle); - s << "[" << (first + i) << "]"; + s << "[" << layout_index << "]"; s << ", stages: " << stages << "(" << std::hex << static_cast(stages) << std::dec << ")"; s << ", table: " << reinterpret_cast(tables[i].handle); uint32_t base_offset = 0; @@ -1031,28 +1032,15 @@ static void OnBindDescriptorTables( device->get_descriptor_heap_offset(tables[i], 0, 0, &heap, &base_offset); s << ", heap: " << reinterpret_cast(heap.handle) << "[" << base_offset << "]"; - const std::shared_lock decriptor_lock(descriptor_data.mutex); - for (uint32_t j = 0; j < 13; ++j) { - auto origin_primary_key = std::pair(tables[i].handle, j); - if (auto pair = descriptor_data.table_descriptor_resource_views.find(origin_primary_key); - pair != descriptor_data.table_descriptor_resource_views.end()) { - auto update = pair->second; - auto view = renodx::utils::descriptor::GetResourceViewFromDescriptorUpdate(update); - if (view.handle != 0) { - auto& data = device->get_private_data(); - const std::shared_lock lock(data.mutex); - s << ", rsv[" << j << "]: " << reinterpret_cast(view.handle); - s << ", res[" << j << "]: " << reinterpret_cast(GetResourceByViewHandle(data, view.handle)); - } - } - } - s << ") [" << i << "]"; reshade::log::message(reshade::log::level::info, s.str().c_str()); } - const auto& info = layout_data.pipeline_layout_data[layout.handle]; - const auto& param = info.params.at(first + i); + auto pipeline_data_pair = layout_data.pipeline_layout_data.find(layout.handle); + if (pipeline_data_pair == layout_data.pipeline_layout_data.end()) continue; + const auto& info = pipeline_data_pair->second; + if (layout_index > info.params.size()) continue; + const auto& param = info.params.at(layout_index); for (uint32_t k = 0; k < param.descriptor_table.count; ++k) { const auto& range = param.descriptor_table.ranges[k]; @@ -1060,18 +1048,26 @@ static void OnBindDescriptorTables( // Skip unbounded ranges if (range.count == UINT32_MAX) continue; - if (range.type != reshade::api::descriptor_type::shader_resource_view - && range.type != reshade::api::descriptor_type::sampler_with_resource_view) { - continue; + switch (range.type) { + case reshade::api::descriptor_type::shader_resource_view: + case reshade::api::descriptor_type::sampler_with_resource_view: + case reshade::api::descriptor_type::buffer_shader_resource_view: + case reshade::api::descriptor_type::unordered_access_view: + break; + default: + continue; } uint32_t base_offset = 0; reshade::api::descriptor_heap heap = {0}; device->get_descriptor_heap_offset(tables[i], range.binding, 0, &heap, &base_offset); + const std::shared_lock descriptor_lock(descriptor_data.mutex); for (uint32_t j = 0; j < range.count; ++j) { - const auto& heap_data = descriptor_data.heaps[heap.handle]; + auto heap_pair = descriptor_data.heaps.find(heap.handle); + if (heap_pair == descriptor_data.heaps.end()) continue; + const auto& heap_data = heap_pair->second; auto offset = base_offset + j; if (offset >= heap_data.size()) continue; const auto& [descriptor_type, descriptor_data] = heap_data[offset]; @@ -1100,7 +1096,7 @@ static void OnBindDescriptorTables( { std::stringstream s; s << "bind_descriptor_table(" << reinterpret_cast(layout.handle); - s << "[" << (first + i) << "]"; + s << "[" << (layout_index) << "]"; s << ", rsv: " << reinterpret_cast(resource_view.handle); s << ", param: " << param.type; s << ", binding: " << range.binding;