Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Alan v.Drake on Sun 18/09/2011 21:36:01

Title: Let's fix D3D Scaling
Post by: Alan v.Drake on Sun 18/09/2011 21:36:01
(http://i56.tinypic.com/s4cba8.gif)
If you want to give it a go download it from here: http://www.mediafire.com/?8vu6h77clvskfz8

I learned a little of D3D today while trying to fix this annoying quirk

Doesn't work well with the "smooth sprites" option, though.

No code yet, because I need to clean up and reorganize. Would be cool if I managed to make feasible to add more gfx filters...


Oh btw,

void D3DGraphicsDriver::RenderToBackBuffer()
{
  throw Ali3DException("D3D driver does not have a back buffer");
}

that line of code made my day.  ::)


- Alan
Title: Re: Let's fix D3D Scaling
Post by: subspark on Mon 19/09/2011 09:21:27
Okay, I've called the celebrant and pre-arranged our Marriage to be held on Thursday, on the Shores of Mozambique for 11:30AM EST.
OMGGG  DDRRAAKKEE!!!!!!  :o I must become your manbitch and fart a few babies out for you!

FTW, kind sir.  :P
Title: Re: Let's fix D3D Scaling
Post by: Alan v.Drake on Mon 19/09/2011 13:11:48
Quote from: subspark on Mon 19/09/2011 09:21:27
Okay, I've called the celebrant and pre-arranged our Marriage to be held on Thursday, on the Shores of Mozambique for 11:30AM EST.
OMGGG  DDRRAAKKEE!!!!!!  :o I must become your manbitch and fart a few babies out for you!

FTW, kind sir.  :P

Woah now, let's not go overboard!
Test it if it works properly.


- Alan
Title: Re: Let's fix D3D Scaling
Post by: Calin Leafshade on Mon 19/09/2011 14:53:24
Cool, this was something i was meaning to fix but i completely forgot.

We should get a bugtracker or something.
Title: Re: Let's fix D3D Scaling
Post by: Snarky on Mon 19/09/2011 15:40:49
Wow, excellent! This has been a longtime annoyance for me.

We discussed this problem last year here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40132). At the time, CJ was pretty adamant that it couldn't be done without losing the benefits of hardware acceleration. Were you able to get around that?

Also in that thread we commented on the color differences between the two rendering options, and how D3D seems to introduce banding. Nefasto recently commented (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=44365.0) that there's some code in the D3D9 rendering loop that is changing the colors. This might have something to do with buggy gamma correction code.

Is that something that can be fixed in the same go?
Title: Re: Let's fix D3D Scaling
Post by: Alan v.Drake on Mon 19/09/2011 17:23:49
I just rendered everything to a backbuffer surface and then stretched it to the screen, I don't know about performances, with my game I see no difference. But who knows, maybe not having to scale indipentently every single sprite makes thing a little faster, or maybe not, I learned d3d yesterday, I can only offer wild guesses  :P

About the color banding thing, if I guess correctly Aeronuts has 16bit gfxs, so the problem lies somewhere in the color translation between 16->32 bit.

edit: yeah, there's definitely something fishy going on, I took two screens on aeronuts and the d3d one has noticeably less colors, and the game window makes everything lag like hell if I move it between my two screens, it never happened to me before, I have no idea what causes it.

- Alan
Title: Re: Let's fix D3D Scaling
Post by: Calin Leafshade on Mon 19/09/2011 17:58:43
Quote from: Snarrrky on Mon 19/09/2011 15:40:49
We discussed this problem last year here (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=40132). At the time, CJ was pretty adamant that it couldn't be done without losing the benefits of hardware acceleration. Were you able to get around that?

The problem there was that AGS renders straight to the backbuffer with scaling so to make the sprites render properly you would have to somehow set the scaling resolution as you draw it, which is not possible.

Really everything should be rendered to a temporary render target at normal size which is *then* rendered to the back buffer and scaled. I assume thats how Alan fixed it.
Title: Re: Let's fix D3D Scaling
Post by: subspark on Tue 20/09/2011 01:31:30
QuoteWoah now, let's not go overboard!
Too late! I slipped of the plank o' lust when I read the subject.  :=
Title: Re: Let's fix D3D Scaling
Post by: Alan v.Drake on Tue 20/09/2011 23:41:13
On a almost unrelated note, I made a couple of directdraw filters, just for the sake of it.
A 2x scanline + noise and a half-assed 4x crt tv mode (http://img703.imageshack.us/img703/8744/draconiancrt.png).

If you're bored and want to test them and give some feedback I won't complain: http://www.mediafire.com/?51h048gt8wsjwuy

They replace the hq2/3x ones at the moment.

EDIT: Optimizations and new x4 PC CRT mode, link updated. the x2 noise, has no noise now, I'm fiddling around with things

- Alan
Title: Re: Let's fix D3D Scaling
Post by: Snarky on Wed 21/09/2011 10:18:48
Quote from: Alan v.Drake on Mon 19/09/2011 17:23:49
edit: yeah, there's definitely something fishy going on, I took two screens on aeronuts and the d3d one has noticeably less colors, and the game window makes everything lag like hell if I move it between my two screens, it never happened to me before, I have no idea what causes it.

Is that running with your build of the engine, or with the original? In other words, are you saying that you are experiencing performance issues with your changes?
Title: Re: Let's fix D3D Scaling
Post by: Alan v.Drake on Wed 21/09/2011 10:37:47
Quote from: Snarky on Wed 21/09/2011 10:18:48
Is that running with your build of the engine, or with the original? In other words, are you saying that you are experiencing performance issues with your changes?

Both mine and original.


- Alan