Skip to content
Merged
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
107 changes: 84 additions & 23 deletions examples/3d-light-playground/3d-light-playground.json
Original file line number Diff line number Diff line change
Expand Up @@ -1035,8 +1035,8 @@
"behaviors": [],
"content": {
"Color": "255;140;70",
"Intensity": 2.2,
"Decay": 2,
"Intensity": 13,
"Decay": 1,
"IsCastingShadow": true,
"ShadowQuality": "Medium",
"ShadowCameraNearPlane": 20,
Expand All @@ -1055,8 +1055,8 @@
"behaviors": [],
"content": {
"Color": "90;190;255",
"Intensity": 2.2,
"Decay": 2,
"Intensity": 13,
"Decay": 1,
"IsCastingShadow": true,
"ShadowQuality": "Medium",
"ShadowCameraNearPlane": 20,
Expand All @@ -1075,8 +1075,8 @@
"behaviors": [],
"content": {
"Color": "255;100;200",
"Intensity": 2.2,
"Decay": 2,
"Intensity": 13,
"Decay": 1,
"IsCastingShadow": true,
"ShadowQuality": "Medium",
"ShadowCameraNearPlane": 20,
Expand Down Expand Up @@ -1603,9 +1603,9 @@
"content": {
"Color": "255;236;180",
"ConeAngle": 34,
"Intensity": 14,
"Intensity": 130,
"Smoothing": 1,
"Decay": 2,
"Decay": 1,
"Image": "",
"IsCastingShadow": true,
"ShadowQuality": "Medium",
Expand All @@ -1626,9 +1626,9 @@
"content": {
"Color": "180;220;255",
"ConeAngle": 34,
"Intensity": 14,
"Intensity": 130,
"Smoothing": 1,
"Decay": 2,
"Decay": 1,
"Image": "",
"IsCastingShadow": true,
"ShadowQuality": "Medium",
Expand Down Expand Up @@ -2656,8 +2656,8 @@
"behaviors": [],
"content": {
"Color": "255;170;110",
"Intensity": 1.5,
"Decay": 2,
"Intensity": 4.9,
"Decay": 1,
"IsCastingShadow": false,
"ShadowQuality": "Medium",
"ShadowCameraNearPlane": 20,
Expand All @@ -2676,8 +2676,8 @@
"behaviors": [],
"content": {
"Color": "255;210;150",
"Intensity": 1.6,
"Decay": 2,
"Intensity": 5.5,
"Decay": 1,
"IsCastingShadow": true,
"ShadowQuality": "Medium",
"ShadowCameraNearPlane": 20,
Expand All @@ -2697,9 +2697,9 @@
"content": {
"Color": "150;205;255",
"ConeAngle": 40,
"Intensity": 5,
"Intensity": 47,
"Smoothing": 1,
"Decay": 2,
"Decay": 1,
"Image": "",
"IsCastingShadow": false,
"ShadowQuality": "Medium",
Expand All @@ -2720,9 +2720,9 @@
"content": {
"Color": "190;225;255",
"ConeAngle": 40,
"Intensity": 5,
"Intensity": 47,
"Smoothing": 1,
"Decay": 2,
"Decay": 1,
"Image": "",
"IsCastingShadow": true,
"ShadowQuality": "Medium",
Expand Down Expand Up @@ -3378,8 +3378,8 @@
"behaviors": [],
"content": {
"Color": "255;205;150",
"Intensity": 1.8,
"Decay": 2,
"Intensity": 7,
"Decay": 1,
"IsCastingShadow": true,
"ShadowQuality": "Medium",
"ShadowCameraNearPlane": 20,
Expand Down Expand Up @@ -3490,7 +3490,7 @@
"name": "Light3D",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/f237ae4e3b857c556846c7b2c0b132556fd4bcdeff217034b4d9c97dc1aab1d6_lightbulb-on-outline.svg",
"shortDescription": "A collection of light object for 3D.",
"version": "1.0.3",
"version": "2.0.0",
"description": "A collection of light object for 3D.",
"origin": {
"identifier": "Light3D",
Expand All @@ -3503,10 +3503,62 @@
"authorIds": [
"IWykYNRvhCZBN3vEgKEbBPOR3Oc2"
],
"changelog": [
{
"version": "2.0.0",
"breaking": "- Point and spot lights now fade with the distance like they do with the 3D renderer of recent GDevelop versions (Three.js r185), including on previous GDevelop versions. Lights made for a previous version of the extension need a higher intensity (and possibly a lower decay) to look the same."
}
],
"dependencies": [],
"globalVariables": [],
"sceneVariables": [],
"eventsFunctions": [
{
"fullName": "",
"functionType": "Action",
"name": "onFirstSceneLoaded",
"sentence": "",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"// Before Three.js r165, GDevelop rendered with \"legacy lights\": point and spot",
"// lights faded linearly up to their range and every light color was",
"// multiplied by PI. Recent GDevelop versions use the physically based falloff",
"// of Three.js r185 instead, which is what the light properties are tuned for.",
"// Use the same falloff with older GDevelop versions so that lights look the",
"// same with every version:",
"// - distances are divided by 100 because recent GDevelop versions render 3D",
"// with a default world scale of 100 pixels per unit, while older versions",
"// work in pixels,",
"// - the attenuation is divided by PI as the legacy light colors are multiplied by PI.",
"// It must be patched before any shader using lights is compiled, as Three.js",
"// caches compiled shaders.",
"const lightsParsBegin = THREE.ShaderChunk.lights_pars_begin;",
"if (!lightsParsBegin.includes('#if defined ( LEGACY_LIGHTS )')) {",
" return;",
"}",
"THREE.ShaderChunk.lights_pars_begin = lightsParsBegin.replace(",
" /#if defined \\( LEGACY_LIGHTS \\)[\\s\\S]*?#else/,",
" [",
" '#if defined ( LEGACY_LIGHTS )',",
" '\\t\\tfloat distanceFalloff = 1.0 / max( pow( lightDistance * 0.01, decayExponent ), 0.01 );',",
" '\\t\\tif ( cutoffDistance > 0.0 ) {',",
" '\\t\\t\\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );',",
" '\\t\\t}',",
" '\\t\\treturn distanceFalloff * RECIPROCAL_PI;',",
" '\\t#else',",
" ].join('\\n')",
");"
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": true
}
],
"parameters": [],
"objectGroups": []
},
{
"description": "Define spot light helper classes JavaScript code.",
"fullName": "Define spot light helper classes",
Expand Down Expand Up @@ -3914,7 +3966,9 @@
" * @param value {number}",
" */",
" setRange(value) {",
" this.pointLight.distance = value;",
" const runtimeScene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeScene.getRenderer3DInverseWorldScale ? runtimeScene.getRenderer3DInverseWorldScale() : 1;",
" this.pointLight.distance = value * inverseWorldScale;",
" }",
"",
" /**",
Expand Down Expand Up @@ -4076,7 +4130,11 @@
" spotLight.castShadow = false;",
" spotLight.visible = false;",
"",
" if (!object.isHidden()) {",
" // Instances hidden at start stay visible in the editor, but their light must not shine.",
" const isHiddenAtStartInEditor =",
" !!editor && !!editor.isInstanceHiddenAtStart && editor.isInstanceHiddenAtStart(object);",
"",
" if (!object.isHidden() && !isHiddenAtStartInEditor) {",
" let isSelected = false;",
" if (editor) {",
" const selectedObject = editor._selection.getLastSelectedObject();",
Expand Down Expand Up @@ -4706,6 +4764,9 @@
"eventsFunctionsFolderStructure": {
"folderName": "__ROOT",
"children": [
{
"functionName": "onFirstSceneLoaded"
},
{
"functionName": "DefineHelperClasses"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1568,10 +1568,10 @@
"effects": [],
"behaviors": [],
"content": {
"Intensity": 2.5,
"Intensity": 9,
"ConeLength": 4000,
"ConeAngle": 22,
"Decay": 10,
"Decay": 1,
"Smoothing": 0.15,
"ShadowBias": 0.0001
}
Expand Down Expand Up @@ -17705,7 +17705,7 @@
"name": "Light3D",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/f237ae4e3b857c556846c7b2c0b132556fd4bcdeff217034b4d9c97dc1aab1d6_lightbulb-on-outline.svg",
"shortDescription": "A collection of light object for 3D.",
"version": "1.0.3",
"version": "2.0.0",
"description": "A collection of light object for 3D.",
"origin": {
"identifier": "Light3D",
Expand All @@ -17718,10 +17718,62 @@
"authorIds": [
"IWykYNRvhCZBN3vEgKEbBPOR3Oc2"
],
"changelog": [
{
"version": "2.0.0",
"breaking": "- Point and spot lights now fade with the distance like they do with the 3D renderer of recent GDevelop versions (Three.js r185), including on previous GDevelop versions. Lights made for a previous version of the extension need a higher intensity (and possibly a lower decay) to look the same."
}
],
"dependencies": [],
"globalVariables": [],
"sceneVariables": [],
"eventsFunctions": [
{
"fullName": "",
"functionType": "Action",
"name": "onFirstSceneLoaded",
"sentence": "",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
"// Before Three.js r165, GDevelop rendered with \"legacy lights\": point and spot",
"// lights faded linearly up to their range and every light color was",
"// multiplied by PI. Recent GDevelop versions use the physically based falloff",
"// of Three.js r185 instead, which is what the light properties are tuned for.",
"// Use the same falloff with older GDevelop versions so that lights look the",
"// same with every version:",
"// - distances are divided by 100 because recent GDevelop versions render 3D",
"// with a default world scale of 100 pixels per unit, while older versions",
"// work in pixels,",
"// - the attenuation is divided by PI as the legacy light colors are multiplied by PI.",
"// It must be patched before any shader using lights is compiled, as Three.js",
"// caches compiled shaders.",
"const lightsParsBegin = THREE.ShaderChunk.lights_pars_begin;",
"if (!lightsParsBegin.includes('#if defined ( LEGACY_LIGHTS )')) {",
" return;",
"}",
"THREE.ShaderChunk.lights_pars_begin = lightsParsBegin.replace(",
" /#if defined \\( LEGACY_LIGHTS \\)[\\s\\S]*?#else/,",
" [",
" '#if defined ( LEGACY_LIGHTS )',",
" '\\t\\tfloat distanceFalloff = 1.0 / max( pow( lightDistance * 0.01, decayExponent ), 0.01 );',",
" '\\t\\tif ( cutoffDistance > 0.0 ) {',",
" '\\t\\t\\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );',",
" '\\t\\t}',",
" '\\t\\treturn distanceFalloff * RECIPROCAL_PI;',",
" '\\t#else',",
" ].join('\\n')",
");"
],
"parameterObjects": "",
"useStrict": true,
"eventsSheetExpanded": true
}
],
"parameters": [],
"objectGroups": []
},
{
"description": "Define spot light helper classes JavaScript code.",
"fullName": "Define spot light helper classes",
Expand Down Expand Up @@ -18129,7 +18181,9 @@
" * @param value {number}",
" */",
" setRange(value) {",
" this.pointLight.distance = value;",
" const runtimeScene = this.object.getRuntimeScene();",
" const inverseWorldScale = runtimeScene.getRenderer3DInverseWorldScale ? runtimeScene.getRenderer3DInverseWorldScale() : 1;",
" this.pointLight.distance = value * inverseWorldScale;",
" }",
"",
" /**",
Expand Down Expand Up @@ -18291,7 +18345,11 @@
" spotLight.castShadow = false;",
" spotLight.visible = false;",
"",
" if (!object.isHidden()) {",
" // Instances hidden at start stay visible in the editor, but their light must not shine.",
" const isHiddenAtStartInEditor =",
" !!editor && !!editor.isInstanceHiddenAtStart && editor.isInstanceHiddenAtStart(object);",
"",
" if (!object.isHidden() && !isHiddenAtStartInEditor) {",
" let isSelected = false;",
" if (editor) {",
" const selectedObject = editor._selection.getLastSelectedObject();",
Expand Down Expand Up @@ -18921,6 +18979,9 @@
"eventsFunctionsFolderStructure": {
"folderName": "__ROOT",
"children": [
{
"functionName": "onFirstSceneLoaded"
},
{
"functionName": "DefineHelperClasses"
},
Expand Down
Loading
Loading