virtual-puppet-project / vpuppr

VTuber application made with Godot 4
Mozilla Public License 2.0
735 stars 61 forks source link

Change Field of View (FOV) #109

Open ja-cop opened 2 years ago

ja-cop commented 2 years ago

Aka focal length. Not sure how Godot does it. Would be nice to have an option for this to simulate a wider lens camera, making objects appear more "flat" and less "fish-eye" distorted.

you-win commented 2 years ago

That's a good suggestion, not sure how I missed that considering that the environment effects + lighting can be adjusted in-app.

Notes for implementation (mostly for me):

Hacker mode

If you are feeling up for it/don't want to wait for me to do change stuff, it's actually possible to hack in the fov change without recompiling.

NOTE: The GUI functions very similarly to html + js, which is not the recommended Godot way of creating GUIs but whatever.

By adding a UI option in tracking.xml and setting a setup callback and then actually creating the setup callback in the associated Tracking.gd file, you could manually manipulate the camera values from there.

The only limitation is that this value won't be persisted in the config, but you could manually persist it in the setup function I suppose.

Something like

tracking.xml

... somewhere next to the other elements ...
<input name="camera fov" setup="set_camera_fov" type="integer"/>

Tracking.gd

func set_camera_fov(e):
    e.line_edit.connect("text_entered", self, "_on_camera_fov_text_entered")

func _on_camera_fov_text_entered(text):
    if text.is_valid_integer():
        AppManager.main.get_node("Camera").fov = int(text)
you-win commented 2 years ago

Update, my hack totally works

ja-cop commented 2 years ago

Awesome, yeah I tested it, got it working just fine here too!

It wasn't obvious at first that I had to press enter in the text field, I wonder if it should have its own button to apply it, or maybe apply it whenever a model is loaded or tracking started or something.

you-win commented 2 years ago

The underlying Godot control that the <input/> tag maps back to is a LineEdit. So if you wanted to have the change take effect immediately (instead of waiting for Enter to be pressed), the signal should be changed to text_changed.