Anti-Aliasing?

Monkey Forums/Monkey Programming/Anti-Aliasing?

Sicilica(Posted 2015) [#1]
So I've looked at this a number of times over the past few months and I'm stumped. For the most part the opengl modules are pretty straight forward (I'm using gles20), but I can't figure any solution for anti-aliasing, and all my polygons look really dirty.

At the moment I'm only ever rendering to the entire screen using a depth buffer the same resolution as the screen. I'd be happy with either shader-based or per-poly AA, but any FSAA solution would be great too. Unfortunately, I don't know enough to figure out how to reinvent the wheel myself (being pretty new to 3D), and every constant or anything I find related to it isn't in the Monkey API - I'm guessing some of this is for cross-platform reasons (ie, creating a context for MSAA is I guess platform dependent) or just the nature of GL ES (I really still don't know what all is different with it and normal GL)?

Is there anyone who has any experience on the subject and wants to shed some wisdom? As it stands, I'm at a total loss for ideas short of making an FBO at 2x resolution and rendering it down, which seems extremely terrible. Thoughts?


bitJericho(Posted 2015) [#2]
This looks particularly relevant to your interests:

http://blog.db-in.com/all-about-opengl-es-2-x-part-3/

It sets up a scene with MSAA in opengl es 2.0.


Sicilica(Posted 2015) [#3]
Thanks, I hadn't seen that. Well, sounds like there's definitely no cross-platform solution then.

I guess this means adding in the platform-dependent gl functions to the opengl module. Has anyone tried that? I'm not too excited if I have to also hack mojo.app to change how it creates the original render context...


skid(Posted 2015) [#4]
This works OK for GLFW on Mac although MSAA is rubbish for lines:

#GLFW_WINDOW_SAMPLES=8

Import mojo

Class Game Extends App

	Method OnCreate()
		SetUpdateRate 0
	End

	Method OnRender()
		Cls 0,0,0
		For Local r#=0 To 90
			Local x=400*Sin(r)
			Local y=400*Cos(r)
			DrawLine 0,0,x,y
		Next
	End
	
	
End

Function Main()
	New Game()
End



Sicilica(Posted 2015) [#5]
Holy crap, I had no idea that was there! Did that get added recently? I've never seen it in the app config settings before.

I guess that would work for all GLFW 3 targets then? I'll have to play with that some, thanks so much.


Edit:
If anyone's curious, targets/glfw/modules/native/glfwgame.cpp simply takes CFG_GLFW_WINDOW_SAMPLES and plugs it in to glfwWindowHint whenever SetDeviceWindow is called. I guess it would be a lot easier to find window creation on a per-platform basis than I thought, if you want to use AA on another target.

I'm actually going to change things up a bit so you can change the number of samples at runtime to enable/disable MSAA. Dunno if Mark would want a pull request?


Soap(Posted 2015) [#6]
#GLFW_WINDOW_SAMPLES is for the GLFW3 target only AFAIK.


Soap(Posted 2015) [#7]
By the way, Sicilica, yes, submit your improvements for Mark to consider. Being able to control it at runtime would be handy.