@@ -222,6 +222,24 @@ Ref<Texture2D> Light3D::get_projector() const {
222222 return projector;
223223}
224224
225+ void Light3D::set_projector_scale (const Vector2 &p_scale) {
226+ projector_scale = p_scale;
227+ RS::get_singleton ()->light_set_projector_scale (light, p_scale);
228+ }
229+
230+ Vector2 Light3D::get_projector_scale () const {
231+ return projector_scale;
232+ }
233+
234+ void Light3D::set_projector_offset (const Vector2 &p_offset) {
235+ projector_offset = p_offset;
236+ RS::get_singleton ()->light_set_projector_offset (light, p_offset);
237+ }
238+
239+ Vector2 Light3D::get_projector_offset () const {
240+ return projector_offset;
241+ }
242+
225243void Light3D::owner_changed_notify () {
226244 // For cases where owner changes _after_ entering tree (as example, editor editing).
227245 _update_visibility ();
@@ -327,8 +345,8 @@ void Light3D::_validate_property(PropertyInfo &p_property) const {
327345 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
328346 }
329347
330- if (get_light_type () != RS::LIGHT_DIRECTIONAL && (p_property.name == " light_angular_distance" || p_property.name == " light_intensity_lux" )) {
331- // Angular distance and Light Intensity Lux are only used in DirectionalLight3D.
348+ if (get_light_type () != RS::LIGHT_DIRECTIONAL && (p_property.name == " light_angular_distance" || p_property.name == " light_intensity_lux" || p_property. name == " Projector " || p_property. name == " light_projector_scale " || p_property. name == " light_projector_offset " )) {
349+ // Angular distance, Light Intensity Lux and Projector Subgroup/Scale/Offset are only used in DirectionalLight3D.
332350 p_property.usage = PROPERTY_USAGE_NONE;
333351 } else if (get_light_type () == RS::LIGHT_DIRECTIONAL && p_property.name == " light_intensity_lumens" ) {
334352 p_property.usage = PROPERTY_USAGE_NONE;
@@ -386,6 +404,12 @@ void Light3D::_bind_methods() {
386404 ClassDB::bind_method (D_METHOD (" set_projector" , " projector" ), &Light3D::set_projector);
387405 ClassDB::bind_method (D_METHOD (" get_projector" ), &Light3D::get_projector);
388406
407+ ClassDB::bind_method (D_METHOD (" set_projector_scale" , " scale" ), &Light3D::set_projector_scale);
408+ ClassDB::bind_method (D_METHOD (" get_projector_scale" ), &Light3D::get_projector_scale);
409+
410+ ClassDB::bind_method (D_METHOD (" set_projector_offset" , " offset" ), &Light3D::set_projector_offset);
411+ ClassDB::bind_method (D_METHOD (" get_projector_offset" ), &Light3D::get_projector_offset);
412+
389413 ClassDB::bind_method (D_METHOD (" set_temperature" , " temperature" ), &Light3D::set_temperature);
390414 ClassDB::bind_method (D_METHOD (" get_temperature" ), &Light3D::get_temperature);
391415 ClassDB::bind_method (D_METHOD (" get_correlated_color" ), &Light3D::get_correlated_color);
@@ -398,8 +422,13 @@ void Light3D::_bind_methods() {
398422 ADD_PROPERTYI (PropertyInfo (Variant::FLOAT, " light_energy" , PROPERTY_HINT_RANGE, " 0,16,0.001,or_greater" ), " set_param" , " get_param" , PARAM_ENERGY);
399423 ADD_PROPERTYI (PropertyInfo (Variant::FLOAT, " light_indirect_energy" , PROPERTY_HINT_RANGE, " 0,16,0.001,or_greater" ), " set_param" , " get_param" , PARAM_INDIRECT_ENERGY);
400424 ADD_PROPERTYI (PropertyInfo (Variant::FLOAT, " light_volumetric_fog_energy" , PROPERTY_HINT_RANGE, " 0,16,0.001,or_greater" ), " set_param" , " get_param" , PARAM_VOLUMETRIC_FOG_ENERGY);
425+
401426 // Only allow texture types that display correctly.
427+ ADD_SUBGROUP (" Projector" , " light_projector_" );
402428 ADD_PROPERTY (PropertyInfo (Variant::OBJECT, " light_projector" , PROPERTY_HINT_RESOURCE_TYPE, " Texture2D,-AnimatedTexture,-AtlasTexture,-CameraTexture,-CanvasTexture,-MeshTexture,-Texture2DRD,-ViewportTexture" ), " set_projector" , " get_projector" );
429+ ADD_PROPERTY (PropertyInfo (Variant::VECTOR2, " light_projector_scale" , PROPERTY_HINT_NONE, " suffix:px" ), " set_projector_scale" , " get_projector_scale" );
430+ ADD_PROPERTY (PropertyInfo (Variant::VECTOR2, " light_projector_offset" ), " set_projector_offset" , " get_projector_offset" );
431+
403432 ADD_PROPERTYI (PropertyInfo (Variant::FLOAT, " light_size" , PROPERTY_HINT_RANGE, " 0,1,0.001,or_greater,suffix:m" ), " set_param" , " get_param" , PARAM_SIZE);
404433 ADD_PROPERTYI (PropertyInfo (Variant::FLOAT, " light_angular_distance" , PROPERTY_HINT_RANGE, " 0,90,0.01,degrees" ), " set_param" , " get_param" , PARAM_SIZE);
405434 ADD_PROPERTY (PropertyInfo (Variant::BOOL, " light_negative" ), " set_negative" , " is_negative" );
@@ -560,7 +589,7 @@ void DirectionalLight3D::_validate_property(PropertyInfo &p_property) const {
560589 p_property.usage = PROPERTY_USAGE_NO_EDITOR;
561590 }
562591
563- if (p_property.name == " light_size" || p_property. name == " light_projector " ) {
592+ if (p_property.name == " light_size" ) {
564593 // Not implemented in DirectionalLight3D (`light_size` is replaced by `light_angular_distance`).
565594 p_property.usage = PROPERTY_USAGE_NONE;
566595 }
@@ -614,6 +643,7 @@ DirectionalLight3D::DirectionalLight3D() :
614643 set_shadow_mode (SHADOW_PARALLEL_4_SPLITS);
615644 blend_splits = false ;
616645 set_sky_mode (SKY_MODE_LIGHT_AND_SKY);
646+ set_projector_scale (Vector2 (1 , 1 ));
617647}
618648
619649void OmniLight3D::set_shadow_mode (ShadowMode p_mode) {
0 commit comments