Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Antialiasing and Get Image

Author
Message
Westmere
14
Years of Service
User Offline
Joined: 12th Mar 2010
Location: Germany
Posted: 1st Jan 2013 23:38
I am currently trying to find a way to get the commands GET IMAGE and Antialiasing to work together since I want to add in an anti aliasing option for the 3D elements in my game.

Unfortunately, when I add the AntiAliasing commands to SET DISPLAY MODE the result always is that Get Image produces a "Tried to read a surface which has no read permissions!"-error.

I've tried searching the forum but the only thing I found is a claim, that this is a DirectX limitation. I don't believe this to be true as it works fine when I force AA onto it via the driver. Good Old "Print Screen" (the one on the keyboard) also works.

Here's a little test code:


Here are some scaled up results: Image

This is a corner of the cube scaled up by 800%.
The 1. part shows the whole thing with no AA, saved by the above code with Set Display Mode 800, 600, 32
The 2. part shows it with driver AA, still saves by the above code with Set Display Mode 800, 600, 32
The 3. part shows the it with DBP activated AA, grabbed by print screen.
The 4. part shows the error message.

I use the Get Image part to prebuild parts of the screen and get them into an image so I don't need to redraw them every single time. I could get around this by using an additional bitmap for predrawing but it would mean going through lots of code, so I might leave out AA if that was the only way.
But since I also need GET IMAGE to get stills from 3D objects I am kind of in trouble here anyway.

Is there any way to get around this?
Like a different way to activate AA (since I can't ask people to switch it on in their driver that is obviously not an option)?
Or a replacement command for Get Image?

I also couldn't find anything useful for this in the excellent MatrixUtils. Has anyone got the two to work together?


MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 2nd Jan 2013 04:26
With my limited knowledge in Anti-Alias..

Looking at the documentation I found this...

Quote: "You cannot grab an image while the target pixels are being locked by the LOCK PIXELS command, as it is not possible to read from a surface that is using the fast write only lock method on the pixels."


And I figured AA might be using this method...

Naturally I went and tried to unlock the pixels and ... fail lol

I have a theory which was to use another camera to project onto a texture surface and save that out... but I am tired right now... and using second cameras is still new to me, but I reckon I could manage it with a little help from the hands On books...

Alternatively, have a look at D3Dfunc and ImageKit... maybe some luck there... I found no luck in STYX either... or any other packs that I have as of present.

I am only posting as I came across this issue a few months or weeks ago and I believe that there is no way to capture AA shots... but I still live in hope

Woodman
14
Years of Service
User Offline
Joined: 11th Jun 2009
Location:
Posted: 3rd Jan 2013 07:16 Edited at: 3rd Jan 2013 08:03
I'll just leave this here.




Edit - Hmm, while that fixes the error, it still doesn't seem to be catching the AA'd output.
Woodman
14
Years of Service
User Offline
Joined: 11th Jun 2009
Location:
Posted: 3rd Jan 2013 10:35
My apologies.

Apparently I am an idiot and need to learn how to read....
MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 3rd Jan 2013 12:17
By golly Woodman, good call old chap

(Sorry been watching Sherlock Holmes movies again lol)

Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 3rd Jan 2013 17:31
Westmere, I have no idea why we cannot safely use DBP anti-aliasing commands; nothing in the documentation states that it should cause the problems you state, therefore it is quite simply a bug that has not been resolved.

If nobody can determine how we are supposed to apply anti-aliasing with DBP without producing any problems, or if TGC are not able to fix the issue, the only two solutions are to investigate how to apply it via the drivers or research a shader alternative.

Westmere
14
Years of Service
User Offline
Joined: 12th Mar 2010
Location: Germany
Posted: 3rd Jan 2013 22:17
@MrValentine Well I did try the forum search and I believe amongst the topics I came accross without any solution is yours.

@Woodman Thanks for the effort.

@Chris Tate Activating it via driver would mean getting drivers from different sources to do the same thing. It might be doable though as we only need to get it working with Nvidia, AMD and Intel drivers to cover 99% of the market. As long as they don't change their drivers that is...
Maybe another solution is somewhere in the DX-Api, if we can set the screen mode manually without locking the pixels.

@TGC
I believe that in whatever you need or want to program in terms of gaming things like AA always have to be workable options - especially if you do anything in 3D - when was the last time you played a game with no AA? I hope that all that FPSC-Reloaded development gives us a good working option for using this.

Or maybe IanM can cook up a way to safely activate AA with his MatrixUtils.

A fact is that searching the forum for this exact problems brings up many threads with no solutions, so it would be kind of nice if TGC would take a look at it. Forcing it on a DBP game by driver is possible and has no apparent sideeffect, so it can't be a "not possible" thing to do it in DBP directly. I am sure there is a way for TGC to make AA in DBP games an option!?


Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Jan 2013 01:37
It might be worth looking at the Matrix1 utilities on the DLL board. I see there's a command



which while it isn't what you want might be relevant. If the saved image IS what you want then it suggests there ought to be a way of grabbing it within DBPro (using a yet to be written Matrix1 function).

I haven't tested the above function myself so it might not be relevant after all.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 6th Jan 2013 02:43 Edited at: 6th Jan 2013 04:43
Quote: "SAVE FRONTBUFFER Filename$"

was thinking similar.

another thought was set camera to image as an end-around to get image but the image ignores AA no matter the d3d format.

add: pretend image AA





Virtual Nomad @ California, USA . DBPro V7.7 . Matrix1Utils 05.27.12
AMD Phenomâ„¢ X4 9750 Quad-Core @ 2.4 GHz . 8 GB PC2-6400 RAM
ATI Radeon HD 3650 @ 512 MB . Vista Home Premium 64 Bit

Attachments

Login to view attachments
The Weeping Corpse
12
Years of Service
User Offline
Joined: 19th Sep 2011
Location: United Kingdom
Posted: 6th Jan 2013 04:56
The dp pro implementation of set camera to image doesn't support antialaising. Only the dx backbuffer and specific rendertargets allows for antialiasing, so only camera 0 is able to produce an AA image.

Westmere
14
Years of Service
User Offline
Joined: 12th Mar 2010
Location: Germany
Posted: 6th Jan 2013 13:16
Quote: "SAVE FRONTBUFFER Filename$"


Yep. This works and might be suitable as a workaround in some cases.

The only downsides are that you have to save and reload something in order for it to work and that it might incoporate windows placed on top of your game.

So yes, if IanM could make a "Get Frontbuffer ImgNo, x1, y1, x2, y2" for the MatrixUtils that could be very helpful for AA stuff.


Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 6th Jan 2013 17:10
Is there not a camera effect that could work? There is an edge detect camera shader that comes with Dark Shader which draws a greyscale image with dark lines around the edges of hard edge pixels in the camera view and applys a blur to the edges; with some work it could apply a blur to these edges with colour information and blend with the scene to get something that simulates AA.

However this truely a good task for a plugin developer or TGC because this could drive away their customers; who wants to use a pixelated game engine in the 21st century? The AA driver issue should really be handled by DBP through the DX API.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 6th Jan 2013 21:49
Quote: "who wants to use a pixelated game engine in the 21st century? "


Me

Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 7th Jan 2013 10:34 Edited at: 7th Jan 2013 12:08
Hi. I looked into this and managed to grab an anti-aliased 3D object and convert it into an anti-aliased image with a transparent background, in game.


(My game thumbnails character portraits for the HUD)

This is not a workable solution. The problem it seems is not the Get Image command. Instead it seems that only Camera 0 is anti-aliased. The other cameras don't appear to support anti-aliasing. This means you would have to do all your image capture and processing on screen in full view of the player. This is not going to work.

My method for enabling Anti-Aliasing in this situation was to use the nVidia driver panel to override the AA settings for my game. I then made the game produce a transparent screenshot with my transparent screen grabbing technique shown here:
http://forum.thegamecreators.com/?m=forum_view&t=184514&b=1
I modified my method to only use camera 0 in this case.


Quote: "The dp pro implementation of set camera to image doesn't support antialaising. Only the dx backbuffer and specific rendertargets allows for antialiasing, so only camera 0 is able to produce an AA image."

My results support this conclusion.

Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 7th Jan 2013 11:51 Edited at: 7th Jan 2013 12:10
Solution Found:

Super Sampling
The solution in this case is to grab an non-AA image of higher than needed resolution. Then use a plugin like Image kit that supports high quality image scaling, to down sample (shrink) the image to the needed size.

(For Reference)http://en.wikipedia.org/wiki/Supersampling

Login to post a reply

Server time is: 2024-04-24 13:38:38
Your offset time is: 2024-04-24 13:38:38