SyntaxBomb - Indie Coders

Languages & Coding => BlitzMax / BlitzMax NG => MiniB3D => Topic started by: JBR on January 16, 2020, 02:13:59

Title: Antialias
Post by: JBR on January 16, 2020, 02:13:59
Using BMax and openb3d.

When I set AntiAlias on I find that my frame rate goes from 2ms to 150ms.

I'm using a laptop a few years old but with a discrete graphics card.

Any way to speed things up to a usable level?

Thanks, Jim.
Title: Re: Antialias
Post by: angros47 on January 17, 2020, 01:02:17
I fear not. Most antialias algorithms work by doing multiple renderings, and then making an average final picture, and this is time consuming. That's actually the main reason why the antialias can be disabled in most graphic engines (you aren't the first one who found out that antialias can kill performance). The most obvious solution is: check the frame rate, and make sure your program could automatically disable antialias if it's too slow.

If you can't live without antialias you can also try to perform a "poor man" antialias, by using a postfx shader that could apply a convolution filter on the rendered image.
Title: Re: Antialias
Post by: Derron on January 17, 2020, 06:02:13
Can't you render with doubled resolution and then scale that down?


Bye
Ron
Title: Re: Antialias
Post by: markcwm on January 17, 2020, 09:19:11
In Openb3dmax there are two alternatives to AntiAlias. First, you need to know that the AntiAlias function is software-based using the Accumulation buffer so it's slow but cross-platform, the alternative is to use the MSAntiAlias function (from code by JoshK) which is hardware-based Multisample Antialiasing and is very fast but is for Windows only and requires you to replace the files in brl.glgraphics with the ones in openb3dmax.docs/mod for it to work. If you're using original/vanilla BMX then the files in brl.mod-NG-093 should work (note: if you're using latest NG source you don't need to do this). So currently the only cross-platform fast solution is with a shader called FXAA which is Fast approXimate AntiAliasing.
Title: Re: Antialias
Post by: JBR on January 19, 2020, 00:00:39
Hi thanks for the advice.

I've tried twice to install the MSantialias and failed miserably.

I really just don't know what I'm doing. :-[

All I'm capable of is installing BMax and installing mods into the mod folder.

Why can't we have it like the old days at blitz.com where you just download the newest 'complete' version.

Anyway, I'm forgetting about AA for now unless someone zips up BMax with latest version of openb3d. 8)

Thanks for your help anyway. Jim.
Title: Re: Antialias
Post by: markcwm on January 19, 2020, 15:33:14
Hi JBR,

sorry that's my fault it failed! The files in brl.mod-NG-093 do not work with original BRL Blitzmax.
Title: Re: Antialias
Post by: JBR on January 19, 2020, 20:50:49
Hi Mark,

It is BlitzMax Win32 v0.105.3.35 : It is NG.

There are 2 MinGW versions in the blixmax directory. I've set up environment variable and path to the x64 version as I always code to the 64 bit.

I've rebuilt all the modules and things are working fine.

So, in baby steps, how do I get MSantialias working.

Thanks, Jim.
Title: Re: Antialias
Post by: markcwm on January 20, 2020, 10:41:18
Hi JBR,

okay, well there's 3 versions in openb3dmax.docs/mod one for 0.93, 0.99 and 1.05, you want the 1.05 version so go and copy the folder in there named glgraphics.mod, the 3 other folders are for the dds tweak so just ignore them, then go to your Blitzmax-105/mod/brl.mod folder and renamed the glgraphics.mod to glgraphics.mod-o (o for original, or whatever you prefer to name it) that disables it, then paste the new glgraphics.mod beside it and go to cmd then type cd ..\..\ and cd Blitzmax-105\bin to get to bmk now type bmk makemods -a -w -g x64 brl.glgraphics and then another bmk makemods -a -w -g x64 brl.graphics (which depends on glgraphics) then you should be able to compile the MSantialias example. Note: these tweaks were made after the NG releases and AFAIK there's no way to add them into the official code.

I'm wondering, what do you think of the FXAA shader example as a solution?
Title: Re: Antialias
Post by: JBR on January 20, 2020, 19:08:11
Hi Mark, I would welcome a shader version. But as usual I know nothing, so it would have to be an 'easy' example.

I appreciate your help!

Jim.
Title: Re: Antialias
Post by: markcwm on January 21, 2020, 10:09:42
Hi JBR,

Oh I see, well to find the FXAA shader example go to openb3dmax.docs/shaders/fxaa.bmx the actual shader code for the examples is in openb3dmax.docs/glsl/fxaa.frag.glsl and the same named vert.glsl GLSL is GL shader language and is split into frag and vert files (one is vertex to process 3d coords the other is fragment or pixel to process 2d texture coords, shaders allow hardware based manipulation). The example is by RonTek so I haven't actually examined it myself but it could do with the ability to set the AntiAlias level, I'll have a look at that (done).
Title: Re: Antialias
Post by: JBR on January 22, 2020, 01:11:02
Hi Mark,

Downloaded all the stuff and initially I was getting an error about version number in the frag file. Then it worked but it has no effect on the screen. Just see the 'jaggies' as before.

Is there a way to use the online stuff on GitHub so you don't have to download anything?

Thanks, Jim.


Title: Re: Antialias
Post by: markcwm on January 23, 2020, 11:09:49
Hi JBR,

not sure why it's doing that with you, there is an error message for shaders in the IDE output window which would help, if you see jaggies then it's not working. You might have an old GL (to find out go to openb3dmax.docs/extended/hardwareinfo and read the Opengl-Version number, you can then deduce the GLSL version) or more likely it's a bug, there are issues in Windows with shaders that need fixing, I thought it was working but haven't checked in a while.

What you can do is install Git, then "git clone https://myurl" a copy and update that when needed with "git pull origin master" but it's easier to just download the zip.
Title: Re: Antialias
Post by: iWasAdam on January 23, 2020, 15:03:12
Not sure if this will help or not...

You could do something like the following:
take a screen simple shader that detects outlines - this will be where you need to alias.
Using the above outline info, you can blur per pixel which should give you the result you want, keep the detail and the speed ?
Title: Re: Antialias
Post by: markcwm on January 23, 2020, 17:08:07
Hi iWasAdam,

yes that sounds like a very fast method but the FXAA is reasonably fast already. Could you point to a shader that detects outlines perhaps, as that sounds interesting in itself? Thanks.
Title: Re: Antialias
Post by: GaborD on January 23, 2020, 17:55:51
FXAA can be very fast, should clock in at somewhere around 1 ms when running high quality FXAA at fullHD.
The downside is that everything gets blurred and you lose texture crispness.
What iWasAdam suggested could actually work well in combination with FXAA to get the best of both worlds. If you already have a depth pass it shouldbn't cost a lot of performance to add it and basically use masked FXAA.
Downside of this approach would ofcourse be that the masked AA won't help against specular aliasing (which oftentimes can be visually even nastier than edge aliasing). But it all depends. If you don't use HDR and/or PBR, specular aliasing maybe won't be an issue anyway.
Title: Re: Antialias
Post by: markcwm on January 24, 2020, 09:19:23
Hi GaborD,

yes I can imagine how you could use the depth buffer as a mask with fxaa, I assume the AA would be in the background to retain foreground crispness. It's a little much for me though, what I would use is AA at 4 and have a best compromise.

I had to look up specular aliasing, there's no PBR stuff in Openb3dmax and I'm not familiar with it.