-
Notifications
You must be signed in to change notification settings - Fork 1.2k
EXT_lights_area #2525
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MiiBond
wants to merge
6
commits into
KhronosGroup:main
Choose a base branch
from
MiiBond:mbond/EXT_lights_area_rect
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+255
−0
Open
EXT_lights_area #2525
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
92b33a5
Add area light extension
MiiBond 5b9e4d9
Address PR comments
MiiBond 0e8aaaf
Fix example json
MiiBond 518ef9e
Update extensions/2.0/Vendor/EXT_lights_area/README.md
MiiBond 575dc4d
Update extensions/2.0/Vendor/EXT_lights_area/README.md
MiiBond e77b27a
Minor updates
MiiBond File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| # EXT_lights_area | ||
|
|
||
| ## Contributors | ||
|
|
||
| * Mike Bond, Adobe, [@miibond](https://github.com/MiiBond) | ||
|
|
||
| ## Status | ||
|
|
||
| Draft | ||
|
|
||
| ## Dependencies | ||
|
|
||
| Written against the glTF 2.0 spec. | ||
|
|
||
| ## Overview | ||
|
|
||
| This extension defines area lights with physically accurate intensity values for use with glTF 2.0. | ||
|
|
||
| Area lights are flat surfaces that uniformly emit light from one side (the side facing in the -Z direction in local space). | ||
| This extension defines two area light types: `rect` (rectangle) and `disk` (circle). These lights are referenced by nodes and inherit the transform of that node, allowing them to be placed in a scene. | ||
|
|
||
| ## Defining Area Lights | ||
|
|
||
| As with KHR_lights_punctual, area lights are defined as a `lights` array inside the `EXT_lights_area` extension at the root of the document. | ||
|
|
||
| The following example defines both a rectangular and a disk area light: | ||
|
|
||
| ```json | ||
| "extensions": { | ||
| "EXT_lights_area": { | ||
| "lights": [ | ||
| { | ||
| "color": [1.0, 1.0, 1.0], | ||
| "intensity": 1000.0, | ||
| "type": "rect", | ||
| "size": 1.0, | ||
| "rect": { | ||
| "aspect": 2.0 | ||
| } | ||
| }, | ||
| { | ||
| "color": [1.0, 0.9, 0.8], | ||
| "intensity": 1500.0, | ||
| "type": "disk", | ||
| "size": 1.2 | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Adding Light Instances to Nodes | ||
|
|
||
| Lights must be attached to a node by defining the `extensions.EXT_lights_area` property and, within that, an index into the `lights` array using the `light` property. | ||
|
|
||
| ```json | ||
| "nodes": [ | ||
| { | ||
| "extensions": { | ||
| "EXT_lights_area": { | ||
| "light": 0 | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| The light will inherit the transform of the node in the following manner: | ||
| 1. The light's centre is defined as the node's world location. | ||
| 2. The light's direction is defined as the 3-vector `(0.0, 0.0, -1.0)` and the rotation of the node orients the light accordingly. That is, an untransformed light points down the -Z axis. | ||
| 3. The light's size is defined as its "size" property multiplied by the absolute value of the largest component of the node's world scale, i.e., the scaling is always uniform and positive. | ||
|
|
||
| ## Light Types | ||
|
|
||
| ### Light Shared Properties | ||
|
|
||
| All light types share the common set of properties listed below. | ||
|
|
||
| | Property | Type | Description | Required | Default | | ||
| |:---------|:-----|:------------|:---------|:--------| | ||
| | `name` | `string` | Name of the light. | No | Default: `""` | | ||
| | `color` | `number[3]` | RGB value for the light's color in linear space. | No | `[1.0, 1.0, 1.0]` | | ||
| | `intensity` | `number` | The luminance of the light surface in nits (cd/m²). Must be a positive value. | No | `1000.0` | | ||
| | `type` | `string` | Declares the type of the light. | :white_check_mark: Yes | `rect` | | ||
| | `size` | `number` | Defines the size of the light in local space. For `rect` lights, this is the dimension along the local y-axis. For `disk` lights, this is the diameter of the light. | No | `1.0` | | ||
|
|
||
| ### Rectangle Lights | ||
|
|
||
| When a light's `type` is `rect`, the `rect` property contains the following optional properties. | ||
|
|
||
| | Property | Type | Description | Required | Default | | ||
| |:---------|:-----|:------------|:---------|:--------| | ||
| | `aspect` | `number` | Defines the relative size of the width of the rectangle compared to the height. | No | `1.0` | | ||
|
|
||
| The rectangle area light's shape extends from -width/2 to +width/2 along the local X-axis, and from -height/2 to +height/2 along the Y-axis where width and height are defined as follows: | ||
|
|
||
| `width = world scale * size * aspect` \ | ||
| `height = world scale * size` | ||
|
|
||
| `world scale` is the largest component of the absolute value of the node's scale. | ||
|
|
||
| ### Disk Lights | ||
|
|
||
| When a light's `type` is `disk`, the light is circular and no additional properties are defined. | ||
|
|
||
| The disk light's shape extends in a circle around the origin in the local XY-plane. The diameter is given by `world scale * size` where `world scale` is the largest component of the absolute value of the node's scale. | ||
|
|
||
| ## Light Emission | ||
|
|
||
| Area lights emit light uniformly from one side of the surface (the side facing in the -Z direction in local space). The light emission follows Lambert's cosine law. The total luminous flux (in lumens) emitted by the light is: | ||
|
|
||
| `Flux = intensity × area × π` | ||
|
|
||
| Where: | ||
|
|
||
| * `intensity` is in nits (cd/m²) | ||
| * `area` is the surface area of the light in square meters: | ||
| * For rectangular lights: `area = width × height` | ||
| * For disk lights: `area = π × radius²` | ||
|
|
||
| The resulting flux is measured in lumens. Notice that when the intensity value remains constant, the total emitted flux will change proportionally to the change in area. | ||
|
|
||
| ### Luminance Units | ||
|
|
||
| The `intensity` property is specified in nits (cd/m²), which is the standard unit for surface luminance. This provides physically accurate lighting values: | ||
|
|
||
| * Typical indoor lighting: 100-500 nits | ||
| * Bright office lighting: 1,000 nits | ||
| * Sunlit white paper: 30,000 nits | ||
| * Direct sunlight: 1,000,000,000+ nits | ||
|
|
||
| ## JSON Schema | ||
|
|
||
| * [light.EXT_lights_area.schema.json](schema/light.area.schema.json) | ||
22 changes: 22 additions & 0 deletions
22
extensions/2.0/Vendor/EXT_lights_area/schema/glTF.EXT_lights_area.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema", | ||
| "title": "EXT_lights_area glTF Document Extension", | ||
| "type": "object", | ||
| "allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
| "properties": { | ||
| "lights": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "object", | ||
| "$ref": "light.area.schema.json" | ||
| }, | ||
| "minItems": 1, | ||
| "description": "An array of area lights (rectangular and disk)." | ||
| }, | ||
| "extensions": { }, | ||
| "extras": { } | ||
| }, | ||
| "required": [ | ||
| "lights" | ||
| ] | ||
| } |
17 changes: 17 additions & 0 deletions
17
extensions/2.0/Vendor/EXT_lights_area/schema/light.rect.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "$schema" : "http://json-schema.org/draft-04/schema", | ||
| "title" : "EXT_lights_area Rectangular Light Properties", | ||
| "type" : "object", | ||
| "allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
| "properties" : { | ||
| "aspect" : { | ||
| "type" : "number", | ||
| "description" : "Aspect ratio of the light (width / height).", | ||
| "default" : 1.0, | ||
| "minimum": 0.0, | ||
| "exclusiveMinimum": true | ||
| }, | ||
| "extensions": { }, | ||
| "extras": { } | ||
| } | ||
| } |
61 changes: 61 additions & 0 deletions
61
extensions/2.0/Vendor/EXT_lights_area/schema/light.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema", | ||
| "title": "EXT_lights_area Area Light Properties", | ||
| "type": "object", | ||
| "description": "An area light (rectangular or disk) that emits light uniformly from one side following Lambert's cosine law.", | ||
| "allOf": [ { "$ref": "glTFChildOfRootProperty.schema.json" } ], | ||
| "properties": { | ||
| "name": { | ||
| "type": "string", | ||
| "description": "The name of the light. This is not necessarily unique." | ||
| }, | ||
| "color": { | ||
| "type": "array", | ||
| "items": { | ||
| "type": "number", | ||
| "minimum": 0.0, | ||
| "maximum": 1.0 | ||
| }, | ||
| "minItems": 3, | ||
| "maxItems": 3, | ||
| "description": "RGB color of the light in linear space. Each component should be in the range [0, 1].", | ||
| "default": [1.0, 1.0, 1.0] | ||
| }, | ||
| "intensity": { | ||
| "type": "number", | ||
| "description": "The luminance of the light surface in nits (cd/m²). Must be a positive value.", | ||
| "default": 1000.0, | ||
| "minimum": 0.0 | ||
| }, | ||
| "size": { | ||
| "type": "number", | ||
| "description": "Size of the light. For rectangular lights, this is the height (y-axis) in local space. Must be a positive value. For disk lights, it is the diameter.", | ||
| "default": 1.0, | ||
| "minimum": 0.0, | ||
| "exclusiveMinimum": true | ||
| }, | ||
| "rect": { | ||
| "type": "object", | ||
| "$ref": "light.rect.schema.json" | ||
| }, | ||
| "type": { | ||
| "type": "string", | ||
| "description": "Specifies the type of area light.", | ||
| "anyOf": [ | ||
| { | ||
| "enum": [ "rect" ], | ||
| "description": "Rectangle lights emit light from a rectangular area." | ||
| }, | ||
| { | ||
| "enum": [ "disk" ], | ||
| "description": "Disk lights emit light from a circular area." | ||
| } | ||
| ] | ||
| }, | ||
| "extensions": { }, | ||
| "extras": { } | ||
| }, | ||
| "required": [ | ||
| "shape" | ||
| ] | ||
| } |
21 changes: 21 additions & 0 deletions
21
extensions/2.0/Vendor/EXT_lights_area/schema/node.EXT_lights_area.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| { | ||
| "$schema": "http://json-schema.org/draft-04/schema", | ||
| "title": "EXT_lights_area glTF Node Extension", | ||
| "type": "object", | ||
| "allOf": [ { "$ref": "glTFProperty.schema.json" } ], | ||
| "properties": { | ||
| "light": { | ||
| "allOf": [ | ||
| { | ||
| "$ref": "glTFid.schema.json" | ||
| } | ||
| ], | ||
| "description": "The index of the area light referenced by this node." | ||
| }, | ||
| "extensions": { }, | ||
| "extras": { } | ||
| }, | ||
| "required": [ | ||
| "light" | ||
| ] | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it help to add a couple of pictures with an example of a rect and a disk in the real world for illustration purposes?