I am trying to make a transition shader for UI interfaces. All the control nodes in the tree share the same shader material. The goal would be to have a shader that is capabe of scaling the whole tree from the center of the screen by a factor. Of course, just muplitplying the vertex coordinates by the factor doesn't work, because the 0,0 coordinates are actually on the top left of the screen, not the center. The latest attempt at it was this:
uniform vec2 screen_center; //in pixels
uniform float factor;
vec2 scaled_around_center(vec2 vec, float amount) {
return (vec - screen_center) * amount + screen_center;
}
void vertex() {
VERTEX = scaled_around_center(VERTEX, factor);
}
This works for control nodes that take all of the viewport space, but fails when they are smaller. I guess the reason why is that I am working with local vertex coordinates instead of global. How would you do it?
(also, if you know of any kind of webside where you can get these kind of shaders please let me know ;)