FFGL plugin. How to get screen aspect ratio from Arena?

FFGL, OSC, GLSL. If you like abbreviations, this is the forum for you
Post Reply
gonzzza
Met Resolume in a bar the other day
Posts: 11
Joined: Wed Feb 27, 2019 19:04

FFGL plugin. How to get screen aspect ratio from Arena?

Post by gonzzza »

Hi! I am trying to write my own FFGL plugins for Arena using examples from Resolume github repo.
It does work, I am using my own 64bit plugins on Mac.

At the moment I have the problem I can not solve. I am developing a single "circle mask" plugin, which would create a circular mask. The problem is that FFGL screen coordinates are normalised to -1,1. So If I try to draw a circle in normalized coordinates it will be oval not circular. To draw a perfect circle in shader i have to know the actual screen aspect ratio. Is there a way to get this information from Arena? Are there any built in variables for that?

Another question is version of OpenGL/shader. What version of shaders is supported by Resolume Arena? This is important, because the GLSL language differs quite a lot from version to version...

Sorry if my questions are lame, I'm new to shaders and FFGL...

gonzzza
Met Resolume in a bar the other day
Posts: 11
Joined: Wed Feb 27, 2019 19:04

Re: FFGL plugin. How to get screen aspect ratio from Arena?

Post by gonzzza »

This is the result if I'm using 1920x1080 composition...

To calculate the distance from the circle center in the shader I am using the function "distance":

Code: Select all

float dist = distance(gl_TexCoord[0].st, vec2(x, y));
Attachments
Screen Shot 2019-03-17 at 18.43.05.png

gonzzza
Met Resolume in a bar the other day
Posts: 11
Joined: Wed Feb 27, 2019 19:04

Re: FFGL plugin. How to get screen aspect ratio from Arena?

Post by gonzzza »

Update: I was able to pass the screen aspect ratio in ProcessOpenGL function. There is a "Texture" variable which has Height and Width parameters. I then passed the ratio of these two numbers as another shader uniform parameter. This works, UNTIL i change the screen resolution, or output to another screen... i don't get it... is ProcessOpenGL called only once while initialising the plugin?

gonzzza
Met Resolume in a bar the other day
Posts: 11
Joined: Wed Feb 27, 2019 19:04

Re: FFGL plugin. How to get screen aspect ratio from Arena?

Post by gonzzza »

Ok i think I found the answer. Again on this forum!
viewtopic.php?f=14&t=15940#p67930
I need to multiply the texture size with maxCoords width and height, so my ratio parameter finally looks like this:

Code: Select all

glUniform1f(m_RatioLocation, ((float)maxCoords.t*Texture.Width)/((float)maxCoords.s*Texture.Height));
I will do some tests later, but currently I see the correct circle on both - preview and external screen.

edwin
Team Resolume
Posts: 1202
Joined: Thu Oct 07, 2004 10:40

Re: FFGL plugin. How to get screen aspect ratio from Arena?

Post by edwin »

When the plugin get's initialised you get a Viewport which has a Width and Height.
When the viewport size changes you get a resize callback in which you again get a Viewport passed in.

Code: Select all

class CFreeFrameGLPlugin 
....
virtual FFResult InitGL( const FFGLViewportStruct* vp )
....
virtual unsigned int Resize( const FFGLViewportStruct* vp )

gonzzza
Met Resolume in a bar the other day
Posts: 11
Joined: Wed Feb 27, 2019 19:04

Re: FFGL plugin. How to get screen aspect ratio from Arena?

Post by gonzzza »

Thanks a lot Edwin! I should have looked at the parent CFreeFrameGLPlugin methods right away!
One more thing I didn't think about - my Composition size should be the same as the monitor I'm using... or at least have the same aspect ratio.

Post Reply