Skip to content

Commit

Permalink
effects: Add standard effect file
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Xaymar committed Oct 6, 2021
1 parent 91e8946 commit c704b99
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
3 changes: 3 additions & 0 deletions data/effects/shared.effect
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ uniform float4x4 ViewProj;
//------------------------------------------------------------------------------
// Samplers
//------------------------------------------------------------------------------
sampler_state BlankSampler {
};

sampler_state PointRepeatSampler {
Filter = Point;
AddressU = Repeat;
Expand Down
27 changes: 27 additions & 0 deletions data/effects/standard.effect
Original file line number Diff line number Diff line change
@@ -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);
};
};

0 comments on commit c704b99

Please sign in to comment.