Archived

This topic is now archived and is closed to further replies.

BerLan

Interesting D3D8 thing i bumped into because of a bug.

Recommended Posts

BerLan    122
I bumped into this interesting little thing with D3D8 while programming my 3D-engine. I don''t know if anyone of you have noticed it before, but here goes... I had a little bug in my window initialization code, which made the window too small for a 640x480 viewport. When rendering the 3D scene to the screen, the rendered image was scaled by D3D8 to fit in to the window. The reason what makes this interesting is that it made the scene look anti-aliased. Detail-shot of the app: (Left one is correctly rendered, the Right one is not) Both versions (buggy and fixed) of the app run at 75FPS, average (8832 polygons in the scene - all environment mapped). I''ve only tested the app on my own computer (525MHzCel, 128Meg with Matrox G400 32Meg - running win98), so i do not know if it will work on any other hardware capable of windowed rendering. Anyway, this actually seems to be an easy little trick for fake anti-aliasing in windowed mode. One down-side (other than the fact that it is actually a bug in the window-initialization code ) is that the rendered scene is a bit squished, but you can hardly notice it. If there is someone smarter than me (and i''m sure there are many), please comment & give your opinions. --BerLan

Share this post


Link to post
Share on other sites
MatrixCubed    199
Not necessarily smarter, but here goes...

When working on my own game engine, I came across a problem where (in Windowed mode) the back buffer is rendered to the front buffer with scaling implemented. That is, with a back buffer of size 1024x768, the final result is rendered to a primary buffer of, say, 1020x748.

Since I''m working on a 2D game, and will eventually implement pixel-perfect mouse click / hover for the UI, this limitation is unacceptable.

I haven''t found a solution, but I think this is an exact duplicate of what you''re seeing.

(I''m also certain of this as a limitation, because OpenGL does NOT render in the same fashion in Windowed mode.)



MatrixCubed
http://MatrixCubed.org






Share this post


Link to post
Share on other sites
DrunkenHyena    805
G''day!

D3D8 does a Stretched Blt when the window size is different than the backbuffer. It CAN slow things down, it all depends on how things work out.

To be honest that looks more blurred than anti-aliased. If you want a real anti-aliasing effect you''d have to do something like make the width & height 2x (or 4x etc) the size of your window, then you''d get some decent anti-aliasing though it would be pretty slow.

D3D8 offers support for multisampling which is likely better than this method, but I haven''t played with it yet.


Stay Casual,

Ken
Drunken Hyena

Share this post


Link to post
Share on other sites
Drakonite    215
This is actually a trick that has been done by programmers using a hardware setup that does not have hardware antialiasing, or atleast not fast enough antialiasing, yet still has acceleration to scale a blit.

I think the dreamcast was the one that got a lot said about it, when games would be rendered a step higher in resolution then scaled down to antialias them.

I''ve also heard talk of it being done on the ps2, since the ps2''s antialiasing is slow.

On a pc though, I doubt it''d be a reliable speed increase, unless you know that the video card used could render just as fast one step up...



Drakonite

[Insert Witty Signature Here]

Share this post


Link to post
Share on other sites