mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-08 14:01:32 +00:00
132 lines
3.9 KiB
C
132 lines
3.9 KiB
C
|
#define HLSL_SOURCE_CODE 0
|
||
|
#define SHADER_ASSEMBLY_CODE 0
|
||
|
|
||
|
// A paletted texture shader
|
||
|
|
||
|
#if HLSL_SOURCE_CODE
|
||
|
// Technically, Palette only needs to be a sampler1D, but that
|
||
|
// produces assembly code to copy index.x to index.y, which is
|
||
|
// totally unnecessary.
|
||
|
|
||
|
sampler2D Image : register(s0);
|
||
|
sampler2D Palette : register(s1);
|
||
|
float4 Flash : register(c0);
|
||
|
float4 InvFlash : register(c1);
|
||
|
|
||
|
float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
||
|
{
|
||
|
float4 index = tex2D (Image, texCoord);
|
||
|
float4 rgb = tex2D (Palette, index);
|
||
|
return Flash + rgb * InvFlash;
|
||
|
}
|
||
|
#endif
|
||
|
#if SHADER_ASSEMBLY_CODE
|
||
|
//
|
||
|
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000
|
||
|
//
|
||
|
// fxc paltex.ps /Tps_1_4 /VnPalTexShaderDef /Fh
|
||
|
//
|
||
|
//
|
||
|
// Parameters:
|
||
|
//
|
||
|
// float4 Flash;
|
||
|
// sampler2D Image;
|
||
|
// float4 InvFlash;
|
||
|
// sampler2D Palette;
|
||
|
//
|
||
|
//
|
||
|
// Registers:
|
||
|
//
|
||
|
// Name Reg Size
|
||
|
// ------------ ----- ----
|
||
|
// Flash c0 1
|
||
|
// InvFlash c1 1
|
||
|
// Image s0 1
|
||
|
// Palette s1 1
|
||
|
//
|
||
|
|
||
|
ps_1_4
|
||
|
texld r0, t0
|
||
|
phase
|
||
|
texld r1, r0
|
||
|
mad r0, r1, c1, c0
|
||
|
|
||
|
// approximately 3 instruction slots used (2 texture, 1 arithmetic)
|
||
|
#endif
|
||
|
|
||
|
const DWORD PalTexShaderDef[] =
|
||
|
{
|
||
|
0xffff0104, 0x003bfffe, 0x42415443, 0x0000001c, 0x000000b4, 0xffff0104,
|
||
|
0x00000004, 0x0000001c, 0x00000100, 0x000000ad, 0x0000006c, 0x00000002,
|
||
|
0x00020001, 0x00000074, 0x00000000, 0x00000084, 0x00000003, 0x00000001,
|
||
|
0x0000008c, 0x00000000, 0x0000009c, 0x00010002, 0x00020001, 0x00000074,
|
||
|
0x00000000, 0x000000a5, 0x00010003, 0x00000001, 0x0000008c, 0x00000000,
|
||
|
0x73616c46, 0xabab0068, 0x00030001, 0x00040001, 0x00000001, 0x00000000,
|
||
|
0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001, 0x00000000,
|
||
|
0x46766e49, 0x6873616c, 0x6c615000, 0x65747465, 0x5f737000, 0x00345f31,
|
||
|
0x7263694d, 0x666f736f, 0x52282074, 0x33442029, 0x20395844, 0x64616853,
|
||
|
0x43207265, 0x69706d6f, 0x2072656c, 0x35312e39, 0x3937372e, 0x3030302e,
|
||
|
0xabab0030, 0x00000042, 0x800f0000, 0xb0e40000, 0x0000fffd, 0x00000042,
|
||
|
0x800f0001, 0x80e40000, 0x00000004, 0x800f0000, 0x80e40001, 0xa0e40001,
|
||
|
0xa0e40000, 0x0000ffff
|
||
|
};
|
||
|
|
||
|
// A texture that doesn't look up colors from a palette.
|
||
|
// Can be used for shaded L8 textures or RGB textures.
|
||
|
|
||
|
#if HLSL_SOURCE_CODE
|
||
|
sampler2D Image : register(s0);
|
||
|
float4 Flash : register(c0);
|
||
|
float4 InvFlash : register(c1);
|
||
|
|
||
|
float4 main (float2 texCoord : TEXCOORD0) : COLOR
|
||
|
{
|
||
|
float4 index = tex2D (Image, texCoord);
|
||
|
return Flash + index * InvFlash;
|
||
|
}
|
||
|
#endif
|
||
|
#if SHADER_ASSEMBLY_CODE
|
||
|
//
|
||
|
// Generated by Microsoft (R) D3DX9 Shader Compiler 9.15.779.0000
|
||
|
//
|
||
|
// fxc shadetex.ps /Tps_1_4 /VnPlainShaderDef /Fh
|
||
|
//
|
||
|
//
|
||
|
// Parameters:
|
||
|
//
|
||
|
// float4 Flash;
|
||
|
// sampler2D Image;
|
||
|
// float4 InvFlash;
|
||
|
//
|
||
|
//
|
||
|
// Registers:
|
||
|
//
|
||
|
// Name Reg Size
|
||
|
// ------------ ----- ----
|
||
|
// Flash c0 1
|
||
|
// InvFlash c1 1
|
||
|
// Image s0 1
|
||
|
//
|
||
|
|
||
|
ps_1_4
|
||
|
texld r0, t0
|
||
|
mad r0, r0, c1, c0
|
||
|
|
||
|
// approximately 2 instruction slots used (1 texture, 1 arithmetic)
|
||
|
#endif
|
||
|
|
||
|
const DWORD PlainShaderDef[] =
|
||
|
{
|
||
|
0xffff0104, 0x0034fffe, 0x42415443, 0x0000001c, 0x00000098, 0xffff0104,
|
||
|
0x00000003, 0x0000001c, 0x00000100, 0x00000091, 0x00000058, 0x00000002,
|
||
|
0x00020001, 0x00000060, 0x00000000, 0x00000070, 0x00000003, 0x00000001,
|
||
|
0x00000078, 0x00000000, 0x00000088, 0x00010002, 0x00020001, 0x00000060,
|
||
|
0x00000000, 0x73616c46, 0xabab0068, 0x00030001, 0x00040001, 0x00000001,
|
||
|
0x00000000, 0x67616d49, 0xabab0065, 0x000c0004, 0x00010001, 0x00000001,
|
||
|
0x00000000, 0x46766e49, 0x6873616c, 0x5f737000, 0x00345f31, 0x7263694d,
|
||
|
0x666f736f, 0x52282074, 0x33442029, 0x20395844, 0x64616853, 0x43207265,
|
||
|
0x69706d6f, 0x2072656c, 0x35312e39, 0x3937372e, 0x3030302e, 0xabab0030,
|
||
|
0x00000042, 0x800f0000, 0xb0e40000, 0x00000004, 0x800f0000, 0x80e40000,
|
||
|
0xa0e40001, 0xa0e40000, 0x0000ffff
|
||
|
};
|