ID:2196988
 
Another year has come, and now I have a new machine for development. This year I remembered to change the copyright dates before the first release of the year. Make with the golf claps.

This week I've been getting to some of the backlog of bug reports from before or during the break, and getting those sewn up for a new release. I had intended to put out a new version today, but I hit a weird snag just before release and decided to hold off. (That's why the release notes say 511.1367; I had generated them already.)

One of the things I discovered with my new system was that even though both this machine and the old one had cards from the same vendor, this one upscales differently as a final step in BYOND rendering--and it looks like crap. BYOND's "nice" upscaling draws to a back buffer that is some integer size (the nearest to the current zoom level) multiple of the actual combined map and HUD, and then that gets upscaled internally when the back buffer is moved to the front. Problem is, that last upscale was bilinear on my old machine and is nearest-neighbor on the new one. So I decided to create a shader that would handle all this in one shot, and hopefully make everything faster as a result.

Well, that shader appeared to be working fine until some last-minute checks determined that, nope, it wasn't right at all. So now I'm wrestling with it to get the correct results, and once that's ready I think we'll be good to go for 511.1367. I'm gonna try to figure that out Monday, assuming I don't get agitated enough to keep at it over the weekend (and if so, actually solve it).

My new second game controller just got here (thanks, Amazon Prime!), which means I can work on support for multiple gamepads and sneak that in before 511 becomes the new stable build.

That's all for now, because my fingers are freaking freezing. Thanks to everyone who became a Member or donated to BYOND in 2016, and especially to Yut Put for organizing the Christmas fundraiser. Your support is a big deal, and always appreciated.
Wouldn't you know it? Minutes after I posted that, I figured out the shader thing. Turns out I was making a rather stupid math error.

This is the shader:

float2 upscaleSize = float2(1,1);
float2 upscaleSizeI = float2(1,1);
float2 upscaleIncI = float2(1,1);
float4 NiceUpscalePS(vertexOut IN) : COLOR0
{
float2 p1,p2,im;
float4 c[4];
p1 = IN.TexCoord0 - upscaleSizeI;
p2 = IN.TexCoord0 + upscaleSizeI;
im = max(float2(0,0), floor(p2 * upscaleSize) - (p1 * upscaleSize)) * upscaleIncI;
c[0] = tex2D(pSampler, p1);
c[1] = tex2D(pSampler, float2(p2.x,p1.y));
c[2] = tex2D(pSampler, float2(p1.x,p2.y));
c[3] = tex2D(pSampler, p2);
return lerp(lerp(c[3], c[2], im.x), lerp(c[1], c[0], im.x), im.y);
}

The error I made was that I really wanted im.x/y to be 1 minus themselves, so I just switched the values around and all was well.

The upscaleSize value is the size, in pixels, of the original image as drawn. The upscaleSizeI value is 0.4 divided by the final upscaled pixel size. And upscaleIncI is 0.5 / (upscaleSize * upscaleSizeI), which represents the inverse of p2-p1.

When downscaling, a simple bilinear filter is used with no need for a special shader.
when could we expect a new public beta now? (^8
So what you're saying is transform scaling is going to look a lot better? :)
I believe this is only a post-processing shader. I believe that prettying up the transform upscaling would have to be addressed by a hard change to the pipeline, as to my knowledge you can't feed the methods that BYOND's renderer uses to handle transformed sprites a shader. We'd have to shift to a full programmable pipeline renderer. If I recall, we're only doing some partial programmable pipeline foo and a lot of it is still using fixedfunction foo.
Super duper hyped for gamepad support beyond one controller. You are the man Lummox.
In response to Ter13
Ter13 wrote:
I believe this is only a post-processing shader. I believe that prettying up the transform upscaling would have to be addressed by a hard change to the pipeline, as to my knowledge you can't feed the methods that BYOND's renderer uses to handle transformed sprites a shader. We'd have to shift to a full programmable pipeline renderer. If I recall, we're only doing some partial programmable pipeline foo and a lot of it is still using fixedfunction foo.

It is indeed just post-processing.

In theory I could probably alter the way transforms are handled to use point sampling, but that would be pretty awful for rotations and downscaling.

The shader I created is meant to work with a simple upscaling, not with arbitrary transforms. Assuming no downscaling at all in an affine transform, in theory it should be possible to create a shader that would handle the interpolation for rotations--but the math would be a lot different. (And for rotation alone I'd love to have something like the RotSprite algorithm, which can preserve a lot of pixel art detail for arbitrary rotation angles.)
In response to Lummox JR
Ahh. So basically it's just gonna look a bit better with the shader update?
In response to Kitsueki
Kitsueki wrote:
Ahh. So basically it's just gonna look a bit better with the shader update?

If your video card is like my old video card, you won't notice a difference. If it's like my new one, you'll notice a tremendous difference. I'm not sure about performance but I have a hunch it'll be slightly improved.
In response to Lummox JR
Sounds good. I think I have a... ATI Radeon HD 6370. Yeah that's it.