How to get position of obs_source?

Frosti

New Member
Hey guys,

I'm trying to write a filter plugin to let the associated scene item randomly fidget for a while on the whole screen, triggered by a hotkey.
The last missing piece is to retrieve the position of the obs_source object to know how far it can be shifted in the 4 directions. There exists the obs_sceneitem_get_pos function, but I haven't found a way to get the obs_sceneitem from an obs_source. Another approach would be to use a vertex shader, add the randomly generated offset to vert_out.pos.xy and take this position modulo the two coordinate boundaries, but then the texture will be stretched all over the screen. (btw. what are the coordinates for the right and top edge in GLSL?)

Thanks in advance,
Frosti
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
You can't technically get the position of the source from the source itself without examining the current matrix.

Instead, you should be modifying the source to shift left/right as much as you see fit, treating the source as though it were at position 0,0. Then, just apply a matrix and draw it in the custom way desired.

If you're making some sort of "shake" filter, I'd just recommend drawing the source with a matrix like that. You don't even need a custom/special effect to just modify its position.
 

Frosti

New Member
Thanks Jim for the hint with the matrix, which led me to the solution.

Now I just set the entries viewProj[3][0] and viewProj[3][1] of the view projection matrix to the desired x and y coordinates (each between -1 and 1) and it works.
 

Lain

Forum Admin
Lain
Forum Moderator
Developer
You're not supposed to modify the viewProj. You're supposed to use gs_matrix_* functions (inside of gs_matrix_push and gs_matrix_pop).
 
Top