Hey there,

I've written a custom interpolation algorithm for point sampling textures but with smooth (linear) edges. The only downside so far is that you have to pass the texture's dimensions to the shader since there's no way to look these up in the shader (in dx9).

Edit: to clarify it a bit more: this algorithm performs "optimal" filtering along the edges between pixels and works at pretty much any viewing angle and distance (mipmapping works aswell).



Here's the algorithm if anyone needs it:

Code:
float4 tex2D_PointSoft(sampler2D smp, float2 tex, float2 resolution)
{
	float2 pixel = 1.0f / resolution;
	tex -= pixel * 0.5f;
	
	float2 tex_pixels = tex * resolution;
	
	float2 deltaPixel = frac(tex_pixels) - 0.5f;
	
	float2 ddXY = fwidth(tex_pixels);
	
	return tex2Dlod(smp, float4(tex + (saturate(deltaPixel / saturate(ddXY) + 0.5f) - deltaPixel) * pixel, log2(ddXY) - 1.0f));
}


When using it make sure to use a LINEAR sampler state.
Also, I'm not sure if the mipmap calculation is 100% accurate but it seemed fine for me.

Cheers, Kartoffel


Edited by Kartoffel (04/20/18 13:36)
Edit Reason: optimized algorithm
_________________________
POTATO-MAN saves the day! - Random