From 889fea64220b72d34f76236cb0a90badae5a2000 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Wed, 6 Oct 2021 02:05:46 +0200 Subject: [PATCH] effects: Add standard effect file There are a number of duplicate shader routines we should combine into a single shader to save disk space, and remove unexpected errors in one copy but not the other. --- CMakeLists.txt | 1 + data/effects/shared.effect | 3 +++ data/effects/standard.effect | 27 +++++++++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 data/effects/standard.effect diff --git a/CMakeLists.txt b/CMakeLists.txt index 14684450..3073f4cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1174,6 +1174,7 @@ list(APPEND PROJECT_DATA "data/effects/color_conversion_rgb_yuv.effect" "data/effects/mipgen.effect" "data/effects/pack-unpack.effect" + "data/effects/standard.effect" "data/effects/shared.effect" "data/locale/en-US.ini" ) diff --git a/data/effects/shared.effect b/data/effects/shared.effect index eed2a740..e47a331e 100644 --- a/data/effects/shared.effect +++ b/data/effects/shared.effect @@ -16,6 +16,9 @@ uniform float4x4 ViewProj; //------------------------------------------------------------------------------ // Samplers //------------------------------------------------------------------------------ +sampler_state BlankSampler { +}; + sampler_state PointRepeatSampler { Filter = Point; AddressU = Repeat; diff --git a/data/effects/standard.effect b/data/effects/standard.effect new file mode 100644 index 00000000..a6ad5050 --- /dev/null +++ b/data/effects/standard.effect @@ -0,0 +1,27 @@ +#include "shared.effect" + +uniform texture2D Channel0; +uniform texture2D Channel1; + +//------------------------------------------------------------------------------ +// Technique: Restore Alpha +//------------------------------------------------------------------------------ +// Parameters: +// - Channel0: RGBX Texture +// - Channel1: XXXA Texture + +float4 PSRestoreAlpha(VertexData vtx) : TARGET { + float4 rgbx = Channel0.Sample(BlankSampler, vtx.uv); + float4 xxxa = Channel1.Sample(BlankSampler, vtx.uv); + rgbx.a = xxxa.a; + return rgbx; +}; + +technique RestoreAlpha +{ + pass + { + vertex_shader = DefaultVertexShader(vtx); + pixel_shader = PSRestoreAlpha(vtx); + }; +};