1
Это код пиксельного шейдера:Как реализовать линейную интерполяцию при растяжении текстуры в HLSL?
sampler s0 : register(s0);
float4 main(float2 tex : TEXCOORD0) : COLOR
{
tex.x=tex.x/8 +0.25;
float4 l = tex2D(s0, tex);
return l;
}
При выполнении приведенного выше кода я получаю следующее:
Я попытался изменить состояние фильтра сэмплера без успеха:
sampler s0 : register(s0) = sampler_state
{
Texture = (s0);
MinFilter = Linear;
MagFilter = Linear;
AddressU = Clamp;
AddressV = Clamp;
};
Я пробовал кубическую фильтрацию, но очень дорого sive:
sampler s0;
float c0;
float c1;
#define sp(a, b) float4 a = tex2D(s0, float2(coord + b * fx * c1.x, tex.y));
float4 main(float2 tex : TEXCOORD0) : COLOR
{
float coord = (tex.x/2)*c0; // assign the output position, normalized to texture width in pixels
float t = frac(coord); // calculate the difference between the output pixel and the original surrounding two pixels
// adjust sampling matrix to put the output pixel on Q2+.25
float fx;
if(t > .5) {
coord = (coord-t+1.5)*c1; fx = -1;
} else {
coord = (coord-t+0.5)*c1; fx = 1;
}
sp(P0, -2)
sp(P1, -1)
sp(P2, 0)
sp(P3, 1)
sp(P4, 2) // original pixels
return (P0 + P2*216 + P3*66 - P1*18 - P4*9)/256; // output interpolated value
}
Спасибо.
Некоторые больше контекста был бы полезно. Например, как вы загружаете шейдер? – terriblememory
D3D9 или D3D10 +? – Matthew
@terriblememory Его пиксельный шейдер для Media Player Classic –