Added New Mods and Profiles Folders

This is a complete rebuild of the modpack, with all new mods and updates for 1.5.3 of Anomaly.
This commit is contained in:
2025-01-14 05:07:53 -05:00
parent 85c665b107
commit 376b4b9689
21217 changed files with 546254 additions and 0 deletions
@@ -0,0 +1,168 @@
<!--
Anomaly Modconfiguration Menu strings
-->
<string_table>
<string id="ui_mcm_beef_nvg_title">
<text>Beef's NVG Settings</text>
</string>
<string id="ui_mcm_beef_nvg_title_2">
<text>Compatibility with Shader Based 2d Scopes</text>
</string>
<string id="ui_mcm_menu_beef_nvg">
<text>Beef's NVG</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_max_mcm">
<text>The max gain that can be applied to NVGs.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_max_mcm_desc">
<text>Higher values allow you more 'brightness', although it will eventually cap out. Recommend to set this based cloudy_dark_2 weather at midnight.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_min_mcm">
<text>The min gain that can be applied to NVGs.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_min_mcm_desc">
<text>Lower values allow you to turn down the NVGs more - very low values will even enable you to use the NVGs during daylight.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_offset_mcm">
<text>An offset applied to world brightness.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_offset_mcm_desc">
<text>1.0 leaves world brightness as-is, larger values multiply world brightness (but not light sources).</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_washout_thresh_mcm">
<text>The threshold for light source washout.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_washout_thresh_mcm_desc">
<text>Generally recommended to keep at 0.1, but can be increased to reduce washout on light sources slightly.
This value scales with the nvg gain so that higher gains have more washout and lower gains have less washout.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_view_through_scope_mcm">
<text>Can use NVG while Aiming Down Sights:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_view_through_scope_mcm_desc">
<text>If this box is checked, you can keep your NVGs on while ADS. If its is unchecked, your character will disable their NVGs while raising their weapon.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_stays_pda_mcm">
<text>NVGs stay on when viewing PDA:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_stays_pda_mcm_desc">
<text>If this box is unchecked, your NVGs automatically disable when looking at your PDA.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_tubes_mcm">
<text>Gen 1 Tube Setup: (Default single tube centered)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_tubes_mcm_desc">
<text>Choose the number of tubes for Gen 1 NVGs.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_tubes_mcm">
<text>Gen 2 Tube Setup: (Default dual tubes centered)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_tubes_mcm_desc">
<text>Choose the number of tubes for Gen 2 NVGs.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_tubes_mcm">
<text>Gen 3 Tube Setup: (Default quad tubes centered)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_tubes_mcm_desc">
<text>Choose the number of tubes for Gen 3 NVGs.</text>
</string>
<string id="ui_mcm_lst_single_centered">
<text>Single Tube, Centered</text>
</string>
<string id="ui_mcm_lst_single_left">
<text>Single Tube, Left Side</text>
</string>
<string id="ui_mcm_lst_single_right">
<text>Single Tube, Right Side</text>
</string>
<string id="ui_mcm_lst_dual_centered">
<text>Dual Tubes, Centered</text>
</string>
<string id="ui_mcm_lst_quad_centered">
<text>Quad Tubes, Centered</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_mode_mcm">
<text>Gen 1 Overlay Background: (Default is No Overlay)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_mode_mcm_desc">
<text>Choose what background overlay you want</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_mode_mcm">
<text>Gen 2 Overlay Background: (Default is Blurred Overlay)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_mode_mcm_desc">
<text>Choose what background overlay you want</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_mode_mcm">
<text>Gen 3 Overlay Background: (Default is Blurred Overlay)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_mode_mcm_desc">
<text>Choose what background overlay you want</text>
</string>
<string id="ui_mcm_lst_blurred_background">
<text>Blurred Overlay</text>
</string>
<string id="ui_mcm_lst_black_background">
<text>Black Overlay</text>
</string>
<string id="ui_mcm_lst_image_overlay">
<text>(Not implemented) Image Overlay</text>
</string>
<string id="ui_mcm_lst_clear_vision">
<text>No Overlay (clear vision)</text>
</string>
<string id="ui_mcm_beef_nvg_shader_scope_compat">
<text>If you have Shader Based 2d Scope, check this box</text>
</string>
<string id="ui_mcm_beef_nvg_shader_scope_compat_desc">
<text>Basically, due to shadering magic, if you have Shader Based 2d Scopes, you need to check this box. Otherwise, don't check this box.</text>
</string>
</string_table>
@@ -0,0 +1,155 @@
<!--
Anomaly Modconfiguration Menu strings
-->
<string_table>
<string id="ui_mcm_beef_nvg_title">
<text>Beef's NVG Íàñòðîéêè</text>
</string>
<string id="ui_mcm_menu_beef_nvg">
<text>Beef's NVG</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_max_mcm">
<text>Ìàêñèìàëüíîå óñèëåíèå ÏÍÂ.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_max_mcm_desc">
<text>Áîëåå âûñîêèå çíà÷åíèÿ ïîçâîëÿþò óâåëè÷èòü "ÿðêîñòü", íî ñ îïðåäåëåííûì ëèìèòîì. Ðåêîìåíäóåòñÿ óñòàíàâëèâàòü ýòó íàñòðîéêó íà îñíîâå ïðåñåòà ïîãîäû cloudy_dark_2 â ïîëíî÷ü.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_min_mcm">
<text>Ìèíèìàëüíîå óñèëåíèå ÏÍÂ.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_min_mcm_desc">
<text>Áîëåå íèçêèå çíà÷åíèÿ ïîçâîëÿþò åù¸ áîëüøå îñëàáëÿòü ÏÍ - î÷åíü íèçêèå çíà÷åíèÿ äàæå ïîçâîëÿò èñïîëüçîâàòü åãî äí¸ì.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_offset_mcm">
<text>Ñìåùåíèå, ïðèìåíÿåìîå ê ÿðêîñòè ìèðà.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gain_offset_mcm_desc">
<text>1.0 îñòàâëÿåò ÿðêîñòü ìèðà êàê åñòü, áîëüøèå çíà÷åíèÿ óìíîæàþò ÿðêîñòü ìèðà (íî íå èñòî÷íèêè ñâåòà).</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_washout_thresh_mcm">
<text>Ïîðîã äëÿ ðàçìûâàíèÿ èñòî÷íèêà ñâåòà.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_washout_thresh_mcm_desc">
<text>Îáû÷íî ðåêîìåíäóåòñÿ îñòàâèòü çíà÷åíèå íà 0,1, íî åãî ìîæíî óâåëè÷èòü, ÷òîáû íåìíîãî óìåíüøèòü ðàçìûâàíèå èñòî÷íèêîâ ñâåòà.
Ýòî çíà÷åíèå ñêåéëèòñÿ ñ êîýôôèöèåíòîì óñèëåíèÿ ÏÍÂ, òàê ÷òî áîëåå âûñîêèå êîýôôèöèåíòû óñèëåíèÿ èìåþò áîëüøèé ðàçìûâ, à áîëåå íèçêèå - ìåíüøèé ðàçìûâ.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_view_through_scope_mcm">
<text>Âîçìîæíîñòü èñïîëüçîâàòü ÏÍÂ ïðè ïðèöåëèâàíèè:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_view_through_scope_mcm_desc">
<text>Åñëè ýòà îïöèÿ âêëþ÷åíà, âû ìîæåòå äåðæàòü ñâîé ÏÍ âêëþ÷åííûì âî âðåìÿ ïðèöåëèâàíèÿ. Åñëè îïöèÿ îòêëþ÷åíà, âàø ïåðñîíàæ îòêëþ÷àåò ÏÍ ïðè ïðèöåëèâàíèè.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_stays_pda_mcm">
<text>ÏÍ îñòàåòñÿ âêëþ÷åííûì â ÊÏÊ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_stays_pda_mcm_desc">
<text>Åñëè ýòà îïöèÿ îòêëþ÷åíà, ÏÍ àâòîìàòè÷åñêè îòêëþ÷àåòñÿ ïðè ïðîñìîòðå âàøåãî ÊÏÊ.</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_tubes_mcm">
<text>Ðàñïîëîæåíèå òðóáîê ó ÏÍÂ 1 ïîêîëåíèÿ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_tubes_mcm_desc">
<text>Âûáåðèòå êîëè÷åñòâî òðóáîê äëÿ ÏÍ 1 ïîêîëåíèÿ. (ïî óìîë÷àíèþ 1 òðóáêà ïîñåðåäèíå)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_tubes_mcm">
<text>Ðàñïîëîæåíèå òðóáîê ó ÏÍÂ 2 ïîêîëåíèÿ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_tubes_mcm_desc">
<text>Âûáåðèòå êîëè÷åñòâî òðóáîê äëÿ ÏÍ 2 ïîêîëåíèÿ. (ïî óìîë÷àíèþ 2 òðóáêè ïîñåðåäèíå)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_tubes_mcm">
<text>Ðàñïîëîæåíèå òðóáîê ó ÏÍÂ 3 ïîêîëåíèÿ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_tubes_mcm_desc">
<text>Âûáåðèòå êîëè÷åñòâî òðóáîê äëÿ ÏÍ 3 ïîêîëåíèÿ. (ïî óìîë÷àíèþ 4 òðóáêè ïîñåðåäèíå)</text>
</string>
<string id="ui_mcm_lst_single_centered">
<text>Îäíà òðóáêà, ïîñåðèäèíå</text>
</string>
<string id="ui_mcm_lst_single_left">
<text>Îäíà òðóáêà, ñëåâà</text>
</string>
<string id="ui_mcm_lst_single_right">
<text>Îäíà òðóáêà, ñïðàâà</text>
</string>
<string id="ui_mcm_lst_dual_centered">
<text>Äâå òðóáêè, ïîñåðåäèíå</text>
</string>
<string id="ui_mcm_lst_quad_centered">
<text>×åòûðå òðóáêè, ïîñåðåäèíå</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_mode_mcm">
<text>Îâåðëåé ÏÍÂ 1 ïîêîëåíèÿ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen1_mode_mcm_desc">
<text>Âûáåðèòå æåëàåìûé ôîíîâûé îâåðëåé (ïî óìîë÷àíèþ Áåç îâåðëåÿ)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_mode_mcm">
<text>Îâåðëåé ÏÍÂ 2 ïîêîëåíèÿ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen2_mode_mcm_desc">
<text>Âûáåðèòå æåëàåìûé ôîíîâûé îâåðëåé (ïî óìîë÷àíèþ Ðàçìûòûé Îâåðëåé)</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_mode_mcm">
<text>Îâåðëåé ÏÍÂ 3 ïîêîëåíèÿ:</text>
</string>
<string id="ui_mcm_beef_nvg_nvg_gen3_mode_mcm_desc">
<text>Âûáåðèòå æåëàåìûé ôîíîâûé îâåðëåé (ïî óìîë÷àíèþ Ðàçìûòûé Îâåðëåé)</text>
</string>
<string id="ui_mcm_lst_blurred_background">
<text>Ðàçìûòûé Îâåðëåé</text>
</string>
<string id="ui_mcm_lst_black_background">
<text>׸ðíûé Îâåðëåé</text>
</string>
<string id="ui_mcm_lst_image_overlay">
<text>(Íå ðåàëèçîâàíî) Îâåðëåé Êàðòèíêà</text>
</string>
<string id="ui_mcm_lst_clear_vision">
<text>Áåç îâåðëåÿ (÷åòêàÿ âèäèìîñòü)</text>
</string>
</string_table>
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,567 @@
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
-- Beef NVG MCM values
local nvg_gain_max = 2.0 -- max value for nvg gain (brightness)
local nvg_gain_min = 0.5 -- min value for nvg gain (brightness)
local nvg_washout_thresh = 0.1 -- used to calculate washout effect on light sources
local nvg_view_through_scope = false -- can you keep your NVGs on when looking through scope?
local nvg_gain_offset = 1.0 -- offset for nvg gain to accomodate for brighter/darker worlds
local nvg_mode_gen1 = 3.0 -- overlay mode gen 1
local nvg_num_tubes_gen2 = 2.0 -- number of tubes for NVG gen 2
local nvg_mode_gen1 = 0.0 -- overlay mode gen 2
local nvg_num_tubes_gen3 = 4.0 -- number of tubes for NVG gen 3
local nvg_mode_gen1 = 0.0 -- overlay mode gen 3
local nvg_stays_pda = true -- disable nvg on PDA?
local shader_scope_compat = false -- compatibility with 2d shader scopes
local nvg_radius = 0.5 -- Radius of circles
-- Variables
local nvg_generation = 0 -- 1, 2, or 3
local nvg_num_tubes = 0 -- 1, 2, or 4 tubes -- 11 for single offset left and 12 for single offset right
local nvg_gain_current = 1 -- current gain setting
local gain_directionality = true -- directionality of brightness adjust
local vignette_amount = 0.05 -- standard vignette value
local vignette_current = 1.0 -- current vignette value, for turn-on/ turn-off effect
local vignette_speed = 1.4 -- how fast vignette changes
local glitch_power = 0 -- how much 'glitch' to add to NVGs
local nvg_mode = 0 -- overlay preset
local crt_latch = false -- latches crt effect on turn-on
local flip_latch = false -- latches flip down effect on turn-on
local nv_eff = {} -- to store the effect
local flip_speed = 1.4 -- how fast to flip down
local flip_down = 1 -- flip down value (1 all the way up, 100 all the way down)
-- Variables for turn-on animation
local torch_anm_state = 0
local torch_anm_start = 0
local torch_anm_time = 0
local mc_anm_time_1 = 0
local torch_anm_sec = "anim_headlamp"
local mc_anm_sec = "anim_mask_clean"
local snd_headlamp = sound_object('interface\\inv_torch')
local hide_hand_speed = 1.5
-- Variables for on-weapon zoom (and shader scopes compat)
local zoomed_in = false
local tube_count_temp = 0
--local vignette_temp = 0
local radius_temp
local scope_blur_temp = 0
local shader_scope_flag = false
local zoom = true
-- Variables for PDA auto-turn-off functionality
local disable_nvg = false
local normal_fov
-----------------------------------------------------------------------------
--
-----------------------------------------------------------------------------
function on_option_change()
nvg_gain_max = z_beefs_nvgs_mcm.get_config("nvg_gain_max_mcm")
nvg_gain_min = z_beefs_nvgs_mcm.get_config("nvg_gain_min_mcm")
nvg_gain_offset = z_beefs_nvgs_mcm.get_config("nvg_gain_offset_mcm")
nvg_washout_thresh = z_beefs_nvgs_mcm.get_config("nvg_washout_thresh_mcm")
nvg_view_through_scope = z_beefs_nvgs_mcm.get_config("nvg_view_through_scope_mcm")
nvg_num_tubes_gen1 = z_beefs_nvgs_mcm.get_config("nvg_gen1_tubes_mcm")
nvg_num_tubes_gen2 = z_beefs_nvgs_mcm.get_config("nvg_gen2_tubes_mcm")
nvg_num_tubes_gen3 = z_beefs_nvgs_mcm.get_config("nvg_gen3_tubes_mcm")
nvg_mode_gen1 = z_beefs_nvgs_mcm.get_config("nvg_gen1_mode_mcm")
nvg_mode_gen2 = z_beefs_nvgs_mcm.get_config("nvg_gen2_mode_mcm")
nvg_mode_gen3 = z_beefs_nvgs_mcm.get_config("nvg_gen3_mode_mcm")
nvg_stays_pda = z_beefs_nvgs_mcm.get_config("nvg_stays_pda_mcm")
shader_scope_compat = z_beefs_nvgs_mcm.get_config("shader_scope_compat")
end
-----------------------------------------------------------------------------
-- NVG DATA PACKING AND UPDATE FUNCTION
-----------------------------------------------------------------------------
function pack_nvg_data()
local x_1 = tostring(nvg_generation) -- Generation (1,2,3) - outputs 1.x to 3.x
local x_2 = tostring(nvg_num_tubes * 10) -- Num Tubes (1,2,4,1.1,1.2) outputs x.10, x.20, x.40, x.11, or x.12
local y_1 = tostring(math.floor(nvg_gain_current * 10)) -- Gain Adjust (0.1 to 3) -- outputs 1.y to 30.y in 1. increment
local y_2 = tostring(math.floor(nvg_washout_thresh * 10)) -- Washout Thresh (0.0 - 0.9) - outputs y.0 to y.9 in .1 increment
local z_1 = tostring(math.floor(vignette_current * 100)) -- Vignette Amount (0.0 to 1.0) outputs 0.z to 100.z in 1. increment
local z_2 = tostring(math.floor(glitch_power * 10)) -- Glitch Power (0.0 - 0.9) - outputs z.0 to z.9 in .1 increment
local w_1 = tostring((math.floor(nvg_gain_offset * 10)) ) -- Gain Offset (0.5 to 3.0) - outputs 5.w to 30.w in 1. increment
local w_2 = tostring(nvg_mode) -- Mode (0,1) - outputs w.0 or w.1 depending on mode
return "(" .. x_1 .. "." .. x_2 .. "," .. y_1 .. "." .. y_2 .. "," .. z_1 .. "." .. z_2 .. "," .. w_1 .. "." .. w_2 .. ")"
end
function pack_nvg_data_2()
local x_1 = tostring(math.floor(flip_down)) -- Flip down amount - outputs 1.x to 100.x
local x_2 = tostring(0)
local y_1 = tostring(0)
local y_2 = tostring(math.floor(nvg_radius*10)) -- Radius for NVG effect - outputs 0.0 to 0.9
local z_1 = tostring(0)
local z_2 = tostring(0)
local w_1 = tostring(0)
local w_2 = tostring(0)
return "(" .. x_1 .. "." .. x_2 .. "," .. y_1 .. "." .. y_2 .. "," .. z_1 .. "." .. z_2 .. "," .. w_1 .. "." .. w_2 .. ")"
end
function update_nvgs()
get_console():execute("r__nightvision " .. nvg_generation )
get_console():execute("shader_param_8 " .. pack_nvg_data() )
get_console():execute("shader_param_7 " .. pack_nvg_data_2() )
end
-----------------------------------------------------------------------------
-- NVG TURN ON AND TURN OFF FUNCTIONS, INCL ANIMATION
-----------------------------------------------------------------------------
function allow_animation()
return (torch_anm_state == 0 and game.hud_motion_allowed() and (not game.only_movekeys_allowed()) and actor_menu.get_last_mode() == 0 and (not IsMoveState("mcClimb")))
end
local lowered_anm_kinds = {
["w_sniper"] = true,
["w_rifle"] = true,
["w_smg"] = true,
["w_shotgun"] = true,
}
local lowered_anm_classes = {
["WP_VAL"] = true,
["WP_AK74"] = true,
["WP_LR300"] = true,
["WP_BM16"] = true,
["WP_SVD"] = true,
["WP_SVU"] = true,
["WP_GROZA"] = true,
["WP_ASHTG"] = true,
["WP_ASHTG"] = true,
["WP_SHOTG"] = true,
["WP_RG6"] = true,
["WP_RPG7"] = true,
["D_PDA"] = true,
}
function item_device.set_nightvision(section,state)
if (not section) then
return
end
nv_eff[section] = nv_eff[section] or ini_sys:r_string_ex(section,"nv_effect")
if nv_eff[section] ~= nil then
if (nv_eff[section] == "nightvision_1") then
nvg_generation = 1
nvg_num_tubes = nvg_num_tubes_gen1
nvg_mode = nvg_mode_gen1
end
if (nv_eff[section] == "nightvision_2") then
nvg_generation = 2
nvg_num_tubes = nvg_num_tubes_gen2
nvg_mode = nvg_mode_gen2
end
if (nv_eff[section] == "nightvision_3") then
nvg_generation = 3
nvg_num_tubes = nvg_num_tubes_gen3
nvg_mode = nvg_mode_gen3
end
if state and (not item_device.nv_state) then
-- Check if headlamp is equipped. No need for battery check
if (not allow_animation()) or (not item_device.can_toggle_torch()) then
return
end
local weapon_zoomed = axr_main.weapon_is_zoomed and (not (IsPistol(db.actor:active_item(),nil)) or db.actor:active_detector())
local det_active = db.actor:active_detector() or nil
local det_hide_time = 0
local new_speed = 0
local anm_name = "script\\headlamp.anm"
local anm_additional_length = 0.45
if (db.actor:active_item()) then
local itm = db.actor:active_item()
local hud = ini_sys:r_string_ex(itm:section(),"hud") or "hud_base"
local name = ini_sys:r_string_ex(hud,"gasmask_anm")
if (name) then
anm_name = name
else
local kind = ini_sys:r_string_ex(itm:section(),"kind") or nil
local class = ini_sys:r_string_ex(itm:section(),"class") or nil
if ((kind and lowered_anm_kinds[kind]) or (class and lowered_anm_classes[class])) then
anm_name = "script\\lower.anm"
anm_additional_length = 0.8
end
end
if (not det_active and weapon_zoomed) then
if (get_console():get_bool("wpn_aim_toggle")) then
level.press_action(bind_to_dik(key_bindings.kWPN_ZOOM))
else
level.release_action(bind_to_dik(key_bindings.kWPN_ZOOM))
end
end
end
if (det_active) then
if (weapon_zoomed) then
det_active:switch_state(2)
det_hide_time = (det_active:play_hud_motion("anm_zoom_hide_fast", true, 3, 1, 0) / 1000)
if (get_console():get_bool("wpn_aim_toggle")) then
level.press_action(bind_to_dik(key_bindings.kWPN_ZOOM))
else
level.release_action(bind_to_dik(key_bindings.kWPN_ZOOM))
end
else
det_hide_time = (det_active:play_hud_motion("anm_hide_fast", true, 3, 2, 0) / 1000) + 0.1
end
if (det_hide_time == 0) then
det_hide_time = (det_active:play_hud_motion("anm_hide", true, 3, 3.5, 0) / 1000) + 0.1
end
game.play_hud_anm(anm_name, 0, 0.25, 1, false)
end
local function torch_toggle_anim_fast()
local time_g = time_global()
if (torch_anm_state == 1) then
game.play_hud_motion(1, torch_anm_sec, "anm_switch", true, 0.75)
level.add_cam_effector("camera_effects\\headlamp\\headlamp.anm", 7539, false, "", 0, false)
torch_anm_start = time_g
torch_anm_state = 2
elseif (torch_anm_state == 2) and (time_g > torch_anm_start + torch_anm_time - 350) then
torch_anm_state = 3
elseif (torch_anm_state == 3) and (time_g > torch_anm_start + torch_anm_time + 1) then
update_nvgs()
utils_obj.play_sound("interface\\inv_nv_start")
item_device.nv_state = true
torch_anm_state = 0
torch_anm_start = 0
game.only_allow_movekeys(false)
game.set_actor_allow_ladder(true)
RemoveTimeEvent(0, "play_torch_toggle")
end
return false
end
local function torch_toggle_anim()
local time_g = time_global()
if (torch_anm_state == 1) then
if (det_active) then
det_active:switch_state(3)
db.actor:force_hide_detector()
else
game.play_hud_anm(anm_name, 0, 1, 1, false)
end
game.play_hud_motion(1, mc_anm_sec, "anm_hide_hand", true, hide_hand_speed)
new_speed = game.set_hud_anm_time(anm_name, ((torch_anm_time + mc_anm_time_1) / 1000) + anm_additional_length)
torch_anm_start = time_g
torch_anm_state = 2
elseif (torch_anm_state == 2) and (time_g > torch_anm_start + mc_anm_time_1 - 10) then
game.play_hud_motion(1, torch_anm_sec, "anm_switch", true, 1)
level.add_cam_effector("camera_effects\\headlamp\\headlamp.anm", 7539, false, "", 0, false)
torch_anm_state = 3
elseif (torch_anm_state == 3) and (time_g > torch_anm_start + mc_anm_time_1 + torch_anm_time - 550) then
torch_anm_state = 4
elseif (torch_anm_state == 4) and (time_g > torch_anm_start + mc_anm_time_1 + torch_anm_time + 15) then
update_nvgs()
utils_obj.play_sound("interface\\inv_nv_start")
item_device.nv_state = true
if (new_speed) then game.play_hud_anm(anm_name, 2, new_speed, 1, false, true) end
if (det_active) then db.actor:show_detector(true) end
torch_anm_state = 5
elseif (torch_anm_state == 5) and (time_g > torch_anm_start + mc_anm_time_1 + torch_anm_time + (anm_additional_length * 1000 + 100)) then
torch_anm_state = 0
torch_anm_start = 0
game.only_allow_movekeys(false)
game.set_actor_allow_ladder(true)
RemoveTimeEvent(0, "play_torch_toggle")
end
return false
end
torch_anm_state = 1
game.only_allow_movekeys(true)
game.set_actor_allow_ladder(false)
RegisterScriptCallback("actor_on_update", actor_on_update)
RegisterScriptCallback("actor_on_weapon_zoom_in", actor_on_weapon_zoom_in)
RegisterScriptCallback("actor_on_weapon_zoom_out", actor_on_weapon_zoom_out)
RegisterScriptCallback("actor_on_info_callback",pda_check)
if (not db.actor:active_item() and not det_active) then
CreateTimeEvent(0, "play_torch_toggle", det_hide_time, torch_toggle_anim_fast)
else
CreateTimeEvent(0, "play_torch_toggle", det_hide_time, torch_toggle_anim)
end
elseif (not state) and item_device.nv_state then
get_console():execute("r__nightvision 0")
get_console():execute("shader_param_8 (0,0,0,0)")
crt_latch = false
flip_latch = false
vignette_current = 1.0
flip_down = 1
nvg_radius = 0.5 -- hack to fix not correctly going back until i am better at this shit
utils_obj.play_sound("interface\\inv_nv_off")
item_device.nv_state = false
UnregisterScriptCallback("actor_on_weapon_zoom_in", actor_on_weapon_zoom_in)
UnregisterScriptCallback("actor_on_weapon_zoom_out", actor_on_weapon_zoom_out)
UnregisterScriptCallback("actor_on_info_callback",pda_check)
UnregisterScriptCallback("actor_on_update", actor_on_update)
end
end
end
-----------------------------------------------------------------------------
-- NVG BRIGHTNESS ADJUSTMENT FUNCTION
-----------------------------------------------------------------------------
function brightness_adjust()
if item_device.nv_state then
local step_size = (nvg_gain_max - nvg_gain_min) / 3
if gain_directionality and nvg_gain_current <= nvg_gain_max then
nvg_gain_current = nvg_gain_current + step_size
if nvg_gain_current >= nvg_gain_max then
nvg_gain_current = nvg_gain_max
gain_directionality = not gain_directionality
end
elseif not gain_directionality and nvg_gain_current >= nvg_gain_min then
nvg_gain_current = nvg_gain_current - step_size
if nvg_gain_current <= nvg_gain_min then
nvg_gain_current = nvg_gain_min
gain_directionality = not gain_directionality
end
end
local snd_adjust = sound_object('interface\\inv_nvg')
snd_adjust:play(db.actor,0,sound_object.s2d)
update_nvgs()
end
end
-----------------------------------------------------------------------------
-- NVG STATE CHANGE EFFECT, MANIPULATES VIGNETTE AND LOCATION TO
-- SIMUALATE FLIPPING DOWN AND TURNING ON NVGS
-----------------------------------------------------------------------------
function state_change_effect()
if not flip_latch and item_device.nv_state then
if flip_down < 100 then
flip_down = flip_down * flip_speed
end
if flip_down >= 100 then
flip_down = 100
flip_latch = true
end
end
if flip_latch and not crt_latch and item_device.nv_state then
if vignette_current > vignette_amount then
vignette_current = vignette_current * ( 1 / vignette_speed)
end
if vignette_current <= vignette_amount then
vignette_current = vignette_amount
crt_latch = true
end
end
end
-----------------------------------------------------------------------------
-- NVG GLITCH EFFECT, CALLED FROM ITEM_DEVICES AND GLITCHES NVG DURING
-- PSY STORM AND BLOWOUT
-----------------------------------------------------------------------------
-- nvg glitch effect during blowouts and psy storms
function nvg_glitch(power)
if item_device.nv_state then
if glitch_power ~= power then
glitch_power = power
if not zoomed_in then
update_nvgs()
end
end
end
end
-----------------------------------------------------------------------------
-- TURNS OFF NVGS WHEN ADS, AS WELL AS CHANGE TO SINGLE CENTERED SCOPE
-- WHEN USING SHADER SCOPES TO MAINTAIN COMPATIBILITY
-----------------------------------------------------------------------------
function actor_on_weapon_zoom_in()
zoom = true
if ((not nvg_view_through_scope) or axr_main.binoc_is_zoomed) and item_device.nv_state then
zoomed_in = true
get_console():execute("r__nightvision 0")
get_console():execute("shader_param_8 (0,0,0,0)")
elseif (shader_scope_compat and item_device.nv_state) then
local scopeName = nil
local wpn = db.actor:active_item()
if wpn:weapon_scope_status() == 2 then
if wpn:weapon_is_scope() then
local scope = utils_item.get_attached_scope(wpn)
scopeName = utils_item.get_param(scope, wpn:id(), "scope_texture", "string")
end
else
scopeName = utils_item.get_param(wpn:section(), wpn:id(), "scope_texture", "string")
end
--local tex_active = get_console():get_integer("scope_2dtexactive")
if scopeName and scopeRadii.scopeRadii[scopeName] then
scope_blur_temp = get_console():get_float("scope_blur_inner")
tube_count_temp = nvg_num_tubes
radius_temp = nvg_radius
--vignette_temp = vignette_current
nvg_num_tubes = 1
get_console():execute("scope_blur_inner 0")
nvg_radius = math.min(scopeRadii.scopeRadii[scopeName],0.9)
--vignette_current = 0.5 - scopeRadii.scopeRadii[scopeName]
CreateTimeEvent("nvg_scope", "nvg_scope", 0.25, function()
update_nvgs()
return true
end)
shader_scope_flag = true
end
end
end
-----------------------------------------------------------------------------
-- TURN NVGS BACK ON AFTER THEY'VE BEEN TEMPORARILY DISABLED BY ADS FUNCTION
-----------------------------------------------------------------------------
function actor_on_weapon_zoom_out()
zoom = false
if (not nvg_view_through_scope and item_device.nv_state and zoomed_in) then
zoomed_in = false
update_nvgs()
elseif (shader_scope_compat and item_device.nv_state and shader_scope_flag) then
--vignette_current = vignette_temp
nvg_num_tubes = tube_count_temp
--nvg_radius = radius_temp
nvg_radius = 0.5 -- hack to fix not correctly going back until i am better at this shit
get_console():execute("scope_blur_inner " .. scope_blur_temp)
RemoveTimeEvent("nvg_scope", "nvg_scope")
shader_scope_flag = false
update_nvgs()
end
end
-----------------------------------------------------------------------------
-- IF AUTO-TURN-OFF IS ENABLED, THEN AUTO DISABLE NVG WHEN BRING UP PDA
-----------------------------------------------------------------------------
function pda_check(npc,info_id)
local actor = db.actor
if actor and item_device.nv_state then
if info_id == "ui_pda" and not nvg_stays_pda then
if not disable_nvg then
get_console():execute("r__nightvision 0")
get_console():execute("shader_param_8 (0,0,0,0)")
disable_nvg = true
end
elseif info_id == "ui_pda_hide" and not nvg_stays_pda then
if disable_nvg then
update_nvgs()
disable_nvg = false
end
end
end
end
-----------------------------------------------------------------------------
-- Actor on update Function - keep as minimal as possible
-----------------------------------------------------------------------------
local tmr = 0
local tmr_step = 200
function actor_on_update()
if (not crt_latch or not flip_latch) and item_device.nv_state then
state_change_effect()
update_nvgs()
end
tg = time_global()
if tg < tmr then return end
tmr = tg + tmr_step
if (not zoom) and (zoomed_in or shader_scope_flag) then
-- check for disable NVG while ADS
if (not nvg_view_through_scope and item_device.nv_state and zoomed_in) then
zoomed_in = false
update_nvgs()
elseif (shader_scope_compat and item_device.nv_state and shader_scope_flag) then
--vignette_current = vignette_temp
nvg_num_tubes = tube_count_temp
--nvg_radius = radius_temp
nvg_radius = 0.5 -- hack to fix not correctly going back until i am better at this shit
get_console():execute("scope_blur_inner " .. scope_blur_temp)
RemoveTimeEvent("nvg_scope", "nvg_scope")
shader_scope_flag = false
update_nvgs()
end
end
end
-----------------------------------------------------------------------------
-- Keybinding Functions
-----------------------------------------------------------------------------
-- long press to turn on/off NVG, short press to change brightness
function on_key_press()
return
end
function on_key_release(key)
return
end
-----------------------------------------------------------------------------
-- RegisterScriptCallback Functions
-----------------------------------------------------------------------------
local function actor_on_first_update()
normal_fov = device().fov * 0.7
end
function on_game_start()
RegisterScriptCallback("on_option_change", on_option_change)
RegisterScriptCallback("on_key_press", on_key_press)
RegisterScriptCallback("on_key_release", on_key_release)
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
on_option_change()
end
@@ -0,0 +1,42 @@
-- If you don't use MCM, change your defaults from here.
local defaults = {
["nvg_gain_max_mcm"] = 2.0,
["nvg_gain_min_mcm"] = 0.5,
["nvg_gain_offset_mcm"] = 1.0,
["nvg_washout_thresh_mcm"] = 0.1,
["nvg_view_through_scope_mcm"] = false,
["nvg_stays_pda_mcm"] = true,
["shader_scope_compat"] = false,
["nvg_gen1_tubes_mcm"] = 1.0,
["nvg_gen2_tubes_mcm"] = 2.0,
["nvg_gen3_tubes_mcm"] = 4.0,
["nvg_gen1_mode_mcm"] = 3.0,
["nvg_gen2_mode_mcm"] = 0.0,
["nvg_gen3_mode_mcm"] = 0.0
}
function get_config(key)
if ui_mcm then return ui_mcm.get("beef_nvg/"..key) else return defaults[key] end
end
function on_mcm_load()
op = { id= "beef_nvg",sh=true ,gr={
{id = "title",type= "slide",link= "ui_options_slider_player",text="ui_mcm_beef_nvg_title",size= {512,50},spacing= 20 },
{id = "nvg_gain_max_mcm", type = "track", val = 2, min=1.0,max=3.0,step=0.1, def = 2.0},
{id = "nvg_gain_min_mcm", type = "track", val = 2, min=0.1,max=0.9,step=0.1, def = 0.5},
{id = "nvg_gain_offset_mcm", type = "track", val = 2, min=0.5,max=3.0,step=0.1, def = 1.0},
{id = "nvg_washout_thresh_mcm", type = "track", val = 2, min=0.1,max=0.9,step=0.1, def = 0.1},
{id = "nvg_view_through_scope_mcm", type = "check", val = 1, def=true},
{id = "nvg_stays_pda_mcm", type = "check", val = 1, def=true},
{id = "nvg_gen1_tubes_mcm", type = "list", val = 2, content={ {1.0,"single_centered"} , {1.1,"single_left"}, {1.2,"single_right"}, {2.0,"dual_centered"}, {4.0,"quad_centered"}}, def=1.0},
{id = "nvg_gen2_tubes_mcm", type = "list", val = 2, content={ {1.0,"single_centered"} , {1.1,"single_left"}, {1.2,"single_right"}, {2.0,"dual_centered"}, {4.0,"quad_centered"}}, def=2.0},
{id = "nvg_gen3_tubes_mcm", type = "list", val = 2, content={ {1.0,"single_centered"} , {1.1,"single_left"}, {1.2,"single_right"}, {2.0,"dual_centered"}, {4.0,"quad_centered"}}, def=4.0},
{id = "nvg_gen1_mode_mcm", type = "list", val = 2, content={ {0.0,"blurred_background"} , {1.0,"black_background"}, {2.0,"image_overlay"}, {3.0,"clear_vision"}}, def=3.0},
{id = "nvg_gen2_mode_mcm", type = "list", val = 2, content={ {0.0,"blurred_background"} , {1.0,"black_background"}, {2.0,"image_overlay"}, {3.0,"clear_vision"}}, def=0.0},
{id = "nvg_gen3_mode_mcm", type = "list", val = 2, content={ {0.0,"blurred_background"} , {1.0,"black_background"}, {2.0,"image_overlay"}, {3.0,"clear_vision"}}, def=0.0},
{id = "title",type= "slide",link= "ui_options_slider_player",text="ui_mcm_beef_nvg_title_2",size= {512,50},spacing= 20 },
{id = "shader_scope_compat", type = "check", val = 1, def=false}
}
}
return op
end
@@ -0,0 +1,220 @@
#include "anomaly_shaders.h"
#include "common.h"
#include "night_vision.h"
#include "lmodel.h"
#include "hmodel.h"
Texture2D s_half_depth;
#include "ssao.ps"
#ifdef HDAO
#define USE_HDAO 1
#endif
#ifdef SM_5
Texture2D<float> s_occ;
#endif // SM_5
#if SSAO_QUALITY <=3
#include "ssdo.ps"
#else
#ifndef USE_HDAO
#define USE_HDAO
#endif
#endif
#ifdef USE_HDAO
#if SSAO_QUALITY > 3
#include "ssao_hdao_new.ps"
#endif
#define USE_HDAO_CODE
#if SSAO_QUALITY <=3
#define g_f2RTSize ( screen_res.xy )
#define g_txDepth s_position
#define g_txNormal s_position
#include "ssao_hdao.ps"
#endif
#else // USE_HDAO
#ifdef USE_HBAO
#include "ssao_hbao.ps"
#endif // USE_HBAO
#endif // USE_HDAO
struct _input
{
float4 tc0 : TEXCOORD0; // tc.xy, tc.w = tonemap scale
float2 tcJ : TEXCOORD1; // jitter coords
float4 pos2d : SV_Position;
};
struct _out
{
float4 low : SV_Target0;
float4 high : SV_Target1;
};
// TODO: DX10: Replace Sample with Load
#ifndef MSAA_OPTIMIZATION
_out main ( _input I )
#else
_out main ( _input I, uint iSample : SV_SAMPLEINDEX )
#endif
{
gbuffer_data gbd = gbuffer_load_data( GLD_P(I.tc0, I.pos2d, ISAMPLE) );
// Sample the buffers:
float4 P = float4( gbd.P, gbd.mtl ); // position.(mtl or sun)
float4 N = float4( gbd.N, gbd.hemi ); // normal.hemi
float4 D = float4( gbd.C, gbd.gloss ); // rgb.gloss
#ifndef USE_MSAA
float4 L = s_accumulator.Sample( smp_nofilter, I.tc0); // diffuse.specular
#else
float4 L = s_accumulator.Load( int3( I.tc0 * screen_res.xy, 0 ), ISAMPLE );
#endif
if (abs(P.w - MAT_FLORA) <= 0.05) {
// Reapply distance factor to fix overtly glossy plants in distance
// Unfortunately some trees etc don't seem to use the same detail shader
float fAtten = 1 - smoothstep(0, 50, P.z);
D.a *= (fAtten * fAtten);
}
// static sun
float mtl = P.w;
#ifdef USE_R2_STATIC_SUN
float sun_occ = P.w*2;
mtl = xmaterial;
L += SRGBToLinear(D.rgb * Ldynamic_color.rgb * sun_occ) * plight_infinity (mtl, P.xyz, N.xyz, D.xyzw, Ldynamic_dir);
#endif
// Calculate SSAO
#ifdef USE_MSAA
int2 texCoord = I.pos2d;
#endif
float3 occ = float3(1.0,1.0,1.0);
#ifdef USE_HDAO
#ifdef SM_5
#if SSAO_QUALITY > 3
occ = s_occ.Sample( smp_nofilter, I.tc0);
#else // SSAO_QUALITY > 3
occ = calc_hdao( CS_P(P, N, I.tc0, I.tcJ, I.pos2d, ISAMPLE ) );
#endif // SSAO_QUALITY > 3
#else // SM_5
#if SSAO_QUALITY > 3
occ = calc_new_hdao( CS_P(P, N, I.tc0, I.tcJ, I.pos2d, ISAMPLE ) );
#else // SSAO_QUALITY > 3
occ = calc_hdao( CS_P(P, N, I.tc0, I.tcJ, I.pos2d, ISAMPLE ) );
#endif // SSAO_QUALITY > 3
#endif // SM_5
#else // USE_HDAO
#ifdef USE_HBAO
occ = calc_hbao( P.z, N, I.tc0, I.pos2d );
#else // USE_HBAO
occ = calc_ssdo(P, N, I.tc0, I.pos2d, ISAMPLE).xxx;
#endif
#endif // USE_HDAO
#ifdef SSAO_QUALITY
occ = compute_colored_ao(occ.x, D.xyz);
#endif
occ = SRGBToLinear(occ); //gamma correct
L.rgb += L.a * SRGBToLinear(D.rgb); //illum in alpha
// hemisphere
float3 hdiffuse, hspecular;
hmodel (hdiffuse, hspecular, mtl, N.w, D, P.xyz, N.xyz);
hdiffuse *= occ;
//hspecular *= occ;
float3 color = L.rgb + hdiffuse.rgb;
color = LinearTosRGB(color); //gamma correct
//// SOME NVG SHIT ////
float lua_param_nvg_generation = floor(shader_param_8.x); // 1, 2, or 3
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f; // 1, 2, 4, 1.1, or 1.2
float lua_param_nvg_gain_current = floor(shader_param_8.y) / 10.0f;
float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f;
// NVG reduces gloss to 0 inside mask
D.a *= (1.0 - compute_lens_mask(aspect_ratio_correction(I.tc0), lua_param_nvg_num_tubes));
//// END NVG SHIT ////
////////////////////////////////////////////////////////////////////////////////
// here should be distance fog
float3 pos = P.xyz;
float distance = length (pos);
float fog = saturate (distance*fog_params.w + fog_params.x); //
color = lerp (color,fog_color,fog); //
float skyblend = saturate (fog*fog);
float tm_scale = I.tc0.w; // interpolated from VS
_out o;
/////////// BEEFS NVGS CHANGES ///////////
if (lua_param_nvg_generation > 0.0f && compute_lens_mask(aspect_ratio_correction(I.tc0), lua_param_nvg_num_tubes) == 1.0f)
{
float lua_param_nvg_gain_offset = floor(shader_param_8.w) / 10.0f;
tonemap(o.low, o.high, color, 10.0f * lua_param_nvg_gain_offset);
// Turn split tonemapping data to YUV and discard UV
o.low.r = dot(o.low.rgb, luma_conversion_coeff);
o.high.r = dot(o.high.rgb, luma_conversion_coeff);
o.low.r *= 4.0f;
o.high.r *= 4.0f;
// Turn s_accumulator data in to YUV and discard UV
o.low.g = pow(dot(L.rgb, luma_conversion_coeff),2.0f)*1.3f;
o.high.g = o.low.g;
// Turn albedo into YUV and discard UV
o.low.b = dot(D.rgb, luma_conversion_coeff);
o.high.b = o.low.b;
o.low *= lua_param_nvg_gain_current;
o.high *= lua_param_nvg_gain_current;
// Extra
o.low.a = skyblend;
o.high.a = skyblend;
// APPLY VIGNETTE
float vignette = calc_vignette(lua_param_nvg_num_tubes, I.tc0, lua_param_vignette_current+0.02);
o.high = clamp(o.high,0.0,1.0);
o.low= clamp(o.low,0.0,1.0);
o.high.rgb *= vignette;
o.low.rgb *= vignette;
}
else
{
tonemap(o.low, o.high, color, tm_scale);
o.low.a = skyblend;
o.high.a = skyblend;
}
return o;
}
@@ -0,0 +1,96 @@
#include "common.h"
#include "anomaly_shaders.h"
#include "night_vision.h"
//////////////////////////////////////////////////////////////////////////////////////////
#ifndef USE_MSAA
Texture2D s_distort;
#define EPSDEPTH 0.001
#else
#ifndef SM_5
Texture2DMS<float4,MSAA_SAMPLES> s_distort;
#else
Texture2DMS<float4> s_distort;
#endif
#define EPSDEPTH 0.001
#endif
//////////////////////////////////////////////////////////////////////////////////////////
float4 e_barrier; // x=norm(.8f), y=depth(.1f), z=clr
float4 e_weights; // x=norm, y=depth, z=clr
float4 e_kernel; // x=norm, y=depth, z=clr
//////////////////////////////////////////////////////////////////////////////////////////
#include "mblur.h"
#include "img_corrections.h"
#include "tonemapping.h"
//////////////////////////////////////////////////////////////////////////////////////////
// Pixel
struct c2_out
{
float4 Color : SV_Target;
#ifdef USE_MSAA
float Depth : SV_Depth;
#endif
};
c2_out main( v2p_aa_AA I )
{
c2_out res;
res.Color = float4(0,0,0,0);
int iSample = 0;
gbuffer_data gbd = gbuffer_load_data(I.Tex0, I.HPos, iSample );
float depth = gbd.P.z;
#ifdef USE_DISTORT
#ifndef USE_MSAA
float4 distort = s_distort.Sample(smp_nofilter, I.Tex0);
#else // USE_MSAA
float4 distort = s_distort.Load( int3( I.Tex0 * screen_res.xy, 0 ), iSample );
#endif // USE_MSAA
float2 offset = (distort.xy-(127.0h/255.0h))*def_distort; // fix newtral offset
float2 center = I.Tex0 + offset;
gbuffer_data gbdx = gbuffer_load_data_offset(I.Tex0, center, I.HPos, iSample);
float depth_x = gbdx.P.z;
if ((depth_x+EPSDEPTH)<depth) center = I.Tex0; // discard new sample
#else // USE_DISTORT
float2 center = I.Tex0;
#endif
float3 img = s_image.Load(int3(center.xy * screen_res.xy, 0),0);
float4 bloom = s_bloom.Sample(smp_rtlinear,center);
img = mblur( center, ( gbd ).P, img.rgb);
float lua_param_nvg_generation = floor(shader_param_8.x); // 1, 2, or 3
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f; // 1, 2, 4, 1.1, or 1.2
// NVG CHANGE TO PREVENT WEIRD COLORS, ONLY APPLY BLOOM WHEN WE'RE NOT IN NVG MASK
if (lua_param_nvg_generation < 0.01f && compute_lens_mask(aspect_ratio_correction(I.Tex0), lua_param_nvg_num_tubes) == 0.0f)
{
img = blend_soft(img, bloom.xyz*bloom.w);
}
if (tnmp_onoff == 1.0)
{
img = Uncharted2ToneMapping(img);
}
img = img_corrections(img);
#ifdef USE_DISTORT
float3 blurred = bloom*def_hdr ;
img = lerp (img,blurred,distort.z);
#endif
res.Color = float4(img,1.0);
#ifdef USE_MSAA
float4 ptp = mul(m_P, float4(gbd.P, 1));
res.Depth = ptp.w==0?1:ptp.z/ptp.w;
#endif
return res;
}
@@ -0,0 +1,453 @@
#include "common.h"
uniform float4 shader_param_8;
uniform float4 shader_param_7;
///////////////////////////////////////////////////////
// BEEF'S SHADER BASED NIGHT VISION EFFECT //
///////////////////////////////////////////////////////
// Huge credit TO LVutner from Anomaly Discord, who //
// literally taught me everything I know, to Sky4Ace //
// who's simple_blur function I've adapted for this //
// shader, and to Meltac, who provided some advice //
// and inspiration for developing this shader. //
///////////////////////////////////////////////////////
// Note: You are free to distribute and adapt this //
// Shader and any components, just please provide //
// credit to myself and/or the above individuals. I //
// have provided credit for individual functions and //
// their original authors where applicable. - BEEF //
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
// USER SETTINGS HERE
///////////////////////////////////////////////////////
//////// GLOBAL SETTINGS(ALL GENERATIONS)////////
#define sky_brightness_factor float (1.0f) // Sky brightness factor. If your sky is too bright, decrease this slightly, if too dim, increase this slightly.
// NVG CRT & NOISE VALUES
//(BE AWARE THAT NOISE AND SCINTILLATION SCALE WITH NVG GAIN)
#define gen_1_crt_effect_factor float(0.05) // Default 0.05 - How much CRT effect to add to NVG image (0 = none, 1 = max).
#define gen_1_nvg_noise_factor float (0.15) // Default 0.15 - How much noise to add to NVG image. (0 = none, 0.5 = insane)
#define gen_1_scintillation_constant float (0.999f) // Default 0.999 - The closer the number is to 1.00000, the less scintillation effect.
#define gen_1_luma_sharpen_factor float(0.0f) // Default 0.0 - How much luma sharpen is added in. (0 = none, 1 = max)
#define gen_2_crt_effect_factor float(0.07) // Default 0.07 - How much CRT effect to add to NVG image (0 = none, 1 = max).
#define gen_2_nvg_noise_factor float (0.1) // Default 0.15 - How much noise to add to NVG image. (0 = none, 0.5 = insane)
#define gen_2_scintillation_constant float (0.9991f) // Default 0.9991 - The closer the number is to 1.00000, the less scintillation effect.
#define gen_2_luma_sharpen_factor float(0.25f) // Default 0.25f - How much luma sharpen is added in. (0 = none, 1 = max)
#define gen_3_crt_effect_factor float(0.1) // Default 0.1 - How much CRT effect to add to NVG image (0 = none, 1 = max).
#define gen_3_nvg_noise_factor float (0.08) // Default 0.15 - How much noise to add to NVG image. (0 = none, 0.5 = insane)
#define gen_3_scintillation_constant float (0.9992f) // Default 0.9992 - The closer the number is to 1.00000, the less scintillation effect.
#define gen_3_luma_sharpen_factor float(0.5f) // Default 0.5 - How much luma sharpen is added in. (0 = none, 1 = max)
// NVG COLOR OPTIONS:
#define gen_1_saturation_color float3 (0.7,1,0.6) // Gen1 NVG color - it defines the max amount of color from 0 to 1 using (Red,Green,Blue)
#define gen_2_saturation_color float3 (0.5,1,0.4) // Gen1 NVG color - it defines the max amount of color from 0 to 1 using (Red,Green,Blue)
#define gen_3_saturation_color float3 (0.2,1,0.9) // Gen1 NVG color - it defines the max amount of color from 0 to 1 using (Red,Green,Blue)
// EXAMPLE COLOR SCHEMES:
// (0.7,1,0.6) - gen 1 soft green
// (0.5,1,0.4) - gen 2 hard green
// (0.2,1,0.9) - gen 3 blueish
// (1.0,1.0,1.0) - black and white
// (1.0,0.7,0.1) - yellow or amber color
///////////////////////////////////////////////////////
// PROBABLY DON'T CHANGE STUFF BELOW HERE UNLESS YOU KNOW WHAT YOU'RE DOING
///////////////////////////////////////////////////////
// Constants
#define tube_radius float (frac(shader_param_7.y))
#define single_tube_centered float2(0.5f, -0.5f + (floor(shader_param_7.x) / 100))
#define single_tube_offset_left float2(0.25f, -0.5f + (floor(shader_param_7.x) / 100)) // Single tube screen position (0.5, 0.5 is centered)
#define single_tube_offset_right float2(0.75f, -0.5f + (floor(shader_param_7.x) / 100)) // Single tube screen position (0.5, 0.5 is centered)
#define dual_tube_offset_1 float2(0.25f, -0.5f + (floor(shader_param_7.x) / 100)) // Offset for dual tube left eye
#define dual_tube_offset_2 float2(0.75f, -0.5f + (floor(shader_param_7.x) / 100)) // Offset for dual tube right eye
#define quad_tube_offset_1 float2(0.05f, -0.5f + (floor(shader_param_7.x) / 100)) // Offset for quad tube left outer tube
#define quad_tube_offset_2 float2(0.3f, -0.5f + (floor(shader_param_7.x) / 100)) // Offset for quad tube left inner tube
#define quad_tube_offset_3 float2(0.7f, -0.5f + (floor(shader_param_7.x) / 100)) // Offset for quad tube right inner tube
#define quad_tube_offset_4 float2(0.95f, -0.5f + (floor(shader_param_7.x) / 100)) // Offset for quad tube right outer tube
#define luma_conversion_coeff float3 (0.299, 0.587, 0.114)// When we convert to YUV, these are the coefficients for Y (since we discard UV)
#define farthest_depth float (25.0f) // The farthest far place that we can reach in regards to DOF effects
// LUA PACKING
// local x_1 = tostring(nvg_generation) -- Generation (1,2,3) - outputs 1.x to 3.x
// local x_2 = tostring(nvg_num_tubes) -- Num Tubes (1,2,4,11,12) outputs x.1, x.2, x.4, x.11, or x.12
// local y_1 = tostring(math.floor(nvg_gain_current * 10)) -- Gain Adjust (0.1 to 3) -- outputs 1.y to 30.y in 1. increment
// local y_2 = tostring(math.floor(nvg_washout_thresh * 10)) -- Washout Thresh (0.0 - 0.9) - outputs y.0 to y.9 in .1 increment
// local z_1 = tostring(math.floor(vignette_current * 100)) -- Vignette Amount (0.0 to 1.0) outputs 0.z to 100.z in 1. increment
// local z_2 = tostring(math.floor(glitch_power * 10)) -- Glitch Power (0.0 - 0.9) - outputs z.0 to z.9 in .1 increment
// local w_1 = tostring((math.floor(nvg_gain_offset * 10)) ) -- Gain Offset (0.5 to 3.0) - outputs 5.w to 30.w in 1. increment
// local w_2 = tostring(nvg_mode) -- Mode (0,1) - outputs w.0 or w.1 depending on mode
// SHADER UNPACKING
// float lua_param_nvg_generation = floor(shader_param_8.x); // 1, 2, or 3
// float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f; // 1, 2, 4, 1.1, or 1.2
// float lua_param_nvg_gain_current = floor(shader_param_8.y) / 10.0f; // 0.0 to 3.0
// float lua_param_nvg_washout_thresh = frac(shader_param_8.y); // 0.0 to 0.9
// float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f; // 0.0 to 1.0
// float lua_param_glitch_power = frac(shader_param_8.z); // 0.0 to 0.9
// float lua_param_nvg_gain_offset = floor(shader_param_8.w) / 10.0f; // 0.5 to 3.0
// float lua_param_nvg_mode = frac(shader_param_8.w) * 10; // 0 to 9 in 1.0 increment
// mode 0: blurred background (default)
// mode 1: black background
// mode 2: image overlay
// mode 3: no changes (clear vision)
// float lua_param_flip_down = floor(shader_param_7.x);
// float lua_param_nvg_radius = frac(shader_param_7.y);
///////////////////////////////////////////////////////
// DEFINE NVG MASK (Credit to LVutner for huge assistance in designing the functions)
///////////////////////////////////////////////////////
float compute_lens_mask(float2 masktc, float num_tubes)
{
float lua_param_flip_down = floor(shader_param_7.x);
lua_param_flip_down = clamp(5 - (lua_param_flip_down / 20.0f),1.0f,5.0f);
masktc.y = masktc.y * lua_param_flip_down;
if (num_tubes > 0.99f && num_tubes < 1.01f) // One tube centered
{
return step(distance(masktc,single_tube_centered), tube_radius);
}
else if (num_tubes > 1.09f && num_tubes < 1.11f) // One tube left offset
{
return step(distance(masktc,single_tube_offset_left), tube_radius);
}
else if (num_tubes > 1.19f && num_tubes < 1.21f) // One tube right offset
{
return step(distance(masktc,single_tube_offset_right), tube_radius);
}
else if (num_tubes > 1.99f && num_tubes < 2.01f) // Two tubes
{
if ( (step(distance(masktc,dual_tube_offset_1), tube_radius) == 1) || (step(distance(masktc,dual_tube_offset_2), tube_radius) == 1))
{
return 1.0f;
}
else
{
return 0.0f;
}
}
else if (num_tubes > 3.99f && num_tubes < 4.01f) // Four Tubes
{
if (((step(distance(masktc,quad_tube_offset_1), tube_radius) == 1) || (step(distance(masktc,quad_tube_offset_2), tube_radius) == 1)) || ((step(distance(masktc,quad_tube_offset_3), tube_radius) == 1) || (step(distance(masktc,quad_tube_offset_4), tube_radius) == 1)))
{
return 1.0f;
}
else
{
return 0.0f;
}
}
else
{
return 0.0f;
}
}
///////////////////////////////////////////////////////
// ASPECT RATIO CORRECTION (Credit LVutner)
///////////////////////////////////////////////////////
float2 aspect_ratio_correction (float2 tc)
{
tc.x -= 0.5f;
tc.x *= (screen_res.x / screen_res.y);
tc.x += 0.5f;
return tc;
}
///////////////////////////////////////////////////////
// CRT EFFECT (adapted from MattiasCRT on ShaderToy, credit Mattias)
///////////////////////////////////////////////////////
float2 curve_texturecoords(float2 curved_tc)
{
curved_tc = (curved_tc - 0.5) * 2.0;
curved_tc *= 1.1;
curved_tc.x *= 1.0 + pow((abs(curved_tc.y) / 5.0), 2.0);
curved_tc.y *= 1.0 + pow((abs(curved_tc.x) / 4.0), 2.0);
curved_tc = (curved_tc / 2.0) + 0.5;
curved_tc = curved_tc *0.92 + 0.04;
return curved_tc;
}
float3 make_crt_ified(float3 fragColor, float2 tc )
{
//float2 screen_res = screen_res.xy; // define screen res variable
float2 uv = curve_texturecoords(tc);
float3 col;
float x = sin(0.3*timers.x+uv.y*21.0)*sin(0.7*timers.x+uv.y*29.0)*sin(0.3+0.33*timers.x+uv.y*31.0)*0.0017;
col.r = fragColor.r;
col.g = fragColor.g;
col.b = fragColor.b;
col.r += 0.08f * fragColor.r;
col.g += 0.05f * fragColor.g;
col.b += 0.08f * fragColor.b;
col = clamp(col*0.6+0.4*col*col*1.0,0.0,1.0);
float vig = (0.0 + 1.0*16.0*uv.x*uv.y*(1.0-uv.x)*(1.0-uv.y));
col *= float(pow(abs(vig),0.3));
col *= float3(0.95,1.05,0.95);
col *= 2.8;
float scans = clamp( 0.35+0.35*sin(uv.y*screen_res.y*2.0), 0.0, 1.0);
float s = pow(scans,1.7);
col = col*float( 0.4+0.7*s) ;
col *= 1.0+0.01*sin(110.0*timers.x);
if (uv.x < 0.0 || uv.x > 1.0)
col *= 0.0;
if (uv.y < 0.0 || uv.y > 1.0)
col *= 0.0;
col*=1.0-0.65*float(clamp(((tc.x % 2.0)-1.0)*2.0,0.0f,1.0f));
float comp = smoothstep( 0.1, 0.9, sin(timers.x) );
fragColor = col;
return fragColor;
}
///////////////////////////////////////////////////////
// VIGNETTE CALCULATOR (USED IN NVG AS WELL AS BLOOM PHASES TO DARKEN EDGES OF SHIT)
///////////////////////////////////////////////////////
float calc_vignette (float num_tubes, float2 tc, float vignette_amount)
{
float vignette;
float2 corrected_texturecoords = aspect_ratio_correction(tc);
float lua_param_flip_down = floor(shader_param_7.x);
lua_param_flip_down = clamp(5 - (lua_param_flip_down / 20.0f),1.0f,5.0f);
corrected_texturecoords.y = corrected_texturecoords.y * lua_param_flip_down;
if (num_tubes > 0.99f && num_tubes < 1.01f)
{
float gen1_vignette = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,single_tube_centered)),3);
vignette = 1.0 - (1.0 - gen1_vignette); // apply vignette
}
else if (num_tubes > 1.09f && num_tubes < 1.11f)
{
float gen1_vignette = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,single_tube_offset_left)),3);
vignette = 1.0 - (1.0 - gen1_vignette); // apply vignette
}
else if (num_tubes > 1.19f && num_tubes < 1.21f)
{
float gen1_vignette = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,single_tube_offset_right)),3);
vignette = 1.0 - (1.0 - gen1_vignette); // apply vignette
}
else if (num_tubes > 1.99f && num_tubes < 2.01f)
{
float gen2_vignette_1 = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,dual_tube_offset_1)),3);
float gen2_vignette_2 = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,dual_tube_offset_2)),3);
vignette = 1.0 - ((1.0 - gen2_vignette_1) * (1.0 - gen2_vignette_2)); // apply vignette
}
else if (num_tubes > 3.99f && num_tubes < 4.01f)
{
float gen3_vignette_1 = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,quad_tube_offset_1)),3);
float gen3_vignette_2 = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,quad_tube_offset_2)),3);
float gen3_vignette_3 = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,quad_tube_offset_3)),3);
float gen3_vignette_4 = pow(smoothstep(tube_radius,tube_radius-vignette_amount, distance(corrected_texturecoords,quad_tube_offset_4)),3);
vignette = 1.0 - ((1.0 - gen3_vignette_1) * (1.0 - gen3_vignette_2) * (1.0 - gen3_vignette_3) * (1.0 - gen3_vignette_4)); // apply vignette
}
return vignette;
}
///// blur functions
float IGN_calc(float2 uv)
{
uv = frac(uv);
float f = 0.06711056 * uv.x + 0.00583715 * uv.y;
return 6.28*(frac(52.9829189 * frac(f)));
}
float2x2 rot(float a)
{
float c;
float s;
sincos(a,s,c);
return float2x2 (c, s, -s, c);
}
///////////////////////////////////////////////////////
// LUMA SHARPEN (adapted from Simple Luma Sharpen on ShaderToy, credit xwize)
///////////////////////////////////////////////////////
float3 YUVFromRGB( float3 color)
{
return float3 (color.r * 0.299 + color.g * 0.587 + color.b * 0.114,
color.r * -0.147 + color.g * -0.289 + color.b * 0.436,
color.r * 0.615 + color.g * -0.515 + color.b * -0.100);
}
float3 RGBFromYUV ( float3 color)
{
return float3 (color.r * 1.0 + color.b * 1.140,
color.r * 1.0 + color.g * -0.395 + color.b * 0.581 ,
color.r * 1.0 + color.g * 2.032);
}
float extractLuma(float3 c)
{
return (c.r * 0.299 + c.g * 0.587 + c.b * 0.114);
}
float3 luma_sharpen(float3 image, float2 uv)
{
float3 yuv = YUVFromRGB(image);
float2 imgSize = screen_res.xy;
float accumY = 0.0;
for(int i = -1; i <= 1; ++i) {
for(int j = -1; j <= 1; ++j) {
float2 offset = float2(i,j) / imgSize;
float s = extractLuma(s_blur_2.SampleLevel(smp_rtlinear,uv + offset,0).rrr);
float notCentre = min(float(i*i + j*j),1.0);
accumY += s * (9.0 - notCentre*10.0);
}
}
accumY /= 9.0;
float gain = 0.9;
accumY = (accumY + yuv.x)*gain;
image = RGBFromYUV (float3(accumY,yuv.y,yuv.z)); // sharpened
return image;
}
///////////////////////////////////////////////////////
// DEPTH BLUR - LITERALLY BLURS THE DEPTH VALUE IN S_POSITION
///////////////////////////////////////////////////////
float blurred_depth (float2 tc)
{
float Pi = 6.28318530718; // Pi*2
float Directions = 12.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
float Quality = 4.0; // BLUR QUALITY (Default 4.0 - More is better but slower)
float Size = 6;
float2 Radius = Size/screen_res.xy;
// how far away is the center of our COC
float center_depth = s_position.Load( int3( (tc)*screen_res.xy, 0 ), 0 ).z;
if (center_depth == 0) { center_depth = 10000; }
// set our average depth to be center depth
float depth_average = 0;
// where we store the depth_sample
float depth_sample;
// where we store the weighted value from sample
float depth_tap;
// where we store our weighted
float weight = 0.0;
// where we store the total weighted
float total_weight = 0.0;
// Blur calculations
for(float i=1.0; i<=Quality; i++) // how far away are we
{
for( float d=0.0; d<Pi; d+=Pi/Directions) // where are we around the circle
{
// pull depth at our sample point
depth_sample = s_position.Load( int3( ((tc+float2(cos(d),sin(d))*Radius*i) * screen_res.xy), 0 ), 0 ).z;
// if we hit the sky, give it a depth of 10k
if (depth_sample == 0) {depth_sample = 10000.0f; }
// if the point we hit is closer than our (center? average), then that point should add blurring to our centerpoint
if (depth_sample <= center_depth )
{
weight = Quality - pow((i - 1),0.5);
depth_average += depth_sample * weight;
total_weight += weight;
}
// but if the point we hit is farther than our (center? average?) then that point should not be adding blur to our centerpoint
}
}
depth_average /= total_weight;
return depth_average;
}
////////////////////////////////////////////////////////////////////
//////// GLITCH EFFECT /////////////////
float3 glitchEffect( float3 image, float2 tc, float power)
{
//tc.y = 1.0 - tc.y;
float time = fmod(timers.x, 32.0); // + modelmat[0].x + modelmat[0].z;
float GLITCH = saturate(power);
float rnd0 = rand(timers.x);
float r0 = saturate((1.0-GLITCH)*0.7 + rnd0);
float rnd1 = rand(floor(tc.x*10.0f * r0) / (10.0f * r0) * time);
float r1 = 0.5 - (0.5 * GLITCH) + rnd1;
r1 = 1.0 - max( 0.0, r1);
float rnd2 = rand(floor(tc.y*40.0f * r1) / (40.0f * r1) * time);
float r2 = saturate(rnd2);
float rnd3 = rand(floor(tc.y*10.0f * r0) / (10.0f * r0) * time);
float r3 = (1.0 - saturate(rnd3 + 0.8)) - 0.1f;
float pxrnd = rand( dot(tc.x,tc.y) + time );
float test_result;
if (rnd0 > 0.5f)
{ test_result = 1.0f; }
else
{test_result = -1.0f; }
float ofs = 0.05 * r2 * GLITCH * test_result;
ofs += 0.5 * pxrnd * ofs;
tc.y += 0.1 * r3 * GLITCH;
int NUM_SAMPLES = 10;
float RCP_NUM_SAMPLES_F = 1.0 / (float)NUM_SAMPLES;
float3 sum = 0.0f;
float3 wsum = 0.0f;
float t0 = 0.0f;
for( int i=0; i<NUM_SAMPLES; ++i )
{
float t = (float)i * RCP_NUM_SAMPLES_F;
tc.x = saturate(tc.x + ofs * t);
float3 samplecol = s_blur_2.SampleLevel(smp_rtlinear, tc, 0).rgb;
// float3 s = spectrum_offset( t );
// samplecol *= s;
sum += samplecol;
wsum += 1.0f;
}
return sum.rgb /= wsum;
}
@@ -0,0 +1,163 @@
///////////////////////////////////////////////////////
// BEEF'S SHADER BASED NIGHT VISION EFFECT //
///////////////////////////////////////////////////////
// Huge credit TO LVutner from Anomaly Discord, who //
// literally taught me everything I know, to Sky4Ace //
// who's simple_blur function I've adapted for this //
// shader, and to Meltac, who provided some advice //
// and inspiration for developing this shader. //
///////////////////////////////////////////////////////
// Note: You are free to distribute and adapt this //
// Shader and any components, just please provide //
// credit to myself and/or the above individuals. I //
// have provided credit for individual functions and //
// their original authors where applicable. - BEEF //
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
// STEP 0 - GLOBAL DEFINITIONS AND INCLUDES
///////////////////////////////////////////////////////
#include "night_vision.h"
#include "common.h"
float3 bokeh_pass_3 (float image, float2 tc)
{
float Pi = 6.28318530718; float blur_directions = 8.0; float blur_quality = 4.0; float blur_radius = 5; float3 color = 0.0f; float3 color_average = 0.0f;
float light_avgs = 0.0f; float weight = 0.0f; float total_weight = 0.0f;
for(float i=1.0; i<=blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_blur_8.SampleLevel(smp_rtlinear, tc + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
color += s_blur_4.SampleLevel(smp_rtlinear, tc + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
if (color.g > 0.0f) { color.g *= 1.0f; light_avgs += 1.0f;} else {light_avgs += 0.5;} color_average += color; } } image = color_average.g / light_avgs;
return image;
}
float4 main(p_screen I) : SV_Target
{
///////////////////////////////////////////////////////
// STEP 0 - LOCAL DEFINITIONS
///////////////////////////////////////////////////////
// TC vars
float2 corrected_texturecoords = aspect_ratio_correction(I.tc0);
///////////////////////////////////////////////////////
// STEP 0 - MAIN SAMPLES
///////////////////////////////////////////////////////
float3 image = s_image.Sample(smp_rtlinear, I.tc0).xyz;
///////////////////////////////////////////////////////
// STEP 0 - MAIN FUNCTION
///////////////////////////////////////////////////////
float3 half_res_blur = s_blur_2.Sample(smp_rtlinear, I.tc0).rgb;
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f;
if (compute_lens_mask(corrected_texturecoords, lua_param_nvg_num_tubes) == 1) // see if we're inside the lens mask
{
// GRAB SAMPLES FOR NVG SHADER
float3 eighth_res_bloom = s_blur_8.Sample(smp_rtlinear, I.tc0).rgb;
float3 quarter_res_bloom = s_blur_4.Sample(smp_rtlinear, I.tc0).rgb;
float4 jitter = float4(
frac(sin(dot(I.tc0, float2(12.0, 78.0) + (timers.x) )) * 12345.0),
frac(sin(dot(I.tc0-fmod(I.tc0,float2(3.0,3.0)/screen_res.xy), float2(12.0, 78.0) + (timers.x) )) * 22738.0),
frac(sin(dot(I.tc0-fmod(I.tc0,float2(3.0,3.0)/screen_res.xy), float2(12.0, 78.0) + (timers.x) )) * 78372.0),
frac(sin(dot(I.tc0, float2(12.0, 78.0) + (timers.x) )) * 37857.0));
//float depth = s_position.Load(int3(I.tc0 * screen_res.xy,0),0).z; // Sample the depth buffer in a better way
//float depth = pow(blurred_depth(I.tc0),2)*1000;
float depth = blurred_depth(I.tc0);
//image.r = lerp(half_res_blur.r,image.r,0.6f);
//image = pow(image,0.75);
image = lerp(image,half_res_blur,clamp(1-smoothstep(0,15,depth),0.4,1)); // NEAR BLUR
if (depth < 1000)
{
float light_att = pow(1.0f-(smoothstep(5,300,depth)),0.5); // Distance from full brightness to full black
if ((image.r+image.g) < 0.9f)
{
image.r *= (light_att+0.1f); //Apply light attenuation (plus offset to prevent sky turning black)
}
}
// GLITCH EFFECT -- TO DO
float lua_param_glitch_power = fmod(shader_param_8.z,1.0f);
if (lua_param_glitch_power > 0.0f)
{
image = lerp(image, glitchEffect(image, I.tc0, lua_param_glitch_power),0.9);
}
// APPLY BLOOM / WASHOUT
float addon = bokeh_pass_3( (eighth_res_bloom.g + quarter_res_bloom.g),I.tc0);
float addon_hard = max(addon - 0.7,0.0) * 2.0f;
float addon_soft = (max(half_res_blur.g - 0.6,0.0f) / 0.6) / 1.0f;
// addon = max(addon - 0.01,0) * 3;
image = image + (float3)addon_soft + (float3)addon_hard;
// image *= 3;
// APPLY CRT EFFECT
image = lerp(image,make_crt_ified(half_res_blur, I.tc0),gen_1_crt_effect_factor); // Adds a CRT effect that I think looks better than draw_scanlines
// APPLY NOISE
float lua_param_nvg_gain_current = floor(shader_param_8.y) / 10.0f;
image.r += jitter.y * (gen_1_nvg_noise_factor * (pow(lua_param_nvg_gain_current,0.5) )); // Add the noise to the image
// APPLY SCINTILLATION EFFECT
if (jitter.z > (gen_1_scintillation_constant - ( (1.0-gen_1_scintillation_constant) * (lua_param_nvg_gain_current - 1.0f) ) ) )
{ image.r = 1.0f; }
// APPLY IMAGE COLOR CORRECTION AND MAKE BRIGHT SPOTS WHITE
image.rgb = saturate(image.r) * gen_1_saturation_color;
if (image.g >= 0.95)
{
image.rgb = pow(image.ggg,2);
}
// APPLY VIGNETTE
float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f;
float vignette = calc_vignette(lua_param_nvg_num_tubes, I.tc0, lua_param_vignette_current);
image = clamp(image,0.0,1.0);
image *= vignette;
// RETURN THE RESULTING IMAGE
return float4(image, 1.0);
}
///////////////////////////////////////////////////////
// OUTSIDE NVG CIRCLES OF EFFECT - If the absolute distance from screen center is farther than circle_radius, then we'll run the other shader effects below
///////////////////////////////////////////////////////
else
{
float lua_param_nvg_mode = frac(shader_param_8.w) * 10;
if (abs(lua_param_nvg_mode-0.0) <= 0.01) // mode 0 - blur
{
image = half_res_blur;
image = clamp(image,0.0,1.0);
}
else if (abs(lua_param_nvg_mode-1.0) <= 0.01) // mode 1 - black
{
image = float3(0.0,0.0,0.0);
}
else if (abs(lua_param_nvg_mode-2.0) <= 0.01) // mode 2 - image overlay
{
image = clamp(image,0.0,1.0);
}
else if (abs(lua_param_nvg_mode-3.0) <= 0.01) // mode 3 - no changes (clear vision)
{
image = clamp(image,0.0,1.0);
}
// RETURN THE RESULTING IMAGE
return float4(image, 1.0);
}
}
@@ -0,0 +1,161 @@
///////////////////////////////////////////////////////
// BEEF'S SHADER BASED NIGHT VISION EFFECT //
///////////////////////////////////////////////////////
// Huge credit TO LVutner from Anomaly Discord, who //
// literally taught me everything I know, to Sky4Ace //
// who's simple_blur function I've adapted for this //
// shader, and to Meltac, who provided some advice //
// and inspiration for developing this shader. //
///////////////////////////////////////////////////////
// Note: You are free to distribute and adapt this //
// Shader and any components, just please provide //
// credit to myself and/or the above individuals. I //
// have provided credit for individual functions and //
// their original authors where applicable. - BEEF //
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
// STEP 0 - GLOBAL DEFINITIONS AND INCLUDES
///////////////////////////////////////////////////////
#include "night_vision.h"
#include "common.h"
float3 bokeh_pass_3 (float image, float2 tc)
{
float Pi = 6.28318530718; float blur_directions = 8.0; float blur_quality = 4.0; float blur_radius = 5; float3 color = 0.0f; float3 color_average = 0.0f;
float light_avgs = 0.0f; float weight = 0.0f; float total_weight = 0.0f;
for(float i=1.0; i<=blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_blur_8.SampleLevel(smp_rtlinear, tc + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
color += s_blur_4.SampleLevel(smp_rtlinear, tc + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
if (color.g > 0.0f) { color.g *= 1.0f; light_avgs += 1.0f;} else {light_avgs += 0.5;} color_average += color; } } image = color_average.g / light_avgs;
return image;
}
float4 main(p_screen I) : SV_Target
{
///////////////////////////////////////////////////////
// STEP 0 - LOCAL DEFINITIONS
///////////////////////////////////////////////////////
// TC vars
float2 corrected_texturecoords = aspect_ratio_correction(I.tc0);
///////////////////////////////////////////////////////
// STEP 0 - MAIN SAMPLES
///////////////////////////////////////////////////////
float3 image = s_image.Sample(smp_rtlinear, I.tc0).xyz;
///////////////////////////////////////////////////////
// STEP 0 - MAIN FUNCTION
///////////////////////////////////////////////////////
float3 half_res_blur = s_blur_2.Sample(smp_rtlinear, I.tc0).rgb;
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f;
if (compute_lens_mask(corrected_texturecoords, lua_param_nvg_num_tubes) == 1) // see if we're inside the lens mask
{
// GRAB SAMPLES FOR NVG SHADER
float3 eighth_res_bloom = s_blur_8.Sample(smp_rtlinear, I.tc0).rgb;
float3 quarter_res_bloom = s_blur_4.Sample(smp_rtlinear, I.tc0).rgb;
float4 jitter = float4(
frac(sin(dot(I.tc0, float2(12.0, 78.0) + (timers.x) )) * 12345.0),
frac(sin(dot(I.tc0-fmod(I.tc0,float2(3.0,3.0)/screen_res.xy), float2(12.0, 78.0) + (timers.x) )) * 22738.0),
frac(sin(dot(I.tc0-fmod(I.tc0,float2(3.0,3.0)/screen_res.xy), float2(12.0, 78.0) + (timers.x) )) * 78372.0),
frac(sin(dot(I.tc0, float2(12.0, 78.0) + (timers.x) )) * 37857.0));
//float depth = s_position.Load(int3(I.tc0 * screen_res.xy,0),0).z; // Sample the depth buffer in a better way
//float depth = pow(blurred_depth(I.tc0),2)*1000;
float depth = blurred_depth(I.tc0);
//image.r = lerp(half_res_blur.r,image.r,0.6f);
//image = pow(image,0.75);
image = lerp(image,half_res_blur,clamp(1-smoothstep(0,15,depth),0.4,1)); // NEAR BLUR
if (depth < 1000)
{
float light_att = pow(1.0f-(smoothstep(5,300,depth)),0.5); // Distance from full brightness to full black
if ((image.r+image.g) < 0.9f)
{
image.r *= (light_att+0.1f); //Apply light attenuation (plus offset to prevent sky turning black)
}
}
// GLITCH EFFECT -- TO DO
float lua_param_glitch_power = fmod(shader_param_8.z,1.0f);
if (lua_param_glitch_power > 0.0f)
{
image = lerp(image, glitchEffect(image, I.tc0, lua_param_glitch_power),0.9);
}
// APPLY BLOOM / WASHOUT
float addon = bokeh_pass_3( (eighth_res_bloom.g + quarter_res_bloom.g),I.tc0);
float addon_hard = max(addon - 0.7,0.0) * 2.0f;
float addon_soft = (max(half_res_blur.g - 0.6,0.0f) / 0.6) / 1.0f;
// addon = max(addon - 0.01,0) * 3;
image = image + (float3)addon_soft + (float3)addon_hard;
// image *= 3;
// APPLY CRT EFFECT
image = lerp(image,make_crt_ified(half_res_blur, I.tc0),gen_2_crt_effect_factor); // Adds a CRT effect that I think looks better than draw_scanlines
// APPLY NOISE
float lua_param_nvg_gain_current = floor(shader_param_8.y) / 10.0f;
image.r += jitter.y * (gen_2_nvg_noise_factor * (pow(lua_param_nvg_gain_current,0.5) )); // Add the noise to the image
// APPLY SCINTILLATION EFFECT
if (jitter.z > (gen_2_scintillation_constant - ( (1.0-gen_2_scintillation_constant) * (lua_param_nvg_gain_current - 1.0f) ) ) )
{ image.r = 1.0f; }
// APPLY IMAGE COLOR CORRECTION AND MAKE BRIGHT SPOTS WHITE
image.rgb = saturate(image.r) * gen_2_saturation_color;
if (image.g >= 0.95)
{
image.rgb = pow(image.ggg,2);
}
// APPLY VIGNETTE
float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f;
float vignette = calc_vignette(lua_param_nvg_num_tubes, I.tc0, lua_param_vignette_current);
image = clamp(image,0.0,1.0);
image *= vignette;
// RETURN THE RESULTING IMAGE
return float4(image, 1.0);
}
///////////////////////////////////////////////////////
// OUTSIDE NVG CIRCLES OF EFFECT - If the absolute distance from screen center is farther than circle_radius, then we'll run the other shader effects below
///////////////////////////////////////////////////////
else
{
float lua_param_nvg_mode = frac(shader_param_8.w) * 10;
if (abs(lua_param_nvg_mode-0.0) <= 0.01) // mode 0 - blur
{
image = half_res_blur;
image = clamp(image,0.0,1.0);
}
else if (abs(lua_param_nvg_mode-1.0) <= 0.01) // mode 1 - black
{
image = float3(0.0,0.0,0.0);
}
else if (abs(lua_param_nvg_mode-2.0) <= 0.01) // mode 2 - image overlay
{
image = clamp(image,0.0,1.0);
}
else if (abs(lua_param_nvg_mode-3.0) <= 0.01) // mode 3 - no changes (clear vision)
{
image = clamp(image,0.0,1.0);
}
// RETURN THE RESULTING IMAGE
return float4(image, 1.0);
}
}
@@ -0,0 +1,161 @@
///////////////////////////////////////////////////////
// BEEF'S SHADER BASED NIGHT VISION EFFECT //
///////////////////////////////////////////////////////
// Huge credit TO LVutner from Anomaly Discord, who //
// literally taught me everything I know, to Sky4Ace //
// who's simple_blur function I've adapted for this //
// shader, and to Meltac, who provided some advice //
// and inspiration for developing this shader. //
///////////////////////////////////////////////////////
// Note: You are free to distribute and adapt this //
// Shader and any components, just please provide //
// credit to myself and/or the above individuals. I //
// have provided credit for individual functions and //
// their original authors where applicable. - BEEF //
///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
// STEP 0 - GLOBAL DEFINITIONS AND INCLUDES
///////////////////////////////////////////////////////
#include "night_vision.h"
#include "common.h"
float3 bokeh_pass_3 (float image, float2 tc)
{
float Pi = 6.28318530718; float blur_directions = 8.0; float blur_quality = 4.0; float blur_radius = 5; float3 color = 0.0f; float3 color_average = 0.0f;
float light_avgs = 0.0f; float weight = 0.0f; float total_weight = 0.0f;
for(float i=1.0; i<=blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_blur_8.SampleLevel(smp_rtlinear, tc + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
color += s_blur_4.SampleLevel(smp_rtlinear, tc + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
if (color.g > 0.0f) { color.g *= 1.0f; light_avgs += 1.0f;} else {light_avgs += 0.5;} color_average += color; } } image = color_average.g / light_avgs;
return image;
}
float4 main(p_screen I) : SV_Target
{
///////////////////////////////////////////////////////
// STEP 0 - LOCAL DEFINITIONS
///////////////////////////////////////////////////////
// TC vars
float2 corrected_texturecoords = aspect_ratio_correction(I.tc0);
///////////////////////////////////////////////////////
// STEP 0 - MAIN SAMPLES
///////////////////////////////////////////////////////
float3 image = s_image.Sample(smp_rtlinear, I.tc0).xyz;
///////////////////////////////////////////////////////
// STEP 0 - MAIN FUNCTION
///////////////////////////////////////////////////////
float3 half_res_blur = s_blur_2.Sample(smp_rtlinear, I.tc0).rgb;
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f;
if (compute_lens_mask(corrected_texturecoords, lua_param_nvg_num_tubes) == 1) // see if we're inside the lens mask
{
// GRAB SAMPLES FOR NVG SHADER
float3 eighth_res_bloom = s_blur_8.Sample(smp_rtlinear, I.tc0).rgb;
float3 quarter_res_bloom = s_blur_4.Sample(smp_rtlinear, I.tc0).rgb;
float4 jitter = float4(
frac(sin(dot(I.tc0, float2(12.0, 78.0) + (timers.x) )) * 12345.0),
frac(sin(dot(I.tc0-fmod(I.tc0,float2(3.0,3.0)/screen_res.xy), float2(12.0, 78.0) + (timers.x) )) * 22738.0),
frac(sin(dot(I.tc0-fmod(I.tc0,float2(3.0,3.0)/screen_res.xy), float2(12.0, 78.0) + (timers.x) )) * 78372.0),
frac(sin(dot(I.tc0, float2(12.0, 78.0) + (timers.x) )) * 37857.0));
//float depth = s_position.Load(int3(I.tc0 * screen_res.xy,0),0).z; // Sample the depth buffer in a better way
//float depth = pow(blurred_depth(I.tc0),2)*1000;
float depth = blurred_depth(I.tc0);
//image.r = lerp(half_res_blur.r,image.r,0.6f);
image = pow(image,0.85);
image = lerp(image,half_res_blur,clamp(1-smoothstep(0,15,depth),0.2,1)); // NEAR BLUR
if (depth < 1000)
{
float light_att = pow(1.0f-(smoothstep(5,300,depth)),0.5); // Distance from full brightness to full black
if ((image.r+image.g) < 0.9f)
{
image.r *= (light_att+0.1f); //Apply light attenuation (plus offset to prevent sky turning black)
}
}
// GLITCH EFFECT -- TO DO
float lua_param_glitch_power = fmod(shader_param_8.z,1.0f);
if (lua_param_glitch_power > 0.0f)
{
image = lerp(image, glitchEffect(image, I.tc0, lua_param_glitch_power),0.9);
}
// APPLY BLOOM / WASHOUT
float addon = bokeh_pass_3( (eighth_res_bloom.g + quarter_res_bloom.g),I.tc0);
float addon_hard = max(addon - 0.7,0.0) * 2.0f;
float addon_soft = (max(half_res_blur.g - 0.6,0.0f) / 0.6) / 1.0f;
// addon = max(addon - 0.01,0) * 3;
image = image + (float3)addon_soft + (float3)addon_hard;
// image *= 3;
// APPLY CRT EFFECT
image = lerp(image,make_crt_ified(half_res_blur, I.tc0),gen_3_crt_effect_factor); // Adds a CRT effect that I think looks better than draw_scanlines
// APPLY NOISE
float lua_param_nvg_gain_current = floor(shader_param_8.y) / 10.0f;
image.r += jitter.y * (gen_3_nvg_noise_factor * (pow(lua_param_nvg_gain_current,0.5) )); // Add the noise to the image
// APPLY SCINTILLATION EFFECT
if (jitter.z > (gen_3_scintillation_constant - ( (1.0-gen_3_scintillation_constant) * (lua_param_nvg_gain_current - 1.0f) ) ) )
{ image.r = 1.0f; }
// APPLY IMAGE COLOR CORRECTION AND MAKE BRIGHT SPOTS WHITE
image.rgb = saturate(image.r) * gen_3_saturation_color;
if (image.g >= 0.95)
{
image.rgb = pow(image.ggg,2);
}
// APPLY VIGNETTE
float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f;
float vignette = calc_vignette(lua_param_nvg_num_tubes, I.tc0, lua_param_vignette_current);
image = clamp(image,0.0,1.0);
image *= vignette;
// RETURN THE RESULTING IMAGE
return float4(image, 1.0);
}
///////////////////////////////////////////////////////
// OUTSIDE NVG CIRCLES OF EFFECT - If the absolute distance from screen center is farther than circle_radius, then we'll run the other shader effects below
///////////////////////////////////////////////////////
else
{
float lua_param_nvg_mode = frac(shader_param_8.w) * 10;
if (abs(lua_param_nvg_mode-0.0) <= 0.01) // mode 0 - blur
{
image = half_res_blur;
image = clamp(image,0.0,1.0);
}
else if (abs(lua_param_nvg_mode-1.0) <= 0.01) // mode 1 - black
{
image = float3(0.0,0.0,0.0);
}
else if (abs(lua_param_nvg_mode-2.0) <= 0.01) // mode 2 - image overlay
{
image = clamp(image,0.0,1.0);
}
else if (abs(lua_param_nvg_mode-3.0) <= 0.01) // mode 3 - no changes (clear vision)
{
image = clamp(image,0.0,1.0);
}
// RETURN THE RESULTING IMAGE
return float4(image, 1.0);
}
}
@@ -0,0 +1,113 @@
#include "common.h"
#include "night_vision.h"
float4 blur_params;
float4 main(p_screen I) : SV_Target
{
// Defines
float3 image;
const float GAUSS_SIGMA = 2.5;
const int support = int(GAUSS_SIGMA * 1.5);
float lua_param_nvg_generation = floor(shader_param_8.x); // 1, 2, or 3
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f;
float lua_param_nvg_washout_thresh = frac(shader_param_8.y);
float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f;
if (lua_param_nvg_generation > 0.0f && compute_lens_mask(aspect_ratio_correction(I.tc0), lua_param_nvg_num_tubes) == 1.0f) // if NVGs are enabled ...
{
// HALF RES BLUR - PASS 1 - R = LUMA, G = LIGHTMAP, B = NORMALIZED DEPTH OUT TO FARTHEST_DEPTH (defined in night_vision.h)
if (blur_params.x == 1 && blur_params.z == (screen_res.x / 2.0f))
{
image = float3(s_image.Sample(smp_rtlinear, I.tc0).rg,saturate(s_position.Load( int3( (I.tc0)*screen_res.xy, 0 ), 0 ).z / farthest_depth));
if (image.b == 0.0f) { image.b = 1.0f; } float scale = 0.05f; scale *= (IGN_calc(I.tc0/2.0*screen_res.xy)); float3 total = 0.0f; float divisor = 0.0f;
float total_depth = image.b; float divisor_depth = 1.0f; float r = 1.0f; float2x2 G = rot(2.399996); float2 offset = float2(scale,scale);
for (int i = 0; i < 16; ++i) {
r += 1.0f / r; offset = mul(offset, G); float3 color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (offset * (r - 1.0f) * 1.0f/screen_res.xy),0).rgb;
color.b = saturate(s_position.Load( int3( (I.tc0*screen_res.xy) + (offset * (r - 1.0f)), 0 ), 0 ).z / (farthest_depth));
if (color.b == 0.0f) { color.b = 1.0f; } float weight = 1.0f; total.rg += color.rg * weight; divisor += weight; if (color.b <= image.b - 0.04)
{ total_depth += color.b; divisor_depth += weight; }
}
image = float3(max((total.rg / divisor),0),max((total_depth / divisor_depth),0));
float vignette = calc_vignette(lua_param_nvg_num_tubes, I.tc0, lua_param_vignette_current); image = clamp(image,0.0,1.0); image *= vignette;
return float4(image, 1.0f);
}
// HALF RES BLUR - PASS 2 - R = LUMA, G = LIGHTMAP, B = BLURRED DEPTH
else if (blur_params.x == 0 && blur_params.z == (screen_res.x / 2.0f)) // half-res fixed DOF blur pass 2
{
image = s_image.Sample(smp_rtlinear, I.tc0).rgb; float scale = 0.3f; float center_depth = image.b; scale *= (IGN_calc(I.tc0/2.0*screen_res.xy));
float3 total = 0.0f; float divisor = 0.0f; float r = 1.0f; float2x2 G = rot(2.399996); float2 offset = float2(scale,scale);
for (int i = 0; i < 24; ++i) { r += 1.0f / r; offset = mul(offset, G);
float falloff = saturate( ( 1.2f * center_depth ) - log(center_depth * 6.4f) - ( 0.4f * pow(center_depth, 2.3f) ) );
float3 color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (offset * (falloff) * (r - 1.02f) * 1.0f/screen_res.xy),0).rgb;
float weight = 1.0f; total += color * weight; divisor += weight;
}
image = max((total.rgb / divisor),0);
float vignette = calc_vignette(lua_param_nvg_num_tubes, I.tc0, lua_param_vignette_current); image = clamp(image,0.0,1.0); image *= vignette;
return float4(image, 1.0f);
}
// QUARTER RES BLUR - PASS 1 - R = LUMA, G = LIGHTMAP, B = ALBEDO
else if (blur_params.x == 1 && blur_params.z == (screen_res.x / 4))
{
float general_threshold = 0.05f; float light_thresh = lua_param_nvg_washout_thresh; float Pi = 6.28318530718; float blur_directions = 12.0; float blur_quality = 6.0;
float blur_radius = 1.5; float3 color = 0.0f; float3 color_average = s_image.Sample(smp_rtlinear, I.tc0).rgb; float weight = 0.0f;
float light_avgs = 0.0f;
for(float i=1.0; i<= blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb; color.rb *= color.rb;
color.rb = saturate((color.rb - general_threshold) / (1.0f - general_threshold)); color.g = saturate((color.g - light_thresh) / (1.0f - light_thresh));
if (color.g > 0.0f) { color.g *= 8.0f; light_avgs += 1.0f;} else {light_avgs += 0.1 * i;}
color.rb = sqrt(color.rb); color_average += color; } }
image.rb = color_average.rb / (blur_directions*blur_quality); image.g = color_average.g / light_avgs;
return float4(image, 1.0f);
}
// QUARTER RES BLUR - PASS 2 - R = LUMA, G = LIGHTMAP, B = ALBEDO
else if (blur_params.x == 0 && blur_params.z == (screen_res.x / 4)) // quarter and eighth res circular bokeh pass 2
{
float Pi = 6.28318530718; float blur_directions = 16.0; float blur_quality = 4.0; float blur_radius = 4; float3 color = 0.0f;
float3 color_average = s_image.Sample(smp_rtlinear, I.tc0).rgb; float light_avgs = 0.0f; float weight = 0.0f; float total_weight = 0.0f;
for(float i=1.0; i<= blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
if (color.g > 0.0f) { color.g *= 4.0f; light_avgs += 1.0f;} else {light_avgs += 0.1 * i;} color_average += color; } }
image.rb = color_average.rb / (blur_directions*blur_quality); image.g = color_average.g / light_avgs;
return float4(image, 1.0f);
}
// EIGHTH RES BLUR - PASS 1 - R = LUMA, G = LIGHTMAP, B = ALBEDO
else if (blur_params.x == 1 && blur_params.z == (screen_res.x / 8)) // quarter and eighth res circular bokeh pass 1
{
float general_threshold = 0.05f; float light_thresh = lua_param_nvg_washout_thresh; float Pi = 6.28318530718; float blur_directions = 12.0; float blur_quality = 4.0;
float blur_radius = 1; float3 color = 0.0f; float3 color_average = s_image.Sample(smp_rtlinear, I.tc0).rgb; float weight = 0.0f; float total_weight = 0.0f;
float light_avgs = 0.0f;
for(float i=1.0; i<= blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb; color.rb *= color.rb;
color.rb = saturate((color.rb - general_threshold) / (1.0f - general_threshold)); color.g = saturate((color.g - light_thresh) / (1.0f - light_thresh));
if (color.g > 0.0f) { color.g *= 8.0f; light_avgs += 1.0f;} else {light_avgs += 0.1 * i;} color.rb = sqrt(color.rb); color_average += color; } }
image.rb = color_average.rb / (blur_directions*blur_quality); image.g = color_average.g / light_avgs;
return float4(image, 1.0f);
}
// EIGHTH RES BLUR - PASS 2 - R = LUMA, G = LIGHTMAP, B = ALBEDO
else if (blur_params.x == 0 && blur_params.z == (screen_res.x / 8)) // quarter and eighth res circular bokeh pass 2
{
float Pi = 6.28318530718; float blur_directions = 16.0; float blur_quality = 4.0; float blur_radius = 4; float3 color = 0.0f;
float3 color_average = s_image.Sample(smp_rtlinear, I.tc0).rgb; float light_avgs = 0.0f; float weight = 0.0f; float total_weight = 0.0f;
for(float i=1.0; i<= blur_quality; i++) { for( float d=0.0; d<Pi; d+=Pi/blur_directions) {
color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (float2(cos(d),sin(d))*blur_radius*i/screen_res.xy),0).rgb;
if (color.g > 0.0f) { color.g *= 4.0f; light_avgs += 1.0f;} else {light_avgs += 0.1 * i;} color_average += color; } }
image.rb = color_average.rb / (blur_directions*blur_quality); image.g = color_average.g / light_avgs;
return float4(image, 1.0f);
}
}
// OTHERWISE, DO NORMAL BLUR
float scale = 0.3f; scale *= (IGN_calc(I.tc0/2.0*screen_res.xy)); float3 total = s_image.Sample(smp_rtlinear, I.tc0).rgb; float divisor = 1.0f;
float r = 0.9f; float2x2 G = rot(2.399996); float2 offset = float2(scale,scale);
for (int i = 0; i < 16; ++i) {r += 1.0f / r; offset = mul(offset, G);
float3 color = s_image.SampleLevel(smp_rtlinear, I.tc0 + (offset * (r - 1.0f) * 1.0f/screen_res.xy),0).rgb; float weight = 1.0f;
total += color * weight; divisor += weight; } image = max((total / divisor),0);
return float4(image, 1.0f);
}
@@ -0,0 +1,64 @@
#include "common.h"
#include "night_vision.h"
struct v2p
{
float4 factor : COLOR0; // for SM3 - factor.rgb - tonemap-prescaled
float3 tc0 : TEXCOORD0;
float3 tc1 : TEXCOORD1;
float4 sv : SV_Position;
};
struct _out
{
float4 low : SV_Target0;
float4 high : SV_Target1;
};
TextureCube s_sky0 :register(t0);
TextureCube s_sky1 :register(t1);
//////////////////////////////////////////////////////////////////////////////////////////
// Pixel
_out main( v2p I )
{
float3 s0 = s_sky0.Sample( smp_rtlinear, I.tc0 );
float3 s1 = s_sky1.Sample( smp_rtlinear, I.tc1 );
float3 sky = lerp (s0,s1,I.factor.w);
sky *= I.factor.rgb;
// final tone-mapping
_out o;
tonemap(o.low, o.high, sky, 1 ) ; //factor contains tonemapping
float2 texturecoord = I.sv.xy / screen_res.xy;
float2 texturecoord_2 = I.sv.xy / screen_res.xy;
float lua_param_nvg_generation = floor(shader_param_8.x); // 1, 2, or 3
float lua_param_nvg_num_tubes = frac(shader_param_8.x) * 10.0f; // 1, 2, 4, 1.1, or 1.2
float lua_param_nvg_gain_current = floor(shader_param_8.y) / 10.0f;
float lua_param_vignette_current = floor(shader_param_8.z) / 100.0f;
if (lua_param_nvg_generation > 0 && ((compute_lens_mask(aspect_ratio_correction(texturecoord), lua_param_nvg_num_tubes) == 1.0f || compute_lens_mask(aspect_ratio_correction(texturecoord_2), lua_param_nvg_num_tubes) == 1.0f)))
{
o.low.r = dot(o.low.rgb * 5.0f, luma_conversion_coeff);
o.high.r = dot(o.high.rgb * 5.0f, luma_conversion_coeff);
o.low.gb = 0.0f;
o.high.gb = 0.0f;
o.low *= lua_param_nvg_gain_current * sky_brightness_factor;
o.high *= lua_param_nvg_gain_current * sky_brightness_factor;
o.high = clamp(o.high,0.0,1.0);
o.low= clamp(o.low,0.0,1.0);
float vignette = calc_vignette(lua_param_nvg_num_tubes, texturecoord, lua_param_vignette_current);
float vignette_2 = calc_vignette(lua_param_nvg_num_tubes, texturecoord_2, lua_param_vignette_current);
o.low *= (vignette * vignette_2);
o.high *= (vignette * vignette_2);
}
return o;
}
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
[General]
gameName=stalkeranomaly
modid=0
version=d2024.11.23.0
newestVersion=
category="-1,"
nexusFileStatus=1
installationFile=Beefs_NVGs.1.zip
repository=Nexus
ignoredVersion=
comments=
notes=
nexusDescription=
url=
hasCustomURL=false
lastNexusQuery=
lastNexusUpdate=
nexusLastModified=2024-11-23T10:11:03Z
nexusCategory=0
converted=false
validated=false
color=@Variant(\0\0\0\x43\0\xff\xff\0\0\0\0\0\0\0\0)
tracked=0
[installedFiles]
size=1
1\modid=0
1\fileid=0
[Plugins]
BAIN%20Installer\option0=Beef's NVGs
BAIN%20Installer\option1=Beef's NVGs - Patch (Only ES No SSR)