Skip to content

Commit

Permalink
lights initial (#217)
Browse files Browse the repository at this point in the history
* lights initial

* Pb -> PB

---------

Co-authored-by: robtfm <[email protected]>
  • Loading branch information
leanmendoza and robtfm authored Sep 18, 2024
1 parent 0207676 commit f199bbd
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 3 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;
}
6 changes: 3 additions & 3 deletions proto/decentraland/sdk/components/gltf_node.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import "decentraland/sdk/components/common/id.proto";
option (common.ecs_component_id) = 1200;

// a GltfNode links a scene entity with a node from within a gltf, allowing the scene to inspect it or modify it.
// This component must be added to a direct child of an entity with a PbGltfContainer component, or
// This component must be added to a direct child of an entity with a PBGltfContainer component, or
// to a direct child of another entity with a GltfNode component, and the referenced gltf node must be a descendent of the gltf node
// in the parent.
// The name must match the path of one of the nodes within the Gltf. These are available on the GltfContainerLoadingState component.
//
// The renderer will attach a PbGltfNodeState to the entity describing the state. Once the state is `GNS_READY`,
// The renderer will attach a PBGltfNodeState to the entity describing the state. Once the state is `GNS_READY`,
// - the `Transform` will be updated to match the position of the node within the gltf (relative to the gltf root, or the parent node),
// - a `MeshRenderer` with a GltfMesh mesh type will be added (if the gltf node has a mesh).
// - a `MeshCollider` with a GltfMesh mesh type will be added (if the gltf node has a collider).
Expand All @@ -27,7 +27,7 @@ option (common.ecs_component_id) = 1200;
// - `MeshCollider` can be added/modified/removed to create/modify/remove a collider on the node.
// - `Material` can be added or modified to change the material properties. If the gltf node has a material, the original material will be
// used as a base, and any gltf features (e.g. occlusion maps) from the gtlf spec that the renderer supports but that are not exposed in the
// PbMaterial will be maintained.
// PBMaterial will be maintained.
//
// The scene can add additional entities as children to the gltf node, but structural modifications of the gltf are not possible:
// - changing the scene hierarchy will not change the gltf node hierarchy. Moving the entity out of the gltf will sever the link and
Expand Down
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 f199bbd

Please sign in to comment.