Path: blob/master/scene/resources/camera_attributes.h
9896 views
/**************************************************************************/1/* camera_attributes.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "core/io/resource.h"33#include "core/templates/rid.h"3435class CameraAttributes : public Resource {36GDCLASS(CameraAttributes, Resource);3738private:39RID camera_attributes;4041protected:42static void _bind_methods();43void _validate_property(PropertyInfo &p_property) const;4445float exposure_multiplier = 1.0;46float exposure_sensitivity = 100.0; // In ISO.47void _update_exposure();4849bool auto_exposure_enabled = false;50float auto_exposure_min = 0.01;51float auto_exposure_max = 64.0;52float auto_exposure_speed = 0.5;53float auto_exposure_scale = 0.4;54virtual void _update_auto_exposure() {}5556public:57virtual RID get_rid() const override;58virtual float calculate_exposure_normalization() const { return 1.0; }5960void set_exposure_multiplier(float p_multiplier);61float get_exposure_multiplier() const;62void set_exposure_sensitivity(float p_sensitivity);63float get_exposure_sensitivity() const;6465void set_auto_exposure_enabled(bool p_enabled);66bool is_auto_exposure_enabled() const;67void set_auto_exposure_speed(float p_auto_exposure_speed);68float get_auto_exposure_speed() const;69void set_auto_exposure_scale(float p_auto_exposure_scale);70float get_auto_exposure_scale() const;7172CameraAttributes();73~CameraAttributes();74};7576class CameraAttributesPractical : public CameraAttributes {77GDCLASS(CameraAttributesPractical, CameraAttributes);7879private:80// DOF blur81bool dof_blur_far_enabled = false;82float dof_blur_far_distance = 10.0;83float dof_blur_far_transition = 5.0;8485bool dof_blur_near_enabled = false;86float dof_blur_near_distance = 2.0;87float dof_blur_near_transition = 1.0;8889float dof_blur_amount = 0.1;90void _update_dof_blur();9192virtual void _update_auto_exposure() override;9394protected:95static void _bind_methods();96void _validate_property(PropertyInfo &p_property) const;9798public:99// DOF blur100void set_dof_blur_far_enabled(bool p_enabled);101bool is_dof_blur_far_enabled() const;102void set_dof_blur_far_distance(float p_distance);103float get_dof_blur_far_distance() const;104void set_dof_blur_far_transition(float p_distance);105float get_dof_blur_far_transition() const;106107void set_dof_blur_near_enabled(bool p_enabled);108bool is_dof_blur_near_enabled() const;109void set_dof_blur_near_distance(float p_distance);110float get_dof_blur_near_distance() const;111void set_dof_blur_near_transition(float p_distance);112float get_dof_blur_near_transition() const;113void set_dof_blur_amount(float p_amount);114float get_dof_blur_amount() const;115116void set_auto_exposure_min_sensitivity(float p_min);117float get_auto_exposure_min_sensitivity() const;118void set_auto_exposure_max_sensitivity(float p_max);119float get_auto_exposure_max_sensitivity() const;120121virtual float calculate_exposure_normalization() const override;122123CameraAttributesPractical();124~CameraAttributesPractical();125};126127class CameraAttributesPhysical : public CameraAttributes {128GDCLASS(CameraAttributesPhysical, CameraAttributes);129130private:131// Exposure132float exposure_aperture = 16.0; // In f-stops;133float exposure_shutter_speed = 100.0; // In 1 / seconds;134135// Camera properties.136float frustum_focal_length = 35.0; // In millimeters.137float frustum_focus_distance = 10.0; // In Meters.138real_t frustum_near = 0.05;139real_t frustum_far = 4000.0;140real_t frustum_fov = 75.0;141void _update_frustum();142143virtual void _update_auto_exposure() override;144145protected:146static void _bind_methods();147void _validate_property(PropertyInfo &property) const;148149public:150void set_aperture(float p_aperture);151float get_aperture() const;152153void set_shutter_speed(float p_shutter_speed);154float get_shutter_speed() const;155156void set_focal_length(float p_focal_length);157float get_focal_length() const;158159void set_focus_distance(float p_focus_distance);160float get_focus_distance() const;161162void set_near(real_t p_near);163real_t get_near() const;164165void set_far(real_t p_far);166real_t get_far() const;167168real_t get_fov() const;169170void set_auto_exposure_min_exposure_value(float p_min);171float get_auto_exposure_min_exposure_value() const;172void set_auto_exposure_max_exposure_value(float p_max);173float get_auto_exposure_max_exposure_value() const;174175virtual float calculate_exposure_normalization() const override;176177CameraAttributesPhysical();178~CameraAttributesPhysical();179};180181182