diff --git a/extern/CommonLibSSE-NG b/extern/CommonLibSSE-NG index 371445d29..887c11060 160000 --- a/extern/CommonLibSSE-NG +++ b/extern/CommonLibSSE-NG @@ -1 +1 @@ -Subproject commit 371445d29867266e1d12bebcab6879392861ef86 +Subproject commit 887c11060ce7866e4c6b6c7e749a3b8404d42d2e diff --git a/package/Shaders/ISAlphaBlend.hlsl b/package/Shaders/ISAlphaBlend.hlsl deleted file mode 100644 index e7d771a19..000000000 --- a/package/Shaders/ISAlphaBlend.hlsl +++ /dev/null @@ -1,83 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState TintMask0Sampler : register(s0); -SamplerState TintMask1Sampler : register(s1); -SamplerState TintMask2Sampler : register(s2); -SamplerState TintMask3Sampler : register(s3); -SamplerState TintMask4Sampler : register(s4); -SamplerState TintMask5Sampler : register(s5); -SamplerState TintMask6Sampler : register(s6); -SamplerState TintMask7Sampler : register(s7); -SamplerState TintMask8Sampler : register(s8); -SamplerState TintMask9Sampler : register(s9); -SamplerState TintMask10Sampler : register(s10); -SamplerState TintMask11Sampler : register(s11); -SamplerState TintMask12Sampler : register(s12); -SamplerState TintMask13Sampler : register(s13); -SamplerState TintMask14Sampler : register(s14); -SamplerState TintMask15Sampler : register(s15); - -Texture2D TintMask0Tex : register(t0); -Texture2D TintMask1Tex : register(t1); -Texture2D TintMask2Tex : register(t2); -Texture2D TintMask3Tex : register(t3); -Texture2D TintMask4Tex : register(t4); -Texture2D TintMask5Tex : register(t5); -Texture2D TintMask6Tex : register(t6); -Texture2D TintMask7Tex : register(t7); -Texture2D TintMask8Tex : register(t8); -Texture2D TintMask9Tex : register(t9); -Texture2D TintMask10Tex : register(t10); -Texture2D TintMask11Tex : register(t11); -Texture2D TintMask12Tex : register(t12); -Texture2D TintMask13Tex : register(t13); -Texture2D TintMask14Tex : register(t14); -Texture2D TintMask15Tex : register(t15); - -cbuffer PerGeometry : register(b2) -{ - float4 Color[16] : packoffset(c0); -}; - -float3 BlendAlpha(Texture2D tintMaskTex, SamplerState tintMaskSamplerState, float2 texCoord, float4 blendColor, float3 color) -{ - float tintMask = tintMaskTex.Sample(tintMaskSamplerState, texCoord).x; - return blendColor.xyz * (1 - tintMask * blendColor.w) + (blendColor.w * tintMask) * color; -} - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float3 color = 0.5.xxx; - - color = BlendAlpha(TintMask0Tex, TintMask0Sampler, input.TexCoord, Color[0], color); - color = BlendAlpha(TintMask1Tex, TintMask1Sampler, input.TexCoord, Color[1], color); - color = BlendAlpha(TintMask2Tex, TintMask2Sampler, input.TexCoord, Color[2], color); - color = BlendAlpha(TintMask3Tex, TintMask3Sampler, input.TexCoord, Color[3], color); - color = BlendAlpha(TintMask4Tex, TintMask4Sampler, input.TexCoord, Color[4], color); - color = BlendAlpha(TintMask5Tex, TintMask5Sampler, input.TexCoord, Color[5], color); - color = BlendAlpha(TintMask6Tex, TintMask6Sampler, input.TexCoord, Color[6], color); - color = BlendAlpha(TintMask7Tex, TintMask7Sampler, input.TexCoord, Color[7], color); - color = BlendAlpha(TintMask8Tex, TintMask8Sampler, input.TexCoord, Color[8], color); - color = BlendAlpha(TintMask9Tex, TintMask9Sampler, input.TexCoord, Color[9], color); - color = BlendAlpha(TintMask10Tex, TintMask10Sampler, input.TexCoord, Color[10], color); - color = BlendAlpha(TintMask11Tex, TintMask11Sampler, input.TexCoord, Color[11], color); - color = BlendAlpha(TintMask12Tex, TintMask12Sampler, input.TexCoord, Color[12], color); - color = BlendAlpha(TintMask13Tex, TintMask13Sampler, input.TexCoord, Color[13], color); - color = BlendAlpha(TintMask14Tex, TintMask14Sampler, input.TexCoord, Color[14], color); - color = BlendAlpha(TintMask15Tex, TintMask15Sampler, input.TexCoord, Color[15], color); - - psout.Color = float4(color, 1); - - return psout; -} -#endif diff --git a/package/Shaders/ISApplyReflections.hlsl b/package/Shaders/ISApplyReflections.hlsl deleted file mode 100644 index ccae1164b..000000000 --- a/package/Shaders/ISApplyReflections.hlsl +++ /dev/null @@ -1,45 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float3 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState SSRSourceSampler : register(s0); -SamplerState WaterMaskSampler : register(s1); -SamplerState MainBufferSampler : register(s2); - -Texture2D SSRSourceTex : register(t0); -Texture2D WaterMaskTex : register(t1); -Texture2D MainBufferTex : register(t2); - -cbuffer PerGeometry : register(b2) -{ - float4 SSRParams : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 adjustedScreenPosition = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord.xy); - - float2 waterMask = WaterMaskTex.SampleLevel(WaterMaskSampler, adjustedScreenPosition, 0).zw; - float3 mainColor = MainBufferTex.Sample(MainBufferSampler, adjustedScreenPosition).xyz; - - float3 colorOffset = 0.0.xxx; - if (waterMask.x >= 1e-5 && waterMask.y > 1e-5) { - float4 ssrSourceColor = SSRSourceTex.Sample(SSRSourceSampler, adjustedScreenPosition); - colorOffset = clamp(SSRParams.x * (ssrSourceColor.xyz * ssrSourceColor.w), - 0, SSRParams.y * mainColor); - } - - psout.Color = colorOffset + mainColor; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISBLensFlare.hlsl b/package/Shaders/ISBLensFlare.hlsl deleted file mode 100644 index b9fe1ebfc..000000000 --- a/package/Shaders/ISBLensFlare.hlsl +++ /dev/null @@ -1,68 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState DownScaledBlurredHDRSampler : register(s0); -SamplerState RampsSampler : register(s1); -SamplerState MasksSampler : register(s2); - -Texture2D DownScaledBlurredHDRTex : register(t0); -Texture2D RampsTex : register(t1); -Texture2D MasksTex : register(t2); - -cbuffer PerGeometry : register(b2) -{ - float lensCount : packoffset(c0.x); - float flareDispersal : packoffset(c0.y); - float lightsRangeDownshift : packoffset(c0.z); - float invLightsRangeDownshift : packoffset(c0.w); - float lateralRepeat : packoffset(c1.x); - float channelsDistortionRed : packoffset(c1.y); - float channelsDistortionGreen : packoffset(c1.z); - float channelsDistortionBlue : packoffset(c1.w); - float texelOffsetX : packoffset(c2.x); - float texelOffsetY : packoffset(c2.y); - float haloFetch : packoffset(c2.z); - float haloWidthPow : packoffset(c2.w); - float dynamicSource : packoffset(c3.x); - float globalIntensity : packoffset(c3.y); -}; - -float4 GetSampleColor(float2 texCoord) -{ - float4 color = DownScaledBlurredHDRTex.Sample(DownScaledBlurredHDRSampler, texCoord); - if (saturate(color.x - lightsRangeDownshift) + saturate(color.y - lightsRangeDownshift) + - saturate(color.z - lightsRangeDownshift) <= - 0) { - return 0; - } - return saturate(color); -} - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 lensColor = 0; - for (int sampleIndex = -asint(lateralRepeat); sampleIndex <= asint(lateralRepeat); ++sampleIndex) { - float4 sampleColor; - if (dynamicSource > 0.5) { - sampleColor = GetSampleColor(GetDynamicResolutionAdjustedScreenPosition( - input.TexCoord + float2(texelOffsetX * sampleIndex, 0))); - } else { - sampleColor = GetSampleColor(input.TexCoord + float2(texelOffsetX * sampleIndex, 0)); - } - lensColor += sampleColor; - } - psout.Color = globalIntensity * lensColor; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISBasicCopy.hlsl b/package/Shaders/ISBasicCopy.hlsl deleted file mode 100644 index 4d9e8b85d..000000000 --- a/package/Shaders/ISBasicCopy.hlsl +++ /dev/null @@ -1,24 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState SourceSampler : register(s0); - -Texture2D SourceTex : register(t0); - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 srcColor = SourceTex.Sample(SourceSampler, input.TexCoord); - psout.Color = srcColor; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISBlur.hlsl b/package/Shaders/ISBlur.hlsl deleted file mode 100644 index 215614a33..000000000 --- a/package/Shaders/ISBlur.hlsl +++ /dev/null @@ -1,63 +0,0 @@ -#include "Common/Color.hlsl" -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); -SamplerState AvgLumSampler : register(s1); - -Texture2D ImageTex : register(t0); -Texture2D AvgLumTex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 BlurBrightPass : packoffset(c0); - float4 BlurScale : packoffset(c1); - float BlurRadius : packoffset(c2); - float4 BlurOffsets[16] : packoffset(c3); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 color = 0.0.xxxx; - - float blurRadius = BLUR_RADIUS; - float2 blurScale = BlurScale.zw; -# if BLUR_RADIUS == 0 - blurRadius = BlurRadius; -# endif -# if BLUR_RADIUS == 0 || defined(BLUR_NON_HDR) - blurScale = 1.0.xx; -# endif - - for (int blurIndex = 0; blurIndex < blurRadius; ++blurIndex) { - float2 screenPosition = BlurOffsets[blurIndex].xy + input.TexCoord.xy; - if (BlurScale.x < 0.5) { - screenPosition = GetDynamicResolutionAdjustedScreenPosition(screenPosition); - } - float4 imageColor = ImageTex.Sample(ImageSampler, screenPosition) * float4(blurScale.yyy, 1); -# if defined(BLUR_BRIGHT_PASS) - imageColor = BlurBrightPass.y * max(0.0.xxxx, -BlurBrightPass.x + imageColor); -# endif - color += imageColor * BlurOffsets[blurIndex].z; - } - -# if defined(BLUR_BRIGHT_PASS) - float avgLum = RGBToLuminance(AvgLumTex.Sample(AvgLumSampler, input.TexCoord.xy).xyz); - color.w = avgLum; -# endif - - psout.Color = color * float4(blurScale.xxx, 1); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISCompositeLensFlareVolumetricLighting.hlsl b/package/Shaders/ISCompositeLensFlareVolumetricLighting.hlsl deleted file mode 100644 index 7e6c25ca8..000000000 --- a/package/Shaders/ISCompositeLensFlareVolumetricLighting.hlsl +++ /dev/null @@ -1,44 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float3 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState VLSourceSampler : register(s0); -SamplerState LFSourceSampler : register(s1); - -Texture2D VLSourceTex : register(t0); -Texture2D LFSourceTex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 VolumetricLightingColor : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float3 color = 0.0.xxx; - -# if defined(VOLUMETRIC_LIGHTING) - float2 screenPosition = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - float volumetricLightingPower = VLSourceTex.Sample(VLSourceSampler, screenPosition).x; - color += VolumetricLightingColor.xyz * volumetricLightingPower; -# endif - -# if defined(LENS_FLARE) - float3 lensFlareColor = LFSourceTex.Sample(LFSourceSampler, input.TexCoord).xyz; - color += lensFlareColor; -# endif - - psout.Color = color; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISCopy.hlsl b/package/Shaders/ISCopy.hlsl deleted file mode 100644 index a966830ee..000000000 --- a/package/Shaders/ISCopy.hlsl +++ /dev/null @@ -1,45 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); - -Texture2D ImageTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 RotationMatrix : packoffset(c0); - float4 ColorSelect : packoffset(c1); - float4 ScaleBias : packoffset(c2); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - -# if !defined(DYNAMIC_FETCH_DISABLED) - float2 screenPosition = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); -# else - float2 screenPosition = input.TexCoord; -# endif - - float4 color = ImageTex.Sample(ImageSampler, screenPosition); - -# if defined(GRAY_SCALE) - color = float4(dot(color, ColorSelect).xxx, color.w); -# elif defined(TEXTURE_MASK) - color.w = 1 - color.x; -# endif - - psout.Color = color; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISDebugSnow.hlsl b/package/Shaders/ISDebugSnow.hlsl deleted file mode 100644 index 95709f0cb..000000000 --- a/package/Shaders/ISDebugSnow.hlsl +++ /dev/null @@ -1,28 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState snowAlphaSpecSampler : register(s0); -SamplerState sceneSampler : register(s1); - -Texture2D snowAlphaSpecTex : register(t0); -Texture2D sceneTex : register(t1); - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float snowAlphaSpec = snowAlphaSpecTex.Sample(snowAlphaSpecSampler, input.TexCoord).y; - float4 sceneColor = sceneTex.Sample(sceneSampler, input.TexCoord); - - psout.Color = sceneColor + float4(snowAlphaSpec, 0, 0, 1); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISDepthOfField.hlsl b/package/Shaders/ISDepthOfField.hlsl deleted file mode 100644 index 75e67bc6b..000000000 --- a/package/Shaders/ISDepthOfField.hlsl +++ /dev/null @@ -1,147 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); -SamplerState BlurredSampler : register(s1); -SamplerState DepthSampler : register(s2); -SamplerState AvgDepthSampler : register(s3); -SamplerState MaskSampler : register(s4); - -Texture2D ImageTex : register(t0); -Texture2D BlurredTex : register(t1); -Texture2D DepthTex : register(t2); -Texture2D AvgDepthTex : register(t3); -Texture2D MaskTex : register(t4); - -cbuffer PerGeometry : register(b2) -{ - float4 invScreenRes : packoffset(c0); // inverse render target width and height in xy - float4 params : packoffset(c1); // DOF near range in x, far range in y - float4 params2 : packoffset(c2); // DOF near blur in x, far blur in w - float4 params3 : packoffset(c3); // 1 / (far - near) in z, near / (far - near) in w - float4 params4 : packoffset(c4); - float4 params5 : packoffset(c5); - float4 params6 : packoffset(c6); - float4 params7 : packoffset(c7); -}; - -void CheckOffsetDepth(float2 center, float2 offset, inout float crossSection, - inout float totalDepth) -{ - float depth = DepthTex - .Sample(DepthSampler, GetDynamicResolutionAdjustedScreenPosition( - invScreenRes.xy * offset + center)) - .x; - - float crossSectionDelta = 0; - if (depth > 0.999998987) { - crossSectionDelta = (1. / 9.); - } - crossSection += crossSectionDelta; - totalDepth += depth; -} - -float GetFinalDepth(float depth, float near, float far) -{ - return (2 * near * far) / ((far + near) - (depth * 2 - 1) * (far - near)); -} - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 adjustedTexCoord = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - - float3 imageColor = ImageTex.Sample(ImageSampler, adjustedTexCoord).xyz; - float3 blurColor = BlurredTex.Sample(BlurredSampler, adjustedTexCoord).xyz; - - float mask = 1; - float4 dofParams = params; - float4 dofParams2 = params2; -# if defined(MASKED) - mask = MaskTex.Sample(MaskSampler, adjustedTexCoord).x; - dofParams = lerp(params, params6, mask); - dofParams2 = lerp(params2, params7, mask); -# endif - - float2 dofBlurRange = float2(dofParams2.x, dofParams.x); - float focusDistance = dofParams.y; - -# if !defined(MASKED) - if (params3.z > 0) { - focusDistance = AvgDepthTex.Sample(AvgDepthSampler, 0).x; - float depthFactor = saturate(focusDistance * params3.z - params3.w); - dofBlurRange = lerp(float2(params2.x, params.x), float2(params2.w, params.y), depthFactor); - } -# endif - - float depthCC = - DepthTex.Sample(DepthSampler, GetDynamicResolutionAdjustedScreenPosition(input.TexCoord)).x; - - float crossSection = 0; - float avgDepth = depthCC; - bool isTooDeep = false; - if (dofParams2.w != 0 && depthCC > 0.999998987) { - crossSection = 1. / 9.; - float totalDepth = depthCC; - CheckOffsetDepth(input.TexCoord, float2(-3, -3), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(-3, 0), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(-3, 3), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(3, -3), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(3, 0), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(3, 3), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(0, -3), crossSection, totalDepth); - CheckOffsetDepth(input.TexCoord, float2(0, 3), crossSection, totalDepth); - - avgDepth = totalDepth / 9; - isTooDeep = avgDepth > 0.999998987; - } - - float blurFactor = 0; - float finalDepth = avgDepth; - if (!isTooDeep && avgDepth > 1e-5) { - float depth, near, far; - if (avgDepth <= 0.01) { - depth = 100 * avgDepth; - near = params3.x; - far = params3.y; - } else { - depth = 1.01 * avgDepth - 0.01; - near = dofParams.z; - far = dofParams.w; - } - finalDepth = GetFinalDepth(depth, near, far); - - float dofStrength = 0; -# if defined(DISTANT_BLUR) - dofStrength = (finalDepth - focusDistance) / dofBlurRange.y; -# elif defined(DOF) - if ((focusDistance > finalDepth || mask == 0) && dofParams2.y != 0) { - dofStrength = (focusDistance - finalDepth) / dofBlurRange.y; - } else if (finalDepth > focusDistance && dofParams2.z != 0) { - dofStrength = (finalDepth - focusDistance) / dofBlurRange.y; - } -# endif - - blurFactor = saturate(dofStrength) * (dofBlurRange.x * (1 - 0.5 * crossSection)); - } - - float3 finalColor = lerp(imageColor, blurColor, blurFactor); -# if defined(FOGGED) - float fogFactor = (params4.w * saturate((finalDepth - params5.y) / (params5.x - params5.y))) * mask; - finalColor = lerp(finalColor, params4.xyz, fogFactor); -# endif - - psout.Color = float4(finalColor, 1); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISDoubleVision.hlsl b/package/Shaders/ISDoubleVision.hlsl deleted file mode 100644 index 77f1dc96a..000000000 --- a/package/Shaders/ISDoubleVision.hlsl +++ /dev/null @@ -1,52 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState Src0Sampler : register(s0); -SamplerState Src1Sampler : register(s1); - -Texture2D Src0Tex : register(t0); -Texture2D Src1Tex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 blurParams : packoffset(c0); - float4 doubleVisParams : packoffset(c1); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 texCoord0 = float2(max(0, -doubleVisParams.x + input.TexCoord.x), - max(-doubleVisParams.y + input.TexCoord.y, 1 - doubleVisParams.w)); - float2 adjustedTexCoord0 = GetDynamicResolutionAdjustedScreenPosition(texCoord0); - float3 src0Color0 = Src0Tex.Sample(Src0Sampler, adjustedTexCoord0).xyz; - - float2 texCoord1 = float2(min(doubleVisParams.z, doubleVisParams.x + input.TexCoord.x), - min(1, doubleVisParams.y + input.TexCoord.y)); - float2 adjustedTexCoord1 = GetDynamicResolutionAdjustedScreenPosition(texCoord1); - float3 src0Color1 = Src0Tex.Sample(Src0Sampler, adjustedTexCoord1).xyz; - - float2 adjustedTexCoord2 = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - float3 src1Color = Src1Tex.Sample(Src1Sampler, adjustedTexCoord2).xyz; - - float src1Factor = min(1, - blurParams.z * - length(float2(2 * ((doubleVisParams.z / doubleVisParams.w) * (input.TexCoord.x - 0.5)), - 2 * (input.TexCoord.y - 0.5)))); - - float3 color = 0.5 * ((1 - src1Factor) * (src0Color0 + src0Color1)) + src1Factor * src1Color; - - psout.Color = float4(color, 1); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISDownsample.hlsl b/package/Shaders/ISDownsample.hlsl deleted file mode 100644 index 5854ce451..000000000 --- a/package/Shaders/ISDownsample.hlsl +++ /dev/null @@ -1,67 +0,0 @@ -#include "Common/Color.hlsl" -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState SourceSampler : register(s0); -SamplerState PreviousFrameSourceSampler : register(s1); -SamplerState MotionVectorsSampler : register(s2); - -Texture2D SourceTex : register(t0); -Texture2D PreviousFrameSourceTex : register(t1); -Texture2D MotionVectorsTex : register(t2); - -cbuffer PerGeometry : register(b2) -{ - float2 TexelSize : packoffset(c0); - float SamplesCount : packoffset(c0.z); - bool CompensateJittering : packoffset(c0.w); - float4 OffsetsAndWeights[16] : packoffset(c1); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 downsampledColor = 0; - float luminance = 0; - for (uint sampleIndex = 0; sampleIndex < asuint(SamplesCount); ++sampleIndex) { - float2 texCoord = OffsetsAndWeights[sampleIndex].xy * TexelSize.xy + input.TexCoord; -# if defined(IGNORE_BRIGHTEST) - texCoord = GetDynamicResolutionAdjustedScreenPosition(texCoord); -# endif - float4 sourceColor = SourceTex.Sample(SourceSampler, texCoord); -# if defined(IGNORE_BRIGHTEST) - downsampledColor += sourceColor; -# else - float sampleLuminance = RGBToLuminanceAlternative(sourceColor.xyz); - if (sampleLuminance > luminance) { - downsampledColor = sourceColor; - luminance = sampleLuminance; - } -# endif - } -# if defined(IGNORE_BRIGHTEST) - psout.Color = downsampledColor / asuint(SamplesCount); -# else - if (CompensateJittering) { - float2 adjustedTexCoord = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - float2 motion = MotionVectorsTex.Sample(MotionVectorsSampler, adjustedTexCoord).xy; - float4 previousFrameColor = - PreviousFrameSourceTex.Sample(PreviousFrameSourceSampler, input.TexCoord + motion).xyzw; - psout.Color = 0.5 * (previousFrameColor + downsampledColor); - } else { - psout.Color = downsampledColor; - } -# endif - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISExp.hlsl b/package/Shaders/ISExp.hlsl deleted file mode 100644 index 076518b3c..000000000 --- a/package/Shaders/ISExp.hlsl +++ /dev/null @@ -1,29 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState OriginalSampler : register(s0); - -Texture2D OriginalTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float Params : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float srcValue = OriginalTex.Sample(OriginalSampler, input.TexCoord).x; - psout.Color = exp2(1.44269502 * Params * srcValue); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISHDR.hlsl b/package/Shaders/ISHDR.hlsl deleted file mode 100644 index 4929cb93d..000000000 --- a/package/Shaders/ISHDR.hlsl +++ /dev/null @@ -1,123 +0,0 @@ -#include "Common/Color.hlsl" -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); -# if defined(DOWNSAMPLE) -SamplerState AdaptSampler : register(s1); -# elif defined(TONEMAP) -SamplerState BlendSampler : register(s1); -# endif -SamplerState AvgSampler : register(s2); - -Texture2D ImageTex : register(t0); -# if defined(DOWNSAMPLE) -Texture2D AdaptTex : register(t1); -# elif defined(TONEMAP) -Texture2D BlendTex : register(t1); -# endif -Texture2D AvgTex : register(t2); - -cbuffer PerGeometry : register(b2) -{ - float4 Flags : packoffset(c0); - float4 TimingData : packoffset(c1); - float4 Param : packoffset(c2); - float4 Cinematic : packoffset(c3); - float4 Tint : packoffset(c4); - float4 Fade : packoffset(c5); - float4 BlurScale : packoffset(c6); - float4 BlurOffsets[16] : packoffset(c7); -}; - -float GetTonemapFactorReinhard(float luminance) -{ - return (luminance * (luminance * Param.y + 1)) / (luminance + 1); -} - -float GetTonemapFactorHejlBurgessDawson(float luminance) -{ - float tmp = max(0, luminance - 0.004); - return Param.y * - pow(((tmp * 6.2 + 0.5) * tmp) / (tmp * (tmp * 6.2 + 1.7) + 0.06), GammaCorrectionValue); -} - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - -# if defined(DOWNSAMPLE) - float3 downsampledColor = 0; - for (int sampleIndex = 0; sampleIndex < SAMPLES_COUNT; ++sampleIndex) { - float2 texCoord = BlurOffsets[sampleIndex].xy * BlurScale.xy + input.TexCoord; - if (Flags.x > 0.5) { - texCoord = GetDynamicResolutionAdjustedScreenPosition(texCoord); - } - float3 imageColor = ImageTex.Sample(ImageSampler, texCoord).xyz; -# if defined(LUM) - imageColor = imageColor.x; -# elif defined(RGB2LUM) - imageColor = RGBToLuminance(imageColor); -# endif - downsampledColor += imageColor * BlurOffsets[sampleIndex].z; - } -# if defined(LIGHT_ADAPT) - float2 adaptValue = AdaptTex.Sample(AdaptSampler, input.TexCoord).xy; - if (isnan(downsampledColor.x) || isnan(downsampledColor.y) || isnan(downsampledColor.z)) { - downsampledColor.xy = adaptValue; - } else { - float2 adaptDelta = downsampledColor.xy - adaptValue; - downsampledColor.xy = - sign(adaptDelta) * clamp(abs(Param.wz * adaptDelta), 0.00390625, abs(adaptDelta)) + - adaptValue; - } -# endif - psout.Color = float4(downsampledColor, BlurScale.z); - -# elif defined(TONEMAP) - float2 adjustedTexCoord = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - float3 blendColor = BlendTex.Sample(BlendSampler, adjustedTexCoord).xyz; - float3 imageColor = 0; - if (Flags.x > 0.5) { - imageColor = ImageTex.Sample(ImageSampler, adjustedTexCoord).xyz; - } else { - imageColor = ImageTex.Sample(ImageSampler, input.TexCoord).xyz; - } - float2 avgValue = AvgTex.Sample(AvgSampler, input.TexCoord).xy; - - float luminance = max(1e-5, RGBToLuminance(blendColor)); - float exposureAdjustedLuminance = (avgValue.y / avgValue.x) * luminance; - float blendFactor; - if (Param.z > 0.5) { - blendFactor = GetTonemapFactorHejlBurgessDawson(exposureAdjustedLuminance); - } else { - blendFactor = GetTonemapFactorReinhard(exposureAdjustedLuminance); - } - - float3 blendedColor = - blendColor * (blendFactor / luminance) + saturate(Param.x - blendFactor) * imageColor; - float blendedLuminance = RGBToLuminance(blendedColor); - - float4 linearColor = lerp(avgValue.x, - Cinematic.w * lerp(lerp(blendedLuminance, float4(blendedColor, 1), Cinematic.x), - blendedLuminance * Tint, Tint.w), - Cinematic.z); - float4 srgbColor = float4(ToSRGBColor(saturate(linearColor.xyz)), linearColor.w); -# if defined(FADE) - srgbColor = lerp(srgbColor, Fade, Fade.w); -# endif - psout.Color = srgbColor; - -# endif - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISIBLensFlare.hlsl b/package/Shaders/ISIBLensFlare.hlsl deleted file mode 100644 index 8d1f52fee..000000000 --- a/package/Shaders/ISIBLensFlare.hlsl +++ /dev/null @@ -1,68 +0,0 @@ -include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - - typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState DownScaledBlurredHDRSampler : register(s0); -SamplerState RampsSampler : register(s1); -SamplerState MasksSampler : register(s2); - -Texture2D DownScaledBlurredHDRTex : register(t0); -Texture2D RampsTex : register(t1); -Texture2D MasksTex : register(t2); - -cbuffer PerGeometry : register(b2) -{ - float lensCount : packoffset(c0.x); - float flareDispersal : packoffset(c0.y); - float lightsRangeDownshift : packoffset(c0.z); - float invLightsRangeDownshift : packoffset(c0.w); - float lateralRepeat : packoffset(c1.x); - float channelsDistortionRed : packoffset(c1.y); - float channelsDistortionGreen : packoffset(c1.z); - float channelsDistortionBlue : packoffset(c1.w); - float texelOffsetX : packoffset(c2.x); - float texelOffsetY : packoffset(c2.y); - float haloFetch : packoffset(c2.z); - float haloWidthPow : packoffset(c2.w); - float dynamicSource : packoffset(c3.x); - float globalIntensity : packoffset(c3.y); -}; - -float4 GetSampleColor(float2 texCoord) -{ - float4 color = DownScaledBlurredHDRTex.Sample(DownScaledBlurredHDRSampler, texCoord); - if (saturate(color.x - lightsRangeDownshift) + saturate(color.y - lightsRangeDownshift) + - saturate(color.z - lightsRangeDownshift) <= - 0) { - return 0; - } - return saturate(color); -} - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 lensColor = 0; - for (int sampleIndex = -asint(lateralRepeat); sampleIndex <= asint(lateralRepeat); ++sampleIndex) { - float4 sampleColor; - if (dynamicSource > 0.5) { - sampleColor = GetSampleColor(GetDynamicResolutionAdjustedScreenPosition( - input.TexCoord + float2(texelOffsetX * sampleIndex, 0))); - } else { - sampleColor = GetSampleColor(input.TexCoord + float2(texelOffsetX * sampleIndex, 0)); - } - lensColor += sampleColor; - } - psout.Color = globalIntensity * lensColor; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISLightingComposite.hlsl b/package/Shaders/ISLightingComposite.hlsl deleted file mode 100644 index 38afe9862..000000000 --- a/package/Shaders/ISLightingComposite.hlsl +++ /dev/null @@ -1,73 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState AlbedoSampler : register(s0); -SamplerState DiffuseSampler : register(s1); -SamplerState SpecularSampler : register(s2); -SamplerState SAOSampler : register(s3); -SamplerState FogSampler : register(s4); -SamplerState DirDiffuseSampler : register(s5); -SamplerState DirSpecularSampler : register(s6); -SamplerState ShadowMaskSampler : register(s7); - -Texture2D AlbedoTex : register(t0); -Texture2D DiffuseTex : register(t1); -Texture2D SpecularTex : register(t2); -Texture2D SAOTex : register(t3); -Texture2D FogTex : register(t4); -Texture2D DirDiffuseTex : register(t5); -Texture2D DirSpecularTex : register(t6); -Texture2D ShadowMaskTex : register(t7); - -cbuffer PerGeometry : register(b2) -{ - float4 FogParam : packoffset(c0); - float4 FogNearColor : packoffset(c1); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 diffuse = DiffuseTex.Sample(DiffuseSampler, input.TexCoord); - float4 specular = SpecularTex.Sample(SpecularSampler, input.TexCoord); - float4 albedo = AlbedoTex.Sample(AlbedoSampler, input.TexCoord); - -# if !defined(NO_DIRECTIONAL_LIGHT) - float4 dirDiffuse = DirDiffuseTex.Sample(DirDiffuseSampler, input.TexCoord); - float4 dirSpecular = DirSpecularTex.Sample(DirSpecularSampler, input.TexCoord); -# else - float4 dirDiffuse = 0; - float4 dirSpecular = 0; -# endif - -# if !defined(MENU) - float shadowMask = ShadowMaskTex.Sample(ShadowMaskSampler, input.TexCoord).x; - float sao = SAOTex.Sample(SAOSampler, input.TexCoord).x; -# else - float shadowMask = 1; - float sao = 1; -# endif - - float4 preFog = (diffuse * sao + shadowMask * dirDiffuse) * albedo + - (specular * sao + dirSpecular * shadowMask); - - float4 fog = FogTex.Sample(FogSampler, input.TexCoord); - - if (fog.x + fog.y + fog.z + fog.w != 0) { - psout.Color = - float4(saturate(FogNearColor.w * lerp(preFog.xyz, fog.xyz, fog.w)), saturate(preFog.w)); - } else { - psout.Color = preFog; - } - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISLocalMap.hlsl b/package/Shaders/ISLocalMap.hlsl deleted file mode 100644 index e3793701b..000000000 --- a/package/Shaders/ISLocalMap.hlsl +++ /dev/null @@ -1,56 +0,0 @@ -#include "Common/Color.hlsl" -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); - -Texture2D ImageTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 TexelSize : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float3 colorLT = - ImageTex.Sample(ImageSampler, input.TexCoord + float2(-TexelSize.x, TexelSize.y)).xyz; - float3 colorCT = ImageTex.Sample(ImageSampler, input.TexCoord + float2(0, TexelSize.y)).xyz; - float3 colorRT = ImageTex.Sample(ImageSampler, input.TexCoord + TexelSize.xy).xyz; - float3 colorLB = ImageTex.Sample(ImageSampler, input.TexCoord - TexelSize.xy).xyz; - float3 colorCB = ImageTex.Sample(ImageSampler, input.TexCoord + float2(0, -TexelSize.y)).xyz; - float3 colorRB = - ImageTex.Sample(ImageSampler, input.TexCoord + float2(TexelSize.x, -TexelSize.y)).xyz; - float3 colorLC = ImageTex.Sample(ImageSampler, input.TexCoord + float2(-TexelSize.x, 0)).xyz; - float3 colorRC = ImageTex.Sample(ImageSampler, input.TexCoord + float2(TexelSize.x, 0)).xyz; - - float3 colorTB = -colorRT * float3(0.5, 0.25, 1) - colorCT * float3(1, 0.5, 2) - - colorLT * float3(0.5, 0.25, 1) + colorRB * float3(0.5, 0.25, 1) + - colorCB * float3(1, 0.5, 2) + float3(0.5, 0.25, 1) * colorLB; - float3 colorLR = -colorRT * float3(0.5, 0.25, 1) - - colorRB * float3(0.5, 0.25, 1) + colorLT * float3(0.5, 0.25, 1) + - colorLC * float3(1, 0.5, 2) + float3(0.5, 0.25, 1) * colorLB; - - float3 unk1 = 4 * (pow(colorLR, 2) + pow(colorTB, 2)); - - float4 colorCC = ImageTex.Sample(ImageSampler, input.TexCoord); - float luminance = RGBToLuminanceAlternative(colorCC.xyz); - - float unk2 = (dot(4 * unk1, 1.75) + 0.04 * luminance) * (1 - colorCC.w); - float2 unk3 = 1 - pow(2 * abs(input.TexCoord - 0.5), 5); - - psout.Color.xyz = unk1.x + 0.04 * luminance; - psout.Color.w = unk2 * unk3.x * unk3.y; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISMap.hlsl b/package/Shaders/ISMap.hlsl deleted file mode 100644 index f4c9dc6e4..000000000 --- a/package/Shaders/ISMap.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState Src0Sampler : register(s0); - -Texture2D Src0Tex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 CameraPos : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 colorLR = 0; - float4 colorBT = 0; - [unroll] for (int j = -1; j <= 1; ++j) - { - [unroll] for (int i = -1; i <= 1; ++i) - { - if (i == 0 && j == 0) { - continue; - } - - float4 currentColor = - Src0Tex - .Sample(Src0Sampler, input.TexCoord + float2(i * CameraPos.x, j * CameraPos.y)); - - float centerMul = 1; - if (i == 0 || j == 0) { - centerMul = 2; - } - - colorLR += -i * centerMul * currentColor; - colorBT += -j * centerMul * currentColor; - } - } - float4 convolved = pow(colorLR, 2) + pow(colorBT, 2); - - float3 mapColor = min(0.275, dot(float3(0.2, 0.2, 0.15), convolved.xyz) + min(0.1, 10 * convolved.w).xxx); - psout.Color.xyz = mapColor; - psout.Color.w = 2 * dot(1, mapColor.zzz); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISNoise.hlsl b/package/Shaders/ISNoise.hlsl deleted file mode 100644 index f4c9dc6e4..000000000 --- a/package/Shaders/ISNoise.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState Src0Sampler : register(s0); - -Texture2D Src0Tex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 CameraPos : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float4 colorLR = 0; - float4 colorBT = 0; - [unroll] for (int j = -1; j <= 1; ++j) - { - [unroll] for (int i = -1; i <= 1; ++i) - { - if (i == 0 && j == 0) { - continue; - } - - float4 currentColor = - Src0Tex - .Sample(Src0Sampler, input.TexCoord + float2(i * CameraPos.x, j * CameraPos.y)); - - float centerMul = 1; - if (i == 0 || j == 0) { - centerMul = 2; - } - - colorLR += -i * centerMul * currentColor; - colorBT += -j * centerMul * currentColor; - } - } - float4 convolved = pow(colorLR, 2) + pow(colorBT, 2); - - float3 mapColor = min(0.275, dot(float3(0.2, 0.2, 0.15), convolved.xyz) + min(0.1, 10 * convolved.w).xxx); - psout.Color.xyz = mapColor; - psout.Color.w = 2 * dot(1, mapColor.zzz); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISRadialBlur.hlsl b/package/Shaders/ISRadialBlur.hlsl deleted file mode 100644 index a9df8e64d..000000000 --- a/package/Shaders/ISRadialBlur.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); - -Texture2D ImageTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 Params : packoffset(c0); - float4 Center : packoffset(c1); -}; - -float GetCircleParam(float centerDistance, float param1, float param2) -{ - float circleDistance = max(0, centerDistance - param1); - float result = 0; - if (circleDistance > 0) { - result = Params.x * (1 - 1 / (param2 * circleDistance + 1)); - } - return result; -} - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 offset = Center.xy - input.TexCoord; - float centerDistance = length(offset); - float2 sampleDelta = - 0.5 * (normalize(offset) * max(0, GetCircleParam(centerDistance, Params.z, Params.y) - - GetCircleParam(centerDistance, Center.z, Params.w))); - - float4 color = 0; - for (float sampleIndex = -SAMPLES_COUNT; sampleIndex <= SAMPLES_COUNT; ++sampleIndex) { - float2 texCoord = input.TexCoord + sampleDelta * sampleIndex; - float2 adjustedTexCoord = GetDynamicResolutionAdjustedScreenPosition(texCoord); - float4 currentColor = ImageTex.SampleLevel(ImageSampler, adjustedTexCoord, 0); - color += currentColor; - } - color *= (1. / (2. * SAMPLES_COUNT + 1.)); - - psout.Color = color; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISRefraction.hlsl b/package/Shaders/ISRefraction.hlsl deleted file mode 100644 index 23874157e..000000000 --- a/package/Shaders/ISRefraction.hlsl +++ /dev/null @@ -1,55 +0,0 @@ -#include "Common/Color.hlsl" -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState Src0Sampler : register(s0); -SamplerState Src1Sampler : register(s1); - -Texture2D Src0Tex : register(t0); -Texture2D Src1Tex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 Tint : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 adjustedTexCoord = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - - float4 src1 = Src1Tex.Sample(Src1Sampler, adjustedTexCoord); - float4 src00 = Src0Tex.Sample(Src0Sampler, adjustedTexCoord); - - float2 texCoord10 = input.TexCoord + float2(1, -1) * (2 * (0.05 * src1.z) * (src1.xy - 0.5)); - float2 texCoord11 = texCoord10 > 0.85 ? lerp(texCoord10, 0.85, 0.78) : texCoord10; - texCoord11 = texCoord10 < 0.15 ? lerp(texCoord10, 0.15, 0.78) : texCoord11; - - float2 texCoord1 = lerp(texCoord10, texCoord11, src1.z); - float2 adjustedTexCoord1 = GetDynamicResolutionAdjustedScreenPosition(texCoord1); - - float unk1 = Src1Tex.Sample(Src1Sampler, adjustedTexCoord1).w; - float4 src01 = Src0Tex.Sample(Src0Sampler, adjustedTexCoord1); - float4 src0 = unk1 != 0 ? src01 : src00; - - if (src1.w > 0.8 && src1.w < 1) { - psout.Color.xyz = - (1 - Tint.w) * src0.xyz + Tint.xyz * (Tint.w * RGBToLuminance2(src01.xyz)); - } else { - psout.Color.xyz = src0.xyz; - } - - psout.Color.w = src0.w; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISSAOMinify.hlsl b/package/Shaders/ISSAOMinify.hlsl deleted file mode 100644 index a7d839f4f..000000000 --- a/package/Shaders/ISSAOMinify.hlsl +++ /dev/null @@ -1,64 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState sourceSampler : register(s0); - -Texture2D sourceTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 g_RenderTargetResolution : packoffset(c0); - float4 g_ContrastParams : packoffset(c1); - float g_UseDynamicSampling : packoffset(c2); -}; - -float2 GetMinifiedTexCoord(float2 texCoord) -{ - return ((float2)(((int2)(g_RenderTargetResolution.yx * texCoord.yx) & 1) ^ 1) * 2 - 1) * - g_RenderTargetResolution.zw + - texCoord; -} - -static const float4 ContrastValues[] = { { 0.300000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, - { 0.500000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, { 0.300000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, - { 2.000000, 0, 0, 0 }, { 2.500000, 0, 0, 0 }, { 2.000000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, - { 0.500000, 0, 0, 0 }, { 2.500000, 0, 0, 0 }, { 3.500000, 0, 0, 0 }, { 2.500000, 0, 0, 0 }, - { 0.500000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, { 2.000000, 0, 0, 0 }, { 2.500000, 0, 0, 0 }, - { 2.000000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, { 0.300000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, - { 0.500000, 0, 0, 0 }, { 0.400000, 0, 0, 0 }, { 0.300000, 0, 0, 0 } }; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 finalTexCoord; - if (asuint(g_UseDynamicSampling) > 0) { - float2 drAdjustedTexCoord = DynamicResolutionParams1.xy * input.TexCoord; - float2 minifiedTexCoord = GetMinifiedTexCoord(drAdjustedTexCoord); - finalTexCoord = clamp(minifiedTexCoord, 0, - DynamicResolutionParams1.xy - float2(CameraPreviousPosAdjust.w, 0)); - } else { - finalTexCoord = GetMinifiedTexCoord(input.TexCoord); - } - - float4 color = sourceTex.Sample(sourceSampler, finalTexCoord); - -# if defined(CONTRAST) - int contrastIndex = (int)(5 * input.TexCoord.x) + (int)(5 * input.TexCoord.y) * 5; - float contrastFactor = ContrastValues[contrastIndex].x * g_ContrastParams.x; - color *= contrastFactor; -# endif - - psout.Color = color; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISSimpleColor.hlsl b/package/Shaders/ISSimpleColor.hlsl deleted file mode 100644 index b43552bab..000000000 --- a/package/Shaders/ISSimpleColor.hlsl +++ /dev/null @@ -1,50 +0,0 @@ -#if defined(DISPLAY_DEPTH) -# include "Common/DummyVSTexCoord.hlsl" -#elif defined(SIMPLE_COLOR) -# include "Common/DummyVS.hlsl" -#endif - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState DepthSampler : register(s0); -SamplerState uintStencilSampler : register(s1); - -Texture2D DepthTex : register(t0); -Texture2D uintStencilTex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 Color : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - -# if defined(DISPLAY_DEPTH) - float depth; - if (1e-5 < Color.z) { - uint2 dimensions; - uint numberOfLevels; - uintStencilTex.GetDimensions(0, dimensions.x, dimensions.y, numberOfLevels); - float3 location = float3(input.TexCoord * dimensions, 0); - depth = uintStencilTex.Load(location).x; - } else { - depth = DepthTex.SampleLevel(DepthSampler, input.TexCoord, 0).x; - } - float screenDepth = saturate((-Color.x + depth) / (Color.y - Color.x)); - psout.Color.xyz = (screenDepth * -2 + 3) * (screenDepth * screenDepth); - psout.Color.w = 1; -# elif defined(SIMPLE_COLOR) - psout.Color = Color; -# endif - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISUpsampleDynamicResolution.hlsl b/package/Shaders/ISUpsampleDynamicResolution.hlsl deleted file mode 100644 index 6e69cabdd..000000000 --- a/package/Shaders/ISUpsampleDynamicResolution.hlsl +++ /dev/null @@ -1,29 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState sourceSampler : register(s0); - -Texture2D sourceTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float4 g_UpsampleParameters : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 upsampleTexCoord = min(g_UpsampleParameters.zw, g_UpsampleParameters.xy * input.TexCoord); - psout.Color = sourceTex.Sample(sourceSampler, upsampleTexCoord).xyzw; - - return psout; -} -#endif diff --git a/package/Shaders/ISVolumetricLighting.hlsl b/package/Shaders/ISVolumetricLighting.hlsl deleted file mode 100644 index 31499ec2f..000000000 --- a/package/Shaders/ISVolumetricLighting.hlsl +++ /dev/null @@ -1,34 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState DepthSampler : register(s0); -SamplerState ShadowMapSampler : register(s1); - -Texture2D DepthTex : register(t0); -Texture2D ShadowMapTex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 g_ViewProj[4] : packoffset(c0); - float4 g_InvViewProj[4] : packoffset(c4); - float4 g_ShadowSampleParam : packoffset(c8); - float4 ShadowMapProj[6] : packoffset(c9); - float4 LightColor_Intensity : packoffset(c15); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - psout.Color = float4(LightColor_Intensity.w * LightColor_Intensity.xyz, LightColor_Intensity.w); - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISWaterBlend.hlsl b/package/Shaders/ISWaterBlend.hlsl deleted file mode 100644 index ffc2f073e..000000000 --- a/package/Shaders/ISWaterBlend.hlsl +++ /dev/null @@ -1,71 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float3 Color : SV_Target0; - float4 Color1 : SV_Target1; -}; - -#if defined(PSHADER) -SamplerState sourceSampler : register(s0); -SamplerState waterHistorySampler : register(s1); -SamplerState motionBufferSampler : register(s2); -SamplerState depthBufferSampler : register(s3); -SamplerState waterMaskSampler : register(s4); - -Texture2D sourceTex : register(t0); -Texture2D waterHistoryTex : register(t1); -Texture2D motionBufferTex : register(t2); -Texture2D depthBufferTex : register(t3); -Texture2D waterMaskTex : register(t4); - -cbuffer PerGeometry : register(b2) -{ - float4 NearFar_Menu_DistanceFactor : packoffset(c0); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 adjustedScreenPosition = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - float waterMask = waterMaskTex.Sample(waterMaskSampler, adjustedScreenPosition).z; - if (waterMask < 1e-4) { - discard; - } - - float3 sourceColor = sourceTex.Sample(sourceSampler, adjustedScreenPosition).xyz; - float2 motion = motionBufferTex.Sample(motionBufferSampler, adjustedScreenPosition).xy; - float2 motionScreenPosition = input.TexCoord + motion; - float2 motionAdjustedScreenPosition = - GetPreviousDynamicResolutionAdjustedScreenPosition(motionScreenPosition); - float4 waterHistory = - waterHistoryTex.Sample(waterHistorySampler, motionAdjustedScreenPosition).xyzw; - - float3 finalColor = sourceColor; - if (motionScreenPosition.x >= 0 && motionScreenPosition.y >= 0 && motionScreenPosition.x <= 1 && - motionScreenPosition.y <= 1 && waterHistory.w == 1) { - float historyFactor = 0.95; - if (NearFar_Menu_DistanceFactor.z == 0) { - float depth = depthBufferTex.Sample(depthBufferSampler, adjustedScreenPosition).x; - float distanceFactor = clamp(250 * ((-NearFar_Menu_DistanceFactor.x + - (2 * NearFar_Menu_DistanceFactor.x * NearFar_Menu_DistanceFactor.y) / - (-(depth * 2 - 1) * - (NearFar_Menu_DistanceFactor.y - NearFar_Menu_DistanceFactor.x) + - (NearFar_Menu_DistanceFactor.y + NearFar_Menu_DistanceFactor.x))) / - (NearFar_Menu_DistanceFactor.y - NearFar_Menu_DistanceFactor.x)), - 0.1, 0.95); - historyFactor = NearFar_Menu_DistanceFactor.w * (distanceFactor * (waterMask * -0.85 + 0.95)); - } - finalColor = lerp(sourceColor, waterHistory.xyz, historyFactor); - } - - psout.Color1 = float4(finalColor, 1); - psout.Color = finalColor; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISWaterDisplacement.hlsl b/package/Shaders/ISWaterDisplacement.hlsl deleted file mode 100644 index 1bd50a56e..000000000 --- a/package/Shaders/ISWaterDisplacement.hlsl +++ /dev/null @@ -1,162 +0,0 @@ -#if defined(SMOOTH_HEIGHTMAP) || defined(RAIN_HEIGHTMAP) || defined(WADING_HEIGHTMAP) -# define HEIGHTMAP -#endif - -struct VS_INPUT -{ - float4 Position : POSITION0; - float2 TexCoord : TEXCOORD0; -}; - -struct VS_OUTPUT -{ - float4 Position : SV_POSITION0; - float2 TexCoord : TEXCOORD0; -#if defined(HEIGHTMAP) - float2 TexCoord1 : TEXCOORD1; - float2 TexCoord2 : TEXCOORD2; - float2 TexCoord3 : TEXCOORD3; - float2 TexCoord4 : TEXCOORD4; -#endif -}; - -#ifdef VSHADER -VS_OUTPUT main(VS_INPUT input) -{ - VS_OUTPUT vsout; - - vsout.Position = float4(input.Position.xyz, 1); - vsout.TexCoord = input.TexCoord.xy; -# if defined(HEIGHTMAP) - vsout.TexCoord1 = input.TexCoord.xy + float2(-0.0009765625, -0.0009765625); - vsout.TexCoord2 = input.TexCoord.xy + float2(-0.0009765625, 0.0009765625); - vsout.TexCoord3 = input.TexCoord.xy + float2(0.0009765625, -0.0009765625); - vsout.TexCoord4 = input.TexCoord.xy + float2(0.0009765625, 0.0009765625); -# endif - - return vsout; -} -#endif - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -# if defined(BLEND_HEIGHTMAPS) -SamplerState HeightMap01Sampler : register(s0); -SamplerState HeightMap02Sampler : register(s1); -# elif defined(NORMALS) -SamplerState DisplaceMapSampler : register(s0); -# elif defined(TEX_OFFSET) -SamplerState DisplaySamplerSampler : register(s0); -# elif defined(HEIGHTMAP) -SamplerState HeightMapSampler : register(s0); -# endif - -# if defined(BLEND_HEIGHTMAPS) -Texture2D HeightMap01Tex : register(t0); -Texture2D HeightMap02Tex : register(t1); -# elif defined(NORMALS) -Texture2D DisplaceMapTex : register(t0); -# elif defined(TEX_OFFSET) -Texture2D DisplaySamplerTex : register(t0); -# elif defined(HEIGHTMAP) -Texture2D HeightMapTex : register(t0); -# endif - -cbuffer PerGeometry : register(b2) -{ - float Time : packoffset(c0.x); - float BlendAmount : packoffset(c0.y); - float2 TextureOffset : packoffset(c0.z); - float fDamp : packoffset(c1.x); - float3 RainVars : packoffset(c1.y); - float4 WadingVars : packoffset(c2.x); -}; - -# if defined(NORMALS) -float GetDisplacementNormalValue(float2 texCoord) -{ - float displaceValue = DisplaceMapTex.Sample(DisplaceMapSampler, texCoord).x; - return fDamp * pow(abs(displaceValue), 7); -} -# endif - -# if defined(HEIGHTMAP) -float4 GetHeight(PS_INPUT input, uniform float3 Vars) -{ - float2 height = HeightMapTex.Sample(HeightMapSampler, input.TexCoord).xy; - float heightLB = HeightMapTex.Sample(HeightMapSampler, input.TexCoord1).x; - float heightLT = HeightMapTex.Sample(HeightMapSampler, input.TexCoord2).x; - float heightRB = HeightMapTex.Sample(HeightMapSampler, input.TexCoord3).x; - float heightRT = HeightMapTex.Sample(HeightMapSampler, input.TexCoord4).x; - - float heightDispersion = -height.x * 4 + (heightLB + heightLT + heightRB + heightRT); - float tmp1 = Vars.x * heightDispersion + (height.y - 0.5); - float heightLR = heightLB + heightLT - heightRB - heightRT; - float heightBT = heightLB - heightLT + heightRB - heightRT; - return 0.5 + float4(max(-1, Vars.z * float2(Vars.y * tmp1 + (height.x - 0.5), tmp1)), 0.5 * float2(heightLR, heightBT)); -} -# endif - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - -# if defined(BLEND_HEIGHTMAPS) - float height01 = HeightMap01Tex.Sample(HeightMap01Sampler, input.TexCoord).x; - float height02 = HeightMap02Tex.Sample(HeightMap02Sampler, input.TexCoord).x; - - psout.Color.xyz = lerp((0.8 / fDamp) * abs(height01), abs(height02), BlendAmount); - psout.Color.w = 1; -# elif defined(CLEAR_SIMULATION) - psout.Color = 0.5; -# elif defined(NORMALS) - - float offset = 0.001953125; - float valueRL = 0; - float valueTB = 0; - [unroll] for (int i = -1; i <= 1; ++i) - { - [unroll] for (int j = -1; j <= 1; ++j) - { - if (i == 0 && j == 0) { - continue; - } - - float currentValue = GetDisplacementNormalValue(input.TexCoord + float2(i * offset, j * offset)); - - float centerMul = 1; - if (i == 0 || j == 0) { - centerMul = 2; - } - - valueRL += i * centerMul * currentValue; - valueTB += j * centerMul * currentValue; - } - } - - psout.Color = float4(normalize(float3(-valueRL, valueTB, 1)), 1) * 0.5 + 0.5; - -# elif defined(RAIN_RIPPLE) || defined(WADING_RIPPLE) - psout.Color = float4(1, 0.5, 0.5, 0.5); -# elif defined(TEX_OFFSET) - float lerpFactor = saturate(10 * (-0.4 + length(input.TexCoord - 0.5))); - float4 displayColor = DisplaySamplerTex.Sample(DisplaySamplerSampler, TextureOffset + input.TexCoord); - psout.Color.xy = displayColor.xy; - psout.Color.zw = lerp(displayColor.zw, 0.5, lerpFactor); -# elif defined(SMOOTH_HEIGHTMAP) - psout.Color = HeightMapTex.Sample(HeightMapSampler, input.TexCoord); -# elif defined(RAIN_HEIGHTMAP) - psout.Color = GetHeight(input, RainVars); -# elif defined(WADING_HEIGHTMAP) - psout.Color = GetHeight(input, WadingVars); -# endif - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISWaterFlow.hlsl b/package/Shaders/ISWaterFlow.hlsl deleted file mode 100644 index 549116fe2..000000000 --- a/package/Shaders/ISWaterFlow.hlsl +++ /dev/null @@ -1,44 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState FlowmapSampler : register(s0); - -Texture2D FlowmapTex : register(t0); - -cbuffer PerGeometry : register(b2) -{ - float2 CellOffset : packoffset(c0.x); - float2 LastCenter : packoffset(c0.z); - float2 Center : packoffset(c1.x); - float Radius : packoffset(c1.z); - float Magnitude : packoffset(c1.w); - float Strength : packoffset(c2.x); - float Falloff : packoffset(c2.y); - float Scale : packoffset(c2.z); - float2 FlowVector : packoffset(c3); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float centerDistance = length(Center - frac(float2(-CellOffset.x + input.TexCoord.x, CellOffset.y + input.TexCoord.y))); - float4 flowmapValue = FlowmapTex.Sample(FlowmapSampler, input.TexCoord); - if (centerDistance < Radius) { - float flowStrength = Strength * (1 - pow(centerDistance / Radius, 4)); - flowmapValue.xy = normalize(normalize(flowmapValue.xy * 2 - 1) + flowStrength * FlowVector) * 0.5 + 0.5; - flowmapValue.z = saturate(Scale * flowStrength + flowmapValue.z); - flowmapValue.w = max(0.1, min(1, 0.002 * (flowmapValue.w * 500 + Magnitude * flowStrength))); - } - psout.Color = flowmapValue; - - return psout; -} -#endif \ No newline at end of file diff --git a/package/Shaders/ISWorldMap.hlsl b/package/Shaders/ISWorldMap.hlsl deleted file mode 100644 index 8371460a8..000000000 --- a/package/Shaders/ISWorldMap.hlsl +++ /dev/null @@ -1,59 +0,0 @@ -#include "Common/DummyVSTexCoord.hlsl" -#include "Common/FrameBuffer.hlsl" - -typedef VS_OUTPUT PS_INPUT; - -struct PS_OUTPUT -{ - float4 Color : SV_Target0; -}; - -#if defined(PSHADER) -SamplerState ImageSampler : register(s0); -SamplerState DepthSampler : register(s1); - -Texture2D ImageTex : register(t0); -Texture2D DepthTex : register(t1); - -cbuffer PerGeometry : register(b2) -{ - float4 CameraParams : packoffset(c0); - float4 DepthParams : packoffset(c1); - float4 TexelSize : packoffset(c2); -}; - -PS_OUTPUT main(PS_INPUT input) -{ - PS_OUTPUT psout; - - float2 adjustedTexCoord = GetDynamicResolutionAdjustedScreenPosition(input.TexCoord); - - float depth = DepthTex.Sample(DepthSampler, adjustedTexCoord).x; - - float depthFactor = DepthParams.w / ((1 - depth) * DepthParams.z + DepthParams.y); - float offsetDelta = min(TexelSize.y, TexelSize.z * abs(depthFactor - TexelSize.x)); -# if defined(NO_SKY_BLUR) - if (1 - depth <= 1e-4) { - offsetDelta = 0; - } -# endif - if (depthFactor < TexelSize.x) { - offsetDelta *= TexelSize.w; - } - float2 startOffset = input.TexCoord - 3 * (CameraParams.xy * offsetDelta); - - float4 color = 0; - for (int i = 0; i < 7; ++i) { - for (int j = 0; j < 7; ++j) { - float2 currentTexCoord = GetDynamicResolutionAdjustedScreenPosition( - startOffset + CameraParams.xy * offsetDelta * float2(i, j)); - float4 currentColor = ImageTex.Sample(ImageSampler, currentTexCoord); - color += currentColor; - } - } - - psout.Color = 0.0204081628 * color; - - return psout; -} -#endif \ No newline at end of file diff --git a/src/ShaderCache.cpp b/src/ShaderCache.cpp index 809859890..cb3fa9a7c 100644 --- a/src/ShaderCache.cpp +++ b/src/ShaderCache.cpp @@ -12,10 +12,6 @@ #include "Features/WaterBlending.h" #include "State.h" -#ifdef max -# undef max -#endif - namespace SIE { namespace SShaderCache @@ -592,171 +588,6 @@ namespace SIE defines[0] = { nullptr, nullptr }; } - static void GetImagespaceShaderDefines(uint32_t descriptor, D3D_SHADER_MACRO* defines) - { - using enum RE::ImageSpaceManager::ImageSpaceEffectEnum; - - const auto descEnum = - static_cast(descriptor); - if ((descriptor >= static_cast(ISBlur3) && - descriptor <= static_cast(ISBrightPassBlur15)) || - descEnum == ISBlur) { - if (descEnum == ISBlur) { - defines[0] = { "BLUR_RADIUS", "0" }; - ++defines; - } else { - static constexpr std::array blurRadiusDefines = { { "3", "5", - "7", "9", "11", "13", "15" } }; - const size_t blurRadius = static_cast( - (descriptor - static_cast(ISBlur3)) % blurRadiusDefines.size()); - defines[0] = { "BLUR_RADIUS", blurRadiusDefines[blurRadius] }; - ++defines; - const size_t blurType = static_cast( - (descriptor - static_cast(ISBlur3)) / blurRadiusDefines.size()); - if (blurType == 1) { - defines[0] = { "BLUR_NON_HDR", nullptr }; - ++defines; - } else if (blurType == 2) { - defines[0] = { "BLUR_BRIGHT_PASS", nullptr }; - ++defines; - } - } - } else if (descEnum == ISDisplayDepth) { - defines[0] = { "DISPLAY_DEPTH", nullptr }; - ++defines; - } else if (descEnum == ISSimpleColor) { - defines[0] = { "SIMPLE_COLOR", nullptr }; - ++defines; - } else if (descEnum == ISCopyDynamicFetchDisabled) { - defines[0] = { "DYNAMIC_FETCH_DISABLED", nullptr }; - ++defines; - } else if (descEnum == ISCopyGrayScale) { - defines[0] = { "GRAY_SCALE", nullptr }; - ++defines; - } else if (descEnum == ISCopyTextureMask) { - defines[0] = { "TEXTURE_MASK", nullptr }; - ++defines; - } else if (descEnum == ISCompositeLensFlare) { - defines[0] = { "VOLUMETRIC_LIGHTING", nullptr }; - ++defines; - } else if (descEnum == ISCompositeVolumetricLighting) { - defines[0] = { "LENS_FLARE", nullptr }; - ++defines; - } else if (descEnum == ISCompositeLensFlareVolumetricLighting) { - defines[0] = { "VOLUMETRIC_LIGHTING", nullptr }; - ++defines; - defines[0] = { "LENS_FLARE", nullptr }; - ++defines; - } else if (descriptor >= static_cast(ISDepthOfField) && - descriptor <= static_cast(ISDistantBlurMaskedFogged)) { - if (descriptor >= static_cast(ISDepthOfField) && - descriptor <= static_cast(ISDepthOfFieldMaskedFogged)) - - { - defines[0] = { "DOF", nullptr }; - ++defines; - } else { - defines[0] = { "DISTANT_BLUR", nullptr }; - ++defines; - } - if (descEnum != ISDepthOfField && descEnum != ISDistantBlur) { - defines[0] = { "FOGGED", nullptr }; - ++defines; - } - if (descEnum == ISDepthOfFieldMaskedFogged || descEnum == ISDistantBlurMaskedFogged) { - defines[0] = { "MASKED", nullptr }; - ++defines; - } - } else if (descEnum == ISDownsampleIgnoreBrightest) { - defines[0] = { "IGNORE_BRIGHTEST", nullptr }; - ++defines; - } else if (descEnum == ISHDRTonemapBlendCinematic) { - defines[0] = { "TONEMAP", nullptr }; - ++defines; - } else if (descEnum == ISHDRTonemapBlendCinematicFade) { - defines[0] = { "TONEMAP", nullptr }; - ++defines; - defines[0] = { "FADE", nullptr }; - ++defines; - } else if (descriptor >= static_cast(ISHDRDownSample16) && - descriptor <= static_cast(ISHDRDownSample16LightAdapt)) { - defines[0] = { "DOWNSAMPLE", nullptr }; - ++defines; - if (descEnum == ISHDRDownSample16 || descEnum == ISHDRDownSample16Lum || - descEnum == ISHDRDownSample16LightAdapt || - descEnum == ISHDRDownSample16LumClamp) { - defines[0] = { "SAMPLES_COUNT", "16" }; - ++defines; - } else { - defines[0] = { "SAMPLES_COUNT", "4" }; - ++defines; - } - if (descEnum == ISHDRDownSample4RGB2Lum) { - defines[0] = { "RGB2LUM", nullptr }; - ++defines; - } else if (descEnum == ISHDRDownSample16Lum || descEnum == ISHDRDownSample16LumClamp) { - defines[0] = { "LUM", nullptr }; - ++defines; - } else if (descEnum == ISHDRDownSample16LightAdapt || - descEnum == ISHDRDownSample4LightAdapt) { - defines[0] = { "LIGHT_ADAPT", nullptr }; - ++defines; - } - } else if (descEnum == ISLightingCompositeMenu) { - defines[0] = { "MENU", nullptr }; - ++defines; - } else if (descEnum == ISLightingCompositeNoDirectionalLight) { - defines[0] = { "NO_DIRECTIONAL_LIGHT", nullptr }; - ++defines; - } else if (descEnum == ISWaterBlendHeightmaps) { - defines[0] = { "BLEND_HEIGHTMAPS", nullptr }; - ++defines; - } else if (descEnum == ISWaterDisplacementClearSimulation) { - defines[0] = { "CLEAR_SIMULATION", nullptr }; - ++defines; - } else if (descEnum == ISWaterDisplacementNormals) { - defines[0] = { "NORMALS", nullptr }; - ++defines; - } else if (descEnum == ISWaterDisplacementRainRipple) { - defines[0] = { "RAIN_RIPPLE", nullptr }; - ++defines; - } else if (descEnum == ISWaterDisplacementTexOffset) { - defines[0] = { "TEX_OFFSET", nullptr }; - ++defines; - } else if (descEnum == ISWaterSmoothHeightmap) { - defines[0] = { "SMOOTH_HEIGHTMAP", nullptr }; - ++defines; - } else if (descEnum == ISWaterRainHeightmap) { - defines[0] = { "RAIN_HEIGHTMAP", nullptr }; - ++defines; - } else if (descEnum == ISWaterWadingHeightmap) { - defines[0] = { "WADING_HEIGHTMAP", nullptr }; - ++defines; - } else if (descEnum == ISWorldMapNoSkyBlur) { - defines[0] = { "NO_SKY_BLUR", nullptr }; - ++defines; - } else if (descEnum == ISMinifyContrast) { - defines[0] = { "CONTRAST", nullptr }; - ++defines; - } else if (descEnum == ISNoiseNormalmap) { - defines[0] = { "NORMALMAP", nullptr }; - ++defines; - } else if (descEnum == ISNoiseScrollAndBlend) { - defines[0] = { "SCROLL_AND_BLEND", nullptr }; - ++defines; - } else if (descEnum == ISRadialBlur) { - defines[0] = { "SAMPLES_COUNT", "2" }; - ++defines; - } else if (descEnum == ISRadialBlurHigh) { - defines[0] = { "SAMPLES_COUNT", "10" }; - ++defines; - } else if (descEnum == ISRadialBlurMedium) { - defines[0] = { "SAMPLES_COUNT", "6" }; - ++defines; - } - defines[0] = { nullptr, nullptr }; - } - static void GetShaderDefines(RE::BSShader::Type type, uint32_t descriptor, D3D_SHADER_MACRO* defines) { @@ -773,9 +604,6 @@ namespace SIE case RE::BSShader::Type::BloodSplatter: GetBloodSplaterShaderDefines(descriptor, defines); break; - case RE::BSShader::Type::ImageSpace: - GetImagespaceShaderDefines(descriptor, defines); - break; case RE::BSShader::Type::Lighting: GetLightingShaderDefines(descriptor, defines); break; @@ -1051,12 +879,12 @@ namespace SIE return result; } - static int32_t GetVariableIndex(ShaderClass shaderClass, const RE::BSShader& shader, const char* name) + static int32_t GetVariableIndex(ShaderClass shaderClass, RE::BSShader::Type shaderType, const char* name) { static auto variableNames = GetVariableIndices(); const auto& names = - variableNames[static_cast(shader.shaderType.get())][static_cast(shaderClass)]; + variableNames[static_cast(shaderType)][static_cast(shaderClass)]; auto it = names.find(name); if (it == names.cend()) { return -1; @@ -1090,9 +918,8 @@ namespace SIE std::array& bufferSizes, std::array& constantOffsets, uint64_t& vertexDesc, - ShaderClass shaderClass, const RE::BSShader& shader, uint32_t descriptor) + ShaderClass shaderClass, RE::BSShader::Type shaderType, uint32_t descriptor) { - RE::BSShader::Type shaderType = shader.shaderType.get(); D3D11_SHADER_DESC desc; if (FAILED(reflector.GetDesc(&desc))) { logger::error("Failed to get shader descriptor for {} shader {}::{}", @@ -1188,7 +1015,7 @@ namespace SIE } const auto variableIndex = - GetVariableIndex(shaderClass, shader, varDesc.Name); + GetVariableIndex(shaderClass, shaderType, varDesc.Name); if (variableIndex != -1) { constantOffsets[variableIndex] = (int8_t)(varDesc.StartOffset / 4); } else { @@ -1222,10 +1049,7 @@ namespace SIE uint32_t descriptor, bool useDiskCache) { const auto type = shader.shaderType.get(); - const auto name = shader.shaderType == RE::BSShader::Type::ImageSpace ? - std::string_view(static_cast(shader).originalShaderName.c_str()) : - shader.fxpFilename; - const std::wstring path = GetShaderPath(name); + const std::wstring path = GetShaderPath(shader.fxpFilename); std::array defines; if (shaderClass == ShaderClass::Vertex) { @@ -1238,7 +1062,7 @@ namespace SIE logger::debug("{}, {}", descriptor, MergeDefinesString(defines)); - auto diskPath = GetDiskPath(name, descriptor, shaderClass); + auto diskPath = GetDiskPath(shader.fxpFilename, descriptor, shaderClass); if (useDiskCache && std::filesystem::exists(diskPath)) { ID3DBlob* shaderBlob = nullptr; @@ -1327,9 +1151,8 @@ namespace SIE } std::unique_ptr CreateVertexShader(ID3DBlob& shaderData, - const RE::BSShader& shader, uint32_t descriptor) + RE::BSShader::Type type, uint32_t descriptor) { - auto type = shader.shaderType.get(); static const auto device = REL::Relocation(RE::Offset::D3D11Device); static const auto perTechniqueBuffersArray = REL::Relocation(RELOCATION_ID(524755, 411371)); @@ -1362,7 +1185,7 @@ namespace SIE std::fill(newShader->constantTable.begin(), newShader->constantTable.end(), 0); #pragma warning(pop) ReflectConstantBuffers(*reflector.Get(), bufferSizes, newShader->constantTable, newShader->shaderDesc, - ShaderClass::Vertex, shader, descriptor); + ShaderClass::Vertex, type, descriptor); if (bufferSizes[0] != 0) { newShader->constantBuffers[0].buffer = (RE::ID3D11Buffer*)perTechniqueBuffersArray.get()[bufferSizes[0]]; @@ -1390,9 +1213,8 @@ namespace SIE } std::unique_ptr CreatePixelShader(ID3DBlob& shaderData, - const RE::BSShader& shader, uint32_t descriptor) + RE::BSShader::Type type, uint32_t descriptor) { - auto type = shader.shaderType.get(); static const auto device = REL::Relocation(RE::Offset::D3D11Device); static const auto perTechniqueBuffersArray = REL::Relocation(RELOCATION_ID(524761, 411377)); @@ -1420,7 +1242,7 @@ namespace SIE uint64_t dummy; ReflectConstantBuffers(*reflector.Get(), bufferSizes, newShader->constantTable, dummy, - ShaderClass::Pixel, shader, descriptor); + ShaderClass::Pixel, type, descriptor); if (bufferSizes[0] != 0) { newShader->constantBuffers[0].buffer = (RE::ID3D11Buffer*)perTechniqueBuffersArray.get()[bufferSizes[0]]; @@ -1446,147 +1268,12 @@ namespace SIE return newShader; } - static uint32_t GetImagespaceShaderDescriptor(const RE::BSImagespaceShader& imagespaceShader) - { - using enum RE::ImageSpaceManager::ImageSpaceEffectEnum; - - static const std::unordered_map descriptors{ - { "BSImagespaceShaderISBlur", static_cast(ISBlur) }, - { "BSImagespaceShaderBlur3", static_cast(ISBlur3) }, - { "BSImagespaceShaderBlur5", static_cast(ISBlur5) }, - { "BSImagespaceShaderBlur7", static_cast(ISBlur7) }, - { "BSImagespaceShaderBlur9", static_cast(ISBlur9) }, - { "BSImagespaceShaderBlur11", static_cast(ISBlur11) }, - { "BSImagespaceShaderBlur13", static_cast(ISBlur13) }, - { "BSImagespaceShaderBlur15", static_cast(ISBlur15) }, - { "BSImagespaceShaderBrightPassBlur3", static_cast(ISBrightPassBlur3) }, - { "BSImagespaceShaderBrightPassBlur5", static_cast(ISBrightPassBlur5) }, - { "BSImagespaceShaderBrightPassBlur7", static_cast(ISBrightPassBlur7) }, - { "BSImagespaceShaderBrightPassBlur9", static_cast(ISBrightPassBlur9) }, - { "BSImagespaceShaderBrightPassBlur11", static_cast(ISBrightPassBlur11) }, - { "BSImagespaceShaderBrightPassBlur13", static_cast(ISBrightPassBlur13) }, - { "BSImagespaceShaderBrightPassBlur15", static_cast(ISBrightPassBlur15) }, - { "BSImagespaceShaderNonHDRBlur3", static_cast(ISNonHDRBlur3) }, - { "BSImagespaceShaderNonHDRBlur5", static_cast(ISNonHDRBlur5) }, - { "BSImagespaceShaderNonHDRBlur7", static_cast(ISNonHDRBlur7) }, - { "BSImagespaceShaderNonHDRBlur9", static_cast(ISNonHDRBlur9) }, - { "BSImagespaceShaderNonHDRBlur11", static_cast(ISNonHDRBlur11) }, - { "BSImagespaceShaderNonHDRBlur13", static_cast(ISNonHDRBlur13) }, - { "BSImagespaceShaderNonHDRBlur15", static_cast(ISNonHDRBlur15) }, - { "BSImagespaceShaderISBasicCopy", static_cast(ISBasicCopy) }, - { "BSImagespaceShaderISSimpleColor", static_cast(ISSimpleColor) }, - { "BSImagespaceShaderApplyReflections", static_cast(ISApplyReflections) }, - { "BSImagespaceShaderISExp", static_cast(ISExp) }, - { "BSImagespaceShaderISDisplayDepth", static_cast(ISDisplayDepth) }, - { "BSImagespaceShaderAlphaBlend", static_cast(ISAlphaBlend) }, - { "BSImagespaceShaderWaterFlow", static_cast(ISWaterFlow) }, - { "BSImagespaceShaderISWaterBlend", static_cast(ISWaterBlend) }, - { "BSImagespaceShaderGreyScale", static_cast(ISCopyGrayScale) }, - { "BSImagespaceShaderCopy", static_cast(ISCopy) }, - { "BSImagespaceShaderCopyScaleBias", static_cast(ISCopyScaleBias) }, - { "BSImagespaceShaderCopyCustomViewport", - static_cast(ISCopyCustomViewport) }, - { "BSImagespaceShaderCopyTextureMask", static_cast(ISCopyTextureMask) }, - { "BSImagespaceShaderCopyDynamicFetchDisabled", - static_cast(ISCopyDynamicFetchDisabled) }, - { "BSImagespaceShaderISCompositeVolumetricLighting", - static_cast(ISCompositeVolumetricLighting) }, - { "BSImagespaceShaderISCompositeLensFlare", - static_cast(ISCompositeLensFlare) }, - { "BSImagespaceShaderISCompositeLensFlareVolumetricLighting", - static_cast(ISCompositeLensFlareVolumetricLighting) }, - { "BSImagespaceShaderISDebugSnow", static_cast(ISDebugSnow) }, - { "BSImagespaceShaderDepthOfField", static_cast(ISDepthOfField) }, - { "BSImagespaceShaderDepthOfFieldFogged", - static_cast(ISDepthOfFieldFogged) }, - { "BSImagespaceShaderDepthOfFieldMaskedFogged", - static_cast(ISDepthOfFieldMaskedFogged) }, - { "BSImagespaceShaderDistantBlur", static_cast(ISDistantBlur) }, - { "BSImagespaceShaderDistantBlurFogged", - static_cast(ISDistantBlurFogged) }, - { "BSImagespaceShaderDistantBlurMaskedFogged", - static_cast(ISDistantBlurMaskedFogged) }, - { "BSImagespaceShaderDoubleVision", static_cast(ISDoubleVision) }, - { "BSImagespaceShaderISDownsample", static_cast(ISDownsample) }, - { "BSImagespaceShaderISDownsampleIgnoreBrightest", - static_cast(ISDownsampleIgnoreBrightest) }, - { "BSImagespaceShaderISUpsampleDynamicResolution", - static_cast(ISUpsampleDynamicResolution) }, - { "BSImageSpaceShaderVolumetricLighting", - static_cast(ISVolumetricLighting) }, - { "BSImagespaceShaderHDRDownSample4", static_cast(ISHDRDownSample4) }, - { "BSImagespaceShaderHDRDownSample4LightAdapt", - static_cast(ISHDRDownSample4LightAdapt) }, - { "BSImagespaceShaderHDRDownSample4LumClamp", - static_cast(ISHDRDownSample4LumClamp) }, - { "BSImagespaceShaderHDRDownSample4RGB2Lum", - static_cast(ISHDRDownSample4RGB2Lum) }, - { "BSImagespaceShaderHDRDownSample16", static_cast(ISHDRDownSample16) }, - { "BSImagespaceShaderHDRDownSample16LightAdapt", - static_cast(ISHDRDownSample16LightAdapt) }, - { "BSImagespaceShaderHDRDownSample16Lum", - static_cast(ISHDRDownSample16Lum) }, - { "BSImagespaceShaderHDRDownSample16LumClamp", - static_cast(ISHDRDownSample16LumClamp) }, - { "BSImagespaceShaderHDRTonemapBlendCinematic", - static_cast(ISHDRTonemapBlendCinematic) }, - { "BSImagespaceShaderHDRTonemapBlendCinematicFade", - static_cast(ISHDRTonemapBlendCinematicFade) }, - { "BSImagespaceShaderISIBLensFlares", static_cast(ISIBLensFlares) }, - { "BSImagespaceShaderISLightingComposite", - static_cast(ISLightingComposite) }, - { "BSImagespaceShaderISLightingCompositeMenu", - static_cast(ISLightingCompositeMenu) }, - { "BSImagespaceShaderISLightingCompositeNoDirectionalLight", - static_cast(ISLightingCompositeNoDirectionalLight) }, - { "BSImagespaceShaderLocalMap", static_cast(ISLocalMap) }, - { "BSISWaterBlendHeightmaps", static_cast(ISWaterBlendHeightmaps) }, - { "BSISWaterDisplacementClearSimulation", - static_cast(ISWaterDisplacementClearSimulation) }, - { "BSISWaterDisplacementNormals", - static_cast(ISWaterDisplacementNormals) }, - { "BSISWaterDisplacementRainRipple", - static_cast(ISWaterDisplacementRainRipple) }, - { "BSISWaterDisplacementTexOffset", - static_cast(ISWaterDisplacementTexOffset) }, - { "BSISWaterWadingHeightmap", static_cast(ISWaterWadingHeightmap) }, - { "BSISWaterRainHeightmap", static_cast(ISWaterRainHeightmap) }, - { "BSISWaterSmoothHeightmap", static_cast(ISWaterSmoothHeightmap) }, - { "BSISWaterWadingHeightmap", static_cast(ISWaterWadingHeightmap) }, - { "BSImagespaceShaderMap", static_cast(ISMap) }, - { "BSImagespaceShaderMap", static_cast(ISMap) }, - { "BSImagespaceShaderWorldMap", static_cast(ISWorldMap) }, - { "BSImagespaceShaderWorldMapNoSkyBlur", - static_cast(ISWorldMapNoSkyBlur) }, - { "BSImagespaceShaderISMinify", static_cast(ISMinify) }, - { "BSImagespaceShaderISMinifyContrast", static_cast(ISMinifyContrast) }, - { "BSImagespaceShaderNoiseNormalmap", static_cast(ISNoiseNormalmap) }, - { "BSImagespaceShaderNoiseScrollAndBlend", - static_cast(ISNoiseScrollAndBlend) }, - { "BSImagespaceShaderRadialBlur", - static_cast(ISRadialBlur) }, - { "BSImagespaceShaderRadialBlurHigh", static_cast(ISRadialBlurHigh) }, - { "BSImagespaceShaderRadialBlurMedium", static_cast(ISRadialBlurMedium) }, - { "BSImagespaceShaderRefraction", static_cast(ISRefraction) }, - }; - - auto it = descriptors.find(imagespaceShader.name.c_str()); - if (it == descriptors.cend()) { - return std::numeric_limits::max(); - } - return it->second; - } } RE::BSGraphics::VertexShader* ShaderCache::GetVertexShader(const RE::BSShader& shader, uint32_t descriptor) { - if (shader.shaderType == RE::BSShader::Type::ImageSpace) { - descriptor = SShaderCache::GetImagespaceShaderDescriptor( - static_cast(shader)); - } - - if (!ShaderCache::IsSupportedShader(shader) || descriptor != std::numeric_limits::max()) { + if (!ShaderCache::IsSupportedShader(shader)) { return nullptr; } @@ -1611,12 +1298,7 @@ namespace SIE RE::BSGraphics::PixelShader* ShaderCache::GetPixelShader(const RE::BSShader& shader, uint32_t descriptor) { - if (shader.shaderType == RE::BSShader::Type::ImageSpace) { - descriptor = SShaderCache::GetImagespaceShaderDescriptor( - static_cast(shader)); - } - - if (!ShaderCache::IsSupportedShader(shader) || descriptor != std::numeric_limits::max()) { + if (!ShaderCache::IsSupportedShader(shader)) { return nullptr; } @@ -1768,7 +1450,7 @@ namespace SIE SShaderCache::CompileShader(ShaderClass::Vertex, shader, descriptor, isDiskCache)) { static const auto device = REL::Relocation(RE::Offset::D3D11Device); - auto newShader = SShaderCache::CreateVertexShader(*shaderBlob, shader, + auto newShader = SShaderCache::CreateVertexShader(*shaderBlob, shader.shaderType.get(), descriptor); std::lock_guard lockGuard(vertexShadersMutex); @@ -1797,7 +1479,7 @@ namespace SIE SShaderCache::CompileShader(ShaderClass::Pixel, shader, descriptor, isDiskCache)) { static const auto device = REL::Relocation(RE::Offset::D3D11Device); - auto newShader = SShaderCache::CreatePixelShader(*shaderBlob, shader, + auto newShader = SShaderCache::CreatePixelShader(*shaderBlob, shader.shaderType.get(), descriptor); std::lock_guard lockGuard(pixelShadersMutex);