|
10 | 10 | "name": "FoliageSwaying3D", |
11 | 11 | "previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/732ef90b7fcf5dd9171fe95d0cf262e09159b487304915a4693baa893d9ce16c_grass.svg", |
12 | 12 | "shortDescription": "Sway foliage of 3D objects according to the wind.", |
13 | | - "version": "1.0.0", |
| 13 | + "version": "1.1.0", |
14 | 14 | "description": [ |
15 | 15 | "Sway foliage of 3D objects according to wind.", |
16 | 16 | "", |
|
30 | 30 | "* Hot reload supports all basic behavior property changes, excluding Sway settings (`Material to sway`, `Sway type`, `Enable uniform sway toggle`) and `Distance culling`, `Debug output`, `GPU instancing`, and `Custom PBR settings` toggles. However, if PBR settings are enabled as you start the preview, changes to specific PBR values will be updated on hot-reload.<br><br>", |
31 | 31 | "" |
32 | 32 | ], |
33 | | - "origin": { |
34 | | - "identifier": "FoliageSwaying3D", |
35 | | - "name": "gdevelop-extension-store" |
36 | | - }, |
37 | 33 | "tags": [ |
38 | | - "3d", |
| 34 | + "3D", |
39 | 35 | "shader", |
40 | 36 | "foliage", |
41 | 37 | "wind", |
|
5029 | 5025 | "parameterObjects": "", |
5030 | 5026 | "useStrict": true, |
5031 | 5027 | "eventsSheetExpanded": true |
| 5028 | + }, |
| 5029 | + { |
| 5030 | + "type": "BuiltinCommonInstructions::JsCode", |
| 5031 | + "inlineCode": [ |
| 5032 | + "// Prepares the shaders of every foliage material ahead of time, so foliage", |
| 5033 | + "// becoming visible for the first time (often on a camera turn) does not", |
| 5034 | + "// compile its shader on that frame. A foliage material can be drawn by plain", |
| 5035 | + "// and by instanced meshes, which use two different programs: one mesh of each", |
| 5036 | + "// kind is compiled per material. Compilation runs again when a material is", |
| 5037 | + "// added or changes version (new defines, such as wind gusts).", |
| 5038 | + "const sceneState = runtimeScene._foliageSwaying3D;", |
| 5039 | + "const activeMaterials = sceneState && sceneState.activeMaterials;", |
| 5040 | + "if (!activeMaterials || activeMaterials.size === 0) return;", |
| 5041 | + "", |
| 5042 | + "let materialsSignature = '';", |
| 5043 | + "activeMaterials.forEach((material) => {", |
| 5044 | + " if (material) materialsSignature += material.uuid + ':' + material.version + '|';", |
| 5045 | + "});", |
| 5046 | + "if (sceneState._precompiledMaterialsSignature === materialsSignature) return;", |
| 5047 | + "", |
| 5048 | + "const layerRenderer = runtimeScene.getLayer(\"\").getRenderer();", |
| 5049 | + "const threeScene = layerRenderer && layerRenderer.getThreeScene ? layerRenderer.getThreeScene() : null;", |
| 5050 | + "if (!threeScene) return;", |
| 5051 | + "sceneState._precompiledMaterialsSignature = materialsSignature;", |
| 5052 | + "", |
| 5053 | + "const meshesToCompile = [];", |
| 5054 | + "const foundVariants = new Set();", |
| 5055 | + "threeScene.traverse((object3D) => {", |
| 5056 | + " if (!object3D.isMesh || !object3D.material) return;", |
| 5057 | + " const materials = Array.isArray(object3D.material) ? object3D.material : [object3D.material];", |
| 5058 | + " for (const material of materials) {", |
| 5059 | + " if (!activeMaterials.has(material)) continue;", |
| 5060 | + " const variantKey = material.uuid + (object3D.isInstancedMesh ? ':instanced' : ':plain');", |
| 5061 | + " if (foundVariants.has(variantKey)) continue;", |
| 5062 | + " foundVariants.add(variantKey);", |
| 5063 | + " meshesToCompile.push(object3D);", |
| 5064 | + " }", |
| 5065 | + "});", |
| 5066 | + "if (meshesToCompile.length === 0) return;", |
| 5067 | + "", |
| 5068 | + "// Compiling outside of a render can produce a program variant that differs", |
| 5069 | + "// from the one used to draw (lights and render state are only set up during", |
| 5070 | + "// the render), so the compilation is done at the start of the next render.", |
| 5071 | + "const previousOnBeforeRender = threeScene.onBeforeRender;", |
| 5072 | + "threeScene.onBeforeRender = function (renderer, scene, camera, renderTarget) {", |
| 5073 | + " threeScene.onBeforeRender = previousOnBeforeRender;", |
| 5074 | + " if (renderer && renderer.compile) {", |
| 5075 | + " for (const mesh of meshesToCompile) {", |
| 5076 | + " // The compiler only collects visible meshes: show this one just for the call.", |
| 5077 | + " const wasVisible = mesh.visible;", |
| 5078 | + " mesh.visible = true;", |
| 5079 | + " try { renderer.compile(mesh, camera, scene); } catch (error) {}", |
| 5080 | + " mesh.visible = wasVisible;", |
| 5081 | + " }", |
| 5082 | + " }", |
| 5083 | + " if (previousOnBeforeRender) previousOnBeforeRender.apply(this, arguments);", |
| 5084 | + "};" |
| 5085 | + ], |
| 5086 | + "parameterObjects": "", |
| 5087 | + "useStrict": true, |
| 5088 | + "eventsSheetExpanded": false |
5032 | 5089 | } |
5033 | 5090 | ], |
5034 | 5091 | "parameters": [ |
|
8879 | 8936 | "value": "", |
8880 | 8937 | "type": "Boolean", |
8881 | 8938 | "label": "Use color gradient", |
8882 | | - "description": "Enables top/bottom gradient tint and color grading (default: off).", |
| 8939 | + "description": "Enables top/bottom gradient tint and color grading (default: off)", |
8883 | 8940 | "group": "Color", |
8884 | 8941 | "name": "UseColorGradient" |
8885 | 8942 | }, |
|
8935 | 8992 | "value": "", |
8936 | 8993 | "type": "String", |
8937 | 8994 | "label": "Material to sway", |
8938 | | - "description": "Material name to target (empty = auto-pick).", |
| 8995 | + "description": "Material name to target. (empty = auto-pick)", |
| 8996 | + "group": "Sway", |
8939 | 8997 | "name": "MaterialName" |
8940 | 8998 | }, |
8941 | 8999 | { |
8942 | 9000 | "value": "true", |
8943 | 9001 | "type": "Boolean", |
8944 | 9002 | "label": "Enable uniform sway", |
8945 | | - "description": "If enabled, all instances sway similarly. If off, each gets random phase variation (default: on).", |
| 9003 | + "description": "If enabled, all instances sway similarly. If off, each gets random phase variation. (default: on)", |
| 9004 | + "group": "Sway", |
8946 | 9005 | "name": "UseUniformSway" |
8947 | 9006 | }, |
8948 | 9007 | { |
8949 | | - "value": "Grass", |
| 9008 | + "value": "", |
8950 | 9009 | "type": "Choice", |
8951 | 9010 | "label": "Sway type", |
8952 | 9011 | "description": "Wind animation model.", |
| 9012 | + "group": "Sway", |
8953 | 9013 | "choices": [ |
8954 | 9014 | { |
8955 | 9015 | "label": "Grass sway", |
|
8974 | 9034 | "value": "false", |
8975 | 9035 | "type": "Boolean", |
8976 | 9036 | "label": "Debug output", |
8977 | | - "description": "Prints material/mesh and auto-scale debug info to console (requires object to be in the scene; default: off).", |
| 9037 | + "description": "Prints material/mesh and auto-scale debug info to console. (requires object to be in the scene; default: off)", |
8978 | 9038 | "advanced": true, |
8979 | 9039 | "name": "DebugOutput" |
8980 | 9040 | }, |
8981 | 9041 | { |
8982 | 9042 | "value": "0", |
8983 | 9043 | "type": "Number", |
8984 | 9044 | "label": "Sway response", |
8985 | | - "description": "How much the object is deformed by the wind. For low-poly models use small number around 0.5. (0-200; 0 = auto)", |
| 9045 | + "description": "Sorts unexpected visual behavior. For low-poly models use smaller number. (0-200; 0 = auto)", |
| 9046 | + "group": "Sway", |
8986 | 9047 | "name": "SwayResponse" |
8987 | 9048 | }, |
8988 | 9049 | { |
|
8997 | 9058 | "value": "", |
8998 | 9059 | "type": "Boolean", |
8999 | 9060 | "label": "GPU instancing", |
9000 | | - "description": "Uses GPU instancing for supported sway types (better performance; default: off).", |
| 9061 | + "description": "Uses GPU instancing for supported sway types. (better performance; default: off).", |
9001 | 9062 | "group": "Instancing", |
9002 | 9063 | "name": "UseGPUInstancing" |
9003 | 9064 | }, |
9004 | 9065 | { |
9005 | 9066 | "value": "", |
9006 | 9067 | "type": "Boolean", |
9007 | 9068 | "label": "Distance culling", |
9008 | | - "description": "Enables distance-based dither fade/culling (default: off).", |
| 9069 | + "description": "Enables distance-based dither fade/culling. (default: off)", |
9009 | 9070 | "group": "Culling", |
9010 | 9071 | "name": "UseDistanceFade" |
9011 | 9072 | }, |
|
9014 | 9075 | "type": "Number", |
9015 | 9076 | "unit": "Pixel", |
9016 | 9077 | "label": "Fade distance start", |
9017 | | - "description": "Distance where fade-out starts. Requires enabled distance culling (0-100000; default: 1200).", |
| 9078 | + "description": "Distance where fade-out starts. Requires enabled distance culling. (0-100000; default: 1200)", |
9018 | 9079 | "group": "Culling", |
9019 | 9080 | "name": "DistanceFadeStart" |
9020 | 9081 | }, |
|
9023 | 9084 | "type": "Number", |
9024 | 9085 | "unit": "Pixel", |
9025 | 9086 | "label": "Fade distance end", |
9026 | | - "description": "Distance where fade reaches zero. Requires enabled distance culling (0-100000; default: 1600).", |
| 9087 | + "description": "Distance where fade reaches zero. Requires enabled distance culling. (0-100000; default: 1600)", |
9027 | 9088 | "group": "Culling", |
9028 | 9089 | "name": "DistanceFadeEnd" |
9029 | 9090 | }, |
9030 | 9091 | { |
9031 | 9092 | "value": "", |
9032 | 9093 | "type": "Boolean", |
9033 | 9094 | "label": "Custom PBR settings", |
9034 | | - "description": "Enables custom PBR tuning controls (default: off).", |
| 9095 | + "description": "Enables custom PBR tuning controls. (default: off)", |
9035 | 9096 | "group": "Custom PBR (experimental)", |
9036 | 9097 | "advanced": true, |
9037 | 9098 | "name": "UseCustomPBR" |
|
9040 | 9101 | "value": "0", |
9041 | 9102 | "type": "Number", |
9042 | 9103 | "label": "Metallic factor", |
9043 | | - "description": "PBR metallic value (0-1; default: 0).", |
| 9104 | + "description": "PBR metallic value. (0-1; default: 0)", |
9044 | 9105 | "group": "Custom PBR (experimental)", |
9045 | 9106 | "advanced": true, |
9046 | 9107 | "name": "Metallic" |
|
9049 | 9110 | "value": "1", |
9050 | 9111 | "type": "Number", |
9051 | 9112 | "label": "Roughness factor", |
9052 | | - "description": "PBR roughness value (0-1; default: 1).", |
| 9113 | + "description": "PBR roughness value. (0-1; default: 1)", |
9053 | 9114 | "group": "Custom PBR (experimental)", |
9054 | 9115 | "advanced": true, |
9055 | 9116 | "name": "Roughness" |
|
9058 | 9119 | "value": "0.1", |
9059 | 9120 | "type": "Number", |
9060 | 9121 | "label": "Specular factor", |
9061 | | - "description": "Specular intensity (where supported; 0-1; default: 0.1).", |
| 9122 | + "description": "Specular intensity. (where supported; 0-1; default: 0.1)", |
9062 | 9123 | "group": "Custom PBR (experimental)", |
9063 | 9124 | "advanced": true, |
9064 | 9125 | "name": "Specular" |
|
9067 | 9128 | "value": "1", |
9068 | 9129 | "type": "Number", |
9069 | 9130 | "label": "Normal strength", |
9070 | | - "description": "Normal map strength (0-1; default: 1).", |
| 9131 | + "description": "Normal map strength. (0-1; default: 1)", |
9071 | 9132 | "group": "Custom PBR (experimental)", |
9072 | 9133 | "advanced": true, |
9073 | 9134 | "name": "NormalStrength" |
|
9076 | 9137 | "value": "1", |
9077 | 9138 | "type": "Number", |
9078 | 9139 | "label": "Ambient Occlusion strength", |
9079 | | - "description": "Ambient occlusion intensity (0-1; default: 1).", |
| 9140 | + "description": "Ambient occlusion intensity. (0-1; default: 1)", |
9080 | 9141 | "group": "Custom PBR (experimental)", |
9081 | 9142 | "advanced": true, |
9082 | 9143 | "name": "AmbientOcclusionStrength" |
|
9085 | 9146 | "value": "1", |
9086 | 9147 | "type": "Number", |
9087 | 9148 | "label": "Environment strength", |
9088 | | - "description": "Environment reflection intensity (0-1; default: 1).", |
| 9149 | + "description": "Environment reflection intensity. (0-1; default: 1)", |
9089 | 9150 | "group": "Custom PBR (experimental)", |
9090 | 9151 | "advanced": true, |
9091 | 9152 | "name": "EnvironmentStrength" |
9092 | 9153 | }, |
9093 | 9154 | { |
9094 | | - "value": "UseSource", |
| 9155 | + "value": "", |
9095 | 9156 | "type": "Choice", |
9096 | 9157 | "label": "Culling mode", |
9097 | 9158 | "description": "3D model face culling mode.", |
|
9116 | 9177 | "value": "true", |
9117 | 9178 | "type": "Boolean", |
9118 | 9179 | "label": "Use two sided lighting", |
9119 | | - "description": "If enabled, both frontface and backface are lit. Useful for planes/cards (default: on).", |
| 9180 | + "description": "If enabled, both frontface and backface are lit. Useful for planes/cards (default: on)", |
9120 | 9181 | "group": "Color", |
9121 | 9182 | "name": "UseTwoSidedLighting" |
9122 | 9183 | } |
9123 | 9184 | ], |
9124 | 9185 | "propertiesFolderStructure": { |
9125 | 9186 | "folderName": "__ROOT", |
9126 | 9187 | "children": [ |
9127 | | - { |
9128 | | - "propertyName": "SwayType" |
9129 | | - }, |
9130 | | - { |
9131 | | - "propertyName": "MaterialName" |
9132 | | - }, |
9133 | | - { |
9134 | | - "propertyName": "SwayResponse" |
9135 | | - }, |
9136 | | - { |
9137 | | - "propertyName": "UseUniformSway" |
9138 | | - }, |
9139 | 9188 | { |
9140 | 9189 | "folderName": "Color", |
9141 | 9190 | "children": [ |
|
9168 | 9217 | } |
9169 | 9218 | ] |
9170 | 9219 | }, |
| 9220 | + { |
| 9221 | + "folderName": "Sway", |
| 9222 | + "children": [ |
| 9223 | + { |
| 9224 | + "propertyName": "SwayType" |
| 9225 | + }, |
| 9226 | + { |
| 9227 | + "propertyName": "MaterialName" |
| 9228 | + }, |
| 9229 | + { |
| 9230 | + "propertyName": "SwayResponse" |
| 9231 | + }, |
| 9232 | + { |
| 9233 | + "propertyName": "UseUniformSway" |
| 9234 | + } |
| 9235 | + ] |
| 9236 | + }, |
9171 | 9237 | { |
9172 | 9238 | "folderName": "Culling", |
9173 | 9239 | "children": [ |
|
0 commit comments