Skip to content

Commit

Permalink
lights initial
Browse files Browse the repository at this point in the history
  • Loading branch information
robtfm committed Sep 2, 2024
1 parent acd1db5 commit 78085ef
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
22 changes: 22 additions & 0 deletions proto/decentraland/sdk/components/global_light.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package decentraland.sdk.components;

import "decentraland/common/colors.proto";
import "decentraland/common/vectors.proto";

import "decentraland/sdk/components/common/id.proto";
option (common.ecs_component_id) = 1206;

// defines the global scene light settings. must be added to the scene root.
// to control sunlight color, intensity, shadows etc, you can also add a PbLight to the scene root.
message PbGlobalLight {
// the direction the directional light shines in.
// default depends on time of day and explorer implementation
optional decentraland.common.Vector3 direction = 1;
// ambient light color
// default: White
optional decentraland.common.Color3 ambient_color = 2;
// ambient light intensity. the explorer default ambient brightness is multiplied by this non-physical quantity.
// default 1
optional float ambient_brightness = 3;
}
42 changes: 42 additions & 0 deletions proto/decentraland/sdk/components/light.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
syntax = "proto3";
package decentraland.sdk.components;

import "decentraland/common/colors.proto";

import "decentraland/sdk/components/common/id.proto";
option (common.ecs_component_id) = 1204;

// defines a light source.
// the world has a default directional light (like sunlight) which can be overridden by adding the light component to the scene root.
// a PbGlobalLight component can also be added to the root to control the directional light direction.
// point lights (lightbulbs) or spotlights can be created by attaching the light component to non-root entities.
message PbLight {
// whether the light is on
// default true
optional bool enabled = 1;
// light brightness in lux (lumens/m^2).
//
// for global directional light, this applies as a constant value at all surfaces and distances (though the effect on the surface still depends on incidence angle).
// the default global light illuminance varies from 400 (sunrise/sunset) to 10,000 (midday).
// for typical values, see https://en.wikipedia.org/wiki/Lux#Illuminance
//
// for point and spot lights, this is the lumens/m^2 at 1m distance from the light. to transform from raw lumens,
// divide lumens by ~12 (4*pi).
// e.g. a 100w household bulb with 1200 lumens would have an illuminance of ~100.
// a lighthouse bulb with 200,000 lumens would have an illuminance of ~15,000 (ignoring beam reflections)
//
// default
// for point/spotlights: 10,000
// for global directional light: depends on explorer implementation. may vary on light direction, time of day, etc
optional float illuminance = 2;
// whether the light should cast shadows.
// note: even when set to true the engine may not display shadows, or may only show shadows for a limited number
// of lights depending on the implementation, platform, and user settings.
// default
// for point/spotlights: false / off
// for global directional light: true / on
optional bool shadows = 3;
// light color
// default White
optional decentraland.common.Color3 color = 4;
}
21 changes: 21 additions & 0 deletions proto/decentraland/sdk/components/spotlight.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
syntax = "proto3";
package decentraland.sdk.components;

import "decentraland/sdk/components/common/id.proto";
option (common.ecs_component_id) = 1205;

// defines a spotlight.
// spotlights are point lights that emit light only in a cone around the transform's forward direction.
// add this component together with the PbLight component to transform a point light into a spotlight.
// note that spotlights do not model any internal reflections / focus, they only restrict the area of effect.
// so for e.g. a torch beam, the bulb illuminance should be multiplied by the solid angle.
// a typical torch with a beam width of 15 degrees would use outer angle of 0.15 (7.5 degrees in radians),
// and an illuminance approximately equal to the bulb's lumens, e.g. 1200.
message PbSpotlight {
// the cone radius in radians. distance away from forward in which the light is visible.
// for a torch a value around 0.15 is appropriate.
float angle = 1;
// optional angle at which the light is brightest. should be <= outer angle.
// if specified, the light will fall off smoothly between `inner_angle` and `angle`.
optional float inner_angle = 2;
}

0 comments on commit 78085ef

Please sign in to comment.