Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scene/3d/light_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ Light3D::Light3D(RenderingServer::LightType p_type) {
case RS::LIGHT_SPOT:
light = RenderingServer::get_singleton()->spot_light_create();
break;
case RS::LIGHT_RECT:
light = RenderingServer::get_singleton()->rect_light_create();
break;
default: {
};
}
Expand Down Expand Up @@ -650,6 +653,31 @@ OmniLight3D::OmniLight3D() :
set_shadow_mode(SHADOW_CUBE);
}

RectLight3D::RectLight3D() :
Light3D(RenderingServer::LIGHT_RECT) {
set_width(1.0);
set_height(1.0);
}

void RectLight3D::_bind_methods() {

ADD_GROUP("Rect", "rect_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "rect_width", PROPERTY_HINT_RANGE, "0,4069,0.001,or_grater,exp,suffix:m"), "set_param", "get_param", PARAM_RANGE);
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "rect_height", PROPERTY_HINT_RANGE, "0,4069,0.001,or_grater,exp,suffix:m"), "set_param", "get_param", PARAM_RANGE);
}

void RectLight3D::set_width(float p_width) {
width = p_width;
}

float RectLight3D::get_width() const {
return width;
}

float RectLight3D::get_height() const {
return height;
}

PackedStringArray SpotLight3D::get_configuration_warnings() const {
PackedStringArray warnings = Light3D::get_configuration_warnings();

Expand Down
23 changes: 23 additions & 0 deletions scene/3d/light_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,29 @@ class DirectionalLight3D : public Light3D {
VARIANT_ENUM_CAST(DirectionalLight3D::ShadowMode)
VARIANT_ENUM_CAST(DirectionalLight3D::SkyMode)

class RectLight3D : public Light3D {
GDCLASS(RectLight3D, Light3D);

private:
// rect light parameters
float width, height;

protected:
static void _bind_methods();

public:

void set_width(float p_width);
void set_height(float p_height);

float get_width() const;
float get_height() const;

PackedStringArray get_configuration_warnings() const override;

RectLight3D();
};

class OmniLight3D : public Light3D {
GDCLASS(OmniLight3D, Light3D);

Expand Down
1 change: 1 addition & 0 deletions servers/rendering_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2506,6 +2506,7 @@ void RenderingServer::_bind_methods() {
ClassDB::bind_method(D_METHOD("directional_light_create"), &RenderingServer::directional_light_create);
ClassDB::bind_method(D_METHOD("omni_light_create"), &RenderingServer::omni_light_create);
ClassDB::bind_method(D_METHOD("spot_light_create"), &RenderingServer::spot_light_create);
ClassDB::bind_method(D_METHOD("rect_light_create"), &RenderingServer::rect_light_create);

ClassDB::bind_method(D_METHOD("light_set_color", "light", "color"), &RenderingServer::light_set_color);
ClassDB::bind_method(D_METHOD("light_set_param", "light", "param", "value"), &RenderingServer::light_set_param);
Expand Down
4 changes: 3 additions & 1 deletion servers/rendering_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,8 @@ class RenderingServer : public Object {
enum LightType {
LIGHT_DIRECTIONAL,
LIGHT_OMNI,
LIGHT_SPOT
LIGHT_SPOT,
LIGHT_RECT
};

enum LightParam {
Expand Down Expand Up @@ -563,6 +564,7 @@ class RenderingServer : public Object {
virtual RID directional_light_create() = 0;
virtual RID omni_light_create() = 0;
virtual RID spot_light_create() = 0;
virtual RID rect_light_create() = 0;

virtual void light_set_color(RID p_light, const Color &p_color) = 0;
virtual void light_set_param(RID p_light, LightParam p_param, float p_value) = 0;
Expand Down