Pixelated
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
extends Camera3D
|
||||
|
||||
const PIXEL_SCALE:float = 2.0;
|
||||
@export var pixelScale:float = 1.0;
|
||||
@export var follow:Node;
|
||||
|
||||
const WORLD_UNITS:float = 32.0;
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -8,17 +10,20 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
# I tried a few things but this is most consistent for both backbuffer and
|
||||
# framebuffer viewports.
|
||||
var viewportHeight = get_viewport().get_visible_rect().size.y;
|
||||
var unitScale = pixelScale * WORLD_UNITS;
|
||||
|
||||
var z:float = (
|
||||
tan((deg_to_rad(180) - deg_to_rad(fov)) / 2.0) *
|
||||
(get_viewport().size.y / 2.0)
|
||||
) / PIXEL_SCALE / WORLD_UNITS;
|
||||
(viewportHeight / 2.0)
|
||||
) / unitScale;
|
||||
|
||||
var rosa = get_node("..");
|
||||
var look = rosa.position;
|
||||
var look = follow.position;
|
||||
var position = Vector3(0, 0, 2) + look;
|
||||
|
||||
look_at_from_position(
|
||||
Vector3(position.x, position.y + z, position.z),
|
||||
look
|
||||
);
|
||||
|
||||
pass
|
||||
|
Reference in New Issue
Block a user