mirror of
https://github.com/FunkyFr3sh/cnc-ddraw.git
synced 2025-03-15 06:04:49 +01:00
add d3d9 catmull rom shader
This commit is contained in:
parent
225b5dc169
commit
e9a18548ed
384
inc/d3d9shader.h
384
inc/d3d9shader.h
@ -341,4 +341,388 @@ const BYTE D3D9_PALETTE_SHADER_BILINEAR[] =
|
||||
228, 128, 255, 255, 0, 0
|
||||
};
|
||||
|
||||
|
||||
/* catmull rom upscaling */
|
||||
|
||||
#if 0
|
||||
//
|
||||
// Generated by Microsoft (R) HLSL Shader Compiler 10.1
|
||||
//
|
||||
// Parameters:
|
||||
//
|
||||
// sampler2D SurfaceTex;
|
||||
// float4 TextureSize;
|
||||
//
|
||||
//
|
||||
// Registers:
|
||||
//
|
||||
// Name Reg Size
|
||||
// ------------ ----- ----
|
||||
// TextureSize c0 1
|
||||
// SurfaceTex s0 1
|
||||
//
|
||||
|
||||
ps_2_0
|
||||
def c1, -0.5, 0.5, 1, 2.5
|
||||
def c2, 1.5, -2.5, 2, 0
|
||||
dcl t0.xy
|
||||
dcl_2d s0
|
||||
mov r0.w, c1.x
|
||||
mad r0.xy, t0, c0, r0.w
|
||||
frc r0.zw, r0.wzyx
|
||||
add r0.xy, -r0.wzyx, r0
|
||||
add r0.zw, r0.wzyx, c1.y
|
||||
mad r1.xy, t0, c0, -r0.wzyx
|
||||
mad r1.zw, r1.wzyx, -c2.x, c2.z
|
||||
mad r1.zw, r1.wzyx, r1, c1.y
|
||||
mul r2.xy, r1.wzyx, r1
|
||||
mad r2.zw, r1.wzyx, c2.x, c2.y
|
||||
mul r3.xy, r1, r1
|
||||
mad r2.zw, r3.wzyx, r2, c1.z
|
||||
mad r1.zw, r1.wzyx, r1, r2
|
||||
rcp r4.x, r1.w
|
||||
rcp r4.y, r1.z
|
||||
mad r0.zw, r2.wzyx, r4.wzyx, r0
|
||||
rcp r2.x, c0.x
|
||||
rcp r2.y, c0.y
|
||||
mul r4.xy, r0.wzyx, r2
|
||||
mov r5.x, r4.x
|
||||
add r0.zw, r0.wzyx, c1.x
|
||||
add r0.xy, r0, c1.w
|
||||
mul r0.xy, r2, r0
|
||||
mul r2.xy, r2, r0.wzyx
|
||||
mov r5.y, r2.y
|
||||
mov r6.x, r5.x
|
||||
mov r7.y, r5.y
|
||||
mov r8.x, r2.x
|
||||
mov r7.x, r0.x
|
||||
mov r9.x, r7.x
|
||||
mov r8.y, r4.y
|
||||
mov r10.x, r8.x
|
||||
mov r9.y, r8.y
|
||||
mov r10.y, r0.y
|
||||
mov r6.y, r10.y
|
||||
texld r5, r5, s0
|
||||
texld r2, r2, s0
|
||||
texld r7, r7, s0
|
||||
texld r4, r4, s0
|
||||
texld r8, r8, s0
|
||||
texld r9, r9, s0
|
||||
texld r0, r0, s0
|
||||
texld r6, r6, s0
|
||||
mul r5, r1.w, r5
|
||||
mad r3.zw, r1.wzyx, -c1.y, c1.z
|
||||
mad r3.zw, r1.wzyx, r3, c1.x
|
||||
mul r3.zw, r1.wzyx, r3
|
||||
mad r1.xy, r1, c1.y, c1.x
|
||||
mul r1.xy, r1, r3
|
||||
mul r5, r3.z, r5
|
||||
mul r2, r2, r3.w
|
||||
mad r2, r2, r3.z, r5
|
||||
mul r5, r1.x, r7
|
||||
mad r2, r5, r3.z, r2
|
||||
mul r4, r1.w, r4
|
||||
mul r5, r1.x, r9
|
||||
mul r7, r3.w, r8
|
||||
mad r2, r7, r1.z, r2
|
||||
mad r2, r4, r1.z, r2
|
||||
mad r2, r5, r1.z, r2
|
||||
mul r0, r0, r1.x
|
||||
texld r4, r10, s0
|
||||
mul r5, r1.w, r6
|
||||
mul r3, r3.w, r4
|
||||
mad r2, r3, r1.y, r2
|
||||
mad r2, r5, r1.y, r2
|
||||
mad r0, r0, r1.y, r2
|
||||
mov oC0, r0
|
||||
|
||||
// approximately 68 instruction slots used (9 texture, 59 arithmetic)
|
||||
|
||||
// fxc.exe /Tps_2_0 shader.hlsl /Fhshader.h
|
||||
/*
|
||||
uniform sampler2D SurfaceTex;
|
||||
|
||||
float4 TextureSize : register(c0);
|
||||
|
||||
float4 catmull_rom(float2 coord)
|
||||
{
|
||||
// The following code is licensed under the MIT license: https://gist.github.com/TheRealMJP/bc503b0b87b643d3505d41eab8b332ae
|
||||
|
||||
// Samples a texture with Catmull-Rom filtering, using 9 texture fetches instead of 16.
|
||||
// See http://vec3.ca/bicubic-filtering-in-fewer-taps/ for more details
|
||||
|
||||
float2 samplePos = coord * TextureSize.xy;
|
||||
float2 texPos1 = floor(samplePos - 0.5f) + 0.5f;
|
||||
|
||||
float2 f = samplePos - texPos1;
|
||||
|
||||
float2 w0 = f * (-0.5f + f * (1.0f - 0.5f * f));
|
||||
float2 w1 = 1.0f + f * f * (-2.5f + 1.5f * f);
|
||||
float2 w2 = f * (0.5f + f * (2.0f - 1.5f * f));
|
||||
float2 w3 = f * f * (-0.5f + 0.5f * f);
|
||||
|
||||
float2 w12 = w1 + w2;
|
||||
float2 offset12 = w2 / (w1 + w2);
|
||||
|
||||
float2 texPos0 = texPos1 - 1;
|
||||
float2 texPos3 = texPos1 + 2;
|
||||
float2 texPos12 = texPos1 + offset12;
|
||||
|
||||
texPos0 /= TextureSize.xy;
|
||||
texPos3 /= TextureSize.xy;
|
||||
texPos12 /= TextureSize.xy;
|
||||
|
||||
float4 result = 0.0f;
|
||||
result += tex2D(SurfaceTex, float2(texPos0.x, texPos0.y)) * w0.x * w0.y;
|
||||
result += tex2D(SurfaceTex, float2(texPos12.x, texPos0.y)) * w12.x * w0.y;
|
||||
result += tex2D(SurfaceTex, float2(texPos3.x, texPos0.y)) * w3.x * w0.y;
|
||||
|
||||
result += tex2D(SurfaceTex, float2(texPos0.x, texPos12.y)) * w0.x * w12.y;
|
||||
result += tex2D(SurfaceTex, float2(texPos12.x, texPos12.y)) * w12.x * w12.y;
|
||||
result += tex2D(SurfaceTex, float2(texPos3.x, texPos12.y)) * w3.x * w12.y;
|
||||
|
||||
result += tex2D(SurfaceTex, float2(texPos0.x, texPos3.y)) * w0.x * w3.y;
|
||||
result += tex2D(SurfaceTex, float2(texPos12.x, texPos3.y)) * w12.x * w3.y;
|
||||
result += tex2D(SurfaceTex, float2(texPos3.x, texPos3.y)) * w3.x * w3.y;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
float4 main(float2 texCoords : TEXCOORD) : COLOR
|
||||
{
|
||||
return catmull_rom(texCoords);
|
||||
}
|
||||
|
||||
*/
|
||||
#endif
|
||||
|
||||
const BYTE D3D9_CATMULL_ROM_SHADER[] =
|
||||
{
|
||||
0, 2, 255, 255, 254, 255,
|
||||
44, 0, 67, 84, 65, 66,
|
||||
28, 0, 0, 0, 131, 0,
|
||||
0, 0, 0, 2, 255, 255,
|
||||
2, 0, 0, 0, 28, 0,
|
||||
0, 0, 0, 1, 0, 0,
|
||||
124, 0, 0, 0, 68, 0,
|
||||
0, 0, 3, 0, 0, 0,
|
||||
1, 0, 0, 0, 80, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
96, 0, 0, 0, 2, 0,
|
||||
0, 0, 1, 0, 2, 0,
|
||||
108, 0, 0, 0, 0, 0,
|
||||
0, 0, 83, 117, 114, 102,
|
||||
97, 99, 101, 84, 101, 120,
|
||||
0, 171, 4, 0, 12, 0,
|
||||
1, 0, 1, 0, 1, 0,
|
||||
0, 0, 0, 0, 0, 0,
|
||||
84, 101, 120, 116, 117, 114,
|
||||
101, 83, 105, 122, 101, 0,
|
||||
1, 0, 3, 0, 1, 0,
|
||||
4, 0, 1, 0, 0, 0,
|
||||
0, 0, 0, 0, 112, 115,
|
||||
95, 50, 95, 48, 0, 77,
|
||||
105, 99, 114, 111, 115, 111,
|
||||
102, 116, 32, 40, 82, 41,
|
||||
32, 72, 76, 83, 76, 32,
|
||||
83, 104, 97, 100, 101, 114,
|
||||
32, 67, 111, 109, 112, 105,
|
||||
108, 101, 114, 32, 49, 48,
|
||||
46, 49, 0, 171, 81, 0,
|
||||
0, 5, 1, 0, 15, 160,
|
||||
0, 0, 0, 191, 0, 0,
|
||||
0, 63, 0, 0, 128, 63,
|
||||
0, 0, 32, 64, 81, 0,
|
||||
0, 5, 2, 0, 15, 160,
|
||||
0, 0, 192, 63, 0, 0,
|
||||
32, 192, 0, 0, 0, 64,
|
||||
0, 0, 0, 0, 31, 0,
|
||||
0, 2, 0, 0, 0, 128,
|
||||
0, 0, 3, 176, 31, 0,
|
||||
0, 2, 0, 0, 0, 144,
|
||||
0, 8, 15, 160, 1, 0,
|
||||
0, 2, 0, 0, 8, 128,
|
||||
1, 0, 0, 160, 4, 0,
|
||||
0, 4, 0, 0, 3, 128,
|
||||
0, 0, 228, 176, 0, 0,
|
||||
228, 160, 0, 0, 255, 128,
|
||||
19, 0, 0, 2, 0, 0,
|
||||
12, 128, 0, 0, 27, 128,
|
||||
2, 0, 0, 3, 0, 0,
|
||||
3, 128, 0, 0, 27, 129,
|
||||
0, 0, 228, 128, 2, 0,
|
||||
0, 3, 0, 0, 12, 128,
|
||||
0, 0, 27, 128, 1, 0,
|
||||
85, 160, 4, 0, 0, 4,
|
||||
1, 0, 3, 128, 0, 0,
|
||||
228, 176, 0, 0, 228, 160,
|
||||
0, 0, 27, 129, 4, 0,
|
||||
0, 4, 1, 0, 12, 128,
|
||||
1, 0, 27, 128, 2, 0,
|
||||
0, 161, 2, 0, 170, 160,
|
||||
4, 0, 0, 4, 1, 0,
|
||||
12, 128, 1, 0, 27, 128,
|
||||
1, 0, 228, 128, 1, 0,
|
||||
85, 160, 5, 0, 0, 3,
|
||||
2, 0, 3, 128, 1, 0,
|
||||
27, 128, 1, 0, 228, 128,
|
||||
4, 0, 0, 4, 2, 0,
|
||||
12, 128, 1, 0, 27, 128,
|
||||
2, 0, 0, 160, 2, 0,
|
||||
85, 160, 5, 0, 0, 3,
|
||||
3, 0, 3, 128, 1, 0,
|
||||
228, 128, 1, 0, 228, 128,
|
||||
4, 0, 0, 4, 2, 0,
|
||||
12, 128, 3, 0, 27, 128,
|
||||
2, 0, 228, 128, 1, 0,
|
||||
170, 160, 4, 0, 0, 4,
|
||||
1, 0, 12, 128, 1, 0,
|
||||
27, 128, 1, 0, 228, 128,
|
||||
2, 0, 228, 128, 6, 0,
|
||||
0, 2, 4, 0, 1, 128,
|
||||
1, 0, 255, 128, 6, 0,
|
||||
0, 2, 4, 0, 2, 128,
|
||||
1, 0, 170, 128, 4, 0,
|
||||
0, 4, 0, 0, 12, 128,
|
||||
2, 0, 27, 128, 4, 0,
|
||||
27, 128, 0, 0, 228, 128,
|
||||
6, 0, 0, 2, 2, 0,
|
||||
1, 128, 0, 0, 0, 160,
|
||||
6, 0, 0, 2, 2, 0,
|
||||
2, 128, 0, 0, 85, 160,
|
||||
5, 0, 0, 3, 4, 0,
|
||||
3, 128, 0, 0, 27, 128,
|
||||
2, 0, 228, 128, 1, 0,
|
||||
0, 2, 5, 0, 1, 128,
|
||||
4, 0, 0, 128, 2, 0,
|
||||
0, 3, 0, 0, 12, 128,
|
||||
0, 0, 27, 128, 1, 0,
|
||||
0, 160, 2, 0, 0, 3,
|
||||
0, 0, 3, 128, 0, 0,
|
||||
228, 128, 1, 0, 255, 160,
|
||||
5, 0, 0, 3, 0, 0,
|
||||
3, 128, 2, 0, 228, 128,
|
||||
0, 0, 228, 128, 5, 0,
|
||||
0, 3, 2, 0, 3, 128,
|
||||
2, 0, 228, 128, 0, 0,
|
||||
27, 128, 1, 0, 0, 2,
|
||||
5, 0, 2, 128, 2, 0,
|
||||
85, 128, 1, 0, 0, 2,
|
||||
6, 0, 1, 128, 5, 0,
|
||||
0, 128, 1, 0, 0, 2,
|
||||
7, 0, 2, 128, 5, 0,
|
||||
85, 128, 1, 0, 0, 2,
|
||||
8, 0, 1, 128, 2, 0,
|
||||
0, 128, 1, 0, 0, 2,
|
||||
7, 0, 1, 128, 0, 0,
|
||||
0, 128, 1, 0, 0, 2,
|
||||
9, 0, 1, 128, 7, 0,
|
||||
0, 128, 1, 0, 0, 2,
|
||||
8, 0, 2, 128, 4, 0,
|
||||
85, 128, 1, 0, 0, 2,
|
||||
10, 0, 1, 128, 8, 0,
|
||||
0, 128, 1, 0, 0, 2,
|
||||
9, 0, 2, 128, 8, 0,
|
||||
85, 128, 1, 0, 0, 2,
|
||||
10, 0, 2, 128, 0, 0,
|
||||
85, 128, 1, 0, 0, 2,
|
||||
6, 0, 2, 128, 10, 0,
|
||||
85, 128, 66, 0, 0, 3,
|
||||
5, 0, 15, 128, 5, 0,
|
||||
228, 128, 0, 8, 228, 160,
|
||||
66, 0, 0, 3, 2, 0,
|
||||
15, 128, 2, 0, 228, 128,
|
||||
0, 8, 228, 160, 66, 0,
|
||||
0, 3, 7, 0, 15, 128,
|
||||
7, 0, 228, 128, 0, 8,
|
||||
228, 160, 66, 0, 0, 3,
|
||||
4, 0, 15, 128, 4, 0,
|
||||
228, 128, 0, 8, 228, 160,
|
||||
66, 0, 0, 3, 8, 0,
|
||||
15, 128, 8, 0, 228, 128,
|
||||
0, 8, 228, 160, 66, 0,
|
||||
0, 3, 9, 0, 15, 128,
|
||||
9, 0, 228, 128, 0, 8,
|
||||
228, 160, 66, 0, 0, 3,
|
||||
0, 0, 15, 128, 0, 0,
|
||||
228, 128, 0, 8, 228, 160,
|
||||
66, 0, 0, 3, 6, 0,
|
||||
15, 128, 6, 0, 228, 128,
|
||||
0, 8, 228, 160, 5, 0,
|
||||
0, 3, 5, 0, 15, 128,
|
||||
1, 0, 255, 128, 5, 0,
|
||||
228, 128, 4, 0, 0, 4,
|
||||
3, 0, 12, 128, 1, 0,
|
||||
27, 128, 1, 0, 85, 161,
|
||||
1, 0, 170, 160, 4, 0,
|
||||
0, 4, 3, 0, 12, 128,
|
||||
1, 0, 27, 128, 3, 0,
|
||||
228, 128, 1, 0, 0, 160,
|
||||
5, 0, 0, 3, 3, 0,
|
||||
12, 128, 1, 0, 27, 128,
|
||||
3, 0, 228, 128, 4, 0,
|
||||
0, 4, 1, 0, 3, 128,
|
||||
1, 0, 228, 128, 1, 0,
|
||||
85, 160, 1, 0, 0, 160,
|
||||
5, 0, 0, 3, 1, 0,
|
||||
3, 128, 1, 0, 228, 128,
|
||||
3, 0, 228, 128, 5, 0,
|
||||
0, 3, 5, 0, 15, 128,
|
||||
3, 0, 170, 128, 5, 0,
|
||||
228, 128, 5, 0, 0, 3,
|
||||
2, 0, 15, 128, 2, 0,
|
||||
228, 128, 3, 0, 255, 128,
|
||||
4, 0, 0, 4, 2, 0,
|
||||
15, 128, 2, 0, 228, 128,
|
||||
3, 0, 170, 128, 5, 0,
|
||||
228, 128, 5, 0, 0, 3,
|
||||
5, 0, 15, 128, 1, 0,
|
||||
0, 128, 7, 0, 228, 128,
|
||||
4, 0, 0, 4, 2, 0,
|
||||
15, 128, 5, 0, 228, 128,
|
||||
3, 0, 170, 128, 2, 0,
|
||||
228, 128, 5, 0, 0, 3,
|
||||
4, 0, 15, 128, 1, 0,
|
||||
255, 128, 4, 0, 228, 128,
|
||||
5, 0, 0, 3, 5, 0,
|
||||
15, 128, 1, 0, 0, 128,
|
||||
9, 0, 228, 128, 5, 0,
|
||||
0, 3, 7, 0, 15, 128,
|
||||
3, 0, 255, 128, 8, 0,
|
||||
228, 128, 4, 0, 0, 4,
|
||||
2, 0, 15, 128, 7, 0,
|
||||
228, 128, 1, 0, 170, 128,
|
||||
2, 0, 228, 128, 4, 0,
|
||||
0, 4, 2, 0, 15, 128,
|
||||
4, 0, 228, 128, 1, 0,
|
||||
170, 128, 2, 0, 228, 128,
|
||||
4, 0, 0, 4, 2, 0,
|
||||
15, 128, 5, 0, 228, 128,
|
||||
1, 0, 170, 128, 2, 0,
|
||||
228, 128, 5, 0, 0, 3,
|
||||
0, 0, 15, 128, 0, 0,
|
||||
228, 128, 1, 0, 0, 128,
|
||||
66, 0, 0, 3, 4, 0,
|
||||
15, 128, 10, 0, 228, 128,
|
||||
0, 8, 228, 160, 5, 0,
|
||||
0, 3, 5, 0, 15, 128,
|
||||
1, 0, 255, 128, 6, 0,
|
||||
228, 128, 5, 0, 0, 3,
|
||||
3, 0, 15, 128, 3, 0,
|
||||
255, 128, 4, 0, 228, 128,
|
||||
4, 0, 0, 4, 2, 0,
|
||||
15, 128, 3, 0, 228, 128,
|
||||
1, 0, 85, 128, 2, 0,
|
||||
228, 128, 4, 0, 0, 4,
|
||||
2, 0, 15, 128, 5, 0,
|
||||
228, 128, 1, 0, 85, 128,
|
||||
2, 0, 228, 128, 4, 0,
|
||||
0, 4, 0, 0, 15, 128,
|
||||
0, 0, 228, 128, 1, 0,
|
||||
85, 128, 2, 0, 228, 128,
|
||||
1, 0, 0, 2, 0, 8,
|
||||
15, 128, 0, 0, 228, 128,
|
||||
255, 255, 0, 0
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user