Skip to content
Merged
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
57 changes: 56 additions & 1 deletion extensions/reviewed/Light3D.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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.6",
"version": "2.0.0",
"description": "A collection of light object for 3D.",
"origin": {
"identifier": "Light3D",
Expand All @@ -23,10 +23,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 @@ -1232,6 +1284,9 @@
"eventsFunctionsFolderStructure": {
"folderName": "__ROOT",
"children": [
{
"functionName": "onFirstSceneLoaded"
},
{
"functionName": "DefineHelperClasses"
},
Expand Down
Loading