Path: blob/master/scene/resources/camera_attributes.cpp
9903 views
/**************************************************************************/1/* camera_attributes.cpp */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#include "camera_attributes.h"3132#include "core/config/project_settings.h"33#include "servers/rendering_server.h"3435void CameraAttributes::set_exposure_multiplier(float p_multiplier) {36exposure_multiplier = p_multiplier;37_update_exposure();38emit_changed();39}4041float CameraAttributes::get_exposure_multiplier() const {42return exposure_multiplier;43}4445void CameraAttributes::set_exposure_sensitivity(float p_sensitivity) {46exposure_sensitivity = p_sensitivity;47_update_exposure();48emit_changed();49}5051float CameraAttributes::get_exposure_sensitivity() const {52return exposure_sensitivity;53}5455void CameraAttributes::_update_exposure() {56float exposure_normalization = 1.0;57// Ignore physical properties if not using physical light units.58if (GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units")) {59exposure_normalization = calculate_exposure_normalization();60}6162RS::get_singleton()->camera_attributes_set_exposure(camera_attributes, exposure_multiplier, exposure_normalization);63}6465void CameraAttributes::set_auto_exposure_enabled(bool p_enabled) {66auto_exposure_enabled = p_enabled;67_update_auto_exposure();68notify_property_list_changed();69}7071bool CameraAttributes::is_auto_exposure_enabled() const {72return auto_exposure_enabled;73}7475void CameraAttributes::set_auto_exposure_speed(float p_auto_exposure_speed) {76auto_exposure_speed = p_auto_exposure_speed;77_update_auto_exposure();78}7980float CameraAttributes::get_auto_exposure_speed() const {81return auto_exposure_speed;82}8384void CameraAttributes::set_auto_exposure_scale(float p_auto_exposure_scale) {85auto_exposure_scale = p_auto_exposure_scale;86_update_auto_exposure();87}8889float CameraAttributes::get_auto_exposure_scale() const {90return auto_exposure_scale;91}9293RID CameraAttributes::get_rid() const {94return camera_attributes;95}9697void CameraAttributes::_validate_property(PropertyInfo &p_property) const {98if (!Engine::get_singleton()->is_editor_hint()) {99return;100}101if (!GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units") && p_property.name == "exposure_sensitivity") {102p_property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;103return;104}105106if (p_property.name.begins_with("auto_exposure_") && p_property.name != "auto_exposure_enabled" && !auto_exposure_enabled) {107p_property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;108return;109}110}111112void CameraAttributes::_bind_methods() {113ClassDB::bind_method(D_METHOD("set_exposure_multiplier", "multiplier"), &CameraAttributes::set_exposure_multiplier);114ClassDB::bind_method(D_METHOD("get_exposure_multiplier"), &CameraAttributes::get_exposure_multiplier);115ClassDB::bind_method(D_METHOD("set_exposure_sensitivity", "sensitivity"), &CameraAttributes::set_exposure_sensitivity);116ClassDB::bind_method(D_METHOD("get_exposure_sensitivity"), &CameraAttributes::get_exposure_sensitivity);117118ClassDB::bind_method(D_METHOD("set_auto_exposure_enabled", "enabled"), &CameraAttributes::set_auto_exposure_enabled);119ClassDB::bind_method(D_METHOD("is_auto_exposure_enabled"), &CameraAttributes::is_auto_exposure_enabled);120ClassDB::bind_method(D_METHOD("set_auto_exposure_speed", "exposure_speed"), &CameraAttributes::set_auto_exposure_speed);121ClassDB::bind_method(D_METHOD("get_auto_exposure_speed"), &CameraAttributes::get_auto_exposure_speed);122ClassDB::bind_method(D_METHOD("set_auto_exposure_scale", "exposure_grey"), &CameraAttributes::set_auto_exposure_scale);123ClassDB::bind_method(D_METHOD("get_auto_exposure_scale"), &CameraAttributes::get_auto_exposure_scale);124125ADD_GROUP("Exposure", "exposure_");126ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "exposure_sensitivity", PROPERTY_HINT_RANGE, "0.1,32000.0,0.1,suffix:ISO"), "set_exposure_sensitivity", "get_exposure_sensitivity");127ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "exposure_multiplier", PROPERTY_HINT_RANGE, "0.0,8.0,0.001,or_greater"), "set_exposure_multiplier", "get_exposure_multiplier");128129ADD_GROUP("Auto Exposure", "auto_exposure_");130ADD_PROPERTY(PropertyInfo(Variant::BOOL, "auto_exposure_enabled"), "set_auto_exposure_enabled", "is_auto_exposure_enabled");131ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_scale", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_auto_exposure_scale", "get_auto_exposure_scale");132ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_speed", PROPERTY_HINT_RANGE, "0.01,64,0.01"), "set_auto_exposure_speed", "get_auto_exposure_speed");133}134135CameraAttributes::CameraAttributes() {136camera_attributes = RS::get_singleton()->camera_attributes_create();137}138139CameraAttributes::~CameraAttributes() {140ERR_FAIL_NULL(RenderingServer::get_singleton());141RS::get_singleton()->free(camera_attributes);142}143144//////////////////////////////////////////////////////145/* CameraAttributesPractical */146147void CameraAttributesPractical::set_dof_blur_far_enabled(bool p_enabled) {148dof_blur_far_enabled = p_enabled;149_update_dof_blur();150notify_property_list_changed();151}152153bool CameraAttributesPractical::is_dof_blur_far_enabled() const {154return dof_blur_far_enabled;155}156157void CameraAttributesPractical::set_dof_blur_far_distance(float p_distance) {158dof_blur_far_distance = p_distance;159_update_dof_blur();160}161162float CameraAttributesPractical::get_dof_blur_far_distance() const {163return dof_blur_far_distance;164}165166void CameraAttributesPractical::set_dof_blur_far_transition(float p_distance) {167dof_blur_far_transition = p_distance;168_update_dof_blur();169}170171float CameraAttributesPractical::get_dof_blur_far_transition() const {172return dof_blur_far_transition;173}174175void CameraAttributesPractical::set_dof_blur_near_enabled(bool p_enabled) {176dof_blur_near_enabled = p_enabled;177_update_dof_blur();178notify_property_list_changed();179}180181bool CameraAttributesPractical::is_dof_blur_near_enabled() const {182return dof_blur_near_enabled;183}184185void CameraAttributesPractical::set_dof_blur_near_distance(float p_distance) {186dof_blur_near_distance = p_distance;187_update_dof_blur();188}189190float CameraAttributesPractical::get_dof_blur_near_distance() const {191return dof_blur_near_distance;192}193194void CameraAttributesPractical::set_dof_blur_near_transition(float p_distance) {195dof_blur_near_transition = p_distance;196_update_dof_blur();197}198199float CameraAttributesPractical::get_dof_blur_near_transition() const {200return dof_blur_near_transition;201}202203void CameraAttributesPractical::set_dof_blur_amount(float p_amount) {204dof_blur_amount = p_amount;205_update_dof_blur();206}207208float CameraAttributesPractical::get_dof_blur_amount() const {209return dof_blur_amount;210}211212void CameraAttributesPractical::_update_dof_blur() {213RS::get_singleton()->camera_attributes_set_dof_blur(214get_rid(),215dof_blur_far_enabled,216dof_blur_far_distance,217dof_blur_far_transition,218dof_blur_near_enabled,219dof_blur_near_distance,220dof_blur_near_transition,221dof_blur_amount);222}223224float CameraAttributesPractical::calculate_exposure_normalization() const {225return exposure_sensitivity / 3072007.0; // Matches exposure normalization for default CameraAttributesPhysical at ISO 100.226}227228void CameraAttributesPractical::set_auto_exposure_min_sensitivity(float p_min) {229auto_exposure_min = p_min;230_update_auto_exposure();231}232233float CameraAttributesPractical::get_auto_exposure_min_sensitivity() const {234return auto_exposure_min;235}236237void CameraAttributesPractical::set_auto_exposure_max_sensitivity(float p_max) {238auto_exposure_max = p_max;239_update_auto_exposure();240}241242float CameraAttributesPractical::get_auto_exposure_max_sensitivity() const {243return auto_exposure_max;244}245246void CameraAttributesPractical::_update_auto_exposure() {247RS::get_singleton()->camera_attributes_set_auto_exposure(248get_rid(),249auto_exposure_enabled,250auto_exposure_min * ((12.5 / 100.0) / exposure_sensitivity), // Convert from Sensitivity to Luminance251auto_exposure_max * ((12.5 / 100.0) / exposure_sensitivity), // Convert from Sensitivity to Luminance252auto_exposure_speed,253auto_exposure_scale);254emit_changed();255}256257void CameraAttributesPractical::_validate_property(PropertyInfo &p_property) const {258if (!Engine::get_singleton()->is_editor_hint()) {259return;260}261if ((!dof_blur_far_enabled && (p_property.name == "dof_blur_far_distance" || p_property.name == "dof_blur_far_transition")) ||262(!dof_blur_near_enabled && (p_property.name == "dof_blur_near_distance" || p_property.name == "dof_blur_near_transition"))) {263p_property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;264}265}266267void CameraAttributesPractical::_bind_methods() {268// DOF blur269270ClassDB::bind_method(D_METHOD("set_dof_blur_far_enabled", "enabled"), &CameraAttributesPractical::set_dof_blur_far_enabled);271ClassDB::bind_method(D_METHOD("is_dof_blur_far_enabled"), &CameraAttributesPractical::is_dof_blur_far_enabled);272ClassDB::bind_method(D_METHOD("set_dof_blur_far_distance", "distance"), &CameraAttributesPractical::set_dof_blur_far_distance);273ClassDB::bind_method(D_METHOD("get_dof_blur_far_distance"), &CameraAttributesPractical::get_dof_blur_far_distance);274ClassDB::bind_method(D_METHOD("set_dof_blur_far_transition", "distance"), &CameraAttributesPractical::set_dof_blur_far_transition);275ClassDB::bind_method(D_METHOD("get_dof_blur_far_transition"), &CameraAttributesPractical::get_dof_blur_far_transition);276277ClassDB::bind_method(D_METHOD("set_dof_blur_near_enabled", "enabled"), &CameraAttributesPractical::set_dof_blur_near_enabled);278ClassDB::bind_method(D_METHOD("is_dof_blur_near_enabled"), &CameraAttributesPractical::is_dof_blur_near_enabled);279ClassDB::bind_method(D_METHOD("set_dof_blur_near_distance", "distance"), &CameraAttributesPractical::set_dof_blur_near_distance);280ClassDB::bind_method(D_METHOD("get_dof_blur_near_distance"), &CameraAttributesPractical::get_dof_blur_near_distance);281ClassDB::bind_method(D_METHOD("set_dof_blur_near_transition", "distance"), &CameraAttributesPractical::set_dof_blur_near_transition);282ClassDB::bind_method(D_METHOD("get_dof_blur_near_transition"), &CameraAttributesPractical::get_dof_blur_near_transition);283ClassDB::bind_method(D_METHOD("set_dof_blur_amount", "amount"), &CameraAttributesPractical::set_dof_blur_amount);284ClassDB::bind_method(D_METHOD("get_dof_blur_amount"), &CameraAttributesPractical::get_dof_blur_amount);285286ClassDB::bind_method(D_METHOD("set_auto_exposure_max_sensitivity", "max_sensitivity"), &CameraAttributesPractical::set_auto_exposure_max_sensitivity);287ClassDB::bind_method(D_METHOD("get_auto_exposure_max_sensitivity"), &CameraAttributesPractical::get_auto_exposure_max_sensitivity);288ClassDB::bind_method(D_METHOD("set_auto_exposure_min_sensitivity", "min_sensitivity"), &CameraAttributesPractical::set_auto_exposure_min_sensitivity);289ClassDB::bind_method(D_METHOD("get_auto_exposure_min_sensitivity"), &CameraAttributesPractical::get_auto_exposure_min_sensitivity);290291ADD_GROUP("DOF Blur", "dof_blur_");292ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dof_blur_far_enabled"), "set_dof_blur_far_enabled", "is_dof_blur_far_enabled");293ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dof_blur_far_distance", PROPERTY_HINT_RANGE, "0.01,8192,0.01,exp,suffix:m"), "set_dof_blur_far_distance", "get_dof_blur_far_distance");294ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dof_blur_far_transition", PROPERTY_HINT_RANGE, "-1,8192,0.01"), "set_dof_blur_far_transition", "get_dof_blur_far_transition");295ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dof_blur_near_enabled"), "set_dof_blur_near_enabled", "is_dof_blur_near_enabled");296ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dof_blur_near_distance", PROPERTY_HINT_RANGE, "0.01,8192,0.01,exp,suffix:m"), "set_dof_blur_near_distance", "get_dof_blur_near_distance");297ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dof_blur_near_transition", PROPERTY_HINT_RANGE, "-1,8192,0.01"), "set_dof_blur_near_transition", "get_dof_blur_near_transition");298ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "dof_blur_amount", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_dof_blur_amount", "get_dof_blur_amount");299300ADD_GROUP("Auto Exposure", "auto_exposure_");301ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_min_sensitivity", PROPERTY_HINT_RANGE, "0,1600,0.01,or_greater,suffic:ISO"), "set_auto_exposure_min_sensitivity", "get_auto_exposure_min_sensitivity");302ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_max_sensitivity", PROPERTY_HINT_RANGE, "0,64000,0.1,or_greater,suffic:ISO"), "set_auto_exposure_max_sensitivity", "get_auto_exposure_max_sensitivity");303}304305CameraAttributesPractical::CameraAttributesPractical() {306_update_dof_blur();307_update_exposure();308set_auto_exposure_min_sensitivity(0.0);309set_auto_exposure_max_sensitivity(800.0);310notify_property_list_changed();311}312313CameraAttributesPractical::~CameraAttributesPractical() {314}315316//////////////////////////////////////////////////////317/* CameraAttributesPhysical */318319void CameraAttributesPhysical::set_aperture(float p_aperture) {320exposure_aperture = p_aperture;321_update_exposure();322_update_frustum();323}324325float CameraAttributesPhysical::get_aperture() const {326return exposure_aperture;327}328329void CameraAttributesPhysical::set_shutter_speed(float p_shutter_speed) {330exposure_shutter_speed = p_shutter_speed;331_update_exposure();332}333334float CameraAttributesPhysical::get_shutter_speed() const {335return exposure_shutter_speed;336}337338void CameraAttributesPhysical::set_focal_length(float p_focal_length) {339frustum_focal_length = p_focal_length;340_update_frustum();341emit_changed();342}343344float CameraAttributesPhysical::get_focal_length() const {345return frustum_focal_length;346}347348void CameraAttributesPhysical::set_focus_distance(float p_focus_distance) {349frustum_focus_distance = p_focus_distance;350_update_frustum();351}352353float CameraAttributesPhysical::get_focus_distance() const {354return frustum_focus_distance;355}356357void CameraAttributesPhysical::set_near(real_t p_near) {358frustum_near = p_near;359_update_frustum();360emit_changed();361}362363real_t CameraAttributesPhysical::get_near() const {364return frustum_near;365}366367void CameraAttributesPhysical::set_far(real_t p_far) {368frustum_far = p_far;369_update_frustum();370emit_changed();371}372373real_t CameraAttributesPhysical::get_far() const {374return frustum_far;375}376377real_t CameraAttributesPhysical::get_fov() const {378return frustum_fov;379}380381void CameraAttributesPhysical::_update_frustum() {382//https://en.wikipedia.org/wiki/Circle_of_confusion#Circle_of_confusion_diameter_limit_based_on_d/1500383Vector2i sensor_size = Vector2i(36, 24); // Matches high-end DSLR, could be made variable if there is demand.384float CoC = sensor_size.length() / 1500.0;385386frustum_fov = Math::rad_to_deg(2 * std::atan(sensor_size.height / (2 * frustum_focal_length)));387388// Based on https://en.wikipedia.org/wiki/Depth_of_field.389float u = MAX(frustum_focus_distance * 1000.0, frustum_focal_length + 1.0); // Focus distance expressed in mm and clamped to at least 1 mm away from lens.390float hyperfocal_length = frustum_focal_length + ((frustum_focal_length * frustum_focal_length) / (exposure_aperture * CoC));391392// This computes the start and end of the depth of field. Anything between these two points has a Circle of Confusino so small393// that it is not picked up by the camera sensors.394// To be properly physically-based, we would run the DoF shader at all depths. To be efficient, we are only running it where the CoC395// will be visible, this introduces some value shifts in the near field that we have to compensate for below.396float depth_near = ((hyperfocal_length * u) / (hyperfocal_length + (u - frustum_focal_length))) / 1000.0; // In meters.397float depth_far = ((hyperfocal_length * u) / (hyperfocal_length - (u - frustum_focal_length))) / 1000.0; // In meters.398float scale = (frustum_focal_length / (u - frustum_focal_length)) * (frustum_focal_length / exposure_aperture);399400bool use_far = (depth_far < frustum_far) && (depth_far > 0.0);401bool use_near = depth_near > frustum_near;402#ifdef DEBUG_ENABLED403if (OS::get_singleton()->get_current_rendering_method() == "gl_compatibility") {404// Force disable DoF in editor builds to suppress warnings.405use_far = false;406use_near = false;407}408#endif409RS::get_singleton()->camera_attributes_set_dof_blur(410get_rid(),411use_far,412u / 1000.0, // Focus distance clampd to focal length expressed in meters.413-1.0, // Negative to tell Bokeh effect to use physically-based scaling.414use_near,415u / 1000.0,416-1.0,417scale / 5.0); // Arbitrary scaling to get close to how much blur there should be.418}419420float CameraAttributesPhysical::calculate_exposure_normalization() const {421const float e = (exposure_aperture * exposure_aperture) * exposure_shutter_speed * (100.0 / exposure_sensitivity);422return 1.0 / (e * 1.2);423}424425void CameraAttributesPhysical::set_auto_exposure_min_exposure_value(float p_min) {426auto_exposure_min = p_min;427_update_auto_exposure();428}429430float CameraAttributesPhysical::get_auto_exposure_min_exposure_value() const {431return auto_exposure_min;432}433434void CameraAttributesPhysical::set_auto_exposure_max_exposure_value(float p_max) {435auto_exposure_max = p_max;436_update_auto_exposure();437}438439float CameraAttributesPhysical::get_auto_exposure_max_exposure_value() const {440return auto_exposure_max;441}442443void CameraAttributesPhysical::_update_auto_exposure() {444RS::get_singleton()->camera_attributes_set_auto_exposure(445get_rid(),446auto_exposure_enabled,447std::pow(2.0, auto_exposure_min) * (12.5 / exposure_sensitivity), // Convert from EV100 to Luminance448std::pow(2.0, auto_exposure_max) * (12.5 / exposure_sensitivity), // Convert from EV100 to Luminance449auto_exposure_speed,450auto_exposure_scale);451emit_changed();452}453454void CameraAttributesPhysical::_validate_property(PropertyInfo &property) const {455if (!Engine::get_singleton()->is_editor_hint()) {456return;457}458if (!GLOBAL_GET_CACHED(bool, "rendering/lights_and_shadows/use_physical_light_units") && (property.name == "exposure_aperture" || property.name == "exposure_shutter_speed")) {459property.usage = PROPERTY_USAGE_NO_EDITOR | PROPERTY_USAGE_INTERNAL;460return;461}462}463464void CameraAttributesPhysical::_bind_methods() {465ClassDB::bind_method(D_METHOD("set_aperture", "aperture"), &CameraAttributesPhysical::set_aperture);466ClassDB::bind_method(D_METHOD("get_aperture"), &CameraAttributesPhysical::get_aperture);467ClassDB::bind_method(D_METHOD("set_shutter_speed", "shutter_speed"), &CameraAttributesPhysical::set_shutter_speed);468ClassDB::bind_method(D_METHOD("get_shutter_speed"), &CameraAttributesPhysical::get_shutter_speed);469470ClassDB::bind_method(D_METHOD("set_focal_length", "focal_length"), &CameraAttributesPhysical::set_focal_length);471ClassDB::bind_method(D_METHOD("get_focal_length"), &CameraAttributesPhysical::get_focal_length);472ClassDB::bind_method(D_METHOD("set_focus_distance", "focus_distance"), &CameraAttributesPhysical::set_focus_distance);473ClassDB::bind_method(D_METHOD("get_focus_distance"), &CameraAttributesPhysical::get_focus_distance);474ClassDB::bind_method(D_METHOD("set_near", "near"), &CameraAttributesPhysical::set_near);475ClassDB::bind_method(D_METHOD("get_near"), &CameraAttributesPhysical::get_near);476ClassDB::bind_method(D_METHOD("set_far", "far"), &CameraAttributesPhysical::set_far);477ClassDB::bind_method(D_METHOD("get_far"), &CameraAttributesPhysical::get_far);478ClassDB::bind_method(D_METHOD("get_fov"), &CameraAttributesPhysical::get_fov);479480ClassDB::bind_method(D_METHOD("set_auto_exposure_max_exposure_value", "exposure_value_max"), &CameraAttributesPhysical::set_auto_exposure_max_exposure_value);481ClassDB::bind_method(D_METHOD("get_auto_exposure_max_exposure_value"), &CameraAttributesPhysical::get_auto_exposure_max_exposure_value);482ClassDB::bind_method(D_METHOD("set_auto_exposure_min_exposure_value", "exposure_value_min"), &CameraAttributesPhysical::set_auto_exposure_min_exposure_value);483ClassDB::bind_method(D_METHOD("get_auto_exposure_min_exposure_value"), &CameraAttributesPhysical::get_auto_exposure_min_exposure_value);484485ADD_GROUP("Frustum", "frustum_");486ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frustum_focus_distance", PROPERTY_HINT_RANGE, "0.01,4000.0,0.01,suffix:m"), "set_focus_distance", "get_focus_distance");487ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frustum_focal_length", PROPERTY_HINT_RANGE, "1.0,800.0,0.01,exp,suffix:mm"), "set_focal_length", "get_focal_length");488ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frustum_near", PROPERTY_HINT_RANGE, "0.001,10,0.001,or_greater,exp,suffix:m"), "set_near", "get_near");489ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "frustum_far", PROPERTY_HINT_RANGE, "0.01,4000,0.01,or_greater,exp,suffix:m"), "set_far", "get_far");490491ADD_GROUP("Exposure", "exposure_");492ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "exposure_aperture", PROPERTY_HINT_RANGE, "0.5,64.0,0.01,exp,suffix:f-stop"), "set_aperture", "get_aperture");493ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "exposure_shutter_speed", PROPERTY_HINT_RANGE, "0.1,8000.0,0.001,suffix:1/s"), "set_shutter_speed", "get_shutter_speed");494495ADD_GROUP("Auto Exposure", "auto_exposure_");496ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_min_exposure_value", PROPERTY_HINT_RANGE, "-16.0,16.0,0.01,or_greater,suffix:EV100"), "set_auto_exposure_min_exposure_value", "get_auto_exposure_min_exposure_value");497ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "auto_exposure_max_exposure_value", PROPERTY_HINT_RANGE, "-16.0,16.0,0.01,or_greater,suffix:EV100"), "set_auto_exposure_max_exposure_value", "get_auto_exposure_max_exposure_value");498}499500CameraAttributesPhysical::CameraAttributesPhysical() {501_update_exposure();502_update_frustum();503set_auto_exposure_min_exposure_value(-8);504set_auto_exposure_max_exposure_value(10); // Use a wide range by default to feel more like a real camera.505notify_property_list_changed();506}507508CameraAttributesPhysical::~CameraAttributesPhysical() {509}510511512