Godot Version
4.4.1
Question
I want to zoom center on the video, scale or any other stuff is not working. How to achieve that?
4.4.1
I want to zoom center on the video, scale or any other stuff is not working. How to achieve that?
VideoStreamPlayer doesn’t support direct scaling or zooming, but you can achieve a centered zoom by placing it inside a Viewport or a Control node. Then, scale the VideoStreamPlayer using rect_scale, and adjust rect_position to shift the video so the center stays visible. This way, you’re effectively zooming in on the center by resizing and repositioning the video within its parent.
Video node is under vboxcontainer/aspect ratio container and regardless of what i do, it does not get scaled.
Tried .get_rect().size *= 1.2
or .scale *= 1.2
both on videoplayer node it self or its parent aspect ratio container.
Above solution did not solve the issue, adding shader in material part solved the issue.
new shadermaterial
shader_type canvas_item;
uniform vec2 top_left = vec2(0.0, 0.0);
uniform vec2 zoom = vec2(1.0, 1.0);
void fragment() {
COLOR = texture(TEXTURE, (UV + top_left) / zoom);
}
params for 2x center zoom:
top left x 0.5
top left y 0.5
zoom x 2
zoom y 2