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,68 @@
#include "common.h"
#define BLUR_QUALITY 2
#define BLUR_DIRECTIONS 8
#define BLUR_SIZE 8
#define BLUR_DIST 0.5
uniform float4 m_hud_params;
float4 ogse_c_screen;
float4 SSFX_get_position(float2 tc, uint iSample : SV_SAMPLEINDEX)
{
#ifndef USE_MSAA
return s_position.SampleLevel(smp_nofilter, tc, 0);
#else
return s_position.Load(int3(tc * screen_res.xy, 0), iSample);
#endif
}
float depth_to_weight(float depth) {
if (depth < SKY_EPS || depth > 200)
depth = 200;
return lerp(0, max(BLUR_DIST - depth, 0) / BLUR_DIST, m_hud_params.x);
}
float pixel_weight(float w) {
if (w < 0.01)
return 0.05;
return 1;
}
float3 weapon_blur(float2 tc)
{
float2 Radius = float2(BLUR_SIZE / screen_res.x, BLUR_SIZE / screen_res.y);
float Pi = 6.28318530718;
float3 Orig = s_image.Sample(smp_rtlinear, tc).rgb;
if (m_hud_params.x == 0)
return Orig;
float Weight = depth_to_weight(SSFX_get_position(tc, 0).z);
float W = Weight * pixel_weight(Weight);
float C = pixel_weight(Weight);
for(int i=BLUR_QUALITY; i>=1; i-=1)
{
for(int d=BLUR_DIRECTIONS; d>=1; d-=1)
{
float2 curTc = tc + float2(cos(Pi / BLUR_DIRECTIONS * d), sin(Pi / BLUR_DIRECTIONS * d)) * Radius / BLUR_QUALITY * i;
float w = depth_to_weight(SSFX_get_position(curTc, 0).z);
W += w * pixel_weight(w);
C += pixel_weight(w);
}
}
W /= C;
W = max(W, Weight);
return lerp(Orig, s_blur_2.SampleLevel(smp_rtlinear, tc, 0).rgb, W);
}
float4 main(p_screen I) : SV_TARGET
{
return float4(weapon_blur(I.tc0), 1);
}
@@ -0,0 +1,171 @@
#ifndef GBUFFER_STAGE_H
#define GBUFFER_STAGE_H
//GBuffer targets struct
struct f_deffer
{
float4 position : SV_Target0; //XY - Normal, Z - Depth, W - Hemi/M_ID
float4 C : SV_Target1; //XYZ - Albedo, W - Specular
float4 H : SV_Target2;
#ifdef EXTEND_F_DEFFER
uint mask : SV_COVERAGE;
#endif
};
uniform float4 L_hotness;
//Unpacked data struct
struct gbuffer_data
{
float3 P; //View space position
float mtl; //Material ID
float3 N; //Unpacked normal
float hemi; //Hemi
float3 C; //Albedo
float gloss; //Specular
};
#ifdef INTERNAL_AMD
float2 gbuf_pack_normal( float3 norm )
{
float2 res;
res.x = norm.z;
res.y = 0.5f * ( norm.x + 1.0f ) ;
res.y *= ( norm.y < 0.0f ? -1.0f : 1.0f );
return res;
}
float3 gbuf_unpack_normal( float2 norm )
{
float3 res;
res.z = norm.x;
res.x = ( 2.0f * abs( norm.y ) ) - 1.0f;
res.y = ( norm.y < 0 ? -1.0 : 1.0 ) * sqrt( abs( 1 - res.x * res.x - res.z * res.z ) );
return res;
}
#else
float2 gbuf_pack_normal( float3 norm )
{
float2 res;
res.x = atan2(norm.y, norm.x) / 3.14159f;
res.y = norm.z;
return res;
}
float3 gbuf_unpack_normal( float2 norm )
{
float2 theta;
sincos(norm.x * 3.14159f, theta.x, theta.y);
float2 phi = float2(sqrt(1.0 - norm.y * norm.y), norm.y);
return float3(theta.y * phi.x, theta.x * phi.x, phi.y);
}
#endif
float gbuf_pack_hemi_mtl( float hemi, float mtl )
{
uint packed_mtl = uint( ( mtl / 1.333333333 ) * 31.0 );
// Clamp hemi max value
uint packed = ( MUST_BE_SET + ( uint( saturate(hemi) * 255.9 ) << 13 ) + ( ( packed_mtl & uint( 31 ) ) << 21 ) );
if( ( packed & USABLE_BIT_13 ) == 0 )
packed |= USABLE_BIT_14;
if( packed_mtl & uint( 16 ) )
packed |= USABLE_BIT_15;
return asfloat( packed );
}
float gbuf_unpack_hemi( float mtl_hemi )
{
return float( ( asuint( mtl_hemi ) >> 13 ) & uint(255) ) * (1.0/254.8);
}
float gbuf_unpack_mtl( float mtl_hemi )
{
uint packed = asuint( mtl_hemi );
uint packed_hemi = ( ( packed >> 21 ) & uint(15) ) + ( ( packed & USABLE_BIT_15 ) == 0 ? 0 : 16 );
return float( packed_hemi ) * (1.0/31.0) * 1.333333333;
}
//Packing stage
#ifndef EXTEND_F_DEFFER
f_deffer pack_gbuffer( float4 norm, float4 pos, float4 col )
#else
f_deffer pack_gbuffer( float4 norm, float4 pos, float4 col, uint imask )
#endif
{
f_deffer res;
res.position = float4( gbuf_pack_normal( norm.xyz ), pos.z, gbuf_pack_hemi_mtl( norm.w, pos.w ) );
res.C = col;
if (L_hotness.x > 0.0)
res.H = float4(L_hotness.x, 0.0, 0.0, 1.0);
else
res.H = float4(0.0, 0.0, 0.0, 0.0);
#ifdef EXTEND_F_DEFFER
res.mask = imask;
#endif
return res;
}
//Unpacking stage
gbuffer_data gbuffer_load_data( float2 tc : TEXCOORD, float2 pos2d, uint iSample )
{
gbuffer_data gbd;
#ifndef USE_MSAA
float4 P = s_position.Sample( smp_nofilter, tc );
float4 C = s_diffuse.Sample( smp_nofilter, tc );
#else
float4 P = s_position.Load( int3( pos2d, 0 ), iSample );
float4 C = s_diffuse.Load( int3( pos2d, 0 ), iSample );
#endif
// 3d view space pos reconstruction math
gbd.P = float3( P.z * ( pos2d * pos_decompression_params.zw - pos_decompression_params.xy ), P.z );
// reconstruct N
gbd.N = gbuf_unpack_normal( P.xy );
// reconstruct material
gbd.mtl = gbuf_unpack_mtl( P.w );
// reconstruct hemi
gbd.hemi = gbuf_unpack_hemi( P.w );
gbd.C = C.xyz;
gbd.gloss = C.w;
return gbd;
}
gbuffer_data gbuffer_load_data( float2 tc : TEXCOORD, float2 pos2d )
{
return gbuffer_load_data( tc, pos2d, 0 );
}
gbuffer_data gbuffer_load_data_offset( float2 tc : TEXCOORD, float2 OffsetTC : TEXCOORD, float2 pos2d )
{
float2 delta = ( ( OffsetTC - tc ) * screen_res.xy );
return gbuffer_load_data( OffsetTC, pos2d + delta, 0 );
}
gbuffer_data gbuffer_load_data_offset( float2 tc : TEXCOORD, float2 OffsetTC : TEXCOORD, float2 pos2d, uint iSample )
{
float2 delta = ( ( OffsetTC - tc ) * screen_res.xy );
return gbuffer_load_data( OffsetTC, pos2d + delta, iSample );
}
#endif //GBUFFER_STAGE_H
@@ -0,0 +1,10 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("deffer_model_flat","deffer_base_flat")
: fog (false)
: blend(true, blend.zero, blend.one)
: scopelense(1)
shader:dx10texture("s_base", t_base)
shader:dx10sampler("smp_base")
shader:dx10stencil(true, cmp_func.always, 2, 2, stencil_op.replace, stencil_op.replace, stencil_op.replace)
shader:dx10stencil_ref(2)
end
@@ -0,0 +1,476 @@
/*
=====================================================================
Addon : Shader 3D Scopes
Link : https://www.moddb.com/mods/stalker-anomaly/addons/shader-3d-scopes
Authors : LVutner, party_50
Date : 01.03.2024
Last Edit : 26.10.2024
=====================================================================
*/
#include "common.h"
#include "nv_utils.h"
#include "thermal_utils.h"
#define PI 3.1415926f
#define RT_NONE 0
#define RT_LED 1
#define RT_LED_MASKED 2
#define RT_ACOG 3
#define RT_SPECTER 4
#define RT_GIPERON 5
#define RT_SCREEN 6
#define RT_ADDITIVE 7
#define IT_NONE 0
#define IT_NV 1
#define IT_THERMAL 2
Texture2D s_prev_frame;
Texture2D s_inside;
Texture2D s_dirt;
TextureCube s_env0;
TextureCube s_env1;
float4 m_hud_params;
float4 m_hud_fov_params;
float4 ogse_c_screen;
uniform float4 s3ds_param_1;
uniform float4 s3ds_param_2;
uniform float4 s3ds_param_3;
uniform float4 s3ds_param_4;
uniform float4 markswitch_current;
uniform float4 markswitch_color;
uniform float4 shader_param_8;
struct vf
{
float4 hpos : SV_Position;
float2 tc0 : TEXCOORD0;
float3 v_pos : TEXCOORD1;
float3 v_nrm : TEXCOORD2;
float3 w_pos : TEXCOORD3;
float3 w_nrm : TEXCOORD4;
float3 v_dir : TEXCOORD5;
float3 v_sun : TEXCOORD6;
};
float3x3 cotangent_frame(float3 N, float3 P, float2 uv)
{
float3 dp1 = ddx(P);
float3 dp2 = ddy(P);
float2 duv1 = ddx(uv);
float2 duv2 = ddy(uv);
float3 dp2perp = cross(dp2, N);
float3 dp1perp = cross(N, dp1);
float3 T = dp2perp * duv1.x + dp1perp * duv2.x;
float3 B = dp2perp * duv1.y + dp1perp * duv2.y;
float invmax = rsqrt(max(dot(T, T), dot(B, B)));
return float3x3(T * invmax, B * invmax, N);
}
float4 sample_shadow(float2 tc, float shadow_width)
{
float a = smoothstep(0.5 - shadow_width, 0.5, distance(tc, float2(0.5, 0.5)));
return float4(0, 0, 0, a);
}
float4 sample_zoom_switch_shadow(float2 tc, float min_zoom, float max_zoom)
{
float shift = smoothstep(min_zoom, max_zoom, ogse_c_screen.x);
float a = smoothstep(1 - 0.1, 1, distance(tc, float2(0.5 + shift * 3, 0.5)));
float b = smoothstep(1 - 0.4, 1, distance(tc, float2(-2.5 + shift * 3, 0.5)));
return float4(0, 0, 0, a * b);
}
float2 project(float2 tc, float2 tangent, float distance, float size)
{
float2 parallax_tc = tc - tangent * distance;
parallax_tc.x = (parallax_tc.x + (size - 1) / 2) / size;
parallax_tc.y = (parallax_tc.y + (size - 1) / 2) / size;
return parallax_tc;
}
float4 blur_sample(Texture2D tex, SamplerState samp, float2 uv)
{
float4 color = float4(0, 0, 0, 0);
float blur_amount = 0.006;
float dither_amount = 0.006;
float2 offsets[9] = {
float2(-1, -1), float2(0, -1), float2(1, -1),
float2(-1, 0), float2(0, 0), float2(1, 0),
float2(-1, 1), float2(0, 1), float2(1, 1)
};
float weights[9] = {
1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0,
2.0 / 16.0, 4.0 / 16.0, 2.0 / 16.0,
1.0 / 16.0, 2.0 / 16.0, 1.0 / 16.0
};
// Generate a small random offset for dithering
float2 dither = float2(
(frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453) - 0.5) * dither_amount,
(frac(sin(dot(uv, float2(93.9898, 67.345))) * 43758.5453) - 0.5) * dither_amount
);
for (int i = 0; i < 9; i++)
{
color += tex.Sample(samp, uv + offsets[i] * blur_amount + dither) * weights[i];
}
return color;
}
float3 chroma_sample(float2 lens_tc, float2 back_tc, float current_fov, float power)
{
float3 color_sum = float3(0, 0, 0);
float3 weight_sum = float3(0, 0, 0);
for(int i = 0; i <= 16; ++i)
{
float step = i / 16.0;
float2 delta = lens_tc - 0.5;
float zoom_multiplier = min(1, 0.005 * (180 / current_fov));
delta = sign(delta) * pow(abs(delta), 3.5) * (2 * power + zoom_multiplier);
float2 coord = back_tc + (step - 0.5) * delta;
float3 weight = float3(step, 1.0 - abs(step + step - 1.0), 1.0 - step);
weight = lerp(float3(0.5, 0.5, 0.5), weight, 2.0);
float3 color = s_prev_frame.Sample(smp_rtlinear, coord).rgb;
color_sum += color * color * weight;
weight_sum += weight;
}
return sqrt(color_sum / weight_sum);
}
float3 back_image_sample(float2 lens_tc, float2 back_tc, float current_fov, float power, int nvg_blur)
{
if (nvg_blur && floor(shader_param_8.x) != 0)
{
return blur_sample(s_prev_frame, smp_rtlinear, back_tc);
}
return chroma_sample(lens_tc, back_tc, current_fov, power);
}
float3 apply_nvg(float2 tc, float3 img)
{
img = BlackandWhite(img);
img = Brightness(img, 0.45, 6);
img = clamp(img, 0, 1);
img = LevelsPass(img);
img = Grain2(img, tc);
img = Grain1(img, tc);
return img;
}
float3 lcd_effect(int2 hpos)
{
float pb = 0.4;
float3 lcdColor = float3(pb, pb, pb);
int px = int(fmod(hpos.x, 3));
if (px == 1)
lcdColor.r = 1;
else if (px == 2)
lcdColor.g = 1;
else
lcdColor.b = 1;
float sclV = 0.25;
if (int(fmod(hpos.y, 3)) == 0)
lcdColor.rgb = float3(sclV, sclV, sclV);
return lcdColor;
}
float2 fisheye_shift(float2 uv, float progress, float2 center)
{
uv -= center;
float ratio = 1;
float pUvX = pow(uv.x * ratio, 2);
float pUvY = pow(uv.y, 2);
float pSum = pUvX + pUvY;
float multiplier = 10 * (1 - progress);
float strength = 1 - multiplier * pSum;
uv *= strength;
uv += center;
return uv;
}
float2 fisheye(float2 tc, float2 tangent)
{
float FISHEYE_STRENGTH = -0.3;
float FISHEYE_PROJECT = 2;
float fish_power = 1 + FISHEYE_STRENGTH * length(tangent);
float2 fished = fisheye_shift(tc, fish_power, project(float2(0.5, 0.5), tangent, FISHEYE_PROJECT, 1.0));
return fished - tc;
}
float current_lum()
{
float lum_min = 0.85;
float lum_max = 3;
float lum = s_tonemap.Load(int3(0, 0, 0)).x;
return clamp(1 - (lum - lum_min) / (lum_max - lum_min), 0, 1);
}
float4 rgba_blend(float4 b, float4 a)
{
float na = a.a + b.a * (1 - a.a);
float3 nc = na > 0 ? (a.rgb * a.a + b.rgb * b.a * (1 - a.a)) / na : float3(0, 0, 0);
return float4(nc, na);
}
float3 sample_sky(float3 dir)
{
dir.y = (dir.y - max(cos(dir.x) * 0.65, cos(dir.z) * 0.65)) * 2.1;
dir.y -= -0.35;
float3 sky0 = s_env0.SampleLevel(smp_base, dir, 0).xyz;
float3 sky1 = s_env1.SampleLevel(smp_base, dir, 0).xyz;
return lerp(sky0, sky1, L_ambient.w);
}
float4 sample_specular(float3 pnt, float3 normal, float3 light_direction)
{
float w = pow(abs(dot(normalize(pnt + light_direction), normal)), 256);
return float4(L_sun_color.rgb * w, w);
}
float4 main(vf I) : SV_Target
{
float RETICLE_SIZE = s3ds_param_1.x;
float EYE_RELIEF = s3ds_param_1.y;
float EXIT_PUPIL = s3ds_param_1.z;
int FFP = s3ds_param_1.w;
float MIN_ZOOM_FOV = m_hud_fov_params.y * 0.75;
float MAX_ZOOM_FOV = m_hud_fov_params.x * 0.75;
int MIN_ZOOM_1X = s3ds_param_2.z;
float ZOOM_FACTOR = s3ds_param_2.w;
int IMAGE_TYPE = s3ds_param_3.x;
int RETICLE_TYPE = s3ds_param_3.y;
float DIRT_INTENSITY = s3ds_param_3.z;
float CHROMA_POWER = s3ds_param_3.w;
float3 LENS_COLOR = s3ds_param_4.xyz;
int NVG_BLUR = s3ds_param_4.w;
// ZOOM_FACTOR = 1 => (0, 1); ZOOM_FACTOR = 1.5 => (0.4, 1.1)
float IMAGE_PROJECT = 0.8 * ZOOM_FACTOR - 0.8;
float IMAGE_SIZE = 0.2 * ZOOM_FACTOR + 0.8;
float RETICLE_PROJECT = 10;
float SHADOW_WIDTH = 0.15;
float3 V = -I.v_pos;
float3x3 TBN = cotangent_frame(I.v_nrm, I.v_pos, I.tc0.xy);
float3 V_tangent = normalize(float3(dot(V, TBN[0]), dot(V, TBN[1]), dot(V, TBN[2])));
float current_zoom = max(MIN_ZOOM_FOV / ogse_c_screen.x, 1);
float zoom_part = max(0, (ogse_c_screen.x - MIN_ZOOM_FOV) / (MAX_ZOOM_FOV - MIN_ZOOM_FOV));
if (MAX_ZOOM_FOV == MIN_ZOOM_FOV)
{
zoom_part = 0;
}
if (MIN_ZOOM_1X)
{
IMAGE_PROJECT *= zoom_part;
IMAGE_SIZE = 1 + (IMAGE_SIZE - 1) * zoom_part;
}
float lum = current_lum();
// Sight reticle
float2 reticle_lens_tc = project(I.tc0, V_tangent.xy, RETICLE_PROJECT, RETICLE_SIZE) + fisheye(I.tc0, V_tangent.xy) / current_zoom;
float2 reticle_tc = project(I.tc0, V_tangent.xy, RETICLE_PROJECT, RETICLE_SIZE * (FFP || RETICLE_TYPE == RT_GIPERON ? current_zoom : 1)) + fisheye(I.tc0, V_tangent.xy) / current_zoom;
float4 mark_texture = float4(0, 0, 0, 0);
if (reticle_tc.x >= 0 && reticle_tc.x <= 1 && reticle_tc.y >= 0 && reticle_tc.y <= 1)
{
mark_texture = s_base.Sample(smp_rtlinear, reticle_tc);
}
if (RETICLE_TYPE == RT_GIPERON)
{
float finder = s_base.Sample(smp_rtlinear, reticle_lens_tc).g;
float reticle = mark_texture.r;
float shift_3x = 0.053;
float angle = -PI * (zoom_part + shift_3x) / (1 + shift_3x);
float2 tc = reticle_lens_tc - 0.5;
tc = float2(tc.x * cos(angle) - tc.y * sin(angle), tc.x * sin(angle) + tc.y * cos(angle));
tc += 0.5;
float numbers = s_base.Sample(smp_rtlinear, tc + fisheye(I.tc0, V_tangent.xy)).b;
mark_texture = float4(0, 0, 0, max(numbers, max(finder, reticle)));
}
if (RETICLE_TYPE == RT_ACOG)
{
float3 black = float3(0, 0, 0);
float3 color = float3(1, 0.2, 0.2);
float3 text = float3(0.3, 0.3, 0.3);
float tritium_lum = 0.2;
mark_texture = rgba_blend(rgba_blend(float4(black, mark_texture.r), float4(color * max(tritium_lum, lum * 2), mark_texture.g)), float4(text, mark_texture.b * lum));
}
if (RETICLE_TYPE == RT_LED || RETICLE_TYPE == RT_GIPERON)
{
mark_texture = float4(markswitch_color.rgb, mark_texture.a);
}
if (RETICLE_TYPE == RT_SPECTER)
{
float3 black = float3(0, 0, 0);
float4 light = float4(0, 0, 0, 0);
if (markswitch_current.x == 1)
light = float4(markswitch_color.rgb, mark_texture.g);
if (markswitch_current.x == 2)
light = float4(markswitch_color.rgb, mark_texture.b);
mark_texture = rgba_blend(float4(black, mark_texture.r), light);
}
if (RETICLE_TYPE == RT_LED_MASKED)
{
float3 black = float3(0, 0, 0);
mark_texture = rgba_blend(float4(black, mark_texture.r), float4(markswitch_color.rgb, mark_texture.g));
}
// Specter switch shadow
float4 zoom_switch_shadow = float4(0, 0, 0, 0);
if (RETICLE_TYPE == RT_SPECTER)
{
zoom_switch_shadow = sample_zoom_switch_shadow(reticle_lens_tc, MIN_ZOOM_FOV, MAX_ZOOM_FOV);
}
// Sight bound
float4 mark_shadow = sample_shadow(reticle_lens_tc, 0.01);
float4 mark_shadow_blue = sample_shadow(reticle_lens_tc, CHROMA_POWER / 2);
mark_shadow_blue.rgb = float3(0.1, 0.1, 0.65);
if (RETICLE_TYPE == RT_SCREEN)
{
if (reticle_lens_tc.y < 0 || reticle_lens_tc.y > 1 || reticle_lens_tc.x < 0 || reticle_lens_tc.x > 1)
mark_shadow = float4(0, 0, 0, 1);
else
mark_shadow = float4(0, 0, 0, 0);
}
// Parallax shadow
float2 exit_pupil_tc = project(I.tc0, V_tangent.xy, -EYE_RELIEF, EXIT_PUPIL);
float4 shadow_texture = sample_shadow(exit_pupil_tc, SHADOW_WIDTH);
// LED-illuminated inside walls
float4 inside = s_inside.Sample(smp_rtlinear, (reticle_lens_tc - 0.5) * 0.62 + 0.5);
inside = float4(markswitch_color.rgb * inside.r, inside.a);
if (RETICLE_TYPE == RT_SCREEN || RETICLE_TYPE == RT_SPECTER) {
inside = float4(0, 0, 0, 0);
}
// Dirt texture
float4 dirt = s_dirt.Sample(smp_rtlinear, I.tc0);
dirt.a *= DIRT_INTENSITY;
// Back image
float2 screen_tc = I.hpos.xy * screen_res.zw;
float zoom = lerp(1, IMAGE_SIZE, m_hud_params.x);
float shift = lerp(0, IMAGE_PROJECT, m_hud_params.x);
float2 scope_tc = (1.0 / zoom) * (screen_tc.xy - 0.5) + 0.5;
V_tangent.x = V_tangent.x / screen_res.x * screen_res.y;
scope_tc = scope_tc + V_tangent.xy * shift;
if (RETICLE_TYPE == RT_SPECTER) {
float smooth_zoom_part = smoothstep(0, 1, zoom_part);
if (distance(I.tc0, float2(0.5 + smooth_zoom_part * 3, 0.5)) <= 1)
scope_tc.x -= 0.2 * smooth_zoom_part;
if (distance(I.tc0, float2(-2.5 + smooth_zoom_part * 3, 0.5)) <= 1)
scope_tc.x += 0.2 * (1 - smooth_zoom_part);
}
float3 back;
if (IMAGE_TYPE == IT_THERMAL && markswitch_current.x < 2) {
float pixelate = int(current_zoom);
scope_tc = (floor(scope_tc * screen_res.xy / (pixelate)) * (pixelate) + 0.5) / screen_res.xy;
gbuffer_data gbd = gbuffer_load_data(scope_tc, scope_tc * screen_res.xy, 0);
back = infrared(gbd, scope_tc * screen_res.xy, scope_tc);
if (markswitch_current.x == 1) {
back = 1 - back;
}
} else {
back = back_image_sample(I.tc0, scope_tc, ogse_c_screen.x, CHROMA_POWER, NVG_BLUR);
back *= LENS_COLOR;
}
if (IMAGE_TYPE == IT_THERMAL) {
back *= lcd_effect(I.hpos);
}
if (IMAGE_TYPE == IT_NV && markswitch_current.x == 0) {
back = apply_nvg(scope_tc, back);
}
// Reflections
float3 normalmap = float3(I.tc0.xy, 1) * 2 - 1;
float3x3 TBNw = cotangent_frame(I.w_nrm, I.w_pos, I.tc0.xy);
float3x3 TBNw_inv = transpose(TBNw);
float3 lensnormal = normalize(float3(dot(normalmap, TBNw_inv[0]), dot(normalmap, TBNw_inv[1]), dot(normalmap, TBNw_inv[2])));
float3 reflections = sample_sky(reflect(normalize(I.w_pos - eye_position), lensnormal));
float angle_factor = (dot(normalize(I.w_pos - eye_position), normalize(I.w_nrm)) + 1) / 2;
reflections *= smoothstep(0, 0.03, angle_factor) * smoothstep(0, 1, lum) * 0.15;
reflections *= pow(1 - dirt.a, 10);
// Specular light
float3x3 TBN_inv = transpose(TBN);
float4 specular = sample_specular(
normalize(I.v_dir),
normalize(float3(dot(normalmap, TBN_inv[0]), dot(normalmap, TBN_inv[1]), dot(normalmap, TBN_inv[2]))),
normalize(I.v_sun)
) * 4;
specular.w *= L_material.g * smoothstep(-0.001, 0.03, angle_factor);
specular.w = min(1, specular.w);
specular.w *= pow(1 - dirt.a, 10);
// Vignette
float4 vignette = float4(0, 0, 0, smoothstep(0.4, 2, 2 * length(I.tc0.xy - float2(0.5, 0.5))));
float3 final_scope = back;
if (RETICLE_TYPE != RT_SCREEN)
{
final_scope = lerp(final_scope, mark_shadow_blue.xyz, mark_shadow_blue.w * BlackandWhite(back));
}
final_scope = lerp(final_scope, vignette.xyz, vignette.w);
final_scope = lerp(final_scope, mark_shadow.xyz, mark_shadow.w);
final_scope = lerp(final_scope, inside.xyz, inside.w);
if (RETICLE_TYPE == RT_ADDITIVE)
{
final_scope += mark_texture.xyz * mark_texture.w;
}
if (RETICLE_TYPE != RT_SCREEN)
{
final_scope = lerp(final_scope, shadow_texture.xyz, shadow_texture.w);
}
if (RETICLE_TYPE != RT_ADDITIVE)
{
final_scope = lerp(final_scope, mark_texture.xyz, mark_texture.w);
}
final_scope = lerp(final_scope, zoom_switch_shadow.xyz, zoom_switch_shadow.w);
final_scope = max(final_scope, reflections);
final_scope += specular.xyz * specular.w;
final_scope = lerp(final_scope, dirt.xyz, dirt.w);
return float4(final_scope, 1.0);
}
@@ -0,0 +1,20 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("models_scope_reticle", "models_scope_reticle")
: fog(true)
: zb(true, false)
: blend(true, blend.srcalpha, blend.invsrcalpha)
: aref(true, 0)
: sorting(2, true)
: distort(true)
: scopelense(3)
shader:dx10texture("s_base", t_base)
shader:dx10texture("s_env0", "$user$sky0")
shader:dx10texture("s_env1", "$user$sky1")
shader:dx10texture("s_prev_frame", "$user$generic_temp")
shader:dx10texture("s_tonemap", "$user$tonemap")
shader:dx10texture("s_heat", "$user$heat")
shader:dx10texture("s_position", "$user$generic2")
shader:dx10texture("s_inside", "wpn\\scope_utility\\inside")
shader:dx10texture("s_dirt", "wpn\\scope_utility\\dirt")
shader:dx10sampler("smp_rtlinear")
end
@@ -0,0 +1,57 @@
#include "common.h"
#include "skin.h"
struct vf
{
float4 hpos : SV_Position;
float2 tc0 : TEXCOORD0;
float3 v_pos : TEXCOORD1;
float3 v_nrm : TEXCOORD2;
float3 w_pos : TEXCOORD3;
float3 w_nrm : TEXCOORD4;
float3 v_dir : TEXCOORD5;
float3 v_sun : TEXCOORD6;
};
vf _main (v_model v)
{
vf o;
o.hpos = mul(m_WVP, v.P);
o.tc0 = v.tc.xy;
o.v_pos = mul(m_WV, v.P).xyz;
o.v_nrm = mul(m_WV, v.N).xyz;
o.w_pos = mul(m_W, v.P).xyz;
o.w_nrm = mul(m_W, v.N).xyz;
o.v_dir = mul(m_V, normalize(o.w_pos - eye_position));
o.v_sun = mul(m_V, L_sun_dir_w);
return o;
}
#ifdef SKIN_NONE
vf main(v_model v) { return _main(v); }
#endif
#ifdef SKIN_0
vf main(v_model_skinned_0 v) { return _main(skinning_0(v)); }
#endif
#ifdef SKIN_1
vf main(v_model_skinned_1 v) { return _main(skinning_1(v)); }
#endif
#ifdef SKIN_2
vf main(v_model_skinned_2 v) { return _main(skinning_2(v)); }
#endif
#ifdef SKIN_3
vf main(v_model_skinned_3 v) { return _main(skinning_3(v)); }
#endif
#ifdef SKIN_4
vf main(v_model_skinned_4 v) { return _main(skinning_4(v)); }
#endif
@@ -0,0 +1,20 @@
#include "common.h"
Texture2D rt_tempzb;
float4 m_hud_params;
struct PSOutput
{
float4 mask : SV_Target3;
float depth : SV_Depth;
};
PSOutput main(float4 hpos : SV_Position)
{
PSOutput output;
output.depth = rt_tempzb[hpos.xy].x;
output.mask = float4(1.0, 0.0, 0.0, 1.0);
return output;
}
@@ -0,0 +1,9 @@
function normal(shader, t_base, t_second, t_detail)
shader:begin("deffer_model_flat","models_scope_zwrite")
: zb(false, true)
: scopelense(2)
shader:dx10texture("rt_tempzb", "$user$temp_zb")
shader:dx10sampler("smp_rtlinear")
shader:dx10stencil(true, cmp_func.equal, 2, 2, stencil_op.zero, stencil_op.zero, stencil_op.zero)
shader:dx10stencil_ref(2)
end
@@ -0,0 +1,299 @@
float4x4 brightnessMatrix( float brightness )
{
return float4x4(1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
brightness, brightness, brightness, 1 );
}
float4x4 contrastMatrix( float contrast )
{
float t = ( 1.0 - contrast ) / 2.0;
return float4x4(contrast, 0, 0, 0,
0, contrast, 0, 0,
0, 0, contrast, 0,
t, t, t, 1 );
}
float4x4 saturationMatrix( float saturation )
{
float3 luminance = float3( 0.3086, 0.6094, 0.0820 );
float oneMinusSat = 1.0 - saturation;
float3 red = float3( luminance.x * oneMinusSat, luminance.x * oneMinusSat, luminance.x * oneMinusSat );
red+= float3( saturation, 0, 0 );
float3 green = float3( luminance.y * oneMinusSat, luminance.y * oneMinusSat, luminance.y * oneMinusSat );
green += float3( 0, saturation, 0 );
float3 blue = float3( luminance.z * oneMinusSat, luminance.z * oneMinusSat, luminance.z * oneMinusSat );
blue += float3( 0, 0, saturation );
return float4x4(red, 0,
green, 0,
blue, 0,
0, 0, 0, 1 );
}
float3 Brightness(float3 color, float brightness, float contrast)
{
const float saturation = 1.0;
float4 res;
res = mul(
float4(color, 1.0),
mul(
mul(
brightnessMatrix( brightness ),
contrastMatrix( contrast )
),
saturationMatrix( saturation )
)
);
return res.rgb;
}
/////////////////////////////////////////////////////////////////////////////////////
float3 RGBToHCV( in float3 RGB )
{
float4 P = ( RGB.g < RGB.b ) ? float4( RGB.bg, -1.0f, 2.0f/3.0f ) : float4( RGB.gb, 0.0f, -1.0f/3.0f );
float4 Q1 = ( RGB.r < P.x ) ? float4( P.xyw, RGB.r ) : float4( RGB.r, P.yzx );
float C = Q1.x - min( Q1.w, Q1.y );
float H = abs(( Q1.w - Q1.y ) / ( 6.0f * C + 0.000001f ) + Q1.z );
return float3( H, C, Q1.x );
}
float3 RGBToHSL( in float3 RGB )
{
RGB.xyz = max( RGB.xyz, 0.000001f );
float3 HCV = RGBToHCV(RGB);
float L = HCV.z - HCV.y * 0.5f;
float S = HCV.y / ( 1.0f - abs( L * 2.0f - 1.0f ) + 0.000001f);
return float3( HCV.x, S, L );
}
float curve( float x, float k )
{
float s = sign( x - 0.5f );
float o = ( 1.0f + s ) / 2.0f;
return o - 0.5f * s * pow( 2.0f * ( o - s * x ), k );
}
float3 ProcessBW( float3 col, float r, float y, float g, float c, float b, float m )
{
float3 hsl = RGBToHSL( col.xyz );
float lum = 1.0f - hsl.z;
float curve_str=4.000000;
float weight_r = curve( max( 1.0f - abs( hsl.x * 6.0f ), 0.0f ), curve_str ) +
curve( max( 1.0f - abs(( hsl.x - 1.0f ) * 6.0f ), 0.0f ), curve_str );
float weight_y = curve( max( 1.0f - abs(( hsl.x - 0.166667f ) * 6.0f ), 0.0f ), curve_str );
float weight_g = curve( max( 1.0f - abs(( hsl.x - 0.333333f ) * 6.0f ), 0.0f ), curve_str );
float weight_c = curve( max( 1.0f - abs(( hsl.x - 0.5f ) * 6.0f ), 0.0f ), curve_str );
float weight_b = curve( max( 1.0f - abs(( hsl.x - 0.666667f ) * 6.0f ), 0.0f ), curve_str );
float weight_m = curve( max( 1.0f - abs(( hsl.x - 0.833333f ) * 6.0f ), 0.0f ), curve_str );
float sat = hsl.y * ( 1.0f - hsl.y ) + hsl.y;
float ret = hsl.z;
ret += ( hsl.z * ( weight_r * r ) * sat * lum );
ret += ( hsl.z * ( weight_y * y ) * sat * lum );
ret += ( hsl.z * ( weight_g * g ) * sat * lum );
ret += ( hsl.z * ( weight_c * c ) * sat * lum );
ret += ( hsl.z * ( weight_b * b ) * sat * lum );
ret += ( hsl.z * ( weight_m * m ) * sat * lum );
return saturate( ret );
}
float3 BlackandWhite(float3 color)
{
color.xyz = saturate( color.xyz );
float red; float yellow; float green;
float cyan; float blue; float magenta;
red = -0.400000;
yellow = 2.000001;
green = 3.000000;
cyan = 0.000000;
blue = -0.600000;
magenta = -0.200000;
color.xyz = ProcessBW( color.xyz, red, yellow, green, cyan, blue, magenta );
return color;
}
/////////////////////////////////////////////////////////////////////////////////////
float3 LevelsPass(float3 color)
{
const float3 InputColor = color;
float3 OutputColor = InputColor;
float3 InputBlackPoint=float3(0.000000,0.000000,0.000000);
float3 InputWhitePoint=float3(1.000000,1.000000,1.000000);
float3 OutputBlackPoint=float3(0.000000,0.000000,0.000000);
float3 OutputWhitePoint=float3(1.000000,1.000000,1.000000);
float3 InputGamma=float3(3.920000,1.000000,7.467000);
OutputColor = pow(abs(((InputColor) - InputBlackPoint)/(InputWhitePoint - InputBlackPoint)), InputGamma) * (OutputWhitePoint - OutputBlackPoint) + OutputBlackPoint;
return OutputColor;
}
//////////////////////////////////////////////////////////////////////////////////////
#define permONE 1.0f / 256.0f
#define permHALF 0.5f * permONE
#define permTexSize 256
float discreteNoise(float rand) {
return float(int(rand * 3.0) * 64) / 256.0;
}
float4 rnm( float2 tc, float t )
{
float grainAdjust=1.000000;
float noise = sin( dot( tc, float2( 12.9898, 78.233 ))) * ( 43758.5453 + t );
float noiseR = frac( noise * grainAdjust ) * 2.0 - 1.0;
float noiseG = frac( noise * 1.2154 * grainAdjust ) * 2.0 - 1.0;
float noiseB = frac( noise * 1.3453 * grainAdjust ) * 2.0 - 1.0;
float noiseA = frac( noise * 1.3647 * grainAdjust ) * 2.0 - 1.0;
return float4( noiseR, noiseG, noiseB, noiseA );
}
float4 samplerPermTex(float2 uv)
{
float4 gen = rnm(uv, 13.14381);
gen.x = discreteNoise(gen.x);
gen.y = discreteNoise(gen.y);
gen.z = discreteNoise(gen.z);
return gen;
}
float fade( float t )
{
return t * t * t * ( t * ( t * 6.0 - 15.0 ) + 10.0 );
}
float pnoise3D( float3 p, float t, float grainSize )
{
float3 pi = permONE * floor( p ) + permHALF;
pi.xy *= permTexSize;
pi.xy = round(( pi.xy - permHALF ) / grainSize ) * grainSize;
pi.xy /= permTexSize;
float3 pf = frac( p );
// Noise contributions from (x=0, y=0), z=0 and z=1
float perm00 = rnm( pi.xy, t ).x;
float3 grad000 = samplerPermTex(float2( perm00, pi.z )).xyz * 4.0 - 1.0;
float n000 = dot( grad000, pf );
float3 grad001 = samplerPermTex(float2( perm00, pi.z + permONE )).xyz * 4.0 - 1.0;
float n001 = dot( grad001, pf - float3( 0.0, 0.0, 1.0 ));
// Noise contributions from (x=0, y=1), z=0 and z=1
float perm01 = rnm( pi.xy + float2( 0.0, permONE ), t ).y ;
float3 grad010 = samplerPermTex(float2( perm01, pi.z )).xyz * 4.0 - 1.0;
float n010 = dot( grad010, pf - float3( 0.0, 1.0, 0.0 ));
float3 grad011 = samplerPermTex(float2( perm01, pi.z + permONE )).xyz * 4.0 - 1.0;
float n011 = dot( grad011, pf - float3( 0.0, 1.0, 1.0 ));
// Noise contributions from (x=1, y=0), z=0 and z=1
float perm10 = rnm( pi.xy + float2( permONE, 0.0 ), t ).z ;
float3 grad100 = samplerPermTex(float2( perm10, pi.z )).xyz * 4.0 - 1.0;
float n100 = dot( grad100, pf - float3( 1.0, 0.0, 0.0 ));
float3 grad101 = samplerPermTex(float2( perm10, pi.z + permONE )).xyz * 4.0 - 1.0;
float n101 = dot( grad101, pf - float3( 1.0, 0.0, 1.0 ));
// Noise contributions from (x=1, y=1), z=0 and z=1
float perm11 = rnm( pi.xy + float2( permONE, permONE ), t ).w ;
float3 grad110 = samplerPermTex(float2( perm11, pi.z )).xyz * 4.0 - 1.0;
float n110 = dot( grad110, pf - float3( 1.0, 1.0, 0.0 ));
float3 grad111 = samplerPermTex(float2( perm11, pi.z + permONE )).xyz * 4.0 - 1.0;
float n111 = dot( grad111, pf - float3( 1.0, 1.0, 1.0 ));
// Blend contributions along x
float4 n_x = lerp( float4( n000, n001, n010, n011 ), float4( n100, n101, n110, n111 ), fade( pf.x ));
// Blend contributions along y
float2 n_xy = lerp( n_x.xy, n_x.zw, fade( pf.y ));
// Blend contributions along z
float n_xyz = lerp( n_xy.x, n_xy.y, fade( pf.z ));
// We're done, return the final noise value
return n_xyz;
}
float3 doGrain(float3 color, float2 texcoord,
float grainSize,
float grainAmount,
float grainIntensity,
float grainColor,
float grainIntHigh,
float grainIntLow,
float grainDensity)
{
float timer = timers.x % 1000.0f;
float2 uv = texcoord.xy * float2( screen_res.x, screen_res.y );
float3 noise = pnoise3D( float3( uv.xy, 1 ), timer, grainSize );
noise.y = pnoise3D( float3( uv.xy, 2 ), timer, grainSize );
noise.z = pnoise3D( float3( uv.xy, 3 ), timer, grainSize );
// Old, practically does the same as grainAmount below
// Added back on request
noise.xyz *= grainIntensity;
// Noise saturation
noise.xyz = lerp( dot( noise.xyz, 1.0f ), noise.xyz, grainColor );
// Control noise density
noise.xyz = pow( abs( noise.xyz ), max( 11.0f - grainDensity, 0.1f )) * sign( noise.xyz );
// Mixing options
float lum = dot( color.xyz, 0.333333f ); // Just using average here
noise.xyz = lerp( noise.xyz * grainIntLow, noise.xyz * grainIntHigh, fade( lum )); // Noise adjustments based on average intensity
color.xyz = lerp( color.xyz, color.xyz + ( noise.xyz ), grainAmount );
return float3( color.xyz );
}
float3 Grain2(float3 color, float2 texcoord)
{
float grainSize = 2.0;
float grainAmount=0.023000 * 0.00004;
float grainIntensity=1.000000;
float grainColor=0.000000;
float grainIntHigh=0.000000;
float grainIntLow=1.000000;
float grainDensity=0.000000;
return doGrain(color, texcoord,
grainSize,
grainAmount,
grainIntensity,
grainColor,
grainIntHigh,
grainIntLow,
grainDensity);
}
//////////////////////////////////////////////////////////////////////////////////////
float3 Grain1(float3 color, float2 texcoord)
{
float grainSize=1.0;
float grainAmount=0.500000;
float grainIntensity=0.300000;
float grainColor=0.000000;
float grainIntHigh=0.000000;
float grainIntLow=0.500000;
float grainDensity=10.000000;
return doGrain(color, texcoord,
grainSize,
grainAmount,
grainIntensity,
grainColor,
grainIntHigh,
grainIntLow,
grainDensity);
}
@@ -0,0 +1,128 @@
/*
=====================================================================
Original Author : vegeta1k95
Link : https://www.moddb.com/mods/stalker-anomaly/addons/heatvision-v02-extension-for-beefs-nvg-dx11engine-mod
=====================================================================
*/
#ifdef USE_MSAA
#ifndef SM_5
Texture2DMS<float4,MSAA_SAMPLES> s_heat;
#else
Texture2DMS<float4> s_heat;
#endif
#else
Texture2D s_heat;
#endif
#define FADE_DISTANCE_START 0.0 // 13.0
#define FADE_DISTANCE_END 100.0 // 20.0
#define COLOR_FAR_MIN float3 (0.0, 0.03, 0.07) // 0.07
#define COLOR_FAR_MAX float3 (0.0, 0.03, 0.15) // 0.15
#define COLOR_DBLUE float3 (0.0, 0.10, 0.35)
#define COLOR_BLUE float3 (0.0, 0.10, 0.5)
#define COLOR_LBLUE float3 (0.0, 0.74, 1.0)
#define COLOR_GREEN float3 (0.4, 1.0, 0.6)
#define COLOR_YELLOW float3 (1.0, 0.8, 0.0)
#define COLOR_RED float3 (1.0, 0.2, 0.0)
#define COLOR_BLACK float3 (0.0, 0.0, 0.0)
#define COLOR_WHITE float3 (1.0, 1.0, 1.0)
#define color_background_min COLOR_DBLUE
#define color_background_max COLOR_BLUE
#define color_gradient_very_low color_background_max
#define color_gradient_low COLOR_GREEN
#define color_gradient_warm COLOR_YELLOW
#define color_gradient_hot COLOR_RED
float3 normal_blur(float2 pos2d, int samples)
{
float3 accum = (0.0, 0.0, 0.0);
for (int i = -samples; i < samples; i++) {
for (int j = -samples; j < samples; j++) {
accum += gbuf_unpack_normal(s_position.Load( int3( pos2d+float2(i,j), 0 ), 0).xy);
}
}
accum /= (samples*samples*4);
return accum;
}
float3 greyscale(float3 img)
{
float Y = 0.6*img.x + 0.5*img.y + 0.55*img.z;
return float3(Y, Y, Y);
}
float3 infrared(gbuffer_data gbd, float2 HPos, float2 Tex0)
{
int BW = 1;
float depth = gbd.P.z;
float3 hotness = s_heat.Load(int3(Tex0 * screen_res.xy, 0 ), 0);
float3 mixed;
if (hotness.r > 0.0)
{
int samples = lerp(15, 4, smoothstep(0.0, 60, depth));
mixed = normal_blur(HPos, samples);
mixed = normalize(mixed);
float projection = dot(mixed, float3(0.0, 0.0, -1.0));
if (projection <= 0.f) {
mixed = color_background_max;
} else {
mixed = lerp(color_gradient_very_low, color_gradient_hot, smoothstep(0, 1.0, projection));
}
mixed = lerp(color_background_max, mixed, hotness.r);
} else if (hotness.g > 0.0) {
float3 blur_2 = s_blur_2.Sample(smp_base, Tex0).rgb;
float luminance = dot(blur_2, float3(0.299f, 0.587f, 0.114f));
luminance *= hotness.g;
if (luminance >= 0.4) {
mixed = color_gradient_hot;
} else if (luminance >= 0.3 && luminance < 0.4) {
mixed = color_gradient_warm;
} else if (luminance >= 0.1 && luminance < 0.3) {
mixed = color_gradient_low;
} else {
float projection = dot(normalize(gbd.N), float3(0.0, 0.0, -1.0));
mixed = lerp(color_background_min, color_background_max, projection);
}
} else if (hotness.b > 0.0) {
mixed = lerp(color_background_min, color_gradient_low, hotness.b);
} else {
float projection = dot(normalize(gbd.N), float3(0.0, 0.0, -1.0));
if (depth <= 0)
{
depth = FADE_DISTANCE_END;
}
if (depth < FADE_DISTANCE_START)
{
mixed = lerp(color_background_min, color_background_max, projection);
}
else
{
float arg = smoothstep(FADE_DISTANCE_START, FADE_DISTANCE_END, clamp(depth, FADE_DISTANCE_START, FADE_DISTANCE_END));
float3 min_color = lerp(color_background_min, COLOR_FAR_MIN - float3(0.0, 0.0, 0.03), arg);
float3 max_color = lerp(color_background_max, COLOR_FAR_MAX - float3(0.0, 0.0, 0.05), arg);
mixed = lerp(min_color, max_color, projection);
}
}
mixed = greyscale(mixed);
return mixed;
}