Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
Merge pull request #338 from KhronosGroup/directional-light
Browse files Browse the repository at this point in the history
Test for KHR_lights_punctual and BRDF normal distribution function
  • Loading branch information
DRx3D authored Dec 3, 2023
2 parents 300e3c8 + 2202396 commit c3b7a75
Show file tree
Hide file tree
Showing 6 changed files with 369 additions and 0 deletions.
53 changes: 53 additions & 0 deletions 2.0/DirectionalLight/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Directional Light

## Screenshot

## Purpose

The purpose of this test model is to verify that the BRDF and microfacet model used by a renderer preserves energy.
It is intended as a test to measure the amount of light factored in by the distribution functions (normal, shadowing and occlusion) - in this case especially the normal distribution function.
At least for realtime rasterizers it is common that the factor returned by this function is applied to the incoming light to calculate specular highlights.
In order to preserve energy it is important that this factor does not add light energy.

The directional lightsource is defined as:

Intensity = 1.0 lumen / m2
Color = [0.9, 0.8, 0.1] - in linear RGB space.

Material roughess:
Left = 0, Middle = 0.16, Right = 0.33

This means that the color of the specular highlight shall retain the same hue as the lightsource.
Where hue is the color without reference to how dull or satururated the color is.
This value can be calculated by dividing each RGB component by the total:
redHue = R / R + G + B
greenHue = G / R + G + B
blueHue = B / R + G + B

Lightsource color = RGB[0.9, 0.8, 0.1]
Hue of the lightsource = [0.9 / 1.8, 0.8 / 1.8, 0.1 / 1.8] = [0.5, 0.444, 0.0555]

The displayed (concentrated) specuar highlight shall retain this hue.
Note that the lightvalues are in linear RGB space.
If display uses sRGB then the sRGB transfer (gamma) function will be applied to resulting scene linear light values.
In this case the values will be roughly [0.96, 0.91, 0.38] depending on exactly what transfer function is applied (this is not specified in the core glTF spec).

This will of course not be an exact measure since values are read and written with different precision.
There will also be a mix with basecolor as the material changes roughness.

## How to check for correct output

The main function tested is the specular highlights, as created by the included directional light.
As the lightsource has an intensity of 1 (lumen / m2) and display output can be considered to be candela / m2 it should never be the case that light contribution go above:
(Color * Intensity) = [0.9, 0.8, 0.1] - in linear space.

Check the specular hightlight with a color picker and verify that the original hue is retained.
For an sRGB display this should be around, depending on the exact gamma/transfer function that is used.
HEX : F3E759

Important to note is that the RG values should not be so high that they are clipped, ie if they are FFFF then that may be a sign that energy has been added and further investigation is needed.


## License Information

[![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png)](http://creativecommons.org/publicdomain/zero/1.0/)
Binary file not shown.
Binary file added 2.0/DirectionalLight/gltf/DirectionalLight.bin
Binary file not shown.
316 changes: 316 additions & 0 deletions 2.0/DirectionalLight/gltf/DirectionalLight.gltf
Original file line number Diff line number Diff line change
@@ -0,0 +1,316 @@
{
"asset": {
"generator": "Khronos glTF Blender I/O v1.7.33 + manual edit",
"version": "2.0"
},
"extensionsUsed": [
"KHR_lights_punctual"
],
"extensionsRequired": [
"KHR_lights_punctual"
],
"extensions": {
"KHR_lights_punctual": {
"lights": [
{
"color": [
0.9,
0.8,
0.1
],
"intensity": 1,
"type": "directional",
"name": "Sun"
}
]
}
},
"scene": 0,
"scenes": [
{
"name": "Scene",
"nodes": [
0,
1,
2,
3,
4
]
}
],
"nodes": [
{
"mesh": 0,
"name": "m0%_r0%",
"rotation": [
0, 0, 0, 1
],
"translation": [
-0.6,
0.0,
0.0
],
"scale": [3, 3, 3]
},
{
"mesh": 1,
"name": "m0%_r16%",
"rotation": [
0, 0, 0, 1
],
"translation": [
0.0,
0.0,
0.0
],
"scale": [3, 3, 3]
},
{
"mesh": 2,
"name": "m0%_r33%",
"rotation": [
0, 0, 0, 1
],
"translation": [
0.6,
0.0,
0.0
],
"scale": [3, 3, 3]
},
{
"extensions" : {
"KHR_lights_punctual" : {
"light" : 0
}
},
"name" : "Sun_Orientation",
"rotation" : [
0, 0, 0, 1
]
},
{
"camera": 0,
"name": "Generated Camera",
"rotation": [
0.0, 0.0, 0.0, 1.0
],
"translation": [
0.0,
0.0,
2
]
}
],
"cameras": [
{
"name": "Generated Camera",
"perspective": {
"aspectRatio": 1.777,
"yfov": 0.65,
"zfar": 5,
"znear": 0.3
},
"type": "perspective"
}
],
"materials": [
{
"name": "mat_0.001",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.6,
0.6,
0.6,
1
],
"metallicFactor": 0,
"roughnessFactor": 0
}
},
{
"name": "mat_1.001",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.6,
0.6,
0.6,
1
],
"metallicFactor": 0,
"roughnessFactor": 0.16
}
},
{
"name": "mat_2.001",
"pbrMetallicRoughness": {
"baseColorFactor": [
0.6,
0.6,
0.6,
1
],
"metallicFactor": 0,
"roughnessFactor": 0.33
}
}
],
"meshes": [
{
"name": "Sphere.098",
"primitives": [
{
"attributes": {
"POSITION": 0,
"NORMAL": 1
},
"indices": 2,
"material": 0
}
]
},
{
"name": "Sphere.099",
"primitives": [
{
"attributes": {
"POSITION": 3,
"NORMAL": 4
},
"indices": 2,
"material": 1
}
]
},
{
"name": "Sphere.100",
"primitives": [
{
"attributes": {
"POSITION": 5,
"NORMAL": 6
},
"indices": 2,
"material": 2
}
]
}
],
"accessors": [
{
"bufferView": 0,
"componentType": 5126,
"count": 5374,
"max": [
0.072314240038394928,
0.072347886860370636,
0.072339475154876709
],
"min": [
-0.072347886860370636,
-0.072347886860370636,
-0.072339475154876709
],
"type": "VEC3"
},
{
"bufferView": 1,
"componentType": 5126,
"count": 5374,
"type": "VEC3"
},
{
"bufferView": 2,
"componentType": 5123,
"count": 31800,
"type": "SCALAR"
},
{
"bufferView": 3,
"componentType": 5126,
"count": 5374,
"max": [
0.072314240038394928,
0.072347886860370636,
0.072339475154876709
],
"min": [
-0.072347886860370636,
-0.072347886860370636,
-0.072339475154876709
],
"type": "VEC3"
},
{
"bufferView": 4,
"componentType": 5126,
"count": 5374,
"type": "VEC3"
},
{
"bufferView": 5,
"componentType": 5126,
"count": 5374,
"max": [
0.072314240038394928,
0.072347886860370636,
0.072339475154876709
],
"min": [
-0.072347886860370636,
-0.072347886860370636,
-0.072339475154876709
],
"type": "VEC3"
},
{
"bufferView": 6,
"componentType": 5126,
"count": 5374,
"type": "VEC3"
}
],
"bufferViews": [
{
"buffer": 0,
"byteLength": 64488,
"byteOffset": 0
},
{
"buffer": 0,
"byteLength": 64488,
"byteOffset": 64488
},
{
"buffer": 0,
"byteLength": 63600,
"byteOffset": 128976
},
{
"buffer": 0,
"byteLength": 64488,
"byteOffset": 192576
},
{
"buffer": 0,
"byteLength": 64488,
"byteOffset": 257064
},
{
"buffer": 0,
"byteLength": 64488,
"byteOffset": 321552
},
{
"buffer": 0,
"byteLength": 64488,
"byteOffset": 386040
}
],
"buffers": [
{
"byteLength": 450528,
"uri": "DirectionalLight.bin"
}
]
}
Binary file added 2.0/DirectionalLight/screenshot/chroma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 2.0/DirectionalLight/screenshot/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c3b7a75

Please sign in to comment.