mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-03-08 18:41:17 +00:00
99 lines
2.3 KiB
PostScript
99 lines
2.3 KiB
PostScript
sampler2D Image : register(s0);
|
|
sampler1D Palette : register(s1);
|
|
|
|
float4 Desaturation : register(c1); // { Desat, 1 - Desat }
|
|
float4 PaletteMod : register(c2);
|
|
float4 Color1 : register(c3);
|
|
float4 Color2 : register(c4);
|
|
float4 Weights : register(c6); // RGB->Gray weighting { 77/256.0, 143/256.0, 37/256.0, 1 }
|
|
float4 Gamma : register(c7);
|
|
|
|
float4 TextureLookup(float2 tex_coord)
|
|
{
|
|
#if PALTEX
|
|
float index = tex2D(Image, tex_coord).x;
|
|
index = index * PaletteMod.x + PaletteMod.y;
|
|
return tex1D(Palette, index);
|
|
#else
|
|
return tex2D(Image, tex_coord);
|
|
#endif
|
|
}
|
|
|
|
float Grayscale(float4 rgb)
|
|
{
|
|
return dot(rgb.rgb, Weights.rgb);
|
|
}
|
|
|
|
float4 SampleTexture(float2 tex_coord)
|
|
{
|
|
float4 texel = TextureLookup(tex_coord);
|
|
#if INVERT
|
|
texel.rgb = Weights.www - texel.xyz;
|
|
#endif
|
|
#if OPAQUE
|
|
texel.a = 1.0;
|
|
#endif
|
|
#if STENCIL
|
|
texel.rgb = Weights.www;
|
|
#endif
|
|
#if ALPHATEX
|
|
texel.a *= Grayscale(texel);
|
|
texel.rgb = Weights.www;
|
|
#endif
|
|
#if DESAT
|
|
float3 intensity;
|
|
intensity.rgb = Grayscale(texel) * Desaturation.x;
|
|
texel.rgb = intensity.rgb + texel.rgb * Desaturation.y;
|
|
#endif
|
|
return texel;
|
|
}
|
|
|
|
// Normal color calculation for most drawing modes.
|
|
|
|
float4 NormalColor(float2 tex_coord : TEXCOORD0, float4 VertexColor : COLOR0) : COLOR
|
|
{
|
|
return Color1 + SampleTexture(tex_coord) * VertexColor;
|
|
}
|
|
|
|
|
|
// Just return the value of c0.
|
|
|
|
float4 VertexColor(float4 color : COLOR0) : COLOR
|
|
{
|
|
return color;
|
|
}
|
|
|
|
// Emulate one of the special colormaps. (Invulnerability, gold, etc.)
|
|
|
|
float4 SpecialColormap(float2 tex_coord : TEXCOORD0) : COLOR
|
|
{
|
|
float4 color = SampleTexture(tex_coord);
|
|
float4 range = Color2 - Color1;
|
|
// We can't store values greater than 1.0 in a color register, so we multiply
|
|
// the final result by 2 and expect the caller to divide the start and end by 2.
|
|
color.rgb = 2 * (Color1 + Grayscale(color) * range).rgb;
|
|
return color;
|
|
}
|
|
|
|
|
|
// Windowed gamma correction.
|
|
|
|
float4 GammaCorrection(float2 tex_coord : TEXCOORD0) : COLOR
|
|
{
|
|
float4 color = tex2D(Image, tex_coord);
|
|
color.rgb = pow(color.rgb, Gamma.rgb);
|
|
return color;
|
|
}
|
|
|
|
// The burn wipe effect.
|
|
|
|
sampler2D NewScreen : register(s0);
|
|
sampler2D Burn : register(s1);
|
|
|
|
float4 BurnWipe(float2 coord[2] : TEXCOORD0) : COLOR
|
|
{
|
|
float4 color = tex2D(NewScreen, coord[0]);
|
|
float4 alpha = tex2D(Burn, coord[1]);
|
|
color.a = alpha.r * 2;
|
|
return color;
|
|
}
|