So I stumbled upon this thread:
http://www.emutalk.net/threads/54215-Em … ng-Shaders
The point of that thread was to somehow incorporate the shader code there into N64 emulator plugins so as to more accurately emulate the N64’s imperfect bilinear filtering. However, in lieu of that, could that code be taken and made into a regular shader for use with any game? I am still not very familiar with Cg, so I am not sure how to make use of it. I was hoping someone more experienced with shaders could convert it to the format RetroArch uses, or at least point me in the right direction.
For the sake of convenience, here is the code:
float4 n64BilinearFilter( in float4 vtx_color : COLOR, in float2 texcoord_0 : TEXCOORD0) : COLOR {
float2 tex_pix_a = float2(1/Texture_X,0);
float2 tex_pix_b = float2(0,1/Texture_Y);
float2 tex_pix_c = float2(tex_pix_a.x,tex_pix_b.y);
float2 half_tex = float2(tex_pix_a.x*0.5,tex_pix_b.y*0.5);
float2 UVCentered = texcoord_0 - half_tex;
float4 diffuseColor = tex2D(ColorSampler,UVCentered);
float4 sample_a = tex2D(ColorSampler,UVCentered+tex_pix_a);
float4 sample_b = tex2D(ColorSampler,UVCentered+tex_pix_b);
float4 sample_c = tex2D(ColorSampler,UVCentered+tex_pix_c);
float interp_x = modf(UVCentered.x * Texture_X, Texture_X);
float interp_y = modf(UVCentered.y * Texture_Y, Texture_Y);
if (UVCentered.x < 0)
{
interp_x = 1-interp_x*(-1);
}
if (UVCentered.y < 0)
{
interp_y = 1-interp_y*(-1);
}
diffuseColor = (diffuseColor + interp_x * (sample_a - diffuseColor) + interp_y * (sample_b - diffuseColor))*(1-step(1, interp_x + interp_y));
diffuseColor += (sample_c + (1-interp_x) * (sample_b - sample_c) + (1-interp_y) * (sample_a - sample_c))*step(1, interp_x + interp_y);
return diffuseColor * vtx_color;